Changeset ac19a0c
- Timestamp:
- 01/13/24 23:19:50 (10 months ago)
- Branches:
- master
- Children:
- e85a562
- Parents:
- e9b4ba9
- Files:
-
- 66 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/package-lock.json
re9b4ba9 rac19a0c 13 13 "@testing-library/user-event": "^13.5.0", 14 14 "axios": "^1.5.0", 15 "axios-extensions": "^3.1.6", 15 16 "bootstrap": "^5.3.0", 16 17 "file-loader": "^6.2.0", … … 5349 5350 } 5350 5351 }, 5352 "node_modules/axios-extensions": { 5353 "version": "3.1.6", 5354 "resolved": "https://registry.npmjs.org/axios-extensions/-/axios-extensions-3.1.6.tgz", 5355 "integrity": "sha512-CmwMYxxAw4DcQDJ7/2Iv4GJj1Ao48lJEPieycgZQH6m1KcYZqf9zm2HM/CsULqheCpYxZbiGrCfZf5tVjXqoLg==", 5356 "dependencies": { 5357 "lru-cache": "^7.14.0", 5358 "tslib": "^2.1.0", 5359 "util": "^0.12.3" 5360 }, 5361 "peerDependencies": { 5362 "axios": "*" 5363 } 5364 }, 5365 "node_modules/axios-extensions/node_modules/lru-cache": { 5366 "version": "7.18.3", 5367 "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", 5368 "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", 5369 "engines": { 5370 "node": ">=12" 5371 } 5372 }, 5351 5373 "node_modules/axios/node_modules/form-data": { 5352 5374 "version": "4.0.0", … … 9425 9447 "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", 9426 9448 "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", 9427 "peer": true,9428 9449 "dependencies": { 9429 9450 "call-bind": "^1.0.2", … … 9564 9585 "engines": { 9565 9586 "node": ">=6" 9587 } 9588 }, 9589 "node_modules/is-generator-function": { 9590 "version": "1.0.10", 9591 "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", 9592 "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", 9593 "dependencies": { 9594 "has-tostringtag": "^1.0.0" 9595 }, 9596 "engines": { 9597 "node": ">= 0.4" 9598 }, 9599 "funding": { 9600 "url": "https://github.com/sponsors/ljharb" 9566 9601 } 9567 9602 }, … … 16800 16835 } 16801 16836 }, 16837 "node_modules/util": { 16838 "version": "0.12.5", 16839 "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", 16840 "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", 16841 "dependencies": { 16842 "inherits": "^2.0.3", 16843 "is-arguments": "^1.0.4", 16844 "is-generator-function": "^1.0.7", 16845 "is-typed-array": "^1.1.3", 16846 "which-typed-array": "^1.1.2" 16847 } 16848 }, 16802 16849 "node_modules/util-deprecate": { 16803 16850 "version": "1.0.2", -
frontend/package.json
re9b4ba9 rac19a0c 8 8 "@testing-library/user-event": "^13.5.0", 9 9 "axios": "^1.5.0", 10 "axios-extensions": "^3.1.6", 10 11 "bootstrap": "^5.3.0", 11 12 "file-loader": "^6.2.0", -
frontend/src/App.js
re9b4ba9 rac19a0c 5 5 import 'bootstrap/dist/js/bootstrap.js'; 6 6 import HomeCarousel from './Components/Layout/CarouselHome/Carousel'; 7 import { Card, Container} from 'react-bootstrap';7 import {Card, Container} from 'react-bootstrap'; 8 8 import TabComponent from './Components/Tab/Tab'; 9 9 import Offers from './Components/Layout/Offers/Offers'; … … 27 27 import TransportEditPage from './Pages/TransportEditPage'; 28 28 import RestaurantDetailsPage from './Pages/RestaurantDetailsPage'; 29 import { BrowserRouter, Route, Routes} from 'react-router-dom';29 import {BrowserRouter, Route, Routes} from 'react-router-dom'; 30 30 import LoginErrorPage from "./Pages/LoginErrorPage"; 31 import {AuthProvider} from "./Components/Context/AuthContext"; 32 import PrivateRoute from "./Components/Misc/PrivateRoute"; 33 import ProfilesManagementPage from "./Pages/ProfilesManagementPage"; 34 import UserReservationsManagement from "./Pages/UserReservationsManagement"; 31 35 32 36 33 37 function App() { 34 38 35 return ( 36 <div className="App" style={{overflow: 'hidden'}}> 37 <BrowserRouter> 38 <Routes> 39 <Route path='/login' element={<LoginPage/>}/> 40 <Route path='/register' element={<RegistrationPage/>}/> 41 <Route path='/profile' element={<ProfilePage/>}/> 42 <Route path="/resources" exact element={<NoBusinessRegisteredError hasRegistration="false"/>} /> 43 <Route path="/resources/hotel" element={<ResourcesPage tab="/hotel"/>}/> 44 <Route path="/resources/hotel/:hotelId" element={<HotelEditPage />}/> 45 <Route path="/resources/restaurant" element={<ResourcesPage tab="/restaurant"/>}/> 46 <Route path='/resources/restaurant/:restaurantId' element={<RestaurantEditPage />}/> 47 <Route path="/resources/transport" element={<ResourcesPage tab="/transport"/>}/> 48 <Route path="/resources/transport/:transportId" element={<TransportEditPage/>}/> 49 <Route path="/home" element={<HomePage/> }/> 50 <Route path="/error" element={<LoginErrorPage/> }/> 51 <Route path='/details/transport' element={<TransportDetailsPage></TransportDetailsPage>}/> 52 <Route path='/details/hotel' element={<HotelDetailsPage></HotelDetailsPage>}/> 53 <Route path='/details/restaurant' element={<RestaurantDetailsPage></RestaurantDetailsPage>}/> 54 <Route path="/search/hotel/:hotelLocation/:dateFrom/:dateTo/:numBeds" element={<SearchPage type="hotel"/> }/> 55 <Route path="/search/transport/:from/:to/:date" element={<SearchPage type="transport"/> }/> 56 </Routes> 57 </BrowserRouter> 58 </div> 59 ); 39 return ( 40 <div className="App" style={{overflow: 'hidden'}}> 41 <AuthProvider> 42 <BrowserRouter> 43 <Routes> 44 <Route path='/login' element={<LoginPage/>}/> 45 <Route path='/register' element={<RegistrationPage/>}/> 46 <Route path='/profile' element={<PrivateRoute><ProfilePage/></PrivateRoute>}/> 47 <Route path='/profiles' element={<PrivateRoute><ProfilesManagementPage/></PrivateRoute>}/> 48 <Route path='/reservations' element={<PrivateRoute><UserReservationsManagement/></PrivateRoute>}/> 49 <Route path="/resources" exact element={<PrivateRoute><NoBusinessRegisteredError 50 hasRegistration="false"/></PrivateRoute>}/> 51 <Route path="/resources/hotel" 52 element={<PrivateRoute><ResourcesPage tab="/hotel"/></PrivateRoute>}/> 53 <Route path="/resources/hotel/:hotelId" element={<PrivateRoute><HotelEditPage/></PrivateRoute>}/> 54 <Route path="/resources/restaurant" 55 element={<PrivateRoute><ResourcesPage tab="/restaurant"/></PrivateRoute>}/> 56 <Route path='/resources/restaurant/:restaurantId' 57 element={<PrivateRoute><RestaurantEditPage/></PrivateRoute>}/> 58 <Route path="/resources/transport" 59 element={<PrivateRoute><ResourcesPage tab="/transport"/></PrivateRoute>}/> 60 <Route path="/resources/transport/:transportId" 61 element={<PrivateRoute><TransportEditPage/></PrivateRoute>}/> 62 <Route path="/home" element={<HomePage/>}/> 63 <Route path="/error" element={<LoginErrorPage/>}/> 64 <Route path='/details/transport' element={<TransportDetailsPage></TransportDetailsPage>}/> 65 <Route path='/details/hotel' element={<HotelDetailsPage></HotelDetailsPage>}/> 66 <Route path='/details/restaurant' element={<RestaurantDetailsPage></RestaurantDetailsPage>}/> 67 <Route path="/search/hotel/:hotelLocation/:dateFrom/:dateTo/:numBeds" 68 element={<SearchPage type="hotel"/>}/> 69 <Route path="/search/transport/:from/:to/:date/:numPassengers" 70 element={<SearchPage type="transport"/>}/> 71 </Routes> 72 </BrowserRouter> 73 </AuthProvider> 74 </div> 75 ); 60 76 } 61 77 -
frontend/src/Components/Forms/AddHotelForm.js
re9b4ba9 rac19a0c 119 119 return prevState + 1; 120 120 }) 121 if(!edit) 122 props.closeModal() 121 123 }} 122 124 > -
frontend/src/Components/Forms/AddRestaurantForm.js
re9b4ba9 rac19a0c 85 85 return prevState + 1; 86 86 }) 87 props.closeModal() 87 88 }} 88 89 > -
frontend/src/Components/Forms/AddRoomForm.js
re9b4ba9 rac19a0c 13 13 hotelRoomDescription: "", 14 14 hotelRoomName: "", 15 num Beds: "",15 numOfBeds: "", 16 16 price: "", 17 17 kitchenAvailable: false, … … 58 58 type="number" 59 59 placeholder="Внесете го бројот на кревети" 60 value={formData.num Beds}61 name="num Beds"60 value={formData.numOfBeds} 61 name="numOfBeds" 62 62 onChange={onFormChange} 63 63 /> … … 117 117 style={{ backgroundColor: "#159895" }} 118 118 size="md" 119 onClick={() => { 120 console.log(formData); 119 onClick={(e) => { 120 e.preventDefault(); 121 props.refresh((prev) => { 122 return ++prev; 123 }) 121 124 createHotelRoom(formData); 125 props.closeModal(); 122 126 }} 123 127 > -
frontend/src/Components/Forms/AddTransportForm.js
re9b4ba9 rac19a0c 11 11 transportName: "", 12 12 carBrand: "", 13 carType: false,13 carType: "", 14 14 carManufacturedYear: 1900, 15 15 noPassengers: 0, … … 107 107 createTransport(formData, edit); 108 108 props.refresh((prev) => { 109 return prev + 1;109 return ++prev; 110 110 }) 111 if(!edit) 112 props.closeModal() 111 113 }} 112 114 > -
frontend/src/Components/Forms/EditRoomForm.js
re9b4ba9 rac19a0c 28 28 } = useGet(`/hotel/rooms/${props.room.hotelRoomId}/available`) 29 29 30 console.log(`/hotel/rooms/${props.room.hotelRoomId}/available`) 31 30 32 !isLoading && console.log(data) 31 33 … … 42 44 <tr> 43 45 <th>#</th> 44 <th>Достапно од</th> 45 <th>Достапно до</th> 46 <th>Број на соби</th> 46 <th>Oд</th> 47 <th>До</th> 48 <th>Време на тргнување</th> 49 <th>Време на пристигнување</th> 50 <th>Цена</th> 47 51 </tr> 48 52 </thead> -
frontend/src/Components/Hooks/Hotel/useCreateHotel.js
re9b4ba9 rac19a0c 6 6 const useCreateHotel = () => { 7 7 8 //const history = useNavigate();9 8 const createHotel = async (hotel, edit) => { 10 9 console.log({hotel}) 11 10 console.log(hotel) 11 console.log("vo createhotel") 12 12 13 13 if(!edit) … … 16 16 .post(`/hotel/add`, hotel, { 17 17 params: { 18 userId: localStorage.getItem("userId")18 userId: JSON.parse(localStorage.getItem("user")).userId 19 19 } 20 20 }) -
frontend/src/Components/Hooks/Restaurant/useCreateRestaurant.js
re9b4ba9 rac19a0c 15 15 .post(`/restaurant/add`, restaurant, { 16 16 params: { 17 userId: localStorage.getItem('userId')17 userId: JSON.parse(localStorage.getItem('user')).userId, 18 18 } 19 19 }) -
frontend/src/Components/Hooks/Transport/useCreateTransport.js
re9b4ba9 rac19a0c 4 4 5 5 const useCreateTransport = () => { 6 6 const userId = JSON.parse(localStorage.getItem('user')).userId 7 7 const createTransport = async (transport, edit) => { 8 8 if(!edit) 9 9 { 10 10 await axios 11 .post(`/transport/add `, transport)11 .post(`/transport/add/` + userId, transport) 12 12 .then((res) => { 13 13 //history.push('/transport'); -
frontend/src/Components/Hooks/User/useLogin.js
re9b4ba9 rac19a0c 4 4 import { Navigate, useAsyncValue, useNavigate } from "react-router-dom"; 5 5 import LoginForm from "../../Login/LoginForm.js"; 6 import {useAuth} from "../../Context/AuthContext"; 6 7 7 8 const useLogin = () => { 8 9 9 10 const navigator = useNavigate() 11 const Auth = useAuth(); 10 12 //const history = useNavigate(); 11 13 const login = async (loginData) => { … … 22 24 }) 23 25 .then((res) => { 26 console.log("RES LOGIN") 27 console.log(res) 28 if(res.status === 200) 29 { 30 const user = { 31 sessionId: res.data.auth.details.sessionId, 32 userId: res.data.auth.principal.userID, 33 username: res.data.auth.principal.username, 34 role: res.data.auth.principal.role, 35 name: res.data.auth.principal.name, 36 surname: res.data.auth.principal.surname, 37 } 38 Auth.userLogin(user); 39 console.log(user) 40 } 24 41 const sessionId = res.data.auth.details.sessionId; 25 42 const userId = res.data.auth.principal.userID; 26 43 27 44 localStorage.setItem("sessionId", sessionId); 28 45 localStorage.setItem("userId", userId); -
frontend/src/Components/Hooks/useGet.js
re9b4ba9 rac19a0c 12 12 console.log("url od get " + uurl) 13 13 await axios. 14 get(uurl ).then((res) => {14 get(uurl, {maxRedirects: 0}).then((res) => { 15 15 setData(res.data); 16 }).catch((err ) => {17 console.log(err )16 }).catch((error) => { 17 console.log(error) 18 18 }) 19 19 .finally(() => { … … 26 26 getData(url); 27 27 }, [dep, url, changed]); 28 28 29 29 return { 30 30 data, -
frontend/src/Components/HotelEdit/HotelEditTab.js
re9b4ba9 rac19a0c 1 1 import React from "react"; 2 import { Container, Col, Row, Image, Nav, Tab} from "react-bootstrap";3 import { useState} from "react";4 import { FaTaxi, FaHotel} from "react-icons/fa";5 import { MdOutlineStickyNote2} from "react-icons/md";2 import {Container, Col, Row, Image, Nav, Tab} from "react-bootstrap"; 3 import {useState} from "react"; 4 import {FaTaxi, FaHotel} from "react-icons/fa"; 5 import {MdOutlineStickyNote2} from "react-icons/md"; 6 6 import AddNew from "../Resources/AddNew"; 7 import { BiData} from "react-icons/bi"7 import {BiData} from "react-icons/bi" 8 8 import RoomListing from "./RoomListing"; 9 9 import HotelEditForm from "./HotelEditForm"; 10 10 import AddHotelForm from "../Forms/AddHotelForm"; 11 11 import EditModal from "../Resources/EditModal"; 12 import AddAvailability from "../Resources/AddAvailability"; 13 import useGet from "../Hooks/useGet"; 14 import ReservationListing from "./ReservationListing"; 12 15 13 16 function HotelEditTab(props) { 14 const [activeTab, setActiveTab] = useState("/hotel");15 const [modalData, setModalData] = useState("");16 const [show, setShow] = useState(false);17 const [activeTab, setActiveTab] = useState("/hotel"); 18 const [modalData, setModalData] = useState(""); 19 const [show, setShow] = useState(false); 17 20 18 const handleClose = () => setShow(false); 19 const handleShow = () => { 20 //e.preventDefault(); 21 setShow(true); 21 console.log(props) 22 22 23 }; 23 const { 24 data, 25 isLoading, 26 setData, 27 getData, 28 setChanged 29 } = useGet(`/hotel/${props.displayRoom.hotelId}/reservations/active`) 24 30 25 const showModal = (modalData) => { 26 setModalData(modalData); 27 handleShow(); 28 } 29 console.log(props.displayRoom) 31 !isLoading && console.log(data) 30 32 31 const handleSelect = (eventKey) => { 32 setActiveTab(eventKey); 33 }; 33 const handleClose = () => setShow(false); 34 const handleShow = () => { 35 //e.preventDefault(); 36 setShow(true); 34 37 35 return ( 36 <Container className="rounded-5"> 37 <Tab.Container 38 activeKey={activeTab} 39 onSelect={handleSelect} 40 className="bg-dark rounded-5" 41 > 42 <Nav 43 fill 44 variant="tabs" 45 className="bg-body rounded-top-5" 46 activeKey="/hotel" 47 id="tab_item" 48 > 49 <Nav.Item className="tab_item rounded-5"> 50 <Nav.Link eventKey="/hotel" className="text-left rounded-5"> 38 }; 39 40 const showModal = (modalData) => { 41 setModalData(modalData); 42 handleShow(); 43 } 44 console.log(props.displayRoom) 45 46 const handleSelect = (eventKey) => { 47 setActiveTab(eventKey); 48 }; 49 50 return ( 51 <Container className="rounded-5"> 52 <Tab.Container 53 activeKey={activeTab} 54 onSelect={handleSelect} 55 className="bg-dark rounded-5" 56 > 57 <Nav 58 fill 59 variant="tabs" 60 className="bg-body rounded-top-5" 61 activeKey="/hotel" 62 id="tab_item" 63 > 64 <Nav.Item className="tab_item rounded-5"> 65 <Nav.Link eventKey="/hotel" className="text-left rounded-5"> 51 66 <span className="ikona"> 52 67 <FaHotel 53 color="#159895"54 style={{ lineHeight: "100em"}}55 size={"1.5em"}56 className="mx-3"68 color="#159895" 69 style={{lineHeight: "100em"}} 70 size={"1.5em"} 71 className="mx-3" 57 72 /> 58 73 </span> 59 <span className="ikona">Соби</span>60 </Nav.Link>61 </Nav.Item>62 <Nav.Item className="tab_item">63 <Nav.Link eventKey="/restaurant">74 <span className="ikona">Соби</span> 75 </Nav.Link> 76 </Nav.Item> 77 <Nav.Item className="tab_item"> 78 <Nav.Link eventKey="/restaurant"> 64 79 <span className="ikona"> 65 <MdOutlineStickyNote2 color="#159895" size={"1.5em"} className="mx-3" 80 <MdOutlineStickyNote2 color="#159895" size={"1.5em"} className="mx-3"/> 66 81 </span> 67 <span className="ikona">Резервации</span>68 </Nav.Link>69 </Nav.Item>70 <Nav.Item className="tab_item rounded-5">71 <Nav.Link eventKey="/transport" className="text-left rounded-5">82 <span className="ikona">Резервации</span> 83 </Nav.Link> 84 </Nav.Item> 85 <Nav.Item className="tab_item rounded-5"> 86 <Nav.Link eventKey="/transport" className="text-left rounded-5"> 72 87 <span className="ikona"> 73 <BiData color="#159895" size={"1.5em"} className="mx-3" 88 <BiData color="#159895" size={"1.5em"} className="mx-3"/> 74 89 </span> 75 <span className="ikona">Општи податоци</span>76 </Nav.Link>77 </Nav.Item>78 </Nav>90 <span className="ikona">Општи податоци</span> 91 </Nav.Link> 92 </Nav.Item> 93 </Nav> 79 94 80 <Tab.Content className="py-5 px-3 border rounded-bottom-5 bg-light"> 81 <Tab.Pane eventKey="/hotel"> 82 {props.displayRoom.hotelRooms.map((room) => { 83 return <RoomListing key={room.hotelRoomId} data={room} showModal={showModal}/> 84 })} 85 <EditModal show={show} handleClose={handleClose} type="room" room={modalData}></EditModal> 86 <AddNew Id={props.displayRoom.hotelId} refresh={props.refresh} type="room"/> 87 </Tab.Pane> 88 <Tab.Pane eventKey="/restaurant"> 89 <AddNew type="restaurant"/> 90 </Tab.Pane> 91 <Tab.Pane eventKey="/transport"> 92 <AddHotelForm refresh={props.refresh} hotel={props.displayRoom}/> 93 </Tab.Pane> 94 </Tab.Content> 95 </Tab.Container> 96 </Container> 97 ); 95 <Tab.Content className="py-5 px-3 border rounded-bottom-5 bg-light"> 96 <Tab.Pane eventKey="/hotel"> 97 {props.displayRoom.hotelRooms.map((room) => { 98 return <RoomListing key={room.hotelRoomId} data={room} showModal={showModal}/> 99 })} 100 <EditModal show={show} handleClose={handleClose} type="room" room={modalData}></EditModal> 101 <AddNew Id={props.displayRoom.hotelId} refresh={props.refresh} type="room"/> 102 </Tab.Pane> 103 <Tab.Pane eventKey="/restaurant"> 104 {!isLoading && data.map((res) => { 105 return ( 106 <ReservationListing data={res}/> 107 ) 108 })} 109 {/*<AddNew type="restaurant"/>*/} 110 </Tab.Pane> 111 <Tab.Pane eventKey="/transport"> 112 <AddHotelForm refresh={props.refresh} hotel={props.displayRoom}/> 113 </Tab.Pane> 114 </Tab.Content> 115 </Tab.Container> 116 </Container> 117 ); 98 118 } 99 119 -
frontend/src/Components/Layout/Navbar/Navigation.js
re9b4ba9 rac19a0c 7 7 import useGet from "../../Hooks/useGet"; 8 8 import axios from "../../../axios.js"; 9 import {useAuth} from "../../Context/AuthContext"; 9 10 //import logo from 'assets/images/logo.png'; 10 11 //src="https://upload.wikimedia.org/wikipedia/commons/0/08/Vergina_Sun_-_Golden_Larnax.png" … … 12 13 function Navigation(props) { 13 14 const navigator = useNavigate(); 14 15 const { data, setData, isLoading, getData } = useGet("/username"); 16 15 const Auth = useAuth(); 16 const isLoggedIn = Auth.userIsAuthenticated(); 17 17 return ( 18 18 <> … … 24 24 > 25 25 <Container> 26 <Navbar.Brand href=" #home">26 <Navbar.Brand href="/home"> 27 27 <span className="ikona"> 28 28 <Image … … 50 50 Pricing 51 51 </Nav.Link> 52 {!isLo ading && !data&& (52 {!isLoggedIn && ( 53 53 <Button 54 54 className="m-2" … … 62 62 </Button> 63 63 )} 64 { !isLoading && data&& (64 {isLoggedIn && ( 65 65 <> 66 66 <Nav.Link className="m-2" href="/profile"> 67 { data}67 {Auth.getUser().username} 68 68 </Nav.Link> 69 69 <Button … … 74 74 await axios.get("/logout") 75 75 .then((res) => { 76 console.log(res) 76 console.log(res); 77 Auth.userLogout(); 77 78 }) 78 79 .catch((err) => { -
frontend/src/Components/Resources/AddNew.js
re9b4ba9 rac19a0c 56 56 </Modal.Header> 57 57 <Modal.Body> 58 {props.type === "hotel" && <AddHotelForm refresh={props.refresh}/>}59 {props.type === "room" && <AddRoomForm refresh={props.refresh} hotelId={props.Id}/>}60 {props.type === "restaurant" && <AddRestaurantForm edit="false" refresh={props.refresh}/>}61 {props.type === "transport" && <AddTransportForm refresh={props.refresh}/>}58 {props.type === "hotel" && <AddHotelForm closeModal={handleClose} refresh={props.refresh}/>} 59 {props.type === "room" && <AddRoomForm closeModal={handleClose} refresh={props.refresh} hotelId={props.Id}/>} 60 {props.type === "restaurant" && <AddRestaurantForm edit="false" closeModal={handleClose} refresh={props.refresh}/>} 61 {props.type === "transport" && <AddTransportForm closeModal={handleClose} refresh={props.refresh}/>} 62 62 {props.type === "menu" && <AddItemMenuForm Id={props.Id} refresh={props.refresh}/>} 63 63 {props.type === "route" && <AddTripForm transportId={props.transport.transportID} setSize={setSizeXl} refresh={props.refresh}/>} -
frontend/src/Components/Resources/EditModal.js
re9b4ba9 rac19a0c 31 31 </Modal.Header> 32 32 <Modal.Body> 33 {props.type === "hotel" && <AddHotelForm />}33 {props.type === "hotel" && <AddHotelForm refresh={props.refresh}/>} 34 34 {props.type === "room" && <EditRoomForm refresh={props.refresh} room={props.room}/>} 35 35 {props.type === "restaurant" && <AddRestaurantForm edit="false" refresh={props.refresh}/>} -
frontend/src/Components/Resources/ResourceListing.js
re9b4ba9 rac19a0c 6 6 7 7 const ResourceListing = (props) => { 8 9 console.log("props " + props.id)10 11 8 12 9 const type = props.type == "hotel" ? "сместувањето" : props.type == "restaurant" ? "ресторанот" : "превозот"; 13 10 const name = props.type == "hotel" ? props.data.hotelName : props.type == "restaurant" ? props.data.restaurantName : props.data.transportName 14 const id = props.type == "hotel" ? props.data.hotelId : props.type == "restaurant" ? props.data.resturantId : props.data.transportID 15 return(<> 11 const id = props.type == "hotel" ? props.data.hotelId : props.type == "restaurant" ? props.data.restaurantID : props.data.transportID 12 console.log(props.data) 13 return(<> 16 14 <a href={`${props.type}/${id}`} style={{textDecoration: "none", color:"black"}}> 17 15 <Container className="py-3 px-1 my-4" -
frontend/src/Components/Resources/ResourcesTab.js
re9b4ba9 rac19a0c 11 11 function ResourcesTab(props) { 12 12 const [activeTab, setActiveTab] = useState(props.tab); 13 // const [changed, setChanged] = useState(0); 14 const userId = localStorage.getItem("userId"); 13 const userId = JSON.parse(localStorage.getItem("user")).userId; 15 14 const { data, setData, isLoading, getData, setChanged } = useGet(`${props.tab}/user/${userId}`); 16 15 17 16 const handleSelect = (eventKey) => { 18 17 setActiveTab(eventKey); 19 console.log(props.refresh);20 18 props.refresh(eventKey); 21 console.log("refresh" + eventKey);22 19 }; 23 24 !isLoading && console.log(data);25 console.log(props.tab);26 20 27 21 return ( … … 78 72 data.map((hotel) => { 79 73 return ( 80 <Link key={hotel.hotelId} to={"/resources/hotel/" + hotel.hotelId}>74 <Link style={{textDecoration: "none"}} key={hotel.hotelId} to={"/resources/hotel/" + hotel.hotelId}> 81 75 <ResourceListing 82 76 key={hotel.hotelId} … … 93 87 {props.tab == "/restaurant" && !isLoading && data != null && 94 88 data.map((restaurant) => { 95 console.log("mapiranje " + restaurant)96 89 return ( 97 <Link key={restaurant.restaurantId} to={"/resources/restaurant/" + restaurant.restaurantID}>98 90 <ResourceListing 99 key={restaurant.restaurantI d}91 key={restaurant.restaurantID} 100 92 type="restaurant" 101 93 data={restaurant} 102 /> 103 </Link> 104 ); 94 />); 105 95 })} 106 96 <AddNew type="restaurant" refresh={setChanged}/> -
frontend/src/Components/RestaurantEdit/RestaurantEditTab.js
re9b4ba9 rac19a0c 100 100 return <MenuListing key={menu.menuId} data={menu} showModal={showModal}/> 101 101 })} 102 {activeTab === '/hotel' && <EditModal show={show} handleClose={handleClose} type="menu" menu={modalData}></EditModal>}102 {activeTab === '/hotel' && <EditModal show={show} refresh={props.refresh} handleClose={handleClose} type="menu" menu={modalData}></EditModal>} 103 103 <AddNew Id={props.displayMenu.restaurantID} refresh={props.refresh} type="menu"/> 104 104 </Tab.Pane> -
frontend/src/Components/SearchCriterias/SearchCriteriasBar.js
re9b4ba9 rac19a0c 2 2 import { Container, Form, Button, Row, Col } from "react-bootstrap"; 3 3 import useFormData from "../Hooks/useFormData"; 4 import SearchCriteriasHotel from "./SearchCriteriasHotel"; 5 import SearchCriteriasTransport from "./SearchCriteriasTransport"; 4 6 5 const SearchCriterias = (props) => {7 const SearchCriteriasBar = (props) => { 6 8 7 const { formData, onFormChange, onCheckBoxChange, setFormData} = useFormData(props.criterias) 8 console.log("KRITERIUMI") 9 console.log(formData) 9 const { criterias, type } = props 10 10 11 return ( 12 <> 13 <Container 14 className="p-1 pb-0 mb-5 mt-3 rounded-2" 15 style={{ backgroundColor: "#002B5B", width: "65%"}} 16 > 17 <Form className="rounded-5"> 18 <Row className="gx-1"> 19 <Col> 20 <Form.Floating className="mb-3"> 21 <Form.Control 22 size="md" 23 type="text" 24 placeholder="Каде ќе патувате?:" 25 id="location" 26 name="hotelLocation" 27 onChange={onFormChange} 28 value={formData.hotelLocation} 29 ></Form.Control> 30 <label htmlFor="location">Локација:</label> 31 </Form.Floating> 32 </Col> 33 <Col> 34 <Form.Floating className="mb-3"> 35 <Form.Control 36 size="md" 37 type="date" 38 placeholder="Датум на пристигнување:" 39 id="dateFrom" 40 name="dateFrom" 41 onChange={onFormChange} 42 value={formData.dateFrom} 43 ></Form.Control> 44 <label htmlFor="dateFrom">Датум на пристигнување:</label> 45 </Form.Floating> 46 </Col> 47 <Col> 48 <Form.Floating className="mb-3"> 49 <Form.Control 50 size="md" 51 type="date" 52 placeholder="Датум на заминување:" 53 id="dateTo" 54 name="dateTo" 55 onChange={onFormChange} 56 value={formData.dateTo} 57 ></Form.Control> 58 <label htmlFor="dateTo">Датум на заминување:</label> 59 </Form.Floating> 60 </Col> 61 <Col> 62 <Form.Floating className="mb-3"> 63 <Form.Control 64 size="md" 65 type="number" 66 placeholder="Број на гости:" 67 id="floatingPassengers" 68 name="numBeds" 69 onChange={onFormChange} 70 value={formData.numBeds} 71 ></Form.Control> 72 <label htmlFor="floatingPassengers">Број на гости:</label> 73 </Form.Floating> 74 </Col> 75 <Col> 76 <Form.Group className="my-1"> 77 <Button 78 type="submit" 79 style={{ backgroundColor: "#159895" }} 80 size="lg" 81 className="w-100" 82 onClick={(e) => { 83 e.preventDefault(); 84 window.location.href = `/search/hotel/${formData.hotelLocation}/${formData.dateFrom}/${formData.dateTo}/${formData.numBeds}` 85 }} 86 > 87 <span className="ikona mx-3">Пребарај</span> 88 </Button> 89 </Form.Group> 90 </Col> 91 </Row> 92 </Form> 93 </Container> 94 </> 95 ); 96 }; 11 return ( 12 <> 13 {type === 'hotel' && <SearchCriteriasHotel criterias={criterias}/>} 14 {type === 'transport' && <SearchCriteriasTransport criterias={criterias}/>} 15 </> 16 ) 17 } 97 18 98 export default SearchCriterias ;19 export default SearchCriteriasBar; -
frontend/src/Components/Tab/TabFormTransport.js
re9b4ba9 rac19a0c 2 2 import { Button, Col, Container, Form, Row } from "react-bootstrap"; 3 3 import { HiMagnifyingGlass } from "react-icons/hi2" 4 import useFormData from "../Hooks/useFormData"; 4 5 5 6 function TabFormTransport() { 7 8 const { formData, onFormChange, setFormData } = useFormData({ 9 from: undefined, 10 to: undefined, 11 date: undefined, 12 numPassengers: 0 13 }) 14 6 15 return ( 7 16 <Form> … … 14 23 placeholder="Од:" 15 24 id="floatingFrom" 25 value={formData.from} 26 name={'from'} 27 onChange={onFormChange} 16 28 ></Form.Control> 17 29 <label htmlFor="floatingFrom">Од:</label> … … 25 37 placeholder="До:" 26 38 id="floatingTo" 39 name={'to'} 40 value={formData.to} 41 onChange={onFormChange} 27 42 ></Form.Control> 28 43 <label htmlFor="floatingTo">До:</label> … … 36 51 placeholder="Датум:" 37 52 id="floatingDate" 53 name={'date'} 54 value={formData.date} 55 onChange={onFormChange} 38 56 ></Form.Control> 39 57 <label htmlFor="floatingDate">Датум:</label> … … 46 64 type="number" 47 65 placeholder="Број на патници:" 66 name={'numPassengers'} 48 67 id="floatingPassengers" 68 value={formData.numPassengers} 69 onChange={onFormChange} 49 70 ></Form.Control> 50 71 <label htmlFor="floatingPassengers">Број на патници:</label> 51 72 </Form.Floating> 52 73 <Form.Group className="my-1"> 53 <Button type="submit" style={{backgroundColor: "#159895"}} size="lg"> 74 <Button type="submit" style={{backgroundColor: "#159895"}} size="lg" onClick={(e) => { 75 e.preventDefault(); 76 window.location.href = `/search/transport/${formData.from}/${formData.to}/${formData.date}/${formData.numPassengers}` 77 }}> 54 78 <span className="ikona my-1"><HiMagnifyingGlass/></span> 55 79 <span className="ikona mx-3">Пребарај</span> -
frontend/src/Components/TransportDetails/FinalPoint.js
re9b4ba9 rac19a0c 17 17 <> 18 18 <Row> 19 {props.left === "true" && <Col className="d-flex flex-column justify-content-center col- auto" style={{paddingLeft: "2.6rem"}}>19 {props.left === "true" && <Col className="d-flex flex-column justify-content-center col-md-4" style={{paddingLeft: "2.6rem"}}> 20 20 <h5 className="m-auto">{getTimeAsString(props.time)}</h5> 21 21 </Col> } -
frontend/src/Components/TransportDetails/Line.js
re9b4ba9 rac19a0c 2 2 3 3 const Line = (props) => { 4 console.log(props.left) 5 const left = props.left === "true" ? "9.08rem" : "2.6rem"; 6 console.log({borderLeft: "5px solid #159895", height: "3em", marginLeft: left, marginTop: "-1.4rem", marginBottom: "-1.4rem"}) 4 const left = props.left === "true" ? "1.8rem" : "1.85rem"; 7 5 return (<> 8 6 <div style={{borderLeft: "5px solid #159895", height: "3em", marginLeft: left, marginTop: "-1.4rem", marginBottom: "-1.4rem"}}></div> -
frontend/src/Components/TransportDetails/Waypoint.js
re9b4ba9 rac19a0c 17 17 <> 18 18 <Row className="d-flex flex-row gap-0"> 19 {props.left === "true" && <Col className="d-flex flex-column justify-content-center col- auto" style={{paddingLeft: "2.6rem"}}>19 {props.left === "true" && <Col className="d-flex flex-column justify-content-center col-md-4" style={{paddingLeft: "2.6rem"}}> 20 20 <h5 style={{color: props.routes === "true" ? "white" : "" }} className="m-auto">{getTimeAsString(props.time)}</h5> 21 21 </Col>} … … 30 30 </Col>} 31 31 </Row> 32 <Row> 33 <Line left={props.left}> </Line> 34 </Row> 32 <Row className="d-flex flex-row gap-0"> 33 {props.left === "true" && <Col className="d-flex flex-column justify-content-center col-md-4" style={{paddingLeft: "2.6rem"}}> 34 35 </Col>} 36 <Col md="auto"> 37 <Line left={props.left}> </Line> 38 </Col> 39 <Col className="d-flex flex-column justify-content-center"> 40 </Col> 41 {props.left !== "true" && <Col className="d-flex flex-column justify-content-center"> 42 43 </Col>} 44 </Row> 45 {/*<Row>*/} 46 {/*<Line left={props.left}> </Line>*/} 47 {/*</Row>*/} 35 48 </> 36 49 ); -
frontend/src/Components/TransportEdit/TransportEditTab.js
re9b4ba9 rac19a0c 12 12 function TransportEditTab(props) { 13 13 const [activeTab, setActiveTab] = useState("/hotel"); 14 const link = "/transport/" + props.displayRoute.transportID + "/available";15 14 console.log(props.displayRoute) 16 const [changed, setChanged] = useState(0)17 const { data, setData, isLoading, getData } = useGet(link, changed);18 15 19 16 -
frontend/src/Components/TransportEdit/TransportListing.js
re9b4ba9 rac19a0c 9 9 10 10 //const type = props.type == "hotel" ? "сместувањето" : props.type == "restaurant" ? "ресторанот" : "превозот"; 11 console.log(props.data)12 console.log(props.data.from)13 11 return (<> 14 12 <a href="#" style={{textDecoration: "none", color: "black"}}> … … 34 32 <Col className="d-flex flex-column justify-content-center" style={{textAlign: "left"}}> 35 33 <h2>{props.data.from} - {props.data.to}</h2> 36 {/* <h6>{props.data.routeCities}</h6> */}37 34 <h6>{props.data.routes.map(x => x).join(", ")}</h6> 38 35 </Col> … … 40 37 <Col className="d-flex flex-column justify-content-center align-content-center"> 41 38 <h5>Цена:</h5> 42 {/* <h4>{props.data.routePrice}</h4> */} 43 <h4>99$</h4> 39 <h4>{props.data.maxPrice}$</h4> 44 40 </Col> 45 41 </Row> -
frontend/src/Components/useFormNested.js
re9b4ba9 rac19a0c 7 7 console.log(e) 8 8 9 const dependantRoutes = e.target. parentElement.getAttribute('dependantRoutes').split(',')9 const dependantRoutes = e.target.name === 'freeSpace' ? e.target.parentElement.getAttribute('dependantRoutes').split(',') : undefined; 10 10 console.log(dependantRoutes) 11 11 -
frontend/src/Pages/HotelDetailsPage.js
re9b4ba9 rac19a0c 1 1 import React from "react"; 2 2 import LoginForm from "../Components/Login/LoginForm"; 3 import { Container, Row, Col, Form} from "react-bootstrap";3 import {Container, Row, Col, Form, FloatingLabel} from "react-bootstrap"; 4 4 import Navigation from "../Components/Layout/Navbar/Navigation"; 5 5 import Carousel from "react-bootstrap/Carousel"; … … 69 69 placeholder="Каде ќе патувате?:" 70 70 id="location" 71 value={data.hotelLocation} 71 72 ></Form.Control> 72 <label htmlFor="location">Локација:</label>73 <label style={{left: "10px"}} htmlFor="location">Локација:</label> 73 74 </Form.Floating> 74 75 </Row> … … 80 81 placeholder="Датум на пристигнување:" 81 82 id="dateFrom" 83 value={from} 82 84 ></Form.Control> 83 <label htmlFor="dateFrom">Датум на пристигнување:</label>85 <label style={{left: "10px"}} htmlFor="dateFrom">Датум на пристигнување:</label> 84 86 </Form.Floating> 85 87 </Row> … … 91 93 placeholder="Датум на заминување:" 92 94 id="dateTo" 95 value={to} 93 96 ></Form.Control> 94 <label htmlFor="dateTo">Датум на заминување:</label>97 <label style={{left: "10px"}} htmlFor="dateTo">Датум на заминување:</label> 95 98 </Form.Floating> 96 99 </Row> … … 103 106 id="floatingPassengers" 104 107 ></Form.Control> 105 <label htmlFor="floatingPassengers">Број на гости:</label>108 <label style={{left: "10px"}} htmlFor="floatingPassengers">Број на гости:</label> 106 109 </Form.Floating> 107 110 </Row> -
frontend/src/Pages/HotelEditPage.js
re9b4ba9 rac19a0c 1 import React, { useState} from "react";2 import { Container, Col, Row, Image} from "react-bootstrap";1 import React, {useState} from "react"; 2 import {Container, Col, Row, Image} from "react-bootstrap"; 3 3 import Navigation from "../Components/Layout/Navbar/Navigation"; 4 4 import ResourcesTab from "../Components/Resources/ResourcesTab"; 5 5 import HotelEditTab from "../Components/HotelEdit/HotelEditTab"; 6 6 import useGet from "../Components/Hooks/useGet"; 7 import { useParams } from "react-router-dom"; 7 import {Navigate, useParams} from "react-router-dom"; 8 import {useAuth} from "../Components/Context/AuthContext"; 8 9 9 10 10 11 const HotelEditPage = () => { 11 12 12 const params = useParams();13 const link = "/hotel/list/" + params.hotelId;14 const [changed, setChanged] = useState(0)15 const { data, setData, isLoading, getData} = useGet(link, changed);13 const params = useParams(); 14 const link = "/hotel/list/" + params.hotelId; 15 const [changed, setChanged] = useState(0) 16 const {data, setData, isLoading, getData} = useGet(link, changed); 16 17 17 18 18 console.log(data)19 return (20 <>21 <Navigation/>22 {!isLoading && <Container>23 <Row className="mb-5">24 <h2 style={{ color: "#159895", textAlign: "left"}}>Мои ресурси</h2>25 </Row>26 <Row className="mb-5">27 <Col>28 <Row className="d-flex mb-3">29 <Col30 className="d-flex justify-content-center"31 style={{ maxWidth: "30%"}}32 >33 <Image34 src="https://t3.ftcdn.net/jpg/05/16/27/58/360_F_516275801_f3Fsp17x6HQK0xQgDQEELoTuERO4SsWV.jpg"35 style={{36 height: "5em",37 borderRadius: "50%",38 maxWidth: "100%",39 }}40 className="m-auto"41 ></Image>42 </Col>43 <Col className="d-flex justify-content-center">44 <Container className="pt-2" style={{ textAlign: "left"}}>45 <h4>{data.hotelName}</h4>46 <h5>{data.hotelLocation}</h5>47 </Container>48 </Col>49 </Row>50 </Col>51 </Row>52 <Row>53 <HotelEditTab refresh={setChanged} displayRoom={data}/>54 </Row>55 </Container>}56 </>57 );19 console.log(data) 20 return ( 21 <> 22 <Navigation/> 23 {!isLoading && <Container> 24 <Row className="mb-5"> 25 <h2 style={{color: "#159895", textAlign: "left"}}>Мои ресурси</h2> 26 </Row> 27 <Row className="mb-5"> 28 <Col> 29 <Row className="d-flex mb-3"> 30 <Col 31 className="d-flex justify-content-center" 32 style={{maxWidth: "30%"}} 33 > 34 <Image 35 src="https://t3.ftcdn.net/jpg/05/16/27/58/360_F_516275801_f3Fsp17x6HQK0xQgDQEELoTuERO4SsWV.jpg" 36 style={{ 37 height: "5em", 38 borderRadius: "50%", 39 maxWidth: "100%", 40 }} 41 className="m-auto" 42 ></Image> 43 </Col> 44 <Col className="d-flex justify-content-center"> 45 <Container className="pt-2" style={{textAlign: "left"}}> 46 <h4>{data.hotelName}</h4> 47 <h5>{data.hotelLocation}</h5> 48 </Container> 49 </Col> 50 </Row> 51 </Col> 52 </Row> 53 <Row> 54 <HotelEditTab refresh={setChanged} displayRoom={data}/> 55 </Row> 56 </Container>} 57 </> 58 ); 58 59 }; 59 60 -
frontend/src/Pages/LoginErrorPage.js
re9b4ba9 rac19a0c 11 11 const [show, setShow] = useState(false); 12 12 const [changed, setChanged] = useState(0); 13 const {data, isLoading} = useGet("/username")14 13 const userId = localStorage.getItem("userId") 15 14 const [registered, setRegistered] = useState(false); -
frontend/src/Pages/LoginPage.js
re9b4ba9 rac19a0c 3 3 import { Container } from "react-bootstrap"; 4 4 import Navigation from "../Components/Layout/Navbar/Navigation"; 5 import {useAuth} from "../Components/Context/AuthContext"; 6 import {Navigate} from "react-router-dom"; 7 5 8 6 9 const LoginPage = () => { … … 8 11 document.body.style.marginTop = "auto"; 9 12 document.body.style.marginBottom = "auto"; 13 14 const Auth = useAuth(); 15 const isLoggedIn = Auth.userIsAuthenticated(); 16 17 if (isLoggedIn) { 18 return <Navigate to={'/home'}/> 19 } 20 10 21 return ( 11 22 <> -
frontend/src/Pages/NoBusinessRegisteredError.js
re9b4ba9 rac19a0c 6 6 import RegisterBusinessForm from "../Components/Forms/RegisterBusinessForm"; 7 7 import useGet from "../Components/Hooks/useGet"; 8 import { useNavigate } from "react-router-dom"; 8 import {Navigate, useNavigate} from "react-router-dom"; 9 import {useAuth} from "../Components/Context/AuthContext"; 9 10 10 11 const NoBusinessRegisteredError = (props) => { 11 12 const [show, setShow] = useState(false); 12 13 const [changed, setChanged] = useState(0); 13 const {data, isLoading} = useGet("/username") 14 const Auth = useAuth(); 15 const isLoggedIn = Auth.userIsAuthenticated(); 14 16 const userId = localStorage.getItem("userId") 15 17 const [registered, setRegistered] = useState(false); … … 45 47 46 48 47 console.log(data) 49 if(!isLoggedIn) 50 { 51 return <Navigate to={'/login'}/> 52 } 48 53 49 !isLoading && !data && navigator("/login")50 54 !firmaIsLoading && firma && firma.length > 0 && firma[0].approved && navigator("/resources/hotel") 51 55 -
frontend/src/Pages/ProfilePage.js
re9b4ba9 rac19a0c 8 8 import ChangePasswordForm from "../Components/Forms/ChangePasswordForm"; 9 9 import useGet from "../Components/Hooks/useGet"; 10 import {useAuth} from "../Components/Context/AuthContext"; 11 import {Navigate} from "react-router-dom"; 10 12 11 13 const ProfilePage = () => { 12 14 13 const { data, setData, isLoading, getData } = useGet("/principal");15 const { data, setData, isLoading, getData } = useGet("/principal"); 14 16 15 17 18 16 19 const profileData = { 17 20 "name": "Марко", … … 19 22 "address": "ул. Раскрсница бр. 10", 20 23 "dateOfBirth": "2002-01-01", 21 "country": " Никогаш Северна само МАКЕДОНИЈА",24 "country": "Македонија", 22 25 "zip": "1000", 23 26 "city": "Скопје", … … 27 30 28 31 32 29 33 return ( 30 34 <> 31 35 <Navigation /> 32 {!isLoading && <Container>36 {!isLoading && <Container> 33 37 <Row className="mb-5"> 34 38 <h2 style={{ color: "#159895", textAlign: "left" }}>Мојот профил</h2> -
frontend/src/Pages/ResourcesPage.js
re9b4ba9 rac19a0c 1 1 import React from "react"; 2 import { Container, Col, Row, Image} from "react-bootstrap";2 import {Container, Col, Row, Image} from "react-bootstrap"; 3 3 import Navigation from "../Components/Layout/Navbar/Navigation"; 4 4 import ResourcesTab from "../Components/Resources/ResourcesTab"; 5 import { useState} from "react";5 import {useState} from "react"; 6 6 import useGet from "../Components/Hooks/useGet"; 7 import {useAuth} from "../Components/Context/AuthContext"; 8 import {Navigate} from "react-router-dom"; 7 9 8 10 const ResourcesPage = (props) => { 9 11 10 console.log(props.tab)11 const { data, setData, isLoading, getData } = useGet("/principal");12 const Auth = useAuth(); 13 const user = Auth.getUser(); 12 14 13 14 return ( 15 <> 16 <Navigation /> 17 {!isLoading && <Container> 18 <Row className="mb-5"> 19 <h2 style={{ color: "#159895", textAlign: "left" }}>Мои ресурси</h2> 20 </Row> 21 <Row className="mb-5"> 22 <Col> 23 <Row className="d-flex mb-3"> 24 <Col 25 className="d-flex justify-content-center" 26 style={{ maxWidth: "30%" }} 27 > 28 <Image 29 src="https://t3.ftcdn.net/jpg/05/16/27/58/360_F_516275801_f3Fsp17x6HQK0xQgDQEELoTuERO4SsWV.jpg" 30 style={{ 31 height: "5em", 32 borderRadius: "50%", 33 maxWidth: "100%", 34 }} 35 className="m-auto" 36 ></Image> 37 </Col> 38 <Col className="d-flex justify-content-center"> 39 <Container className="pt-2" style={{ textAlign: "left" }}> 40 <h4>{data.name + " " + data.surname}</h4> 41 <h5>{data.email}</h5> 42 </Container> 43 </Col> 44 </Row> 45 </Col> 46 </Row> 47 <Row> 48 <ResourcesTab tab={props.tab}></ResourcesTab> 49 </Row> 50 </Container>} 51 </> 52 ); 15 return ( 16 <> 17 <Navigation/> 18 {<Container> 19 <Row className="mb-5"> 20 <h2 style={{color: "#159895", textAlign: "left"}}>Мои ресурси</h2> 21 </Row> 22 <Row className="mb-5"> 23 <Col> 24 <Row className="d-flex mb-3"> 25 <Col 26 className="d-flex justify-content-center" 27 style={{maxWidth: "30%"}} 28 > 29 <Image 30 src="https://t3.ftcdn.net/jpg/05/16/27/58/360_F_516275801_f3Fsp17x6HQK0xQgDQEELoTuERO4SsWV.jpg" 31 style={{ 32 height: "5em", 33 borderRadius: "50%", 34 maxWidth: "100%", 35 }} 36 className="m-auto" 37 ></Image> 38 </Col> 39 <Col className="d-flex justify-content-center"> 40 <Container className="pt-2" style={{textAlign: "left"}}> 41 <h4>{user.name + " " + user.surname}</h4> 42 <h5>{user.username}</h5> 43 </Container> 44 </Col> 45 </Row> 46 </Col> 47 </Row> 48 <Row> 49 <ResourcesTab tab={props.tab}></ResourcesTab> 50 </Row> 51 </Container>} 52 </> 53 ); 53 54 }; 54 55 -
frontend/src/Pages/RestaurantEditPage.js
re9b4ba9 rac19a0c 6 6 import RestaurantEditTab from "../Components/RestaurantEdit/RestaurantEditTab"; 7 7 import useGet from "../Components/Hooks/useGet"; 8 import { useParams, useSearchParams } from "react-router-dom"; 8 import {Navigate, useParams, useSearchParams} from "react-router-dom"; 9 import {useAuth} from "../Components/Context/AuthContext"; 9 10 10 11 const RestaurantEditPage = () => { -
frontend/src/Pages/SearchPage.js
re9b4ba9 rac19a0c 11 11 import BecomeAHost from "../Components/BecomeAHost/BecomeAHost" 12 12 import HotelLisitng from "../Components/Listings/HotelListing" 13 import SearchCriterias from "../Components/SearchCriterias/SearchCriteriasBar";13 import SearchCriteriasHotel from "../Components/SearchCriterias/SearchCriteriasHotel"; 14 14 import SortButton from "../Components/Listings/SortButton"; 15 15 import FilterButton from "../Components/Listings/FilterButton"; … … 17 17 import useGet from "../Components/Hooks/useGet"; 18 18 import { useParams } from "react-router-dom"; 19 import SearchCriteriasBar from "../Components/SearchCriterias/SearchCriteriasBar"; 19 20 20 21 … … 36 37 } 37 38 38 let link = props.type === "transport" ? `/transport/search?from=${params.from}&to=${params.to}&date=${params.date} ` : props.type === "hotel" ? `/hotel/search?hotelLocation=${params.hotelLocation}&dateFrom=${params.dateFrom}&dateTo=${params.dateTo}&numBeds=${params.numBeds}` : ""39 let link = props.type === "transport" ? `/transport/search?from=${params.from}&to=${params.to}&date=${params.date}&numPassengers=${params.numPassengers}` : props.type === "hotel" ? `/hotel/search?hotelLocation=${params.hotelLocation}&dateFrom=${params.dateFrom}&dateTo=${params.dateTo}&numBeds=${params.numBeds}` : "" 39 40 console.log(link) 40 41 const { data, isLoading, getData, setData } = useGet(link); … … 43 44 <> 44 45 <Navigation></Navigation> 45 <SearchCriterias criterias={useParams()}></SearchCriterias>46 <SearchCriteriasBar type={props.type} criterias={useParams()}></SearchCriteriasBar> 46 47 <Container className="d-flex justify-content-end gx-5" style={{maxWidth: "60%"}}> 47 48 <Row> -
frontend/src/Pages/TransportEditPage.js
re9b4ba9 rac19a0c 1 import React, { useState} from "react";2 import { Container, Col, Row, Image} from "react-bootstrap";1 import React, {useState} from "react"; 2 import {Container, Col, Row, Image} from "react-bootstrap"; 3 3 import Navigation from "../Components/Layout/Navbar/Navigation"; 4 4 import ResourcesTab from "../Components/Resources/ResourcesTab"; … … 7 7 import TransportEditTab from "../Components/TransportEdit/TransportEditTab"; 8 8 import useGet from "../Components/Hooks/useGet"; 9 import { useParams } from "react-router-dom"; 9 import {Navigate, useParams} from "react-router-dom"; 10 import {useAuth} from "../Components/Context/AuthContext"; 10 11 11 12 const TransportEditPage = () => { 12 const params = useParams();13 console.log("transportot ima id " + params.transportId);14 const link = "/transport/" + params.transportId;15 const [changed, setChanged] = useState(0);16 const { data, setData, isLoading, getData } = useGet(link, changed);17 13 18 !isLoading && console.log(data)14 const params = useParams(); 19 15 20 return ( 21 <> 22 <Navigation /> 23 {!isLoading && ( 24 <Container> 25 <Row className="mb-5"> 26 <h2 style={{ color: "#159895", textAlign: "left" }}>Мои ресурси</h2> 27 </Row> 28 <Row className="mb-5"> 29 <Col> 30 <Row className="d-flex mb-3"> 31 <Col 32 className="d-flex justify-content-center" 33 style={{ maxWidth: "30%" }} 34 > 35 <Image 36 src="https://t3.ftcdn.net/jpg/05/16/27/58/360_F_516275801_f3Fsp17x6HQK0xQgDQEELoTuERO4SsWV.jpg" 37 style={{ 38 height: "5em", 39 borderRadius: "50%", 40 maxWidth: "100%", 41 }} 42 className="m-auto" 43 ></Image> 44 </Col> 45 <Col className="d-flex justify-content-center"> 46 <Container className="pt-2" style={{ textAlign: "left" }}> 47 <h4>{data.transportName}</h4> 48 <h5>{data.carBrand + " " + data.carType}</h5> 49 </Container> 50 </Col> 51 </Row> 52 </Col> 53 </Row> 54 <Row> 55 {data && <TransportEditTab displayRoute={data} refresh={setChanged}/>} 56 </Row> 57 </Container> 58 )} 59 </> 60 ); 16 const link = "/transport/" + params.transportId; 17 18 const {data, setData, isLoading, getData, setChanged} = useGet(link); 19 20 !isLoading && console.log(data) 21 22 return ( 23 <> 24 <Navigation/> 25 {!isLoading && ( 26 <Container> 27 <Row className="mb-5"> 28 <h2 style={{color: "#159895", textAlign: "left"}}>Мои ресурси</h2> 29 </Row> 30 <Row className="mb-5"> 31 <Col> 32 <Row className="d-flex mb-3"> 33 <Col 34 className="d-flex justify-content-center" 35 style={{maxWidth: "30%"}} 36 > 37 <Image 38 src="https://t3.ftcdn.net/jpg/05/16/27/58/360_F_516275801_f3Fsp17x6HQK0xQgDQEELoTuERO4SsWV.jpg" 39 style={{ 40 height: "5em", 41 borderRadius: "50%", 42 maxWidth: "100%", 43 }} 44 className="m-auto" 45 ></Image> 46 </Col> 47 <Col className="d-flex justify-content-center"> 48 <Container className="pt-2" style={{textAlign: "left"}}> 49 <h4>{data.transportName}</h4> 50 <h5>{data.carBrand + " " + data.carType}</h5> 51 </Container> 52 </Col> 53 </Row> 54 </Col> 55 </Row> 56 <Row> 57 {data && <TransportEditTab displayRoute={data} refresh={setChanged}/>} 58 </Row> 59 </Container> 60 )} 61 </> 62 ); 61 63 }; 62 64 -
frontend/src/axios.js
re9b4ba9 rac19a0c 1 1 import axios from "axios"; 2 2 3 3 4 const instance = axios.create({ 4 5 baseURL: "http://localhost:8080/", 5 6 withCredentials: true, 6 maxRedirects: 1 7 maxRedirects: 1, 8 beforeRedirect: (options, { headers }) => { 9 console.log(options) 10 if (options.hostname === "example.com") { 11 options.auth = "user:password"; 12 }} 13 7 14 }) 8 15 9 instance.interceptors.response.use(function (response) {10 // Any status code that lie within the range of 2xx cause this function to trigger11 // Do something with response data12 return response;13 }, function (error) {14 console.log(error)15 // window.location.href="/login"16 // Any status codes that falls outside the range of 2xx cause this function to trigger17 // Do something with response error18 return Promise.reject(error);19 });20 21 16 export default instance -
src/main/java/com/tourMate/config/SecurityConfig.java
re9b4ba9 rac19a0c 7 7 import org.springframework.http.HttpHeaders; 8 8 import org.springframework.http.HttpMethod; 9 import org.springframework.http.HttpStatus; 9 10 import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 11 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; … … 14 15 import org.springframework.security.web.SecurityFilterChain; 15 16 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 17 import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; 16 18 import org.springframework.security.web.util.matcher.AntPathRequestMatcher; 17 19 import org.springframework.web.cors.CorsConfiguration; … … 72 74 .anyRequest().authenticated() 73 75 .and() 74 .formLogin() .loginPage("http://localhost:3000/login")76 .formLogin() 75 77 .loginProcessingUrl("/api/login").usernameParameter("username").passwordParameter("password") 76 78 .successHandler((request, response, authentication) -> { 77 79 response.setStatus(HttpServletResponse.SC_OK); 80 response.setCharacterEncoding("UTF-8"); 78 81 response.setContentType("application/json"); 79 82 response.getWriter().print("{\"message\": \"Login successful\","); … … 83 86 .failureHandler((request, response, exception) -> { 84 87 response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); 85 response.getWriter().print("Pukla veza\n" + exception.getMessage()); 88 response.sendRedirect("/login"); 89 response.getWriter().print("Neuspesna najava\n" + exception.getMessage()); 86 90 response.getWriter().flush(); 87 91 }) … … 91 95 .sessionCreationPolicy(SessionCreationPolicy.ALWAYS) 92 96 .and() 93 .logout() 97 .logout().logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))) 94 98 .permitAll(); 95 99 -
src/main/java/com/tourMate/controllers/HotelController.java
re9b4ba9 rac19a0c 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto; 5 import com.tourMate.dto.HotelReservationUserDto; 4 6 import com.tourMate.entities.*; 5 7 import com.tourMate.services.HotelManager; … … 117 119 //HOTEL ROOM CRUD 118 120 @PostMapping(path = "/hotel/rooms/add") 119 public void addRoom(@RequestBody HotelRoom room, @RequestParam(name = "hotelId") long hotelId) { 121 public void addRoom(@RequestBody HotelRoom room, 122 @RequestParam(name = "hotelId") long hotelId) { 120 123 Hotels h = hotelManager.findHotelByID(hotelId); 121 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice() );124 hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice(), room.getNumOfBeds()); 122 125 } 123 126 … … 162 165 //HOTEL AVAILABILITY CRUD 163 166 @PostMapping(path = "/hotel/rooms/available/{id}/add") 164 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, @PathVariable long id) 167 public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, 168 @PathVariable long id) 165 169 { 166 170 HotelRoom hotelRoom = hotelManager.findRoomById(id); … … 191 195 public List<HotelRoomAvailable> getRoomAvailability(@PathVariable Long id) 192 196 { 193 return hotelManager.getRoomsAvail ibility();197 return hotelManager.getRoomsAvailableById(id); 194 198 } 195 199 196 200 @GetMapping(path = "/hotel/search") 197 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 198 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, @RequestParam(name = "numBeds") int numBeds) 201 public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, 202 @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom, 203 @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, 204 @RequestParam(name = "numBeds") int numBeds) 199 205 { 200 206 System.out.println(hotelLocation); … … 216 222 } 217 223 224 @GetMapping(path = "/hotel/{id}/reservations/active") 225 public List<HotelReservationDto> getActiveReservationsForHotel(@PathVariable Long id) 226 { 227 return hotelManager.findVaidReseravtionsByHotel(id); 228 } 229 230 @GetMapping(path = "/hotel/reservations/user/{id}") 231 public List<HotelReservationUserDto> getActiveReservationsForUser(@PathVariable Long id) 232 { 233 return hotelManager.findValidHotelReservationsByUser(id); 234 } 218 235 } -
src/main/java/com/tourMate/controllers/TransportController.java
re9b4ba9 rac19a0c 23 23 24 24 // TRANSPORT CRUD // 25 @PostMapping(path = "/transport/add") 26 public void add(@RequestBody Transport transport) { 27 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), new User(), transport.getCarPlate()); 25 @PostMapping(path = "/transport/add/{userId}") 26 public void add(@RequestBody Transport transport, 27 @PathVariable Long userId) { 28 transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), userId, transport.getCarPlate()); 28 29 29 30 } … … 48 49 public TransportDto getTransport(@PathVariable(name = "id") long transportId) 49 50 { 50 System.out.println("TUKA SUUUUUM");51 51 return transportManager.findTransportById(transportId); 52 52 } … … 92 92 @PostMapping(path = "/transport/available/add") 93 93 public void add(@RequestBody TransportAvailible transportAvailable, @RequestParam(name = "transportId") long transportId) { 94 System.out.println("OREEEEEL");95 System.out.println("DVA ORLA");96 94 Transport t = transportManager.getTransportById(transportId); 97 95 List<TransportRoute> routes = transportAvailable.getRoutes().stream().toList(); … … 135 133 136 134 @GetMapping(path = "/transport/search") 137 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, @RequestParam(name = "to") String to, 138 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date){ 139 return transportManager.getTransportsAvailableByFilters(from, to, date); 135 public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, 136 @RequestParam(name = "to") String to, 137 @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date, 138 @RequestParam(name = "numPassengers") int numPassengers){ 139 return transportManager.getTransportsAvailableByFilters(from, to, date, numPassengers); 140 140 } 141 141 } -
src/main/java/com/tourMate/controllers/UsersController.java
re9b4ba9 rac19a0c 11 11 import org.springframework.web.bind.annotation.*; 12 12 13 import java.util.ArrayList;14 13 import java.util.List; 15 14 … … 39 38 { 40 39 return businessManager.getUnapprovedBusinessesOfUser(userId); 40 } 41 42 @GetMapping(path = "/business/unapproved") 43 public List<Business> getAllUnapprovedBusinesses() 44 { 45 return businessManager.getUnapprovedBusinesses(); 46 } 47 48 @GetMapping(path = "/users/unapproved") 49 public List<User> getAllUnapprovedUsers() 50 { 51 return usersManager.getUnapprovedUsers(); 52 } 53 54 @GetMapping(path = "/users/approve/{userId}") 55 public ResponseEntity<?> approveUserProfile(@PathVariable Long userId) 56 { 57 usersManager.approveUserProfile(userId); 58 return new ResponseEntity<>(HttpStatus.OK); 59 60 61 } 62 63 @GetMapping(path = "/business/approve/{businessId}") 64 public ResponseEntity<?> approveBusiness(@PathVariable Long businessId) 65 { 66 businessManager.approveBusiness(businessId); 67 return new ResponseEntity<>(HttpStatus.OK); 41 68 } 42 69 -
src/main/java/com/tourMate/dao/BusinessDao.java
re9b4ba9 rac19a0c 11 11 @Transactional 12 12 void createBusiness(Business business, long userId); 13 publicList<Business> getUnapprovedBusinessesOfUser(long userId);14 publicvoid deleteBusiness(long businessId);15 publicList<Business> getCreatedBusinesses();16 publicBusiness findBusinessById (long businessId);13 List<Business> getUnapprovedBusinessesOfUser(long userId); 14 void deleteBusiness(long businessId); 15 List<Business> getCreatedBusinesses(); 16 Business findBusinessById (long businessId); 17 17 18 18 @Transactional 19 19 void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved); 20 publicboolean hasBusiness(long userId);20 boolean hasBusiness(long userId); 21 21 22 List<Business> getUnapprovedBusinesses(); 23 24 void approveBusiness(Business business); 22 25 } -
src/main/java/com/tourMate/dao/HotelDao.java
re9b4ba9 rac19a0c 23 23 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 24 24 25 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price );25 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds); 26 26 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 27 27 public void deleteRoom(long hotelRoomId); -
src/main/java/com/tourMate/dao/TransportDao.java
re9b4ba9 rac19a0c 12 12 public interface TransportDao { 13 13 14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate); 15 15 16 16 public void deleteTransport(long transportId); … … 47 47 public List<TransportAvailible> getTransportsAvailable(); 48 48 49 public List<TransportRoute> getTransportsAvailableByFilters (String from, String to,Date date);49 public List<TransportRoute> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers); 50 50 51 51 public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order); -
src/main/java/com/tourMate/dao/UsersDao.java
re9b4ba9 rac19a0c 23 23 24 24 UserDetails findUserByUsername(String username); 25 26 List<User> getUnapprovedUsers(); 27 28 void approveUserProfile(User u); 25 29 } -
src/main/java/com/tourMate/dao/impl/BusinessDaoImpl.java
re9b4ba9 rac19a0c 46 46 } 47 47 48 @Override 49 public List<Business> getUnapprovedBusinesses() { 50 return em.createQuery("select b from Business b where not b.approved").getResultList(); 51 } 52 53 @Override 54 @Transactional 55 public void approveBusiness(Business b) { 56 b.setApproved(true); 57 em.persist(b); 58 } 59 48 60 49 61 @Override -
src/main/java/com/tourMate/dao/impl/HotelDaoImpl.java
re9b4ba9 rac19a0c 28 28 public List<Hotels> getHotels() { 29 29 List<Hotels> hoteli = em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); 30 System.out.println("OREEEEEEL");31 30 return hoteli; 32 31 //return em.createQuery("select h from Hotels h order by h.hotelId").getResultList(); … … 119 118 @Transactional 120 119 @Override 121 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {122 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price );120 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 121 HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds); 123 122 em.persist(hotelRoom); 124 123 } … … 188 187 public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds) { 189 188 return em.createQuery("select hr from HotelRoomAvailable hr where hr.dateFrom <= :dateFrom and hr.dateTo >= :dateTo " + 190 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr. numberOfBeds >= :numBeds")189 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.hotelRoom.numOfBeds >= :numBeds") 191 190 .setParameter("hotelLocation", hotelLocation) 192 191 .setParameter("dateFrom", dateFrom) … … 236 235 public List<HotelRoomReservations> findReservationByHotel(Hotels hotel) { 237 236 List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel.getHotelId()); 238 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom in :hotelRooms").setParameter("hotelRooms", hotelRooms).getResultList();237 return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom.hotel = :hotel").setParameter("hotel", hotel).getResultList(); 239 238 } 240 239 -
src/main/java/com/tourMate/dao/impl/TransportDaoImpl.java
re9b4ba9 rac19a0c 22 22 @Override 23 23 @Transactional 24 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) {25 User u = em.find(User.class, 1);24 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) { 25 User u = em.find(User.class, userId); 26 26 Transport t=new Transport(transportName,carBrand,carType,carManufacturedYear,noPassengers,noBags,EMBG,u,carPlate); 27 27 em.persist(t); … … 62 62 y.getFreeSpace(), 63 63 y.getTime(), 64 y.getRoutes() 65 )).toList() 64 y.getRoutes(), 65 y.getRoutes().stream() 66 .mapToDouble(TransportRoute::getPrice) 67 .max().orElse(0) 68 )).toList(), 69 x.getAvailableRoutes().stream() 70 .flatMapToDouble(y -> y.getRoutes() 71 .stream() 72 .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0) 66 73 )).toList(); 67 74 } … … 78 85 x.getFreeSpace(), 79 86 x.getTime(), 80 x.getRoutes() 87 x.getRoutes(), 88 x.getRoutes().stream() 89 .mapToDouble(TransportRoute::getPrice) 90 .max().orElse(0) 81 91 )).toList(); 82 92 } … … 103 113 y.getFreeSpace(), 104 114 y.getTime(), 105 y.getRoutes() 106 )).toList()); 115 y.getRoutes(), 116 y.getRoutes().stream() 117 .mapToDouble(TransportRoute::getPrice) 118 .max().orElse(0) 119 )).toList(), 120 x.getAvailableRoutes().stream() 121 .flatMapToDouble(y -> y.getRoutes() 122 .stream() 123 .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0)); 107 124 } 108 125 … … 151 168 152 169 @Override 153 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date ) {170 public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date, int numPassengers) { 154 171 System.out.println(fromL + " " + toL); 155 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol").setParameter("froml", fromL). 156 setParameter("tol", toL).getResultList(); 172 return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol and h.freeSpace >= :nump") 173 .setParameter("froml", fromL) 174 .setParameter("tol", toL) 175 .setParameter("nump", numPassengers) 176 .getResultList(); 157 177 } 158 178 -
src/main/java/com/tourMate/dao/impl/UsersDaoImpl.java
re9b4ba9 rac19a0c 74 74 } 75 75 76 @Override 77 public List<User> getUnapprovedUsers() { 78 return em.createQuery("select u from User u where not u.enabled").getResultList(); 79 } 80 81 @Override 82 @Transactional 83 public void approveUserProfile(User u) { 84 u.setEnabled(true); 85 em.persist(u); 86 } 76 87 77 88 -
src/main/java/com/tourMate/dto/RouteListingDto.java
re9b4ba9 rac19a0c 18 18 private Date time; 19 19 private Collection<String> routes; 20 private Double maxPrice; 20 21 21 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes ) {22 public RouteListingDto(long transportAvailibleId, String from, String to, Date date, int freeSpace, Date time, Collection<TransportRoute> routes, Double maxPrice) { 22 23 this.transportAvailibleId = transportAvailibleId; 23 24 this.from = from; … … 27 28 this.time = time; 28 29 this.routes = routes.stream().map(x -> x.getFrom()).distinct().skip(1).toList(); 30 this.maxPrice = maxPrice; 29 31 } 30 32 … … 84 86 this.routes = routes; 85 87 } 88 89 public Double getMaxPrice() { 90 return maxPrice; 91 } 86 92 } -
src/main/java/com/tourMate/dto/TransportDto.java
re9b4ba9 rac19a0c 16 16 private User owner; 17 17 private String carPlate; 18 private Double maxPrice; 18 19 private Collection<RouteListingDto> availableRoutes; 19 20 20 public TransportDto(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate, Collection<RouteListingDto> availableRoutes ) {21 public TransportDto(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate, Collection<RouteListingDto> availableRoutes, Double maxPrice) { 21 22 this.transportID = transportID; 22 23 this.transportName = transportName; … … 30 31 this.carPlate = carPlate; 31 32 this.availableRoutes = availableRoutes; 33 this.maxPrice = maxPrice; 32 34 } 33 35 -
src/main/java/com/tourMate/entities/Business.java
re9b4ba9 rac19a0c 88 88 } 89 89 90 @OneToOne(fetch = FetchType. LAZY)90 @OneToOne(fetch = FetchType.EAGER) 91 91 @JoinColumn(name = "owner_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_biznis_kon_korisnik")) 92 92 public User getUser() { … … 107 107 this.approved = approved; 108 108 } 109 109 110 } -
src/main/java/com/tourMate/entities/HotelRoom.java
re9b4ba9 rac19a0c 16 16 private String hotelRoomName; 17 17 private double price; 18 private int numOfBeds; 18 19 private Boolean kitchenAvailable; 19 20 private Boolean airConditioning; 20 21 private Boolean balcony; 21 22 22 public HotelRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, double price, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony ) {23 public HotelRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, double price, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, int numOfBeds) { 23 24 this.hotelRoomId = hotelRoomId; 24 25 this.hotel = hotel; … … 29 30 this.airConditioning = airConditioning; 30 31 this.balcony = balcony; 32 this.numOfBeds = numOfBeds; 31 33 } 32 34 33 35 public HotelRoom(Hotels hotel, String hotelRoomDescription, String type, 34 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {36 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 35 37 this.hotel = hotel; 36 38 this.hotelRoomDescription = hotelRoomDescription; … … 40 42 this.balcony = balcony; 41 43 this.price = price; 44 this.numOfBeds = numOfBeds; 42 45 } 43 46 44 47 public HotelRoom(String hotelRoomDescription, String type, 45 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {48 Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 46 49 this.hotel = hotel; 47 50 this.hotelRoomDescription = hotelRoomDescription; … … 51 54 this.balcony = balcony; 52 55 this.price = price; 56 this.numOfBeds = numOfBeds; 53 57 } 54 58 … … 68 72 } 69 73 70 @ManyToOne(fetch = FetchType. LAZY)74 @ManyToOne(fetch = FetchType.EAGER) 71 75 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_room_kon_hotel")) 72 76 public Hotels getHotel() { … … 134 138 this.balcony = balcony; 135 139 } 140 141 @Column(name = "hotel_room_num_beds", unique = false) 142 public int getNumOfBeds() { 143 return numOfBeds; 144 } 145 146 public void setNumOfBeds(int numOfBeds) { 147 this.numOfBeds = numOfBeds; 148 } 136 149 } -
src/main/java/com/tourMate/entities/HotelRoomReservations.java
re9b4ba9 rac19a0c 41 41 } 42 42 43 @ManyToOne(fetch = FetchType. LAZY)43 @ManyToOne(fetch = FetchType.EAGER) 44 44 @JoinColumn(name = "room_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_room")) 45 45 public HotelRoom getHotelRoom() { … … 57 57 } 58 58 59 @OneToOne(fetch = FetchType. LAZY)59 @OneToOne(fetch = FetchType.EAGER) 60 60 @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_user")) 61 61 public User getUser() { -
src/main/java/com/tourMate/entities/Reviews.java
re9b4ba9 rac19a0c 71 71 72 72 @ManyToOne(fetch = FetchType.LAZY) 73 @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))73 @JoinColumn(name = "hotel_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel")) 74 74 public Hotels getHotel () { 75 75 return hotel; … … 81 81 82 82 @ManyToOne(fetch = FetchType.LAZY) 83 @JoinColumn(name = "restaurant_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))83 @JoinColumn(name = "restaurant_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani")) 84 84 public Restaurant getRestaurant () { 85 85 return restaurant; … … 91 91 92 92 @ManyToOne(fetch = FetchType.LAZY) 93 @JoinColumn(name = "transport_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))93 @JoinColumn(name = "transport_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport")) 94 94 public Transport getTransport () { 95 95 return transport; -
src/main/java/com/tourMate/entities/User.java
re9b4ba9 rac19a0c 52 52 private Role role; 53 53 @Column(name = "locked", unique = false, nullable = false) 54 boolean locked ;54 boolean locked = false; 55 55 56 56 @Column(name = "enabled", unique = false, nullable = false) … … 162 162 @Override 163 163 public boolean isAccountNonLocked() { 164 return true;164 return locked; 165 165 } 166 166 -
src/main/java/com/tourMate/services/BusinessManager.java
re9b4ba9 rac19a0c 9 9 public List<Business> getUnapprovedBusinessesOfUser(long userId); 10 10 public void deleteBusiness(long businessId); 11 public List<Business> getCreatedBusinesses(); 11 public List<Business> getUnapprovedBusinesses(); 12 public void approveBusiness(Long businessId); 12 13 public Business findBusinessById (long businessId); 13 14 public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved); -
src/main/java/com/tourMate/services/HotelManager.java
re9b4ba9 rac19a0c 2 2 3 3 import com.tourMate.dto.HotelDto; 4 import com.tourMate.dto.HotelReservationDto; 5 import com.tourMate.dto.HotelReservationUserDto; 4 6 import com.tourMate.entities.*; 5 7 … … 23 25 public HotelRoom findRoomById (long hotelRoomId); 24 26 public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom); 25 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price );27 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds); 26 28 public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price); 27 29 public void deleteRoom(long hotelRoomId); 28 public List<HotelRoomAvailable> getRoomsAvailable(Long id);29 30 public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); 30 31 public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds); … … 33 34 public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId); 34 35 public List<HotelRoomAvailable> getRoomsAvailibility(); 36 public List<HotelRoomAvailable> getRoomsAvailableById(Long id); 35 37 public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel); 36 38 public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds); … … 38 40 public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds); 39 41 public void deleteReservation(long hotelRoomReservedId); 42 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId); 43 public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId); 40 44 public HotelRoomReservations findReservationById(long hotelRoomReservedId); 41 45 public List<HotelRoomReservations> findReservationByUser(User user); -
src/main/java/com/tourMate/services/TransportManager.java
re9b4ba9 rac19a0c 12 12 public interface TransportManager { 13 13 14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);14 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate); 15 15 16 16 public void deleteTransport(long transportId); … … 33 33 public Transport getTransportById(long transportId); 34 34 35 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date );35 public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers); 36 36 37 37 public List<TransportReservation> getTransportsReservationsByUserID(long userID); -
src/main/java/com/tourMate/services/UsersManager.java
re9b4ba9 rac19a0c 16 16 17 17 public void editUser(long userID, String name, String surname, String email, Date birthDate, String address, String contact); 18 public List<User> getUnapprovedUsers(); 19 public void approveUserProfile(long userId); 18 20 } -
src/main/java/com/tourMate/services/impl/BusinessManagerImpl.java
re9b4ba9 rac19a0c 34 34 35 35 @Override 36 public boolean hasBusiness(long userId){37 return businessDao. hasBusiness(userId);36 public List<Business> getUnapprovedBusinesses() { 37 return businessDao.getUnapprovedBusinesses(); 38 38 } 39 39 40 40 @Override 41 public List<Business> getCreatedBusinesses() { 42 return businessDao.getCreatedBusinesses(); 41 public void approveBusiness(Long businessId) { 42 Business b = findBusinessById(businessId); 43 businessDao.approveBusiness(b); 44 } 45 46 @Override 47 public boolean hasBusiness(long userId){ 48 return businessDao.hasBusiness(userId); 43 49 } 44 50 -
src/main/java/com/tourMate/services/impl/HotelManagerImpl.java
re9b4ba9 rac19a0c 4 4 import com.tourMate.dao.UsersDao; 5 5 import com.tourMate.dto.HotelDto; 6 import com.tourMate.dto.HotelReservationDto; 7 import com.tourMate.dto.HotelReservationUserDto; 6 8 import com.tourMate.entities.*; 7 9 import com.tourMate.services.HotelManager; … … 10 12 11 13 import java.time.Duration; 12 import java.util.Collection;13 14 import java.util.Date; 14 15 import java.util.List; … … 104 105 105 106 @Override 106 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price ) {107 hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price );107 public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) { 108 hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds); 108 109 } 109 110 … … 118 119 } 119 120 120 @Override 121 public List<HotelRoomAvailable> getRoomsAvailable(Long id) { 121 122 @Override 123 public List<HotelRoomAvailable> getRoomsAvailableById(Long id) { 122 124 return hotelDao.getRoomsAvailable(id); 123 125 } … … 203 205 204 206 @Override 207 public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId) { 208 Hotels hotel = findHotelByID(hotelId); 209 List<HotelRoomReservations> reservations = hotelDao.findReservationByHotel(hotel); 210 return reservations.stream() 211 // .filter(x -> x.getDateFrom().after(new Date())) 212 .map(x -> new HotelReservationDto( 213 x.getUser(), 214 x.getHotelRoom(), 215 x.getDateFrom(), 216 x.getDateTo(), 217 x.getNumberOfBeds() 218 )).toList(); 219 } 220 221 @Override 222 public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId) { 223 User u = usersDao.findUserByID(userId); 224 List<HotelRoomReservations> reservations = hotelDao.findReservationByUser(u); 225 return reservations.stream().map(x -> new HotelReservationUserDto( 226 x.getUser(), 227 x.getHotelRoom(), 228 x.getDateFrom(), 229 x.getDateTo(), 230 x.getNumberOfBeds(), 231 x.getHotelRoom().getHotel().getHotelName(), 232 x.getHotelRoom().getHotel().getHotelLocation(), 233 "" 234 )).toList(); 235 } 236 237 @Override 205 238 public HotelRoomReservations findReservationById(long hotelRoomReservedId) { 206 239 return hotelDao.findReservationById(hotelRoomReservedId); -
src/main/java/com/tourMate/services/impl/TransportManagerImpl.java
re9b4ba9 rac19a0c 24 24 25 25 @Override 26 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) {27 transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, owner, carPlate);26 public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) { 27 transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, userId, carPlate); 28 28 } 29 29 … … 83 83 84 84 @Override 85 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date ) {86 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date );85 public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date, int numPassengers) { 86 List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date, numPassengers); 87 87 Map<TransportAvailible, List<TransportRoute>> transportsByTransporter = transportAvailable.stream().collect(Collectors.groupingBy(x -> x.getParentRoute())); 88 88 List<TransportListingDto> transportList = transportsByTransporter.keySet().stream().toList().stream() -
src/main/java/com/tourMate/services/impl/UsersManagerImpl.java
re9b4ba9 rac19a0c 45 45 46 46 @Override 47 public List<User> getUnapprovedUsers() { 48 return usersDao.getUnapprovedUsers(); 49 } 50 51 @Override 52 public void approveUserProfile(long userId) { 53 User u = findUserByID(userId); 54 usersDao.approveUserProfile(u); 55 } 56 57 @Override 47 58 public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 48 59 return usersDao.findUserByUsername(username);
Note:
See TracChangeset
for help on using the changeset viewer.