Changeset 07f4e8b


Ignore:
Timestamp:
01/24/24 17:42:28 (10 months ago)
Author:
darsov2 <62809499+darsov2@…>
Branches:
master
Children:
0f5aa27
Parents:
5528b99
Message:

prefinal fixes

Files:
3 added
1 deleted
113 edited

Legend:

Unmodified
Added
Removed
  • frontend/package-lock.json

    r5528b99 r07f4e8b  
    1313        "@testing-library/user-event": "^13.5.0",
    1414        "axios": "^1.5.0",
     15        "axios-extensions": "^3.1.6",
    1516        "bootstrap": "^5.3.0",
    1617        "file-loader": "^6.2.0",
     
    53495350      }
    53505351    },
     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    },
    53515373    "node_modules/axios/node_modules/form-data": {
    53525374      "version": "4.0.0",
     
    94259447      "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz",
    94269448      "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==",
    9427       "peer": true,
    94289449      "dependencies": {
    94299450        "call-bind": "^1.0.2",
     
    95649585      "engines": {
    95659586        "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"
    95669601      }
    95679602    },
     
    1680016835      }
    1680116836    },
     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    },
    1680216849    "node_modules/util-deprecate": {
    1680316850      "version": "1.0.2",
  • frontend/package.json

    r5528b99 r07f4e8b  
    88    "@testing-library/user-event": "^13.5.0",
    99    "axios": "^1.5.0",
     10    "axios-extensions": "^3.1.6",
    1011    "bootstrap": "^5.3.0",
    1112    "file-loader": "^6.2.0",
  • frontend/src/App.js

    r5528b99 r07f4e8b  
    55import 'bootstrap/dist/js/bootstrap.js';
    66import HomeCarousel from './Components/Layout/CarouselHome/Carousel';
    7 import { Card, Container } from 'react-bootstrap';
     7import {Card, Container} from 'react-bootstrap';
    88import TabComponent from './Components/Tab/Tab';
    99import Offers from './Components/Layout/Offers/Offers';
     
    2727import TransportEditPage from './Pages/TransportEditPage';
    2828import RestaurantDetailsPage from './Pages/RestaurantDetailsPage';
    29 import { BrowserRouter, Route, Routes } from 'react-router-dom';
     29import {BrowserRouter, Route, Routes} from 'react-router-dom';
    3030import LoginErrorPage from "./Pages/LoginErrorPage";
     31import {AuthProvider} from "./Components/Context/AuthContext";
     32import PrivateRoute from "./Components/Misc/PrivateRoute";
     33import ProfilesManagementPage from "./Pages/ProfilesManagementPage";
     34import UserReservationsManagement from "./Pages/UserReservationsManagement";
    3135
    3236
    3337function App() {
    3438
    35 <<<<<<< HEAD
    3639    return (
    3740        <div className="App" style={{overflow: 'hidden'}}>
     
    6265                        <Route path='/details/hotel' element={<HotelDetailsPage></HotelDetailsPage>}/>
    6366                        <Route path='/details/restaurant' element={<RestaurantDetailsPage></RestaurantDetailsPage>}/>
    64                         <Route path="/search/hotel/:hotelLocation/:dateFrom/:dateTo/:numBeds"
     67                        <Route path="/search/hotel/:hotelLocation/:dateFrom/:dateTo/:numBeds/:flexible"
    6568                               element={<SearchPage type="hotel"/>}/>
    6669                        <Route path="/search/transport/:from/:to/:date/:numPassengers"
     
    7376        </div>
    7477    );
    75 =======
    76   return (
    77     <div className="App" style={{overflow: 'hidden'}}>
    78       <BrowserRouter>
    79         <Routes>
    80           <Route path='/login' element={<LoginPage/>}/>
    81           <Route path='/register' element={<RegistrationPage/>}/>
    82           <Route path='/profile' element={<ProfilePage/>}/>
    83           <Route path="/resources" exact element={<NoBusinessRegisteredError hasRegistration="false"/>} />
    84           <Route path="/resources/hotel" element={<ResourcesPage tab="/hotel"/>}/>
    85           <Route path="/resources/hotel/:hotelId" element={<HotelEditPage />}/>
    86           <Route path="/resources/restaurant" element={<ResourcesPage tab="/restaurant"/>}/>
    87           <Route path='/resources/restaurant/:restaurantId' element={<RestaurantEditPage />}/>
    88           <Route path="/resources/transport" element={<ResourcesPage tab="/transport"/>}/>
    89           <Route path="/resources/transport/:transportId" element={<TransportEditPage/>}/>
    90           <Route path="/home" element={<HomePage/> }/>
    91           <Route path="/error" element={<LoginErrorPage/> }/>
    92           <Route path='/details/transport' element={<TransportDetailsPage></TransportDetailsPage>}/>
    93           <Route path='/details/hotel' element={<HotelDetailsPage></HotelDetailsPage>}/>
    94           <Route path='/details/restaurant' element={<RestaurantDetailsPage></RestaurantDetailsPage>}/>
    95           <Route path="/search/hotel/:hotelLocation/:dateFrom/:dateTo/:numBeds" element={<SearchPage type="hotel"/> }/>
    96           <Route path="/search/transport/:from/:to/:date" element={<SearchPage type="transport"/> }/>
    97         </Routes>
    98       </BrowserRouter>
    99     </div>
    100   );
    101 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    10278}
    10379
  • frontend/src/Components/AdminPanel/AllProfilesTable.js

    r5528b99 r07f4e8b  
    5252                            {f.accountNonLocked &&
    5353                                <FaLock size={'2.2em'} color={'#159895'} onClick={() => {
    54                                     approveProfile('/users/lock/' + f.userID).then(() => {
     54                                    approveProfile('/users/unlock/' + f.userID).then(() => {
    5555                                        setChanged((prev) => {
    5656                                            return Math.random();
  • frontend/src/Components/Forms/AddHotelForm.js

    r5528b99 r07f4e8b  
    119119                  return prevState + 1;
    120120                })
     121                if(!edit)
     122                  props.closeModal()
    121123              }}
    122124            >
  • frontend/src/Components/Forms/AddRestaurantForm.js

    r5528b99 r07f4e8b  
    8282                e.preventDefault()
    8383                createRestaurant(formData, edit);
    84                 props.refresh((prevState) => {
    85                   return prevState + 1;
    86                 })
     84                props.refresh(Math.random())
     85                if(!edit) props.closeModal()
    8786              }}
    8887            >
  • frontend/src/Components/Forms/AddRoomForm.js

    r5528b99 r07f4e8b  
    1313    hotelRoomDescription: "",
    1414    hotelRoomName: "",
    15     numBeds: "",
     15    numOfBeds: "",
    1616    price: "",
    1717    kitchenAvailable: false,
     
    5858            type="number"
    5959            placeholder="Внесете го бројот на кревети"
    60             value={formData.numBeds}
    61             name="numBeds"
     60            value={formData.numOfBeds}
     61            name="numOfBeds"
    6262            onChange={onFormChange}
    6363            />
     
    117117              style={{ backgroundColor: "#159895" }}
    118118              size="md"
    119               onClick={() => {
    120                 console.log(formData);
     119              onClick={(e) => {
     120                e.preventDefault();
     121                props.refresh((prev) => {
     122                  return ++prev;
     123                })
    121124                createHotelRoom(formData);
     125                props.closeModal();
    122126              }}
    123127            >
  • frontend/src/Components/Forms/AddTableAvailabilityForm.js

    r5528b99 r07f4e8b  
    6262              onClick={() => {
    6363                createTableAvailability(formData, props.table.tableId)
     64                props.refresh(Math.random())
     65                props.close()
    6466              }}
    6567            >
  • frontend/src/Components/Forms/AddTransportForm.js

    r5528b99 r07f4e8b  
    1111      transportName: "",
    1212      carBrand: "",
    13       carType: false,
     13      carType: "",
    1414      carManufacturedYear: 1900,
    1515      noPassengers: 0,
     
    107107                createTransport(formData, edit);
    108108                props.refresh((prev) => {
    109                   return prev + 1;
     109                  return ++prev;
    110110                })
     111                if(!edit)
     112                    props.closeModal()
    111113              }}
    112114            >
  • frontend/src/Components/Forms/AddTripForm.js

    r5528b99 r07f4e8b  
    232232                                    console.log(wayPointNames);
    233233                                    for (let i = 0; i < routeCount - 1; i++) {
     234                                        console.log(wayPoints[i])
    234235                                        wayPointNames.push(wayPoints[i].value);
    235236                                    }
  • frontend/src/Components/Forms/EditRoomForm.js

    r5528b99 r07f4e8b  
    2828    } = useGet(`/hotel/rooms/${props.room.hotelRoomId}/available`)
    2929
     30    console.log(`/hotel/rooms/${props.room.hotelRoomId}/available`)
     31
    3032    !isLoading && console.log(data)
    3133
     
    4244                            <tr>
    4345                                <th>#</th>
    44 <<<<<<< HEAD
    4546                                <th>Oд</th>
    4647                                <th>До</th>
    4748                                <th>Цена</th>
    48 =======
    49                                 <th>Достапно од</th>
    50                                 <th>Достапно до</th>
    51                                 <th>Број на соби</th>
    52 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    5349                            </tr>
    5450                            </thead>
  • frontend/src/Components/Hooks/Hotel/useCreateHotel.js

    r5528b99 r07f4e8b  
    66const useCreateHotel = () => {
    77
    8     //const history = useNavigate();
    98    const createHotel = async (hotel, edit) => {
    109                console.log({hotel})
    1110                console.log(hotel)
     11                console.log("vo createhotel")
    1212
    1313                if(!edit)
     
    1616                        .post(`/hotel/add`, hotel, {
    1717                                params: {
    18                                         userId: localStorage.getItem("userId")
     18                                        userId: JSON.parse(localStorage.getItem("user")).userId
    1919                                }
    2020                        })
  • frontend/src/Components/Hooks/Restaurant/useCreateRestaurant.js

    r5528b99 r07f4e8b  
    1515                        .post(`/restaurant/add`, restaurant, {
    1616                                params: {
    17                                         userId: localStorage.getItem('userId')
     17                                        userId: JSON.parse(localStorage.getItem('user')).userId,
    1818                                }
    1919                        })
  • frontend/src/Components/Hooks/Restaurant/useCreateTable.js

    r5528b99 r07f4e8b  
    1313                    .then((res) => {
    1414                                        console.log(res)
    15                                         refresh(prev => ++prev)
     15                                        refresh(Math.random())
    1616                        //history.push('/restaurant');
    1717                    })
  • frontend/src/Components/Hooks/Transport/useCreateTransport.js

    r5528b99 r07f4e8b  
    44
    55const useCreateTransport = () => {
    6 
     6        const userId = JSON.parse(localStorage.getItem('user')).userId
    77    const createTransport = async (transport, edit) => {
    88                        if(!edit)
    99                        {
    1010                                await axios
    11                     .post(`/transport/add`, transport)
     11                    .post(`/transport/add/` + userId, transport)
    1212                    .then((res) => {
    1313                        //history.push('/transport');
  • frontend/src/Components/Hooks/User/useLogin.js

    r5528b99 r07f4e8b  
    44import { Navigate, useAsyncValue, useNavigate } from "react-router-dom";
    55import LoginForm from "../../Login/LoginForm.js";
     6import {useAuth} from "../../Context/AuthContext";
    67
    78const useLogin = () => {
    89
    910    const navigator = useNavigate()
     11        const Auth = useAuth();
    1012    //const history = useNavigate();
    1113    const login = async (loginData) => {
     
    2224                })
    2325                    .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                                        }
    2441                                        const sessionId = res.data.auth.details.sessionId;
    2542                                        const userId = res.data.auth.principal.userID;
    26                                        
     43
    2744                                        localStorage.setItem("sessionId", sessionId);
    2845                                        localStorage.setItem("userId", userId);
  • frontend/src/Components/Hooks/useCreate.js

    r5528b99 r07f4e8b  
    1616                //history.push('/hotel');
    1717                console.log(res)
     18                console.log("gotovo")
    1819                getData(prev => ++prev)
    1920                getData2(prev => ++prev)
  • frontend/src/Components/Hooks/useGet.js

    r5528b99 r07f4e8b  
    1111        console.log(localStorage.getItem("sessionId"))
    1212        console.log("url od get " + uurl)
    13 <<<<<<< HEAD
    1413        await axios.get(uurl, {maxRedirects: 0}).then((res) => {
    1514            console.log(res);
     
    2322            // window.location.href = '/error'
    2423        })
    25 =======
    26         await axios.
    27             get(uurl).then((res) => {
    28                 setData(res.data);
    29             }).catch((err) => {
    30                 console.log(err)
    31             })
    32 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    3324            .finally(() => {
    3425                setIsLoading(false);
     
    4031        getData(url);
    4132    }, [dep, url, changed]);
    42    
     33
    4334    return {
    4435        data,
  • frontend/src/Components/HotelDetails/RoomRow.js

    r5528b99 r07f4e8b  
    88    const [getData, setData] = useState(0);
    99    const room = props.room
     10    console.log("dasdaskjdhaskdjashdkajk")
    1011    console.log(props.data)
     12    console.log(Array(props.data.find(x => x.hotelRoom.hotelRoomId === room.hotelRoomId)))
    1113    return (
    1214        <>
     
    2224                    }}>
    2325                        <option></option>
    24                         {[...Array(props.data.find(x => x.hotelRoom.hotelRoomId === room.hotelRoomId).numberOfBeds).keys()].map(x => {
     26                        {[...Array(props.data.filter(x => x.hotelRoom.hotelRoomId === room.hotelRoomId).reduce((sum, x) => x.numberOfBeds)).keys()].map(x => {
    2527                            return (
    2628                                <option value={x+1}  >{x + 1}</option>
  • frontend/src/Components/HotelDetails/RoomsTable.js

    r5528b99 r07f4e8b  
    77
    88const RoomsTable = (props) => {
    9 
    109
    1110    return (
     
    2120                </thead>
    2221                <tbody>
    23                 {Array.from(new Set(props.data.map(x => x.hotelRoom))).map((room) => {
     22                {Array.from(
     23                    new Set(props.data.map((x) => JSON.stringify(x.hotelRoom)))
     24                ).map((roomString) => JSON.parse(roomString)).map((room) => {
    2425                    return (
    2526                        <>
  • frontend/src/Components/HotelEdit/HotelEditTab.js

    r5528b99 r07f4e8b  
    11import 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";
     2import {Container, Col, Row, Image, Nav, Tab} from "react-bootstrap";
     3import {useState} from "react";
     4import {FaTaxi, FaHotel} from "react-icons/fa";
     5import {MdOutlineStickyNote2} from "react-icons/md";
    66import AddNew from "../Resources/AddNew";
    7 import { BiData } from "react-icons/bi"
     7import {BiData} from "react-icons/bi"
    88import RoomListing from "./RoomListing";
    99import HotelEditForm from "./HotelEditForm";
    1010import AddHotelForm from "../Forms/AddHotelForm";
    1111import EditModal from "../Resources/EditModal";
     12import AddAvailability from "../Resources/AddAvailability";
     13import useGet from "../Hooks/useGet";
     14import ReservationListing from "./ReservationListing";
    1215
    1316function 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);
    1720
    18   const handleClose = () => setShow(false);
    19   const handleShow = () => {
    20     //e.preventDefault();
    21     setShow(true);
     21    console.log(props)
    2222
    23   };
     23    const {
     24        data,
     25        isLoading,
     26        setData,
     27        getData,
     28        setChanged
     29    } = useGet(`/hotel/${props.displayRoom.hotelId}/reservations/active`)
    2430
    25   const showModal = (modalData) => {
    26     setModalData(modalData);
    27     handleShow();
    28   }
    29   console.log(props.displayRoom)
     31    !isLoading && console.log(data)
    3032
    31   const handleSelect = (eventKey) => {
    32     setActiveTab(eventKey);
    33   };
     33    const handleClose = () => setShow(false);
     34    const handleShow = () => {
     35        //e.preventDefault();
     36        setShow(true);
    3437
    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">
    5166              <span className="ikona">
    5267                <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"
    5772                />
    5873              </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">
    6479              <span className="ikona">
    65                 <MdOutlineStickyNote2 color="#159895" size={"1.5em"} className="mx-3" />
     80                <MdOutlineStickyNote2 color="#159895" size={"1.5em"} className="mx-3"/>
    6681              </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">
    7287              <span className="ikona">
    73                 <BiData color="#159895" size={"1.5em"} className="mx-3" />
     88                <BiData color="#159895" size={"1.5em"} className="mx-3"/>
    7489              </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>
    7994
    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 type={'hotel'} 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    );
    98118}
    99119
  • frontend/src/Components/HotelEdit/ReservationListing.js

    r5528b99 r07f4e8b  
    33
    44const ReservationListing = (props) => {
     5
     6    const dateFormatter = (str) => {
     7        const inputDate = new Date(str);
     8
     9        const options = {
     10            year: '2-digit',
     11            month: '2-digit',
     12            day: '2-digit',
     13        };
     14
     15        return inputDate.toLocaleString('de-DE', options);
     16    }
     17
    518    return(
    619        <>
     
    1528                    <Col md={8} className="d-flex flex-column justify-content-start ps-5">
    1629                        <h3 style={{fontWeight: "bold"}} className={'text-start'}>Резервација за:</h3>
    17                         <h4 className={'text-start'}>{props.data.hotelRoom.hotelRoomName}</h4>
     30                        {props.type === 'hotel' && <h4 className={'text-start'}>{props.data.hotelRoom.hotelRoomName}</h4>}
     31                        {props.type === 'restaurant' && <h4 className={'text-start'}>{'Маса за ' + props.data.restaurantsTable.noSeats}</h4>}
     32                        {props.type === 'transport' && <h4 className={'text-start'}>{props.data.transportRoute.from + ' ' + props.data.transportRoute.to}</h4>}
     33                        {props.type === 'transport' && <h4 className={'text-start'}>{props.data.noSeats + ' ' + 'патници'}</h4>}
    1834                        <h4 className={'text-start'}>{props.data.user.name + ' ' + props.data.user.surname}</h4>
    19                         <h5 className={'text-start'}>{props.data.dateFrom + ' - ' + props.data.dateTo}</h5>
     35                        {props.type !== 'transport' && <h5
     36                            className={'text-start'}>{dateFormatter(props.data.dateFrom) + ' - ' + dateFormatter(props.data.dateTo)}</h5>}
    2037                    </Col>
    2138                    <Col md={4} className="d-flex flex-column justify-content-center align-content-center">
    22                         <h3>Вкупна цена: <br></br>{props.data.hotelRoom.price}$</h3>
     39                        {props.type === 'hotel' && <h3>Вкупна цена: <br></br>{props.data.hotelRoom.price}$</h3>}
    2340                    </Col>
    2441                </Row>
  • frontend/src/Components/Layout/Navbar/Navigation.js

    r5528b99 r07f4e8b  
    77import useGet from "../../Hooks/useGet";
    88import axios from "../../../axios.js";
    9 <<<<<<< HEAD
    109import {useAuth} from "../../Context/AuthContext";
    1110import ImageUpload from "../../ImageUpload/ImageUpload";
    12 =======
    13 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    1411//import logo from 'assets/images/logo.png';
    1512//src="https://upload.wikimedia.org/wikipedia/commons/0/08/Vergina_Sun_-_Golden_Larnax.png"
     
    1714function Navigation(props) {
    1815  const navigator = useNavigate();
    19 <<<<<<< HEAD
    2016  const Auth = useAuth();
    2117  const isLoggedIn = Auth.userIsAuthenticated();
     
    2622  const handleShow = () => setShow(true);
    2723
    28 =======
    29 
    30   const { data, setData, isLoading, getData } = useGet("/username");
    31  
    32 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    3324  return (
    3425    <>
     
    4031      >
    4132        <Container>
    42           <Navbar.Brand href="#home">
     33          <Navbar.Brand href="/home">
    4334            <span className="ikona">
    4435              <Image
     
    6657                <Button onClick={handleShow}></Button>
    6758              </Nav.Link>
    68               {!isLoading && !data && (
     59              {!isLoggedIn && (
    6960                <Button
    7061                  className="m-2"
     
    7869                </Button>
    7970              )}
    80               {!isLoading && data && (
     71              {isLoggedIn && (
    8172                <>
    8273                  <Nav.Link className="m-2" href="/profile">
    83                     {data}
     74                    {Auth.getUser().username}
    8475                  </Nav.Link>
    8576                  <Button
     
    9081                      await axios.get("/logout")
    9182                      .then((res) => {
    92                         console.log(res)
     83                        console.log(res);
     84                        Auth.userLogout();
    9385                      })
    9486                      .catch((err) => {
  • frontend/src/Components/Listings/HotelListing.js

    r5528b99 r07f4e8b  
    8080                      }}
    8181                  >
    82                     {/* {props.data.hotelRating} */}
    83                       9.1
     82                        {(props.data.hotelReviews.reduce((sum, r) => sum + r.numStar, 0) / props.data.hotelReviews.length).toFixed(1)}
    8483                  </span>
    8584                                </Col>
  • frontend/src/Components/Listings/SortButton.js

    r5528b99 r07f4e8b  
    33import { BsSortUp } from "react-icons/bs"
    44
    5 const SortButton = () => {
     5const SortButton = (props) => {
    66    return (
    7         <Dropdown>
     7        <Dropdown onSelect={(event, x) => {
     8            console.log(event)
     9            props.setSortingArg(event)
     10        }}>
    811          <Dropdown.Toggle variant="success" id="dropdown-basic" size="lg">
    912          <span className="ikona my-1"><BsSortUp/></span>
     
    1114          </Dropdown.Toggle>
    1215   
    13           <Dropdown.Menu>
    14             <Dropdown.Item href="#/action-1">Цена растечки</Dropdown.Item>
    15             <Dropdown.Item href="#/action-2">Цена опаѓачки</Dropdown.Item>
    16             <Dropdown.Item href="#/action-3">Име растечки</Dropdown.Item>
    17             <Dropdown.Item href="#/action-3">Име опаѓачки</Dropdown.Item>
     16          <Dropdown.Menu >
     17              {props.type !== 'restaurant' && <Dropdown.Item eventKey={'priceDesc'}>Цена растечки</Dropdown.Item>}
     18              {props.type !== 'restaurant' && <Dropdown.Item eventKey={'priceAsc'}>Цена опаѓачки</Dropdown.Item>}
     19              {props.type !== 'transport' && <Dropdown.Item eventKey={'nameAsc'}>Име растечки</Dropdown.Item>}
     20              {props.type !== 'transport' && <Dropdown.Item eventKey={'nameDesc'}>Име опаѓачки</Dropdown.Item>}
    1821          </Dropdown.Menu>
    1922        </Dropdown>
  • frontend/src/Components/Listings/TransportListing.js

    r5528b99 r07f4e8b  
    99
    1010const TransportListing = (props) => {
    11  
     11
    1212
    1313
     
    5656                    }}
    5757                  >
    58                     9.1
     58                      {(props.data.reviews.reduce((sum, r) => sum + r.numStar, 0) / props.data.reviews.length).toFixed(1)}
    5959                  </span>
    6060                </Col>
  • frontend/src/Components/Resources/AddAvailability.js

    r5528b99 r07f4e8b  
    1 import React from "react";
     1 import React from "react";
    22import { Container, Row, Modal, Im } from "react-bootstrap";
    33import { useState } from "react";
     
    4242        <Modal.Body>
    4343            {props.type === "hotel" && <AddHotelForm/>}
    44             {props.type === "room" && <AddRoomAvailablityForm hotelRoomId={props.hotelRoomId}/>}
    45             {props.type === "table" && <AddTableAvailablityForm table={props.table}/>}
     44            {props.type === "room" && <AddRoomAvailablityForm refresh={props.refresh} close={props.closeModal}  hotelRoomId={props.hotelRoomId}/>}
     45            {props.type === "table" && <AddTableAvailablityForm refresh={props.refresh} close={props.closeModal} table={props.table}/>}
    4646            {props.type === "restaurant" && <AddRestaurantForm/>}
    4747            {props.type === "transport" && <AddTransportForm/>}
  • frontend/src/Components/Resources/AddImages.js

    r5528b99 r07f4e8b  
    5353                    {!isLoading && data.map((image) => {
    5454                        let link = image.url;
    55                         console.log("SLIKATAAA")
    56                         console.log(image)
    5755                        if (image.url.includes('Desktop')) {
    5856                            link = 'http://localhost:8080/download?fileName=' + encodeURIComponent(image.url);
  • frontend/src/Components/Resources/AddNew.js

    r5528b99 r07f4e8b  
    5656        </Modal.Header>
    5757        <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}/>}
    6262            {props.type === "menu" && <AddItemMenuForm Id={props.Id} refresh={props.refresh}/>}
    6363            {props.type === "route" && <AddTripForm transportId={props.transport.transportID} setSize={setSizeXl} refresh={props.refresh}/>}
  • frontend/src/Components/Resources/EditModal.js

    r5528b99 r07f4e8b  
    3232        </Modal.Header>
    3333        <Modal.Body>
    34             {props.type === "hotel" && <AddHotelForm/>}
     34            {props.type === "hotel" && <AddHotelForm refresh={props.refresh}/>}
    3535            {props.type === "room" && <EditRoomForm refresh={props.refresh} room={props.room}/>}
    3636            {props.type === "restaurant" && <AddRestaurantForm edit="false" refresh={props.refresh}/>}
  • frontend/src/Components/Resources/ResourceListing.js

    r5528b99 r07f4e8b  
    88
    99const ResourceListing = (props) => {
    10  
    11     console.log("props " + props.id)
    12  
    1310
    1411    const type = props.type == "hotel" ? "сместувањето" : props.type == "restaurant" ? "ресторанот" : "превозот";
    1512    const name = props.type == "hotel" ? props.data.hotelName : props.type == "restaurant" ? props.data.restaurantName : props.data.transportName
    16 <<<<<<< HEAD
    1713    const id = props.type == "hotel" ? props.data.hotelId : props.type == "restaurant" ? props.data.restaurantID : props.data.transportID
    1814    console.log(props.data)
     
    5450                    </Col>
    5551
    56                     <Col className="d-flex flex-column justify-content-center align-content-center">
    57                         <AddImages type={props.type} Id={id} />
    58                     </Col>
     52                    {props.type !== 'transport' && <Col className="d-flex flex-column justify-content-center align-content-center">
     53                        <AddImages type={props.type} Id={id}/>
     54                    </Col>}
    5955                    <Col className="d-flex justify-content-center align-content-center">
    60 =======
    61     const id = props.type == "hotel" ? props.data.hotelId : props.type == "restaurant" ? props.data.resturantId : props.data.transportID
    62     return(<>
    63     <a href={`${props.type}/${id}`} style={{textDecoration: "none", color:"black"}}>
    64         <Container className="py-3 px-1 my-4"
    65         style={{
    66           border: "4px solid #159895",
    67           borderRadius: "1em",
    68           boxShadow: "0 3px 5px #159895",
    69           maxWidth: "90%",
    70         }}>
    71             <Row>
    72                 <Col className="d-flex justify-content-center">
    73                     <Image
    74                     src="https://www.imgacademy.com/sites/default/files/legacyhotel.jpg"
    75                     style={{
    76                         height: "8em",
    77                         borderRadius: "1em",
    78                         boxShadow: "0 4px 20px lightblue",
    79                         maxWidth: "100%",
    80                     }}
    81                     ></Image>
    82                 </Col>
    83                 <Col >
    84                     <h2 style={{textAlign: "left"}}>{name}</h2>
    85                     {props.type === "hotel" && (<>
    86                       <h5 style={{textAlign: "left"}}>{props.data.hotelLocation}</h5>
    87                       <h5 style={{textAlign: "left"}}>{props.data.hotelEmail}</h5>
    88                     </>)}
    89                     {props.type === "restaurant" && (<>
    90                       <h5 style={{textAlign: "left"}}>{props.data.restaurantLocation}</h5>
    91                       <h5 style={{textAlign: "left"}}>{props.data.cousineType} кујна</h5>
    92                     </>)}
    93                     {props.type === "transport" && (<>
    94                       <h5 style={{textAlign: "left"}}>{props.data.carBrand}</h5>
    95                       <h5 style={{textAlign: "left"}}>{props.data.carPlate}</h5>
    96                     </>)}
    97                 </Col>
    98                 <Col className="d-flex justify-content-center align-content-center" >
    99 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    10056                  <span
    10157                      style={{
  • frontend/src/Components/Resources/ResourcesTab.js

    r5528b99 r07f4e8b  
    1010
    1111function ResourcesTab(props) {
    12 <<<<<<< HEAD
    1312    const [activeTab, setActiveTab] = useState(props.tab);
    1413    const userId = JSON.parse(localStorage.getItem("user")).userId;
     
    3635                    <Nav.Item className="tab_item rounded-5">
    3736                        <Nav.Link href="/resources/hotel" className="text-left rounded-5">
    38 =======
    39   const [activeTab, setActiveTab] = useState(props.tab);
    40   // const [changed, setChanged] = useState(0);
    41   const userId = localStorage.getItem("userId");
    42   const { data, setData, isLoading, getData, setChanged } = useGet(`${props.tab}/user/${userId}`);
    43 
    44   const handleSelect = (eventKey) => {
    45     setActiveTab(eventKey);
    46     console.log(props.refresh);
    47     props.refresh(eventKey);
    48     console.log("refresh" + eventKey);
    49   };
    50 
    51   !isLoading && console.log(data);
    52   console.log(props.tab);
    53 
    54   return (
    55     <Container className="rounded-5">
    56       <Tab.Container
    57         activeKey={activeTab}
    58         onSelect={handleSelect}
    59         className="bg-dark rounded-5"
    60       >
    61         <Nav
    62           fill
    63           variant="tabs"
    64           className="bg-body rounded-top-5"
    65           activeKey="/hotel"
    66           id="tab_item"
    67         >
    68           <Nav.Item className="tab_item rounded-5">
    69             <Nav.Link href="/resources/hotel" className="text-left rounded-5">
    70 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    7137              <span className="ikona">
    7238                <FaHotel
     
    10167                </Nav>
    10268
    103 <<<<<<< HEAD
    10469                <Tab.Content className="py-5 px-3 border rounded-bottom-5 bg-light">
    10570                    <Tab.Pane eventKey="/hotel" key="hotelPane">
     
    150115        </Container>
    151116    );
    152 =======
    153         <Tab.Content className="py-5 px-3 border rounded-bottom-5 bg-light">
    154           <Tab.Pane eventKey="/hotel" key="hotelPane">
    155             {props.tab == "/hotel" && !isLoading && data != null &&
    156               data.map((hotel) => {
    157                 return (
    158                   <Link key={hotel.hotelId} to={"/resources/hotel/" + hotel.hotelId}>
    159                     <ResourceListing
    160                       key={hotel.hotelId}
    161                       id={hotel.hotelId}
    162                       type="hotel"
    163                       data={hotel}
    164                     />
    165                   </Link>
    166                 );
    167               })}
    168             <AddNew type="hotel" refresh={setChanged} />
    169           </Tab.Pane>
    170           <Tab.Pane eventKey="/restaurant" key="restaurantPane">
    171             {props.tab == "/restaurant" && !isLoading && data != null &&
    172               data.map((restaurant) => {
    173                 console.log("mapiranje " + restaurant)
    174                 return (
    175                   <Link key={restaurant.restaurantId} to={"/resources/restaurant/" + restaurant.restaurantID}>
    176                     <ResourceListing
    177                       key={restaurant.restaurantId}
    178                       type="restaurant"
    179                       data={restaurant}
    180                     />
    181                   </Link>
    182                 );
    183               })}
    184             <AddNew type="restaurant" refresh={setChanged}/>
    185           </Tab.Pane>
    186           <Tab.Pane eventKey="/transport" key="transportPane">
    187             {props.tab == "/transport" && !isLoading && data.length > 0 &&
    188               data.map((transport) => {
    189                 return (
    190                   <ResourceListing
    191                     key={transport.transportId}
    192                     id={transport.transportId}
    193                     type="transport"
    194                     data={transport}
    195                   />
    196                 );
    197               })}
    198             <AddNew type="transport" refresh={setChanged}/>
    199           </Tab.Pane>
    200         </Tab.Content>
    201       </Tab.Container>
    202     </Container>
    203   );
    204 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    205117}
    206118
  • frontend/src/Components/RestaurantDetails/Carousel.js

    r5528b99 r07f4e8b  
    1212            <Row className='d-flex justify-content-center align-items-center'><h2>Мени</h2></Row>
    1313            <hr className='m-2'></hr>
    14             <Menu menu={props.menu}></Menu>
     14            <Menu images={props.images} menu={props.menu}></Menu>
    1515        </>
    1616    );
  • frontend/src/Components/RestaurantDetails/Menu.js

    r5528b99 r07f4e8b  
    2323
    2424
     25
     26
    2527    return (<>
    2628        <Carousel activeIndex={ind} onSelect={handleSelect} indicators={false}>
     
    3436                                        return (
    3537                                            <Col>
    36                                                 <MenuItem data={menuItem}/>
     38                                                <MenuItem images={    props.images.filter(x => {
     39                                                    console.log(x)
     40                                                    return x.menu.menuId === menuItem.menuId
     41                                                })} data={menuItem}/>
    3742                                            </Col>
    3843                                        )
  • frontend/src/Components/RestaurantDetails/MenuItem.js

    r5528b99 r07f4e8b  
    11import React from "react";
    22import {Col, Row, Image, Container} from "react-bootstrap";
     3import Carousel from "react-bootstrap/Carousel";
    34
    45const MenuItem = (props) => {
    56
    67    const data = props.data;
     8    console.log("dva orla")
     9    console.log(props)
    710    return (<>
    811
     
    1720                <Row>
    1821                    <Col className="d-flex justify-content-center mb-3">
    19                         <Image
    20                             src="https://www.tasteofhome.com/wp-content/uploads/2019/01/medium-rare-steak-shutterstock_706040446.jpg"
    21                             style={{
    22                                 height: "7em",
    23                                 borderRadius: "1em",
    24                                 boxShadow: "0 4px 20px lightblue",
    25                                 maxWidth: "100%",
    26                             }}
    27                         ></Image>
     22                        <Carousel>
     23                            {props.images.map((image) => {
     24                                let link = image.url;
     25                                if (image.url.includes('Desktop')) {
     26                                    link = 'http://localhost:8080/download?fileName=' + encodeURIComponent(image.url);
     27                                }
     28                                return (
     29                                    <Carousel.Item>
     30                                        <img
     31                                            className="d-block w-100 h-400 rounded-5"
     32                                            src={link}
     33                                            alt="First slide"
     34                                            style={{
     35                                                height: "7em",
     36                                                borderRadius: "1em",
     37                                                boxShadow: "0 4px 20px lightblue",
     38                                                maxWidth: "100%",
     39                                            }}
     40                                        />
     41                                    </Carousel.Item>
     42                                )
     43                            })}
     44                            {props.images.length == 0 && <Carousel.Item>
     45                                <Image
     46                                    src="https://www.tasteofhome.com/wp-content/uploads/2019/01/medium-rare-steak-shutterstock_706040446.jpg"
     47                                    style={{
     48                                        height: "7em",
     49                                        borderRadius: "1em",
     50                                        boxShadow: "0 4px 20px lightblue",
     51                                        maxWidth: "100%",
     52                                    }}
     53                                ></Image>
     54                            </Carousel.Item>}
     55                        </Carousel>
    2856                    </Col>
    2957                </Row>
  • frontend/src/Components/RestaurantDetails/TablesTable.js

    r5528b99 r07f4e8b  
    2222                </thead>
    2323                <tbody>
    24                 {Array.from(new Set(props.data.map(x => x.restaurantTable))).map((table) => {
     24                {Array.from(
     25                    new Set(props.data.map((x) => JSON.stringify(x.restaurantTable)))
     26                ).map((roomString) => JSON.parse(roomString)).map((table) => {
    2527                    return (
    2628                        <>
  • frontend/src/Components/RestaurantEdit/MenuListing.js

    r5528b99 r07f4e8b  
    66import { AiOutlinePlusCircle } from "react-icons/ai"
    77import EditModal from "../Resources/EditModal";
     8import AddImages from "../Resources/AddImages";
    89
    910const MenuListing = (props) => {
     
    1213    console.log(props.data)
    1314    return(<>
    14     <a href="#" onClick={(e) => {e.preventDefault(); props.showModal(props.data);
    15     console.log("kliknav")} } style={{textDecoration: "none", color:"black"}}>
     15    <a href="#" style={{textDecoration: "none", color:"black"}}>
    1616        <Container className="py-3 px-1 my-4"
    1717        style={{
     
    2323            <Row>
    2424                <Col className="d-flex justify-content-center">
    25                     <Image
     25                    <Image onClick={(e) => {
     26                        e.preventDefault();
     27                        props.showModal(props.data);
     28                        console.log("kliknav")
     29                    }}
    2630                    src="https://www.tasteofhome.com/wp-content/uploads/2019/01/medium-rare-steak-shutterstock_706040446.jpg"
    2731                    style={{
     
    3741                    <h6>{props.data.ingredients}</h6>
    3842                </Col>
     43                <Col className="d-flex flex-column justify-content-center align-content-center">
     44                    <AddImages type="menu" Id={props.data.menuId} />
     45                </Col>
    3946               
    4047                <Col className="d-flex flex-column justify-content-center align-content-center">
  • frontend/src/Components/RestaurantEdit/RestaurantEditTab.js

    r5528b99 r07f4e8b  
    1010import TableListing from "./TableListing";
    1111import EditModal from "../Resources/EditModal";
     12import ReservationListing from "../HotelEdit/ReservationListing";
     13import useGet from "../Hooks/useGet";
    1214
    1315function RestaurantEditTab(props) {
     
    3537    setActiveTab(eventKey);
    3638  };
     39
     40  const {
     41    data,
     42    isLoading,
     43    setData,
     44    getData,
     45    setChanged: dhanged
     46  } = useGet(`/restaurant/${props.displayMenu.restaurantID}/reservations/active`)
    3747
    3848  console.log(props.displayMenu.restaurantID)
     
    100110              return <MenuListing key={menu.menuId} data={menu} showModal={showModal}/>
    101111            })}
    102             {activeTab === '/hotel' && <EditModal show={show} handleClose={handleClose} type="menu" menu={modalData}></EditModal>}
     112            {activeTab === '/hotel' && <EditModal show={show} refresh={props.refresh} handleClose={handleClose} type="menu" menu={modalData}></EditModal>}
    103113            <AddNew Id={props.displayMenu.restaurantID} refresh={props.refresh} type="menu"/>
    104114          </Tab.Pane>
    105115          <Tab.Pane eventKey="/masi">
    106116           {props.displayMenu.tables.map((table) => {
    107               return <TableListing key={table.tableId} showModal={showModal} data={table}/>
     117              return <TableListing key={table.tableId} refresh={props.refresh} showModal={showModal} handleClose={handleClose} data={table}/>
    108118            })}
    109119            {activeTab === '/masi' && <EditModal show={show} handleClose={handleClose} refresh={props.refresh} type="table"
     
    112122          </Tab.Pane>
    113123          <Tab.Pane eventKey="/restaurant">
    114             <AddNew type="restaurant"/>
     124            {!isLoading && data.map((res) => {
     125              return (
     126                  <ReservationListing type={'restaurant'} data={res}/>
     127              )
     128            })}
    115129          </Tab.Pane>
    116130          <Tab.Pane eventKey="/transport">
  • frontend/src/Components/RestaurantEdit/TableListing.js

    r5528b99 r07f4e8b  
    4141               
    4242                <Col className="d-flex flex-column justify-content-center align-content-center">
    43                   <AddAvailability type="table" table={props.data}/>
     43                  <AddAvailability type="table" refresh={props.refresh} closeModal={props.handleClose} table={props.data}/>
    4444                </Col>
    4545
  • frontend/src/Components/SearchCriterias/SearchCriteriasBar.js

    r5528b99 r07f4e8b  
    22import { Container, Form, Button, Row, Col } from "react-bootstrap";
    33import useFormData from "../Hooks/useFormData";
    4 <<<<<<< HEAD
    54import SearchCriteriasHotel from "./SearchCriteriasHotel";
    65import SearchCriteriasTransport from "./SearchCriteriasTransport";
    76import SearchCriteriasRestaurant from "./SearchCriteriasRestaurant";
    8 =======
    9 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    107
    11 const SearchCriterias = (props) => {
     8const SearchCriteriasBar = (props) => {
    129
    13   const { formData, onFormChange, onCheckBoxChange, setFormData} = useFormData(props.criterias)
    14   console.log("KRITERIUMI")
    15   console.log(formData)
     10    const { criterias, type } = props
    1611
    17 <<<<<<< HEAD
    1812    return (
    1913        <>
     
    2418    )
    2519}
    26 =======
    27   return (
    28     <>
    29       <Container
    30         className="p-1 pb-0 mb-5 mt-3 rounded-2"
    31         style={{ backgroundColor: "#002B5B", width: "65%"}}
    32       >
    33         <Form className="rounded-5">
    34           <Row className="gx-1">
    35             <Col>
    36               <Form.Floating className="mb-3">
    37                 <Form.Control
    38                   size="md"
    39                   type="text"
    40                   placeholder="Каде ќе патувате?:"
    41                   id="location"
    42                   name="hotelLocation"
    43                   onChange={onFormChange}
    44                   value={formData.hotelLocation}
    45                 ></Form.Control>
    46                 <label htmlFor="location">Локација:</label>
    47               </Form.Floating>
    48             </Col>
    49             <Col>
    50               <Form.Floating className="mb-3">
    51                 <Form.Control
    52                   size="md"
    53                   type="date"
    54                   placeholder="Датум на пристигнување:"
    55                   id="dateFrom"
    56                   name="dateFrom"
    57                   onChange={onFormChange}
    58                   value={formData.dateFrom}
    59                 ></Form.Control>
    60                 <label htmlFor="dateFrom">Датум на пристигнување:</label>
    61               </Form.Floating>
    62             </Col>
    63             <Col>
    64               <Form.Floating className="mb-3">
    65                 <Form.Control
    66                   size="md"
    67                   type="date"
    68                   placeholder="Датум на заминување:"
    69                   id="dateTo"
    70                   name="dateTo"
    71                   onChange={onFormChange}
    72                   value={formData.dateTo}
    73                 ></Form.Control>
    74                 <label htmlFor="dateTo">Датум на заминување:</label>
    75               </Form.Floating>
    76             </Col>
    77             <Col>
    78               <Form.Floating className="mb-3">
    79                 <Form.Control
    80                   size="md"
    81                   type="number"
    82                   placeholder="Број на гости:"
    83                   id="floatingPassengers"
    84                   name="numBeds"
    85                   onChange={onFormChange}
    86                   value={formData.numBeds}
    87                 ></Form.Control>
    88                 <label htmlFor="floatingPassengers">Број на гости:</label>
    89               </Form.Floating>
    90             </Col>
    91             <Col>
    92               <Form.Group className="my-1">
    93                 <Button
    94                   type="submit"
    95                   style={{ backgroundColor: "#159895" }}
    96                   size="lg"
    97                   className="w-100"
    98                   onClick={(e) => {
    99                     e.preventDefault();
    100                     window.location.href = `/search/hotel/${formData.hotelLocation}/${formData.dateFrom}/${formData.dateTo}/${formData.numBeds}`
    101                   }}
    102                 >
    103                   <span className="ikona mx-3">Пребарај</span>
    104                 </Button>
    105               </Form.Group>
    106             </Col>
    107           </Row>
    108         </Form>
    109       </Container>
    110     </>
    111   );
    112 };
    113 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    11420
    115 export default SearchCriterias;
     21export default SearchCriteriasBar;
  • frontend/src/Components/Tab/TabFormHotel.js

    r5528b99 r07f4e8b  
    11import React from "react";
    2 import { Button, Col, Container, Form, Row } from "react-bootstrap";
    3 import { FaMagnet } from "react-icons/fa"
    4 import { HiMagnifyingGlass } from "react-icons/hi2"
     2import {Button, Col, Container, Form, InputGroup, Row} from "react-bootstrap";
     3import {FaMagnet} from "react-icons/fa"
     4import {HiMagnifyingGlass} from "react-icons/hi2"
    55import useFormData from "../Hooks/useFormData";
    66
    77function TabFormHotel() {
    88
    9   const { formData, onFormChange, setFormData } = useFormData({
    10     hotelLocation: undefined,
    11     dateFrom: undefined,
    12     dateTo: undefined,
    13     numBeds: undefined
    14   })
     9    const {formData, onFormChange, setFormData, onCheckBoxChange} = useFormData({
     10        hotelLocation: undefined,
     11        dateFrom: undefined,
     12        dateTo: undefined,
     13        numBeds: undefined,
     14        flexible: false,
     15    })
    1516
    16   return (
    17     <Form className='rounded-5' >
    18       <Row>
    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               value={formData.hotelLocation}
    28               onChange={onFormChange}
    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               value={formData.dateFrom}
    42               onChange={onFormChange}
    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               value={formData.dateTo}
    56               onChange={onFormChange}
    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               value={formData.numBeds}
    70               onChange={onFormChange}
    71             ></Form.Control>
    72             <label htmlFor="floatingPassengers">Број на гости:</label>
    73           </Form.Floating>
     17    return (
     18        <Form className='rounded-5'>
     19            <Row>
     20                <Col>
     21                    <Form.Floating className="mb-3">
     22                        <Form.Control
     23                            size="md"
     24                            type="text"
     25                            placeholder="Каде ќе патувате?:"
     26                            id="location"
     27                            name="hotelLocation"
     28                            value={formData.hotelLocation}
     29                            onChange={onFormChange}
     30                        ></Form.Control>
     31                        <label htmlFor="location">Локација:</label>
     32                    </Form.Floating>
     33                    <div className="mb-3">
     34                        <Form.Check
     35                            type={"checkbox"}
     36                            id={`default-checkbox}`}
     37                            label={`флексибилност +- 3 дена`}
     38                            onChange={onCheckBoxChange}
     39                            name={'flexible'}
     40                            value={formData.flexible}
     41                        />
     42                    </div>
     43                </Col>
     44                <Col>
     45                    <Form.Floating className="mb-3">
     46                        <Form.Control
     47                            size="md"
     48                            type="date"
     49                            placeholder="Датум на пристигнување:"
     50                            id="dateFrom"
     51                            name="dateFrom"
     52                            value={formData.dateFrom}
     53                            onChange={onFormChange}
     54                        ></Form.Control>
     55                        <label htmlFor="dateFrom">Датум на пристигнување:</label>
     56                    </Form.Floating>
     57                </Col>
     58                <Col>
     59                    <Form.Floating className="mb-3">
     60                        <Form.Control
     61                            size="md"
     62                            type="date"
     63                            placeholder="Датум на заминување:"
     64                            id="dateTo"
     65                            name="dateTo"
     66                            value={formData.dateTo}
     67                            onChange={onFormChange}
     68                        ></Form.Control>
     69                        <label htmlFor="dateTo">Датум на заминување:</label>
     70                    </Form.Floating>
     71                </Col>
     72                <Col>
     73                    <Form.Floating className="mb-3">
     74                        <Form.Control
     75                            size="md"
     76                            type="number"
     77                            placeholder="Број на гости:"
     78                            id="floatingPassengers"
     79                            name="numBeds"
     80                            value={formData.numBeds}
     81                            onChange={onFormChange}
     82                        ></Form.Control>
     83                        <label htmlFor="floatingPassengers">Број на гости:</label>
     84                    </Form.Floating>
    7485
    75           <Form.Group className="my-1">
    76             <Button type="submit" style={{backgroundColor: "#159895"}} size="lg"
    77             onClick={(e) => {
    78               e.preventDefault();
    79               window.location.href = `/search/hotel/${formData.hotelLocation}/${formData.dateFrom}/${formData.dateTo}/${formData.numBeds}`
    80             }}>
    81               <span className="ikona my-1"><HiMagnifyingGlass/></span>
    82               <span className="ikona mx-3">Пребарај</span>
    83             </Button>
    84           </Form.Group>
    85         </Col>
     86                    <Form.Group className="my-1">
     87                        <Button type="submit" style={{backgroundColor: "#159895"}} size="lg"
     88                                onClick={(e) => {
     89                                    e.preventDefault();
     90                                    window.location.href = `/search/hotel/${formData.hotelLocation}/${formData.dateFrom}/${formData.dateTo}/${formData.numBeds}/${formData.flexible}`
     91                                }}>
     92                            <span className="ikona my-1"><HiMagnifyingGlass/></span>
     93                            <span className="ikona mx-3">Пребарај</span>
     94                        </Button>
     95                    </Form.Group>
     96                </Col>
    8697
    87       </Row>
    88     </Form>
    89   );
     98            </Row>
     99        </Form>
     100    );
    90101}
    91102
  • frontend/src/Components/Tab/TabFormTransport.js

    r5528b99 r07f4e8b  
    22import { Button, Col, Container, Form, Row } from "react-bootstrap";
    33import { HiMagnifyingGlass } from "react-icons/hi2"
     4import useFormData from "../Hooks/useFormData";
    45
    56function TabFormTransport() {
     7
     8  const { formData, onFormChange, setFormData } = useFormData({
     9    from: undefined,
     10    to: undefined,
     11    date: undefined,
     12    numPassengers: 0
     13  })
     14
    615  return (
    716    <Form>
     
    1423              placeholder="Од:"
    1524              id="floatingFrom"
     25              value={formData.from}
     26              name={'from'}
     27              onChange={onFormChange}
    1628            ></Form.Control>
    1729            <label htmlFor="floatingFrom">Од:</label>
     
    2537              placeholder="До:"
    2638              id="floatingTo"
     39              name={'to'}
     40              value={formData.to}
     41              onChange={onFormChange}
    2742            ></Form.Control>
    2843            <label htmlFor="floatingTo">До:</label>
     
    3651              placeholder="Датум:"
    3752              id="floatingDate"
     53              name={'date'}
     54              value={formData.date}
     55              onChange={onFormChange}
    3856            ></Form.Control>
    3957            <label htmlFor="floatingDate">Датум:</label>
     
    4664              type="number"
    4765              placeholder="Број на патници:"
     66              name={'numPassengers'}
    4867              id="floatingPassengers"
     68              value={formData.numPassengers}
     69              onChange={onFormChange}
    4970            ></Form.Control>
    5071            <label htmlFor="floatingPassengers">Број на патници:</label>
    5172          </Form.Floating>
    5273          <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            }}>
    5478              <span className="ikona my-1"><HiMagnifyingGlass/></span>
    5579              <span className="ikona mx-3">Пребарај</span>
  • frontend/src/Components/TransportDetails/FinalPoint.js

    r5528b99 r07f4e8b  
    1717    <>
    1818      <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"}}>
    2020            <h5 className="m-auto">{getTimeAsString(props.time)}</h5>
    2121        </Col>  }
  • frontend/src/Components/TransportDetails/Line.js

    r5528b99 r07f4e8b  
    22
    33const 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";
    75    return (<>
    86        <div style={{borderLeft: "5px solid #159895", height: "3em", marginLeft: left, marginTop: "-1.4rem", marginBottom: "-1.4rem"}}></div>
  • frontend/src/Components/TransportDetails/Waypoint.js

    r5528b99 r07f4e8b  
    1616    }
    1717
    18 <<<<<<< HEAD
    1918    return (
    2019        <>
     
    5857        </>
    5958    );
    60 =======
    61   return (
    62     <>
    63       <Row className="d-flex flex-row gap-0">
    64       {props.left === "true" && <Col className="d-flex flex-column justify-content-center col-auto" style={{paddingLeft: "2.6rem"}}>
    65             <h5 style={{color: props.routes === "true" ? "white" : "" }} className="m-auto">{getTimeAsString(props.time)}</h5>
    66         </Col>}
    67         <Col md="auto">
    68           <RxDot size={"4rem"} color="#159895"></RxDot>
    69         </Col>
    70         <Col className="d-flex flex-column justify-content-center">
    71           <h3 className="my-auto" style={{...style, fontSize: props.routes === "true" ? "1.3rem" : "", color: props.routes === "true" ? "#708090        " : ""}}>{props.city}</h3>
    72         </Col>
    73       {props.left !== "true" && <Col className="d-flex flex-column justify-content-center">
    74             <h5>{getTimeAsString(props.time)}</h5>
    75         </Col>}
    76       </Row>
    77       <Row>
    78       <Line left={props.left}> </Line>
    79       </Row>
    80     </>
    81   );
    82 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    8359};
    8460
  • frontend/src/Components/TransportEdit/TransportEditTab.js

    r5528b99 r07f4e8b  
    99import TransportListing from "./TransportListing";
    1010import useGet from "../Hooks/useGet";
     11import ReservationListing from "../HotelEdit/ReservationListing";
    1112
    1213function TransportEditTab(props) {
    1314  const [activeTab, setActiveTab] = useState("/hotel");
    14   const link = "/transport/" + props.displayRoute.transportID + "/available";
    15   console.log(props.displayRoute)
    16   const [changed, setChanged] = useState(0)
    17   const { data, setData, isLoading, getData } = useGet(link, changed);
     15  console.log(props)
     16
     17
     18  const {
     19    data,
     20    isLoading,
     21    setData,
     22    getData,
     23    setChanged: dhanged
     24  } = useGet(`/transport/${props.displayRoute.transportID}/reservations/active`)
     25
    1826
    1927
     
    7583          </Tab.Pane>
    7684          <Tab.Pane eventKey="/restaurant">
    77             <AddNew type="restaurant"/>
     85            {!isLoading && data.map((res) => {
     86              return (
     87                  <ReservationListing type={'transport'} data={res}/>
     88              )
     89            })}
    7890          </Tab.Pane>
    7991          <Tab.Pane eventKey="/transport">
  • frontend/src/Components/TransportEdit/TransportListing.js

    r5528b99 r07f4e8b  
    99
    1010    //const type = props.type == "hotel" ? "сместувањето" : props.type == "restaurant" ? "ресторанот" : "превозот";
    11     console.log(props.data)
    12     console.log(props.data.from)
    1311    return (<>
    1412        <a href="#" style={{textDecoration: "none", color: "black"}}>
     
    3432                    <Col className="d-flex flex-column justify-content-center" style={{textAlign: "left"}}>
    3533                        <h2>{props.data.from} - {props.data.to}</h2>
    36                         {/* <h6>{props.data.routeCities}</h6> */}
    3734                        <h6>{props.data.routes.map(x => x).join(", ")}</h6>
    3835                    </Col>
     
    4037                    <Col className="d-flex flex-column justify-content-center align-content-center">
    4138                        <h5>Цена:</h5>
    42                         {/* <h4>{props.data.routePrice}</h4> */}
    43                         <h4>99$</h4>
     39                         <h4>{props.data.maxPrice}$</h4>
    4440                    </Col>
    4541                </Row>
  • frontend/src/Components/UserPanel/HotelReservationListing.js

    r5528b99 r07f4e8b  
    1212import data from "bootstrap/js/src/dom/data";
    1313import {AiOutlinePlusCircle} from "react-icons/ai";
    14 import {MdOutlineRateReview} from "react-icons/md";
     14import { MdCancel } from "react-icons/md";
     15import { MdOutlineRateReview } from "react-icons/md"
    1516import useFormData from "../Hooks/useFormData";
    1617import useCreate from "../Hooks/useCreate";
     
    2627
    2728    console.log(props.data)
     29    const { createEntity } = useCreate();
    2830    const dateFormatter = (str) => {
    2931        const inputDate = new Date(str);
     
    114116                        <h3>Вкупна цена: <br></br>{props.data.transportRoute.price}$</h3>
    115117                    </Col>}
     118                {(!props.past) && <Col className="d-flex flex-column justify-content-center align-content-center">
     119                    {<Container id={'ocn'} onClick={(e) => {
     120                        console.log(e.target)
     121                        if (e.target.id === 'icon') {
     122                            createEntity(`/restaurant/${props.data.reservationId}/cancel`, props.setChanged, props.setChanged)
     123                            window.location.href="/reservations"
     124                        }
     125                    }}>
     126                        <h5 id={'icon'}>Откажи<br/>резервација</h5>
     127                        <div className="d-flex justify-content-center align-content-center">
     128                            <MdCancel size={50} color="#159895"/></div>
     129
     130                    </Container>}
     131                </Col>}
    116132                {(props.past) && <Col className="d-flex flex-column justify-content-center align-content-center">
    117133                    {!props.data.reviewed && <Container id={'ocn'} onClick={(e) => {
     
    132148            </Row>
    133149        </Container>
    134         {props.type === 'hotel' && <HotelReservationModal show={show} handleClose={handleClose} data={props.data}/>}
    135         <ReviewModal type={props.type} showReview={showReview} handleCloseReview={handleCloseReview} data={props.data}/>
     150        {props.type === 'hotel' && <HotelReservationModal setChanged={props.setChanged} show={show} handleClose={handleClose} data={props.data}/>}
     151        <ReviewModal setChanged={props.setChanged} type={props.type} showReview={showReview} handleCloseReview={handleCloseReview} data={props.data}/>
    136152    </>)
    137153}
  • frontend/src/Components/UserPanel/HotelReservationModal.js

    r5528b99 r07f4e8b  
    55import {TbToolsKitchen2} from "react-icons/tb";
    66import React from "react";
     7import useCreate from "../Hooks/useCreate";
    78
    89const HotelReservationModal = (props) => {
     10
     11    const {createEntity} = useCreate();
    912
    1013    const dateFormatter = (str) => {
     
    1720            hour12: false,
    1821        };
     22
     23        console.log(props)
    1924
    2025        return inputDate.toLocaleString('de-DE', options);
     
    189194                        Затвори
    190195                    </Button>
     196                    <Button variant="danger" onClick={() => {
     197                        createEntity(`/hotel/${props.data.reservationId}/cancel`, props.setChanged)
     198                        props.handleClose()
     199                    }
     200                    }>
     201                        Откажи резервација
     202                    </Button>
    191203                </Modal.Footer>
    192204            </Modal>
  • frontend/src/Components/UserPanel/PastHotelReservations.js

    r5528b99 r07f4e8b  
    1010        <>
    1111            {!isLoading && data.map((res) => {
    12                 return (<HotelReservationListing past={true} data={res} type={'hotel'}></HotelReservationListing>)
     12                return (<HotelReservationListing setChanged={setChanged} past={true} data={res} type={'hotel'}></HotelReservationListing>)
    1313            })}
    1414            {(!isLoading && data.length === 0) && <h3 className={'my-5'}>Нема податоци за одбраните критериуми!</h3>}
  • frontend/src/Components/UserPanel/PastRestaurantReservations.js

    r5528b99 r07f4e8b  
    1111        <>
    1212            {!isLoading && data.map((res) => {
    13                 return (<HotelReservationListing past={true} data={res} type={'restaurant'}></HotelReservationListing>)
     13                console.log(res)
     14                return (<HotelReservationListing setChanged={setChanged} past={true} data={res} type={'restaurant'}></HotelReservationListing>)
    1415            })}
    1516            {(!isLoading && data.length === 0) && <h3 className={'my-5'}>Нема податоци за одбраните критериуми!</h3>}
  • frontend/src/Components/UserPanel/PastTransportReservations.js

    r5528b99 r07f4e8b  
    1010        <>
    1111            {!isLoading && data.map((res) => {
    12                 return (<HotelReservationListing past={true} data={res} type={'transport'}></HotelReservationListing>)
     12                return (<HotelReservationListing setChanged={setChanged} past={true} data={res} type={'transport'}></HotelReservationListing>)
    1313            })}
    1414
  • frontend/src/Components/UserPanel/ReviewModal.js

    r5528b99 r07f4e8b  
    1010        description: "",
    1111    }
     12    console.log(props)
    1213
    1314    const {createEntity} = useCreate();
     
    8081                                ...formData,
    8182                                hotelId: props.data.hotelId,
    82                                 userId: 1
     83                                userId: 1,
     84                                reservationId: props.data.reservationId
    8385                            } :
    8486                            props.type === 'restaurant' ? {
    85                                     ...formData,
    86                                     restaurantId: props.data.restaurantId,
    87                                     userId: 1
    88                                 } : {
     87                                ...formData,
     88                                restaurantId: props.data.restaurantId,
     89                                userId: 1,
     90                                reservationId: props.data.reservationId
     91                            } : {
    8992                                ...formData,
    9093                                transportId: props.data.transportId,
    91                                 userId: 1
     94                                userId: 1,
     95                                reservationId: props.data.reservationId
    9296                            }
    93                                 createEntity('/review/add', dataToPost)
     97                        createEntity('/review/add', dataToPost, props.setChanged)
    9498                        setFormData(dummy)
    9599                        props.handleCloseReview()
  • frontend/src/Components/useFormNested.js

    r5528b99 r07f4e8b  
    77        console.log(e)
    88
    9         const dependantRoutes = e.target.parentElement.getAttribute('dependantRoutes').split(',')
     9        const dependantRoutes = e.target.name === 'freeSpace' ? e.target.parentElement.getAttribute('dependantRoutes').split(',') : undefined;
    1010        console.log(dependantRoutes)
    1111
  • frontend/src/Pages/HotelDetailsPage.js

    r5528b99 r07f4e8b  
    11import React from "react";
    22import LoginForm from "../Components/Login/LoginForm";
    3 <<<<<<< HEAD
    43import {Container, Row, Col, Form, FloatingLabel, Modal, Button} from "react-bootstrap";
    5 =======
    6 import { Container, Row, Col, Form } from "react-bootstrap";
    7 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    84import Navigation from "../Components/Layout/Navbar/Navigation";
    95import Carousel from "react-bootstrap/Carousel";
     
    7369                  placeholder="Каде ќе патувате?:"
    7470                  id="location"
     71                  value={data.hotelLocation}
    7572                ></Form.Control>
    76                 <label htmlFor="location">Локација:</label>
     73                <label style={{left: "10px"}} htmlFor="location">Локација:</label>
    7774              </Form.Floating>
    7875            </Row>
     
    8481                  placeholder="Датум на пристигнување:"
    8582                  id="dateFrom"
     83                  value={from}
    8684                ></Form.Control>
    87                 <label htmlFor="dateFrom">Датум на пристигнување:</label>
     85                <label style={{left: "10px"}} htmlFor="dateFrom">Датум на пристигнување:</label>
    8886              </Form.Floating>
    8987            </Row>
     
    9593                  placeholder="Датум на заминување:"
    9694                  id="dateTo"
     95                  value={to}
    9796                ></Form.Control>
    98                 <label htmlFor="dateTo">Датум на заминување:</label>
     97                <label style={{left: "10px"}} htmlFor="dateTo">Датум на заминување:</label>
    9998              </Form.Floating>
    10099            </Row>
     
    107106                  id="floatingPassengers"
    108107                ></Form.Control>
    109                 <label htmlFor="floatingPassengers">Број на гости:</label>
     108                <label style={{left: "10px"}} htmlFor="floatingPassengers">Број на гости:</label>
    110109              </Form.Floating>
    111110            </Row>
     
    117116                  {data.images.map((image) => {
    118117                    let link = image.url;
    119                     console.log("SLIKATAAA")
    120                     console.log(image)
    121118                    if (image.url.includes('Desktop')) {
    122119                      link = 'http://localhost:8080/download?fileName=' + encodeURIComponent(image.url);
  • frontend/src/Pages/HotelEditPage.js

    r5528b99 r07f4e8b  
    1 import React, { useState } from "react";
    2 import { Container, Col, Row, Image } from "react-bootstrap";
     1import React, {useState} from "react";
     2import {Container, Col, Row, Image} from "react-bootstrap";
    33import Navigation from "../Components/Layout/Navbar/Navigation";
    44import ResourcesTab from "../Components/Resources/ResourcesTab";
    55import HotelEditTab from "../Components/HotelEdit/HotelEditTab";
    66import useGet from "../Components/Hooks/useGet";
    7 import { useParams } from "react-router-dom";
     7import {Navigate, useParams} from "react-router-dom";
     8import {useAuth} from "../Components/Context/AuthContext";
    89
    910
    1011const HotelEditPage = () => {
    1112
    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/${params.hotelId}/list`;
     15    const [changed, setChanged] = useState(0)
     16    const {data, setData, isLoading, getData} = useGet(link, changed);
    1617
    1718
    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               <Col
    30                 className="d-flex justify-content-center"
    31                 style={{ maxWidth: "30%" }}
    32               >
    33                 <Image
    34                   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    );
    5859};
    5960
  • frontend/src/Pages/LoginErrorPage.js

    r5528b99 r07f4e8b  
    1111    const [show, setShow] = useState(false);
    1212    const [changed, setChanged] = useState(0);
    13     const {data, isLoading} = useGet("/username")
    1413    const userId = localStorage.getItem("userId")
    1514    const [registered, setRegistered] = useState(false);
  • frontend/src/Pages/LoginPage.js

    r5528b99 r07f4e8b  
    33import { Container } from "react-bootstrap";
    44import Navigation from "../Components/Layout/Navbar/Navigation";
     5import {useAuth} from "../Components/Context/AuthContext";
     6import {Navigate} from "react-router-dom";
     7
    58
    69const LoginPage = () => {
     
    811  document.body.style.marginTop = "auto";
    912  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
    1021  return (
    1122    <>
  • frontend/src/Pages/NoBusinessRegisteredError.js

    r5528b99 r07f4e8b  
    66import RegisterBusinessForm from "../Components/Forms/RegisterBusinessForm";
    77import useGet from "../Components/Hooks/useGet";
    8 import { useNavigate } from "react-router-dom";
     8import {Navigate, useNavigate} from "react-router-dom";
     9import {useAuth} from "../Components/Context/AuthContext";
    910
    1011const NoBusinessRegisteredError = (props) => {
    1112  const [show, setShow] = useState(false);
    1213  const [changed, setChanged] = useState(0);
    13   const {data, isLoading} = useGet("/username")
     14  const Auth = useAuth();
     15  const isLoggedIn = Auth.userIsAuthenticated();
    1416  const userId = localStorage.getItem("userId")
    1517  const [registered, setRegistered] = useState(false);
     
    4547
    4648
    47   console.log(data)
     49  if(!isLoggedIn)
     50  {
     51    return <Navigate to={'/login'}/>
     52  }
    4853
    49   !isLoading && !data && navigator("/login")
    5054  !firmaIsLoading && firma && firma.length > 0 && firma[0].approved && navigator("/resources/hotel")
    5155 
  • frontend/src/Pages/ProfilePage.js

    r5528b99 r07f4e8b  
    88import ChangePasswordForm from "../Components/Forms/ChangePasswordForm";
    99import useGet from "../Components/Hooks/useGet";
     10import {useAuth} from "../Components/Context/AuthContext";
     11import {Navigate} from "react-router-dom";
    1012
    1113const ProfilePage = () => {
    1214
    13   const { data, setData, isLoading, getData } = useGet("/principal");
     15    const { data, setData, isLoading, getData } = useGet("/principal");
    1416
    15  
     17
     18
    1619    const profileData = {
    1720        "name": "Марко",
     
    1922        "address": "ул. Раскрсница бр. 10",
    2023        "dateOfBirth": "2002-01-01",
    21         "country": "Никогаш Северна само МАКЕДОНИЈА",
     24        "country": "Македонија",
    2225        "zip": "1000",
    2326        "city": "Скопје",
     
    2730
    2831
     32
    2933  return (
    3034    <>
    3135      <Navigation />
    32 {      !isLoading && <Container>
     36    {!isLoading && <Container>
    3337        <Row className="mb-5">
    3438          <h2 style={{ color: "#159895", textAlign: "left" }}>Мојот профил</h2>
  • frontend/src/Pages/ResourcesPage.js

    r5528b99 r07f4e8b  
    11import React from "react";
    2 import { Container, Col, Row, Image } from "react-bootstrap";
     2import {Container, Col, Row, Image} from "react-bootstrap";
    33import Navigation from "../Components/Layout/Navbar/Navigation";
    44import ResourcesTab from "../Components/Resources/ResourcesTab";
    5 import { useState } from "react";
     5import {useState} from "react";
    66import useGet from "../Components/Hooks/useGet";
     7import {useAuth} from "../Components/Context/AuthContext";
     8import {Navigate} from "react-router-dom";
    79
    810const ResourcesPage = (props) => {
    911
    10   console.log(props.tab)
    11   const { data, setData, isLoading, getData } = useGet("/principal");
     12    const Auth = useAuth();
     13    const user = Auth.getUser();
    1214
    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    );
    5354};
    5455
  • frontend/src/Pages/RestaurantDetailsPage.js

    r5528b99 r07f4e8b  
    133133                            <Row>
    134134                                <Carousel activeIndex={index} onSelect={handleSelect}>
    135                                     <Carousel.Item>
     135                                    {data.images.map((image) => {
     136                                        let link = image.url;
     137                                        if (image.url.includes('Desktop')) {
     138                                            link = 'http://localhost:8080/download?fileName=' + encodeURIComponent(image.url);
     139                                        }
     140                                        return (
     141                                            <Carousel.Item>
     142                                                <img
     143                                                    className="d-block w-100 h-400 rounded-5"
     144                                                    src={link}
     145                                                    alt="First slide"
     146                                                    style={{ height: "50vh" }}
     147                                                />
     148                                            </Carousel.Item>
     149                                        )
     150                                    })}
     151                                    {data.images.length == 0 && <Carousel.Item>
    136152                                        <img
    137153                                            className="d-block w-100 h-400 rounded-5"
     
    140156                                            style={{height: "50vh"}}
    141157                                        />
    142                                     </Carousel.Item>
    143                                     <Carousel.Item>
    144                                         <img
    145                                             className="d-block w-100 rounded-5"
    146                                             src="https://emagazin.mk/wp-content/uploads/2022/03/Karos_Photography-7871.jpg"
    147                                             alt="Second slide"
    148                                             style={{height: "50vh"}}
    149                                         />
    150                                     </Carousel.Item>
    151                                     <Carousel.Item>
    152                                         <img
    153                                             className="d-block w-100 rounded-5"
    154                                             src="https://lh5.googleusercontent.com/p/AF1QipMQAwahuuJCJ2rDUYNrhnwiX1070adTsM6LmzV5=w480-h300-k-n"
    155                                             alt="Third slide"
    156                                             style={{height: "50vh"}}
    157                                         />
    158                                     </Carousel.Item>
     158                                    </Carousel.Item>}
    159159                                </Carousel>
    160160                            </Row>
     
    169169                    <Col className="col-md-4"><ReviewsCarousel reviews={data.reviews}></ReviewsCarousel></Col>
    170170                </Row>
    171                 <Row className="mb-3"><MenuCarousel menu={data.menus}></MenuCarousel></Row>
     171                <Row className="mb-3"><MenuCarousel images={data.menuImages} menu={data.menus}></MenuCarousel></Row>
    172172                <Row><TablesTable params={formData} data={data.tables}></TablesTable></Row>
    173173                <Row><ContactBar></ContactBar></Row>
  • frontend/src/Pages/RestaurantEditPage.js

    r5528b99 r07f4e8b  
    66import RestaurantEditTab from "../Components/RestaurantEdit/RestaurantEditTab";
    77import useGet from "../Components/Hooks/useGet";
    8 import { useParams, useSearchParams } from "react-router-dom";
     8import {Navigate, useParams, useSearchParams} from "react-router-dom";
     9import {useAuth} from "../Components/Context/AuthContext";
    910
    1011const RestaurantEditPage = () => {
  • frontend/src/Pages/SearchPage.js

    r5528b99 r07f4e8b  
    1 import React from "react";
     1import React, {useState} from "react";
    22import Navigation from '../Components/Layout/Navbar/Navigation';
    33import 'bootstrap/dist/css/bootstrap.css';
    44import 'bootstrap/dist/js/bootstrap.js';
    55import HomeCarousel from '../Components/Layout/CarouselHome/Carousel';
    6 import { Card, Container, Nav, Row, Col } from 'react-bootstrap';
     6import {Card, Container, Nav, Row, Col} from 'react-bootstrap';
    77import TabComponent from '../Components/Tab/Tab';
    88import Offers from '../Components/Layout/Offers/Offers';
     
    1111import BecomeAHost from "../Components/BecomeAHost/BecomeAHost"
    1212import HotelLisitng from "../Components/Listings/HotelListing"
    13 import SearchCriterias from "../Components/SearchCriterias/SearchCriteriasBar";
     13import SearchCriteriasHotel from "../Components/SearchCriterias/SearchCriteriasHotel";
    1414import SortButton from "../Components/Listings/SortButton";
    1515import FilterButton from "../Components/Listings/FilterButton";
    1616import TransportListing from "../Components/Listings/TransportListing";
    1717import useGet from "../Components/Hooks/useGet";
    18 import { useParams } from "react-router-dom";
    19 <<<<<<< HEAD
     18import {useParams} from "react-router-dom";
    2019import SearchCriteriasBar from "../Components/SearchCriterias/SearchCriteriasBar";
    2120import RestaurantDetailsPage from "./RestaurantDetailsPage";
    2221import RestaurantListing from "../Components/Listings/RestaurantListing";
    23 =======
    24 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    2522
    2623
     
    2926    const params = useParams();
    3027    console.log(params)
    31 
     28    const [sortingArg, setSortingArg] = useState("")
    3229
    3330    document.body.style.backgroundColor = "white"
     
    4138
    4239    }
    43    
    44 <<<<<<< HEAD
    45     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}` : `/restaurant/search?restaurantLocation=${params.restaurantLocation}&date=${params.date}&hourFrom=${params.hourFrom}&hourTo=${params.hourTo}&numPeople=${params.numPeople}`
    46 =======
    47     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}` : ""
    48 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
     40
     41    const getSortingFn = (type, arg) => {
     42        if (type === 'hotel') {
     43            if (arg === "priceAsc")
     44            {
     45                return (a, b) => {
     46                    return a.totalPrice - b.totalPrice;
     47                }
     48            }
     49            else if (arg === "priceDesc")
     50            {
     51                return (a, b) => {
     52                    return -(a.totalPrice - b.totalPrice);
     53                }
     54            }
     55            else if (arg === 'nameAsc')
     56            {
     57                return (a, b) => {
     58                    return a.hotelName.localeCompare(b.hotelName);
     59                }
     60            }
     61            else if(arg === 'nameDesc')
     62            {
     63                return (a, b) => {
     64                    return -a.hotelName.localeCompare(b.hotelName);
     65                }
     66            }
     67        }
     68        else if (type === 'transport')
     69        {
     70            if (arg === "priceAsc")
     71            {
     72                return (a, b) => {
     73                    return a.price - b.price;
     74                }
     75            }
     76            else if (arg === "priceDesc")
     77            {
     78                return (a, b) => {
     79                    return -(a.price - b.price);
     80                }
     81            }
     82        }
     83        else if (type === 'restaurant')
     84        {
     85            if (arg === 'nameAsc')
     86            {
     87                return (a, b) => {
     88                    return a.restaurantName.localeCompare(b.restaurantName);
     89                }
     90            }
     91            else if(arg === 'nameDesc')
     92            {
     93                return (a, b) => {
     94                    return -a.restaurantName.localeCompare(b.restaurantName);
     95                }
     96            }
     97        }
     98    }
     99
     100    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}&flexible=${params.flexible}` : `/restaurant/search?restaurantLocation=${params.restaurantLocation}&date=${params.date}&hourFrom=${params.hourFrom}&hourTo=${params.hourTo}&numPeople=${params.numPeople}`
    49101    console.log(link)
    50102    console.log(params.date)
    51     const { data, isLoading, getData, setData } = useGet(link);
     103    const {data, isLoading, getData, setData} = useGet(link);
    52104    !isLoading && console.log(data)
    53105    return (
    54106        <>
    55107            <Navigation></Navigation>
    56             <SearchCriterias criterias={useParams()}></SearchCriterias>
     108            <SearchCriteriasBar type={props.type} criterias={useParams()}></SearchCriteriasBar>
    57109            <Container className="d-flex justify-content-end gx-5" style={{maxWidth: "60%"}}>
    58110                <Row>
     
    61113                    </Col>
    62114                    <Col>
    63                         <SortButton></SortButton>
     115                        <SortButton setSortingArg={setSortingArg} type={props.type}></SortButton>
    64116                    </Col>
    65117                </Row>
    66118            </Container>
    67119            {props.type === "hotel" && !isLoading && data && <Container fluid>
    68                 {data.map(hotel => {
     120                {data.sort(getSortingFn(props.type, sortingArg)).map(hotel => {
    69121                    return <HotelLisitng from={params.dateFrom} to={params.dateTo} data={hotel}/>
    70122                })}
    71                 </Container>}
     123            </Container>}
    72124            {props.type === "transport" && !isLoading && data && <Container fluid>
    73                 {data.map(transport => {
     125                {data.sort(getSortingFn(props.type, sortingArg)).map(transport => {
    74126                    return <TransportListing params={params} data={transport}/>
    75127                })}
    76128            </Container>}
    77129            {props.type === "restaurant" && !isLoading && data && <Container fluid>
    78                 {data.map(restaurant => {
     130                {data.sort(getSortingFn(props.type, sortingArg)).map(restaurant => {
    79131                    return <RestaurantListing params={params} data={restaurant}/>
    80132                })}
  • frontend/src/Pages/TransportEditPage.js

    r5528b99 r07f4e8b  
    1 import React, { useState } from "react";
    2 import { Container, Col, Row, Image } from "react-bootstrap";
     1import React, {useState} from "react";
     2import {Container, Col, Row, Image} from "react-bootstrap";
    33import Navigation from "../Components/Layout/Navbar/Navigation";
    44import ResourcesTab from "../Components/Resources/ResourcesTab";
     
    77import TransportEditTab from "../Components/TransportEdit/TransportEditTab";
    88import useGet from "../Components/Hooks/useGet";
    9 import { useParams } from "react-router-dom";
     9import {Navigate, useParams} from "react-router-dom";
     10import {useAuth} from "../Components/Context/AuthContext";
    1011
    1112const 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);
    1713
    18   !isLoading && console.log(data)
     14    const params = useParams();
    1915
    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    );
    6163};
    6264
  • frontend/src/axios.js

    r5528b99 r07f4e8b  
    11import axios from "axios";
     2
    23
    34const instance = axios.create({
    45    baseURL: "http://localhost:8080/",
    56    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
    714})
    815
    9 instance.interceptors.response.use(function (response) {
    10     // Any status code that lie within the range of 2xx cause this function to trigger
    11     // Do something with response data
    12     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 trigger
    17     // Do something with response error
    18     return Promise.reject(error);
    19   });
    20 
    2116export default instance
  • src/main/java/com/tourMate/config/SecurityConfig.java

    r5528b99 r07f4e8b  
    55import org.springframework.context.annotation.Bean;
    66import org.springframework.context.annotation.Configuration;
    7 import org.springframework.http.HttpHeaders;
    87import org.springframework.http.HttpMethod;
     8import org.springframework.http.HttpStatus;
    99import org.springframework.security.config.annotation.web.builders.HttpSecurity;
    1010import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
     
    1313import org.springframework.security.crypto.password.PasswordEncoder;
    1414import org.springframework.security.web.SecurityFilterChain;
    15 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
     15import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;
    1616import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
    1717import org.springframework.web.cors.CorsConfiguration;
     
    2121import java.util.Arrays;
    2222
    23 import static org.springframework.security.config.Customizer.withDefaults;
    24 
    2523@Configuration
    2624@EnableWebSecurity
    2725public class SecurityConfig {
     26
     27    private final UserSecurity userSecurity;
     28
     29    public SecurityConfig(UserSecurity userSecurity) {
     30        this.userSecurity = userSecurity;
     31    }
    2832
    2933    @Bean
     
    6468                            try {
    6569                                authz
    66                                         .requestMatchers(new AntPathRequestMatcher("/1/hasBusiness")).permitAll()
    67                                         .requestMatchers(new AntPathRequestMatcher("/business/1/unapproved")).permitAll()
     70                                        .requestMatchers(new AntPathRequestMatcher("/{userId}/hasBusiness")).access(userSecurity)
     71                                        .requestMatchers(new AntPathRequestMatcher("/business/*/unapproved")).permitAll()
    6872                                        .requestMatchers(new AntPathRequestMatcher("/register")).permitAll()
    6973                                        .requestMatchers(new AntPathRequestMatcher("/hotel/search")).permitAll()
     
    7175                                        .requestMatchers(new AntPathRequestMatcher("/restaurant/search")).permitAll()
    7276                                        .requestMatchers(new AntPathRequestMatcher("/upload")).permitAll()
    73                                         .requestMatchers(new AntPathRequestMatcher("/business/*")).hasAnyAuthority("SUPERADMIN")
    74                                         .anyRequest().authenticated()
     77                                        .requestMatchers(new AntPathRequestMatcher("/business/approve/*")).hasAnyAuthority("SUPERADMIN")
     78                                        .requestMatchers(new AntPathRequestMatcher("/business/add/*")).authenticated()
     79                                        .requestMatchers(new AntPathRequestMatcher("/*/user/{userId}")).access(userSecurity)
     80                                        .anyRequest().permitAll()
     81//                                        .anyRequest().authenticated()
    7582                                        .and()
    76                                         .formLogin().loginPage("http://localhost:3000/login")
     83                                        .formLogin()
    7784                                        .loginProcessingUrl("/api/login").usernameParameter("username").passwordParameter("password")
    7885                                        .successHandler((request, response, authentication) -> {
    7986                                            response.setStatus(HttpServletResponse.SC_OK);
     87                                            response.setCharacterEncoding("UTF-8");
    8088                                            response.setContentType("application/json");
    8189                                            response.getWriter().print("{\"message\": \"Login successful\",");
     
    8593                                        .failureHandler((request, response, exception) -> {
    8694                                            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    87                                             response.getWriter().print("Pukla veza\n" + exception.getMessage());
     95                                            response.sendRedirect("/login");
     96                                            response.getWriter().print("Neuspesna najava\n" + exception.getMessage());
    8897                                            response.getWriter().flush();
    8998                                        })
     
    93102                                        .sessionCreationPolicy(SessionCreationPolicy.ALWAYS)
    94103                                        .and()
    95                                         .logout()
     104                                        .logout().logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK)))
    96105                                        .permitAll();
    97106
  • src/main/java/com/tourMate/controllers/HotelController.java

    r5528b99 r07f4e8b  
    22
    33import com.tourMate.dto.HotelDto;
     4import com.tourMate.dto.HotelReservationDto;
     5import com.tourMate.dto.HotelReservationUserDto;
    46import com.tourMate.entities.*;
    57import com.tourMate.services.HotelManager;
     
    5052    }
    5153
    52     @GetMapping(path = "/hotel/list/{id}")
     54    @GetMapping(path = "/hotel/{id}/list")
    5355    public ResponseEntity<Hotels> getHotelById (@PathVariable(name = "id") long hotelId)
    5456    {
     
    104106    //HOTEL ROOM CRUD
    105107    @PostMapping(path = "/hotel/rooms/add")
    106     public void addRoom(@RequestBody HotelRoom room, @RequestParam(name = "hotelId") long hotelId) {
     108    public void addRoom(@RequestBody HotelRoom room,
     109                        @RequestParam(name = "hotelId") long hotelId) {
    107110        Hotels h = hotelManager.findHotelByID(hotelId);
    108         hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice());
     111        hotelManager.createRoom(h, room.getHotelRoomDescription(), room.getHotelRoomName(), room.getKitchenAvailable(), room.getAirConditioning(), room.getBalcony(), room.getPrice(), room.getNumOfBeds());
    109112    }
    110113
     
    149152        //HOTEL AVAILABILITY CRUD
    150153    @PostMapping(path = "/hotel/rooms/available/{id}/add")
    151     public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable, @PathVariable long id)
     154    public void addRoomAvailible(@RequestBody HotelRoomAvailable hotelRoomAvailable,
     155                                 @PathVariable long id)
    152156    {
    153157        HotelRoom hotelRoom = hotelManager.findRoomById(id);
     
    178182    public List<HotelRoomAvailable> getRoomAvailability(@PathVariable Long id)
    179183    {
    180         return hotelManager.getRoomsAvailibility();
     184        return hotelManager.getRoomsAvailableById(id);
    181185    }
    182186
    183187    @GetMapping(path = "/hotel/search")
    184     public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation, @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom,
    185                                                @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo, @RequestParam(name = "numBeds") int numBeds)
    186     {
    187         System.out.println(hotelLocation);
     188    public List<HotelDto> searchAvailibleRooms(@RequestParam(name = "hotelLocation") String hotelLocation,
     189                                               @RequestParam(name = "dateFrom") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateFrom,
     190                                               @RequestParam(name = "dateTo") @DateTimeFormat(pattern = "yyyy-MM-dd") Date dateTo,
     191                                               @RequestParam(name = "numBeds") int numBeds,
     192                                               @RequestParam(name = "flexible") Boolean flexible)
     193    {
     194        System.out.println(flexible);
    188195        System.out.println(dateFrom + " " + dateTo);
    189         return hotelManager.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numBeds);
     196        return hotelManager.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numBeds, flexible);
    190197    }
    191198
     
    203210    }
    204211
    205 <<<<<<< HEAD
    206212    @GetMapping(path = "/hotel/{id}/reservations/active")
    207213    public List<HotelReservationDto> getActiveReservationsForHotel(@PathVariable Long id)
     
    233239        return hotelManager.getRoomImages(id);
    234240    }
    235 =======
    236 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
     241
     242    @PostMapping("/hotel/{id}/cancel")
     243    public void cancelHotelReservation(@PathVariable Long id){
     244        hotelManager.deleteReservation(id);
     245    }
     246
    237247}
  • src/main/java/com/tourMate/controllers/RestaurantController.java

    r5528b99 r07f4e8b  
    11package com.tourMate.controllers;
    22
     3import com.tourMate.dto.HotelReservationDto;
    34import com.tourMate.dto.RestaurantDto;
     5import com.tourMate.dto.RestaurantReservationDto;
    46import com.tourMate.dto.RestaurantReservationUserDto;
    57import com.tourMate.entities.*;
     
    3436    }
    3537
     38    @PostMapping("/restaurant/{id}/cancel")
     39    public void removeRestaurant(@PathVariable Long id){
     40        restaurantManager.deleteReservation(id);
     41    }
     42
    3643    @GetMapping(path = "/restaurant")
    3744    public List<Restaurant> showRestaurants() {
     
    4249    public List<Restaurant> showRestaurantsForUser(@PathVariable(name = "id") long userId) {
    4350
    44         return restaurantManager.getRestaurants();
     51        return restaurantManager.getRestaurantsByUser(userId);
    4552    }
    4653
     
    133140                                  @PathVariable Long id) {
    134141        System.out.println(restaurantsAvailible.getHourFrom() + " " + restaurantsAvailible.getHourTo());
    135         restaurantManager.createTableAvailable(id, restaurantsAvailible.getHourFrom(), restaurantsAvailible.getHourTo());
     142        restaurantManager.createTableAvailable(id, restaurantsAvailible.getHourFrom(), restaurantsAvailible.getHourTo(), restaurantsAvailible.getNumTables());
    136143    }
    137144
     
    170177        return restaurantManager.getRestaurantImages(id);
    171178    }
     179
     180    @GetMapping(path = "/menu/{id}/images")
     181    public List<MenuImages> getImagesForMenu(@PathVariable Long id)
     182    {
     183        return restaurantManager.getMenuImages(id);
     184    }
     185
     186    @GetMapping(path = "/restaurant/{id}/reservations/active")
     187    public List<RestaurantReservationDto> getActiveReservationsForHotel(@PathVariable Long id)
     188    {
     189        return restaurantManager.findReservationByRestaurant(id);
     190    }
    172191}
    173192
  • src/main/java/com/tourMate/controllers/ReviewController.java

    r5528b99 r07f4e8b  
    2020                    @RequestParam(name = "hotelId", required = false) Long hotelId,
    2121                    @RequestParam(name = "restaurantId", required = false) Long restaurantId,
    22                     @RequestParam(name = "transportId", required = false) Long transportId ) {
    23         reviewManager.createReview(title, numStars, description, hotelId, restaurantId, transportId);
     22                    @RequestParam(name = "transportId", required = false) Long transportId,
     23                    @RequestParam(name = "reservationId") Long reservationId) {
     24        reviewManager.createReview(title, numStars, description, hotelId, restaurantId, transportId, reservationId);
    2425    }
    2526
  • src/main/java/com/tourMate/controllers/TransportController.java

    r5528b99 r07f4e8b  
    2020
    2121    // TRANSPORT CRUD //
    22     @PostMapping(path = "/transport/add")
    23     public void add(@RequestBody Transport transport) {
    24         transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), new User(), transport.getCarPlate());
     22    @PostMapping(path = "/transport/add/{userId}")
     23    public void add(@RequestBody Transport transport,
     24                    @PathVariable Long userId) {
     25        transportManager.createTransport(transport.getTransportName(), transport.getCarBrand(), transport.getCarType(), transport.getCarManufacturedYear(), transport.getNoPassengers(), transport.getNoBags(), transport.getEMBG(), userId, transport.getCarPlate());
    2526
    2627    }
     
    4546    public TransportDto getTransport(@PathVariable(name = "id") long transportId)
    4647    {
    47         System.out.println("TUKA SUUUUUM");
    4848        return transportManager.findTransportById(transportId);
    4949    }
     
    8484    @PostMapping(path = "/transport/available/add")
    8585    public void add(@RequestBody TransportAvailible transportAvailable, @RequestParam(name = "transportId") long transportId) {
    86         System.out.println("OREEEEEL");
    87         System.out.println("DVA ORLA");
    8886        Transport t = transportManager.getTransportById(transportId);
    8987        List<TransportRoute> routes = transportAvailable.getRoutes().stream().toList();
     
    127125
    128126    @GetMapping(path = "/transport/search")
    129     public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from, @RequestParam(name = "to") String to,
    130                                                               @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date){
    131         return transportManager.getTransportsAvailableByFilters(from, to, date);
     127    public List<TransportListingDto> searchAvailableTransport(@RequestParam(name = "from") String from,
     128                                                              @RequestParam(name = "to") String to,
     129                                                              @RequestParam(name = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") Date date,
     130                                                              @RequestParam(name = "numPassengers") int numPassengers){
     131        return transportManager.getTransportsAvailableByFilters(from, to, date, numPassengers);
    132132    }
    133133
     
    151151        return transportManager.findPastTransportReservationsByUser(id);
    152152    }
     153
     154    @GetMapping(path = "/transport/{id}/reservations/active")
     155    public List<TransportReservation> showTransportReservationsByTransport(@PathVariable Long id) {
     156        return transportManager.findTransportReservationByTransportId(id);
     157    }
    153158}
  • src/main/java/com/tourMate/controllers/UsersController.java

    r5528b99 r07f4e8b  
    1111import org.springframework.web.bind.annotation.*;
    1212
    13 import java.util.ArrayList;
    1413import java.util.List;
    1514
     
    3938    {
    4039        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);
    4168    }
    4269
     
    85112        }
    86113    }
     114
     115    @GetMapping("/users/unlock/{id}")
     116    public ResponseEntity unlock(@PathVariable Long id)
     117    {
     118        usersManager.unlock(id);
     119        return new ResponseEntity(HttpStatus.OK);
     120    }
    87121}
    88122
  • src/main/java/com/tourMate/dao/BusinessDao.java

    r5528b99 r07f4e8b  
    99public interface BusinessDao {
    1010
    11     @Transactional
    12     void createBusiness(Business business, long userId);
    13     public List<Business> getUnapprovedBusinessesOfUser(long userId);
    14     public void deleteBusiness(long businessId);
    15     public List<Business> getCreatedBusinesses();
    16     public Business findBusinessById (long businessId);
     11    List<Business> getCreatedBusinesses();
     12
     13    Business findBusinessById(long businessId);
    1714
    1815    @Transactional
    19     void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved);
    20     public boolean hasBusiness(long userId);
     16    void createBusiness(Business business);
    2117
     18    List<Business> getUnapprovedBusinessesOfUser(User u);
     19
     20    @Transactional
     21    void deleteBusiness(Business business);
     22
     23    boolean hasBusiness(User u);
     24
     25    List<Business> getUnapprovedBusinesses();
     26
     27    void approveBusiness(Business business);
     28
     29    @Transactional
     30    void editBusiness(Business business);
    2231}
  • src/main/java/com/tourMate/dao/HotelDao.java

    r5528b99 r07f4e8b  
    99
    1010public interface HotelDao {
    11     public void createHotel(Hotels hotel, long userId);
    12     public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable);
    13     public void deleteHotel(long hotelId);
    14     public Hotels findHotelByID (long hotelId);
    15     public List<Hotels> getHotels();
    16     public List<Hotels> getHotelsForUser(long userId);
    17     public List<Hotels> getHotelsByLocation(String hotelLocation);
     11    @Transactional
     12    void createHotel(Hotels hotel);
    1813
    19     public void deleteHotelImage(long hotelImageId);
    20     public HotelsImages findHotelImageById(long hotelImageId);
    21     public List<HotelsImages> getHotelImages(Hotels hotels);
    22     public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom);
     14    List<Hotels> getHotels();
    2315
    24     public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
    25     public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
    26     public void deleteRoom(long hotelRoomId);
    27     public HotelRoom findRoomById (long hotelRoomId);
    28     public List<HotelRoom> getRoomsOfHotel (long hotelId);
    29     public List<HotelRoomAvailable> getRoomsAvailable(Long id);
     16    List<Hotels> getHotelsForUser(User u);
     17
     18    List<Hotels> getHotelsByLocation(String hotelLocation);
    3019
    3120    @Transactional
    32     public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
    33     public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
    34     public void deleteRoomAvailible(long hotelRoomAvailableId);
    35     public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId);
    36     public List<HotelRoomAvailable> getRoomsAvailibility();
    37     public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel);
    38     public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds);
     21    void editHotel(Hotels hotel);
    3922
    40     public void createReservation(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds);
    41     public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds);
    42     public void deleteReservation(long hotelRoomReservedId);
    43     public HotelRoomReservations findReservationById(long hotelRoomReservedId);
    44     public List<HotelRoomReservations> findReservationByUser(User user);
    45     public List<HotelRoomReservations> findReservationByHotel(Hotels hotel);
    46     public List<HotelRoomReservations> getReservations();
     23    @Transactional
     24    void deleteHotel(Hotels hotel);
     25
     26    Hotels findHotelByID(long hotelId);
     27
     28    List<HotelsImages> getHotelImages(Hotels hotel);
     29
     30    @Transactional
     31    void addHotelImage(HotelsImages image);
     32
     33    @Transactional
     34    void addRoomImage(HotelRoomImages x);
     35
     36    @Transactional
     37    void  saveReservation(HotelRoomReservations hotelRoomReservations);
     38
     39    @Transactional
     40    HotelsImages findHotelImageById(long hotelImageId);
     41
     42    @Transactional
     43    void deleteHotelImage(HotelsImages hotelsImages);
     44
     45    List<HotelRoom> getRoomsOfHotel(Hotels hotel);
     46
     47    List<HotelRoomAvailable> getRoomsAvailable(Long id);
     48
     49    HotelRoom findRoomById(long hotelRoomId);
     50
     51    List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom);
     52
     53    @Transactional
     54    void createRoom(HotelRoom hotelRoom);
     55
     56    @Transactional
     57    void editRoom(HotelRoom hr);
     58
     59    @Transactional
     60    void deleteRoom(HotelRoom hr);
     61
     62    @Transactional
     63    void createRoomAvailible(HotelRoomAvailable hra);
     64
     65    @Transactional
     66    void editRoomAvailible(HotelRoomAvailable hr);
     67
     68    @Transactional
     69    void deleteRoomAvailible(HotelRoomAvailable hra);
     70
     71    HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId);
     72
     73    List<HotelRoomAvailable> getRoomsAvailibility();
     74
     75    List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel);
     76
     77    List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible);
     78
     79    @Transactional
     80    void createReservation(HotelRoomReservations r);
     81
     82    @Transactional
     83    void editReservation(HotelRoomReservations hr);
     84
     85    @Transactional
     86    void deleteReservation(HotelRoomReservations hr);
     87
     88    HotelRoomReservations findReservationById(long hotelRoomReservedId);
     89
     90    List<HotelRoomReservations> findReservationByUser(User user);
     91
     92    List<HotelRoomReservations> findReservationByHotel(Hotels hotel);
     93
     94    List<HotelRoomReservations> getReservations();
    4795
    4896    List<Reviews> findReviewsByHotel(Hotels hotel);
    4997
    5098    List<HotelRoomReservations> findPastReservationByUser(User u);
    51 
    52     void addHotelImage(HotelsImages x);
    53 
    54     void addRoomImage(HotelRoomImages x);
     99//    public void createHotel(Hotels hotel, long userId);
     100//    public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable);
     101//    public void deleteHotel(long hotelId);
     102//    public Hotels findHotelByID (long hotelId);
     103//    public List<Hotels> getHotels();
     104//    public List<Hotels> getHotelsForUser(long userId);
     105//    public List<Hotels> getHotelsByLocation(String hotelLocation);
     106//
     107//    public void deleteHotelImage(long hotelImageId);
     108//    public HotelsImages findHotelImageById(long hotelImageId);
     109//    public List<HotelsImages> getHotelImages(Hotels hotels);
     110//    public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom);
     111//
     112//    public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds);
     113//    public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String HotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
     114//    public void deleteRoom(long hotelRoomId);
     115//    public HotelRoom findRoomById (long hotelRoomId);
     116//    public List<HotelRoom> getRoomsOfHotel (long hotelId);
     117//    public List<HotelRoomAvailable> getRoomsAvailable(Long id);
     118//
     119//    @Transactional
     120//    public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
     121//    public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
     122//    public void deleteRoomAvailible(long hotelRoomAvailableId);
     123//    public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId);
     124//    public List<HotelRoomAvailable> getRoomsAvailibility();
     125//    public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel);
     126//    public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible);
     127//
     128//    public void createReservation(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds);
     129//    public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds);
     130//    public void deleteReservation(long hotelRoomReservedId);
     131//    public HotelRoomReservations findReservationById(long hotelRoomReservedId);
     132//    public List<HotelRoomReservations> findReservationByUser(User user);
     133//    public List<HotelRoomReservations> findReservationByHotel(Hotels hotel);
     134//    public List<HotelRoomReservations> getReservations();
     135//
     136//    List<Reviews> findReviewsByHotel(Hotels hotel);
     137//
     138//    List<HotelRoomReservations> findPastReservationByUser(User u);
     139//
     140//    void addHotelImage(HotelsImages x);
     141//
     142//    void addRoomImage(HotelRoomImages x);
     143//    void saveReservation(HotelRoomReservations hotelRoomReservations);
    55144}
  • src/main/java/com/tourMate/dao/MenuDao.java

    r5528b99 r07f4e8b  
    22
    33import com.tourMate.entities.Menu;
     4import jakarta.transaction.Transactional;
    45
    56import java.util.List;
    67
    78public interface MenuDao {
    8     public void createMenu(String name, String ingredients, double price);
    9     public void deleteMenu(long menuId);
    10     public List<Menu> getCreatedMenus();
    11     public Menu findMenuById(long menuId);
    12     public void editMenu(long menuId, String name, String ingredients, double price);
     9    @Transactional
     10    void createMenu(Menu menu);
     11
     12    @Transactional
     13    void deleteMenu(Menu menu);
     14
     15    List<Menu> getCreatedMenus();
     16
     17    Menu findMenuById(long menuId);
     18
     19    @Transactional
     20    void editMenu(Menu menu);
     21//    public void createMenu(String name, String ingredients, double price);
     22//
     23//    @Transactional
     24//    void createMenu(Menu menu);
     25//
     26//    public void deleteMenu(long menuId);
     27//
     28//    @Transactional
     29//    void deleteMenu(Menu menu);
     30//
     31//    public List<Menu> getCreatedMenus();
     32//    public Menu findMenuById(long menuId);
     33//    public void editMenu(long menuId, String name, String ingredients, double price);
    1334}
  • src/main/java/com/tourMate/dao/RestaurantDao.java

    r5528b99 r07f4e8b  
    88
    99public interface RestaurantDao {
    10     public void createRestaurant(Restaurant restaurant, long userId);
    11     public void deleteRestaurant(long restaurantID);
    1210    @Transactional
    13     public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner);
    14     public Restaurant findRestaurantByID (long restaurantID);
    15     public List<Restaurant> searchByRestaurantName(String restaurantName);
    16     public List<Restaurant> searchByRestaurantLocation(String restaurantLocation);
    17     public List<Restaurant> getRestaurants();
     11    void createRestaurant(Restaurant restaurant);
     12    List<RestaurantsAvailible> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats);
    1813    @Transactional
    19     public void addMenuToRestaurant(long restaurantId, Menu menu);
     14    void addRestaurantImage(RestaurantImages restaurantImages);
     15    @Transactional
     16    void removeRestaurantImage(RestaurantImages image);
     17    @Transactional
     18    void saveTable(RestaurantsTable resTable);
     19    @Transactional
     20    RestaurantImages findRestaurantImageById(long restaurantImageId);
     21    void deleteRestaurant(Restaurant r);
     22    List<Restaurant> getRestaurants();
     23    @Transactional
     24    void addMenuToRestaurant(Menu menu);
     25    Restaurant findRestaurantByID(long restaurantID);
     26    List<RestaurantImages> getRestaurantImages(long restaurantID);
     27    List<RestaurantsTable> getRestaurantTables(long restaurantID);
     28    RestaurantsTable findTableById(long tableId);
     29    @Transactional
     30    void deleteTable(RestaurantsTable rt);
     31    List<Restaurant> getRestaurantsByUser(User u);
     32    List<RestaurantsAvailible> getTablesAvailabilityById(Long id);
     33    @Transactional
     34    void saveTableAvailable(RestaurantsAvailible ra);
     35    @Transactional
     36    void deleteTableAvailable(RestaurantsAvailible ra);
    2037
    21     public List<RestaurantsAvailible> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats);
     38    List<RestaurantsAvailible> getTablesAvailability();
    2239
    23     public void createTable(Restaurant restaurant, int noSeats);
    24     public void editTable(Restaurant restaurant, long tableId, int noSeats);
    25     public void deleteTable(long tableId);
    26     public List<Restaurant> getRestaurantsByUser(long userId);
    27     public RestaurantsTable findTableById(long tableId);
    28     public List<RestaurantsTable> searchByNoSeats(int noSeats);
    29     public List<RestaurantsTable> getRestaurantTables(long restaurantID);
     40    //    List<RestaurantsAvailible> getTablesAvailability();
     41    @Transactional
     42    void createReservation(RestaurantReservations reservations);
     43    @Transactional
     44    void deleteReservation(RestaurantReservations r);
     45    RestaurantReservations findReservationByID(long tableId);
     46    RestaurantsAvailible findAvailableReservationByID(long availibleId);
     47    List<RestaurantReservations> findReservationByUser(User user);
     48    List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant);
     49    List<RestaurantReservations> getReservations();
     50    List<Restaurant> searchByRestaurantName(String restaurantName);
    3051
    31     public void addRestaurantImage(RestaurantImages restaurantImages);
    32     public void removeRestaurantImage(long restaurantImageId);
    33     public RestaurantImages findRestaurantImageById(long restaurantImageId);
    34     public List<RestaurantImages> getRestaurantImages(long restaurantID);
     52    List<Restaurant> searchByRestaurantLocation(String restaurantLocation);
    3553
    36     public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo, int noSeats);
    37     @Transactional
    38     abstract void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo);
    39     public List<RestaurantsAvailible> getTablesAvailabilityById(Long id);
    40     public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats);
    41     public void deleteTableAvailable(long tableId);
    42     public RestaurantsAvailible findAvailableReservationByID(long availibleId);
    43 
    44     public List<RestaurantsAvailible> getTablesAvailability();
    45     public void createReservation(RestaurantReservations reservations);
    46     public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user);
    47     public void deleteReservation(long restaurantsTableId);
    48     public RestaurantReservations findReservationByID(long tableId);
    49     public List<RestaurantReservations> findReservationByUser(User user);
    50     public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant);
    51     public List<RestaurantReservations> getReservations();
     54    List<RestaurantsTable> searchByNoSeats(int noSeats);
    5255
    5356    List<Reviews> findReviewsByRestaurant(Restaurant restaurant);
    5457
    55     List<RestaurantReservations> findPastReservationsByUser(User u);
     58    List<RestaurantReservations> findPastReservationsByUser(User user);
     59
     60    List<MenuImages> getMenuImages(long menuId);
     61
     62    List<MenuImages> getMenuImagesByRestaurant(Restaurant restaurant);
     63
     64    @Transactional
     65    void addMenuImage(MenuImages menuImages);
     66
     67    Menu findMenuId(Long menuId);
     68
     69    void saveReservation(RestaurantReservations r);
     70
     71//    public void createRestaurant(Restaurant restaurant, long userId);
     72//    public void deleteRestaurant(long restaurantID);
     73//    @Transactional
     74//    public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner);
     75//    public Restaurant findRestaurantByID (long restaurantID);
     76//    public List<Restaurant> searchByRestaurantName(String restaurantName);
     77//    public List<Restaurant> searchByRestaurantLocation(String restaurantLocation);
     78//    public List<Restaurant> getRestaurants();
     79//    @Transactional
     80//    public void addMenuToRestaurant(long restaurantId, Menu menu);
     81//
     82//    public List<RestaurantsAvailible> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats);
     83//
     84//    public void createTable(Restaurant restaurant, int noSeats);
     85//    public void editTable(Restaurant restaurant, long tableId, int noSeats);
     86//    public void deleteTable(long tableId);
     87//    public List<Restaurant> getRestaurantsByUser(long userId);
     88//    public RestaurantsTable findTableById(long tableId);
     89//    public List<RestaurantsTable> searchByNoSeats(int noSeats);
     90//    public List<RestaurantsTable> getRestaurantTables(long restaurantID);
     91//
     92//    public void addRestaurantImage(RestaurantImages restaurantImages);
     93//    public void removeRestaurantImage(long restaurantImageId);
     94//    public RestaurantImages findRestaurantImageById(long restaurantImageId);
     95//    public List<RestaurantImages> getRestaurantImages(long restaurantID);
     96//
     97//    public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo, int noSeats);
     98//    @Transactional
     99//    abstract void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo);
     100//    public List<RestaurantsAvailible> getTablesAvailabilityById(Long id);
     101//    public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats);
     102//    public void deleteTableAvailable(long tableId);
     103//    public RestaurantsAvailible findAvailableReservationByID(long availibleId);
     104//
     105//    public List<RestaurantsAvailible> getTablesAvailability();
     106//    public void createReservation(RestaurantReservations reservations);
     107//    public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user);
     108//    public void deleteReservation(long restaurantsTableId);
     109//    public RestaurantReservations findReservationByID(long tableId);
     110//    public List<RestaurantReservations> findReservationByUser(User user);
     111//    public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant);
     112//    public List<RestaurantReservations> getReservations();
     113//
     114//    List<Reviews> findReviewsByRestaurant(Restaurant restaurant);
     115//
     116//    List<RestaurantReservations> findPastReservationsByUser(User u);
     117//    List<MenuImages> getMenuImages(long menuId);
     118//    public void addMenuImage(MenuImages menuImages);
     119//
     120//    Menu findMenuId(Long menuId);
     121//
     122//    void saveReservation(RestaurantReservations restaurantReservations);
    56123}
  • src/main/java/com/tourMate/dao/ReviewDao.java

    r5528b99 r07f4e8b  
    1010
    1111public interface ReviewDao {
    12 
    1312    @Transactional
    1413    void createReview(Reviews review);
    1514
    16     public void deleteReview(long id);
    17     public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport);
    18     public Reviews findReviewById(long id);
    19     public List<Reviews> getAllReviews();
    20     public List<Reviews> getHotelReviews();
    21     public List<Reviews> getTransportReviews();
    22     public List<Reviews> getRestaurantReviews();
    23     public List<Reviews> getHotelReviews(Hotels hotel);
    24     public List<Reviews> getRestaurantReviews(Restaurant restaurant);
    25     public List<Reviews> getTransportReviews(Transport transport);
     15    void deleteReview(Reviews review);
     16
     17    Reviews findReviewById(long id);
     18
     19    void editReview(Reviews review);
     20
     21    List<Reviews> getAllReviews();
     22
     23    List<Reviews> getHotelReviews();
     24
     25    List<Reviews> getTransportReviews();
     26
     27    List<Reviews> getRestaurantReviews();
     28
     29    List<Reviews> getHotelReviews(Hotels hotel);
     30
     31    List<Reviews> getRestaurantReviews(Restaurant restaurant);
     32
     33    List<Reviews> getTransportReviews(Transport transport);
     34//    @Transactional
     35//    void createReview(Reviews review);
     36//
     37//    public void deleteReview(long id);
     38//    public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport);
     39//    public Reviews findReviewById(long id);
     40//    public List<Reviews> getAllReviews();
     41//    public List<Reviews> getHotelReviews();
     42//    public List<Reviews> getTransportReviews();
     43//    public List<Reviews> getRestaurantReviews();
     44//    public List<Reviews> getHotelReviews(Hotels hotel);
     45//    public List<Reviews> getRestaurantReviews(Restaurant restaurant);
     46//    public List<Reviews> getTransportReviews(Transport transport);
    2647
    2748}
  • src/main/java/com/tourMate/dao/TransportDao.java

    r5528b99 r07f4e8b  
    44import com.tourMate.dto.TransportDto;
    55import com.tourMate.entities.*;
     6import jakarta.transaction.Transactional;
    67
    78
    8 import java.util.Collection;
    99import java.util.Date;
    1010import java.util.List;
    1111
    1212public interface TransportDao {
     13    @Transactional
     14    void createTransport(Transport t);
    1315
    14     public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);
     16    @Transactional
     17    void deleteTransport(Transport t);
    1518
    16     public void deleteTransport(long transportId);
     19    List<Transport> getTransports();
    1720
    18     public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);
     21    List<TransportDto> getTransportsByUser(User u);
    1922
    20     public List<Transport> getTransports();
    21     public List<TransportDto> getTransportsByUser(long userId);
     23    List<RouteListingDto> getRoutesForTransport(Transport t);
    2224
    23     public List<RouteListingDto> getRoutesForTransport(long transportId);
    24     public Transport getTransportById(long transportId);
    25     public TransportDto findTransportById (long transportId);
     25    TransportDto findTransportById(long transportId);
    2626
    27     public void createTransportReservation(TransportReservation transportReservation);
     27    Transport getTransportById(long transportId);
    2828
    29     public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour);
     29    @Transactional
     30    void editTransport(Transport t);
    3031
    31     public void deleteTransportReservation(long reservationID);
     32    @Transactional
     33    void createTransportReservation(TransportReservation transportReservation);
    3234
    33     public TransportReservation findTransportReservationByID(long reservationID);
     35    TransportReservation findTransportReservationByID(long reservationID);
    3436
    35     public List<TransportReservation> getTransportReservations();
     37    List<TransportReservation> getTransportReservations();
    3638
    37     public List<TransportReservation> getTransportsReservationsByUserID(long userID);
     39    TransportAvailible findTransportAvailableByID(long reservationID);
    3840
    39     public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes);
     41    List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date, int numPassengers);
    4042
    41     public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour);
     43    List<TransportReservation> getTransportsReservationsByUserID(long userID);
    4244
    43     public void deleteTransportAvailable(long availableID);
     45    List<TransportAvailible> getTransportsAvailable();
    4446
    45     public TransportAvailible findTransportAvailableByID (long reservationID);
     47    @Transactional
     48    void createTransportAvailable(TransportAvailible ta);
    4649
    47     public List<TransportAvailible> getTransportsAvailable();
     50    void editTransportAvailable(TransportAvailible ta);
    4851
    49     public List<TransportRoute> getTransportsAvailableByFilters (String from,String to,Date date);
    50 
    51     public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order);
    52 
    53     public void deleteTransportRoute(long transportRouteId);
    54 
    55     public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order);
    56 
    57     public TransportRoute findTransportRouteById(long transportRouteId);
     52    TransportRoute findTransportRouteById(long transportRouteId);
    5853
    5954    List<Reviews> getReviewsForTransport(Transport transport);
    6055
    61     List<TransportReservation> findReservationByUser(User u);
     56    List<TransportReservation> findPastReservationByUser(User user);
    6257
    63     List<TransportReservation> findPastReservationByUser(User user);
     58    @Transactional
     59    void saveReservation(TransportReservation transportReservation);
     60
     61    List<TransportReservation> findReservationByUser(User user);
     62
     63    @Transactional
     64    void deleteTransportReservation(TransportReservation tr);
     65
     66    @Transactional
     67    void deleteTransportAvailable(TransportAvailible ta);
     68
     69    void createTransportRoute(TransportRoute tr);
     70
     71    void deleteTransportRoute(TransportRoute tr);
     72
     73    void editTransportRoute(TransportRoute tr);
     74
     75    List<TransportReservation> findTransportReservationByTransportId(Transport t);
     76
     77//    public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate);
     78//
     79//    public void deleteTransport(long transportId);
     80//
     81//    public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);
     82//
     83//    public List<Transport> getTransports();
     84//    public List<TransportDto> getTransportsByUser(long userId);
     85//
     86//    public List<RouteListingDto> getRoutesForTransport(long transportId);
     87//    public Transport getTransportById(long transportId);
     88//    public TransportDto findTransportById (long transportId);
     89//
     90//    public void createTransportReservation(TransportReservation transportReservation);
     91//
     92//    public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour);
     93//
     94//    public void deleteTransportReservation(long reservationID);
     95//
     96//    public TransportReservation findTransportReservationByID(long reservationID);
     97//
     98//    public List<TransportReservation> getTransportReservations();
     99//
     100//    public List<TransportReservation> getTransportsReservationsByUserID(long userID);
     101//
     102//    public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes);
     103//
     104//    public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour);
     105//
     106//    public void deleteTransportAvailable(long availableID);
     107//
     108//    public TransportAvailible findTransportAvailableByID (long reservationID);
     109//
     110//    public List<TransportAvailible> getTransportsAvailable();
     111//
     112//    public List<TransportRoute> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers);
     113//
     114//    public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order);
     115//
     116//    public void deleteTransportRoute(long transportRouteId);
     117//
     118//    public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order);
     119//
     120//    public TransportRoute findTransportRouteById(long transportRouteId);
     121//
     122//    List<Reviews> getReviewsForTransport(Transport transport);
     123//
     124//    List<TransportReservation> findReservationByUser(User u);
     125//
     126//    List<TransportReservation> findPastReservationByUser(User user);
     127//
     128//    void saveReservation(TransportReservation transportReservation);
    64129}
  • src/main/java/com/tourMate/dao/UsersDao.java

    r5528b99 r07f4e8b  
    2323
    2424    UserDetails findUserByUsername(String username);
     25
     26    List<User> getUnapprovedUsers();
     27
     28    void approveUserProfile(User u);
     29
     30    Role findById(Long id);
     31    void updateUser(User s);
    2532}
  • src/main/java/com/tourMate/dao/impl/BusinessDaoImpl.java

    r5528b99 r07f4e8b  
    1919    @Transactional
    2020    @Override
    21     public void createBusiness(Business business, long userId) {
    22         User u = em.find(User.class, userId);
    23         business.setUser(u);
     21    public void createBusiness(Business business) {
    2422        em.persist(business);
    2523    }
    2624
    2725    @Override
    28     public List<Business> getUnapprovedBusinessesOfUser(long userId) {
    29         User u = em.find(User.class, userId);
     26    public List<Business> getUnapprovedBusinessesOfUser(User u) {
    3027        return em.createQuery("SELECT b FROM Business b WHERE b.user = :user").setParameter("user", u).getResultList();
    3128    }
     
    3330    @Transactional
    3431    @Override
    35     public void deleteBusiness(long businessId) {
    36         Business business = findBusinessById(businessId);
     32    public void deleteBusiness(Business business) {
    3733        em.remove(business);
    38 
    3934    }
    4035
    4136    @Override
    42     public boolean hasBusiness(long userId)
     37    public boolean hasBusiness(User u)
    4338    {
    44         User u = em.find(User.class, userId);
    4539        return Integer.parseInt(em.createQuery("SELECT COUNT(b) FROM Business b WHERE b.user = :user").setParameter("user", u).getSingleResult().toString()) > 0;
     40    }
     41
     42    @Override
     43    public List<Business> getUnapprovedBusinesses() {
     44        return em.createQuery("select b from Business b where not b.approved").getResultList();
     45    }
     46
     47    @Override
     48    @Transactional
     49    public void approveBusiness(Business b) {
     50        em.persist(b);
    4651    }
    4752
     
    5762    }
    5863
     64
    5965    @Transactional
    6066    @Override
    61     public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved) {
    62         Business business = findBusinessById(businessId);
    63         business.setName(name);
    64         business.setPhone(phone);
    65         business.setAddress(address);
    66         business.setEdbs(edbs);
    67         business.setUser(user);
    68         business.setApproved(approved);
     67    public void editBusiness(Business business) {
    6968        em.persist(business);
    7069    }
  • src/main/java/com/tourMate/dao/impl/HotelDaoImpl.java

    r5528b99 r07f4e8b  
    88import org.springframework.stereotype.Service;
    99
     10import java.util.Calendar;
    1011import java.util.Date;
    1112import java.util.List;
     
    1920    @Override
    2021    @Transactional
    21     public void createHotel(Hotels hotel, long userId) {
    22         User u = em.find(User.class, userId);
    23         Hotels h = new Hotels(hotel.getHotelName(), hotel.getHotelDescripiton(), hotel.getHotelLocation(), hotel.getHotelEDBS(), hotel.getParking(), hotel.getPetFriendly(), hotel.getInternetAvailable(), u);
    24         em.persist(h);
     22    public void createHotel(Hotels hotel) {
     23        em.persist(hotel);
    2524    }
    2625
    2726    @Override
    2827    public List<Hotels> getHotels() {
    29         List<Hotels> hoteli = em.createQuery("select h from Hotels h order by h.hotelId").getResultList();
    30         System.out.println("OREEEEEEL");
    31         return hoteli;
    32         //return em.createQuery("select h from Hotels h order by h.hotelId").getResultList();
    33     }
    34 
    35     @Override
    36     public List<Hotels> getHotelsForUser(long userId) {
    37         User u = em.find(User.class, userId);
     28        return em.createQuery("select h from Hotels h order by h.hotelId").getResultList();
     29    }
     30
     31    @Override
     32    public List<Hotels> getHotelsForUser(User u) {
    3833        return em.createQuery("select h from Hotels h where h.owner = :u").setParameter("u", u).getResultList();
    3934    }
     
    4641    @Transactional
    4742    @Override
    48     public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable) {
    49         Hotels hotel = findHotelByID(hotelId);
    50         hotel.setHotelName(hotelName);
    51         hotel.setHotelDescripiton(hotelDescripiton);
    52         hotel.setHotelLocation(hotelLocation);
    53         hotel.setHotelEDBS(hotelEDBS);
    54         hotel.setParking(parking);
    55         hotel.setPetFriendly(petFriendly);
    56         hotel.setInternetAvailable(internetAvailable);
     43    public void editHotel(Hotels hotel) {
    5744        em.persist(hotel);
    5845    }
     
    6047    @Transactional
    6148    @Override
    62     public void deleteHotel(long hotelId) {
    63         Hotels h = findHotelByID(hotelId);
    64         em.remove(h);
     49    public void deleteHotel(Hotels hotel) {
     50        em.remove(hotel);
    6551    }
    6652
     
    8975    @Override
    9076    @Transactional
     77    public void  saveReservation(HotelRoomReservations hotelRoomReservations) {
     78        em.persist(hotelRoomReservations);
     79    }
     80
     81    @Override
     82    @Transactional
    9183    public HotelsImages findHotelImageById(long hotelImageId) {
    9284        return em.find(HotelsImages.class, hotelImageId);
     
    9587    @Override
    9688    @Transactional
    97     public void deleteHotelImage(long hotelImageId) {
    98         HotelsImages hotelsImages = findHotelImageById(hotelImageId);
     89    public void deleteHotelImage(HotelsImages hotelsImages) {
    9990        em.remove(hotelsImages);
    10091    }
    10192
    10293    @Override
    103     public List<HotelRoom> getRoomsOfHotel(long hotelId) {
    104         Hotels h = findHotelByID(hotelId);
    105         return em.createQuery("SELECT hr from HotelRoom hr where hr.hotel = :hotel").setParameter("hotel", h).getResultList();
     94    public List<HotelRoom> getRoomsOfHotel(Hotels hotel) {
     95        return em.createQuery("SELECT hr from HotelRoom hr where hr.hotel = :hotel").setParameter("hotel", hotel).getResultList();
    10696    }
    10797
     
    123113    @Transactional
    124114    @Override
    125     public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {
    126         HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price);
     115    public void createRoom(HotelRoom hotelRoom) {
    127116        em.persist(hotelRoom);
    128117    }
     
    130119    @Transactional
    131120    @Override
    132     public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {
    133         HotelRoom hr = findRoomById(hotelRoomId);
    134         hr.setHotel(hotel);
    135         hr.setHotelRoomDescription(hotelRoomDescription);
    136         hr.setHotelRoomName(hotelRoomName);
    137         hr.setKitchenAvailable(kitchenAvailable);
    138         hr.setAirConditioning(airConditioning);
    139         hr.setBalcony(balcony);
    140         hr.setPrice(price);
     121    public void editRoom(HotelRoom hr) {
    141122        em.persist(hr);
    142123    }
     
    144125    @Transactional
    145126    @Override
    146     public void deleteRoom(long hotelRoomId) {
    147         HotelRoom hr = findRoomById(hotelRoomId);
     127    public void deleteRoom(HotelRoom hr) {
    148128        em.remove(hr);
    149129    }
     
    151131    @Transactional
    152132    @Override
    153     public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) {
    154         HotelRoomAvailable hra = new HotelRoomAvailable(hotelRoom, dateFrom, dateTo, numberOfBeds);
     133    public void createRoomAvailible(HotelRoomAvailable hra) {
    155134        em.persist(hra);
    156135    }
     
    158137    @Transactional
    159138    @Override
    160     public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) {
    161         HotelRoomAvailable hr = findAvailibleRoomById(hotelRoomAvailableId);
    162         hr.setHotelRoom(hotelRoom);
    163         hr.setDateFrom(dateFrom);
    164         hr.setDateTo(dateTo);
    165         hr.setNumberOfBeds(numberOfBeds);
     139    public void editRoomAvailible(HotelRoomAvailable hr) {
    166140        em.persist(hr);
    167141    }
     
    169143    @Transactional
    170144    @Override
    171     public void deleteRoomAvailible(long hotelRoomAvailableId) {
    172         HotelRoomAvailable hra = findAvailibleRoomById(hotelRoomAvailableId);
     145    public void deleteRoomAvailible(HotelRoomAvailable hra) {
    173146        em.remove(hra);
    174147    }
     
    190163
    191164    @Override
    192     public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds) {
    193         return em.createQuery("select hr from HotelRoomAvailable hr where hr.dateFrom <= :dateFrom and hr.dateTo >= :dateTo " +
    194 <<<<<<< HEAD
    195                         "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.hotelRoom.numOfBeds >= :numBeds")
    196 =======
    197                 "and hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation and hr.numberOfBeds >= :numBeds")
    198 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    199                 .setParameter("hotelLocation", hotelLocation)
    200                 .setParameter("dateFrom", dateFrom)
    201                 .setParameter("dateTo", dateTo)
    202                 .setParameter("numBeds", numberOfBeds)
    203                 .getResultList();
    204     }
    205 
    206     @Override
    207     @Transactional
    208     public void createReservation(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds) {
    209         HotelRoomReservations r = new HotelRoomReservations(user, hotelRoom, dateFrom, dateTo, numberOfBeds);
     165    public List<HotelRoomAvailable> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible) {
     166        if(flexible)
     167        {
     168            Calendar calendar = Calendar.getInstance();
     169            Calendar calendar1 = Calendar.getInstance();
     170            calendar.setTime(dateTo);
     171            calendar1.setTime(dateFrom);
     172            return em.createQuery("SELECT hr FROM HotelRoomAvailable hr WHERE " +
     173                            "((hr.dateFrom <= :dateTo AND hr.dateTo >= :dateFrom) OR " +
     174                            "(hr.dateFrom <= :dateToMinus1 AND hr.dateTo >= :dateFromMinus1) OR " +
     175                            "(hr.dateFrom <= :dateToMinus2 AND hr.dateTo >= :dateFromMinus2) OR " +
     176                            "(hr.dateFrom <= :dateToMinus3 AND hr.dateTo >= :dateFromMinus3) OR " +
     177                            "(hr.dateFrom <= :dateToPlus1 AND hr.dateTo >= :dateFromPlus1) OR " +
     178                            "(hr.dateFrom <= :dateToPlus2 AND hr.dateTo >= :dateFromPlus2) OR " +
     179                            "(hr.dateFrom <= :dateToPlus3 AND hr.dateTo >= :dateFromPlus3)) " +
     180                            "AND hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation " +
     181                            "AND hr.hotelRoom.numOfBeds >= :numBeds")
     182                    .setParameter("hotelLocation", hotelLocation)
     183                    .setParameter("dateFrom", dateFrom)
     184                    .setParameter("dateTo", dateTo)
     185                    .setParameter("dateToMinus1", subtractDays(calendar, 1))
     186                    .setParameter("dateToMinus2", subtractDays(calendar, 2))
     187                    .setParameter("dateToMinus3", subtractDays(calendar, 3))
     188                    .setParameter("dateToPlus1", addDays(calendar, 1))
     189                    .setParameter("dateToPlus2", addDays(calendar, 2))
     190                    .setParameter("dateToPlus3", addDays(calendar, 3))
     191                    .setParameter("dateFromMinus1", subtractDays(calendar1, 1))
     192                    .setParameter("dateFromMinus2", subtractDays(calendar1, 2))
     193                    .setParameter("dateFromMinus3", subtractDays(calendar1, 3))
     194                    .setParameter("dateFromPlus1", addDays(calendar1, 1))
     195                    .setParameter("dateFromPlus2", addDays(calendar1, 2))
     196                    .setParameter("dateFromPlus3", addDays(calendar1, 3))
     197                    .setParameter("numBeds", numberOfBeds)
     198                    .getResultList();
     199        }
     200        else
     201        {
     202            return em.createQuery("SELECT hr FROM HotelRoomAvailable hr WHERE " +
     203                            "((hr.dateFrom <= :dateTo AND hr.dateTo >= :dateFrom)) " +
     204                            "AND hr.hotelRoom.hotel.hotelLocation LIKE :hotelLocation " +
     205                            "AND hr.hotelRoom.numOfBeds >= :numBeds")
     206                    .setParameter("hotelLocation", hotelLocation)
     207                    .setParameter("dateFrom", dateFrom)
     208                    .setParameter("dateTo", dateTo)
     209                    .setParameter("numBeds", numberOfBeds)
     210                    .getResultList();
     211        }
     212
     213
     214
     215
     216    }
     217
     218    private Date addDays(Calendar calendar, int days) {
     219        Calendar newCalendar = (Calendar) calendar.clone();
     220        newCalendar.add(Calendar.DAY_OF_MONTH, days);
     221        return newCalendar.getTime();
     222    }
     223
     224    private Date subtractDays(Calendar calendar, int days) {
     225        Calendar newCalendar = (Calendar) calendar.clone();
     226        newCalendar.add(Calendar.DAY_OF_MONTH, -days);
     227        return newCalendar.getTime();
     228    }
     229
     230    @Override
     231    @Transactional
     232    public void createReservation(HotelRoomReservations  r) {
    210233        em.persist(r);
    211234    }
     
    213236    @Override
    214237    @Transactional
    215     public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds) {
    216         HotelRoomReservations hr = findReservationById(hotelRoomReservedId);
    217         hr.setUser(user);
    218         hr.setHotelRoom(hotelRoom);
    219         hr.setDateFrom(dateFrom);
    220         hr.setDateTo(dateTo);
    221         hr.setNumberOfBeds(numberOfBeds);
     238    public void editReservation(HotelRoomReservations hr) {
    222239        em.persist(hr);
    223 
    224     }
    225 
    226     @Transactional
    227     @Override
    228     public void deleteReservation(long hotelRoomReservedId) {
    229         HotelRoomReservations r = findReservationById(hotelRoomReservedId);
    230         em.remove(hotelRoomReservedId);
     240    }
     241
     242    @Transactional
     243    @Override
     244    public void deleteReservation(HotelRoomReservations hr) {
     245
     246        em.remove(hr);
    231247    }
    232248
     
    244260    @Override
    245261    public List<HotelRoomReservations> findReservationByHotel(Hotels hotel) {
    246         List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel.getHotelId());
    247         return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom in :hotelRooms").setParameter("hotelRooms", hotelRooms).getResultList();
     262        List<HotelRoom> hotelRooms = getRoomsOfHotel(hotel);
     263        return em.createQuery("select hr from HotelRoomReservations hr where hr.hotelRoom.hotel = :hotel").setParameter("hotel", hotel).getResultList();
    248264    }
    249265
  • src/main/java/com/tourMate/dao/impl/MenuDaoImpl.java

    r5528b99 r07f4e8b  
    1818    @Transactional
    1919    @Override
    20     public void createMenu(String name, String ingredients, double price) {
    21         Menu menu = new Menu(name, ingredients, price);
     20    public void createMenu(Menu menu) {
    2221        em.persist(menu);
    2322    }
     
    2524    @Transactional
    2625    @Override
    27     public void deleteMenu(long menuId) {
    28         Menu menu = findMenuById(menuId);
     26    public void deleteMenu(Menu menu) {
    2927        em.remove(menu);
    3028    }
     
    4240    @Transactional
    4341    @Override
    44     public void editMenu(long menuId, String name, String ingredients, double price) {
    45         Menu menu = findMenuById(menuId);
    46         menu.setName(name);
    47         menu.setIngredients(ingredients);
    48         menu.setPrice(price);
     42    public void editMenu(Menu menu) {
     43
    4944        em.persist(menu);
    5045    }
  • src/main/java/com/tourMate/dao/impl/RestaurantDaoImpl.java

    r5528b99 r07f4e8b  
    1818    @Override
    1919    @Transactional
    20     public void createRestaurant(Restaurant restaurant, long userId) {
    21         User u = em.find(User.class, userId);
    22         Restaurant r = new Restaurant(restaurant.getRestaurantName(), restaurant.getRestaurantLocation(), restaurant.getCousineType(), restaurant.getRestaurantDescription(), restaurant.getRestaurantEdbs(), u);
    23         em.persist(r);
     20    public void createRestaurant(Restaurant restaurant) {
     21        em.persist(restaurant);
    2422    }
    2523
     
    4341    @Transactional
    4442    @Override
    45     public void removeRestaurantImage(long restaurantImageId){
    46         RestaurantImages restaurantImage = findRestaurantImageById(restaurantImageId);
    47         em.remove(restaurantImage);
     43    public void removeRestaurantImage(RestaurantImages image){
     44        em.remove(image);
    4845    }
    4946
     
    5552
    5653    @Override
    57     public void deleteRestaurant(long restaurantID) {
    58         Restaurant r = findRestaurantByID(restaurantID);
     54    public void deleteRestaurant(Restaurant r) {
    5955        em.remove(r);
    6056    }
     
    6763    @Override
    6864    @Transactional
    69     public void addMenuToRestaurant(long restaurantId, Menu menu) {
    70         Restaurant r = findRestaurantByID(restaurantId);
    71         menu.setRestaurant(r);
     65    public void addMenuToRestaurant(Menu menu) {
    7266        em.persist(menu);
    7367    }
     
    8478
    8579    @Override
    86     @Transactional
    87     public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner) {
    88         Restaurant res = findRestaurantByID(restaurantID);
    89         res.setRestaurantName(restaurantName);
    90         res.setRestaurantLocation(restaurantLocation);
    91         res.setRestaurantEdbs(restaurantEdbs);
    92         res.setRestaurantDescription(restaurantDescription);
    93         res.setRestaurantOwner(restaurantOwner);
    94         res.setCousineType(cousineType);
    95         em.persist(res);
    96     }
    97 
    98     @Override
    9980    public List<RestaurantsTable> getRestaurantTables(long restaurantID) {
    100         List<RestaurantsTable> restaurantsTables = getRestaurantTables(restaurantID);
    101         return restaurantsTables;
     81        return em.createQuery("select rt from RestaurantsTable rt where rt.restaurant.restaurantID = :restaurantId").setParameter("restaurantId", restaurantID).getResultList();
    10282    }
    10383
     
    10989    @Override
    11090    @Transactional
    111     public void createTable(Restaurant restaurant, int noSeats) {
    112         RestaurantsTable resTable = new RestaurantsTable(restaurant, noSeats);
     91    public void saveTable(RestaurantsTable resTable) {
    11392        em.persist(resTable);
    11493    }
    11594
    116     @Override
    117     @Transactional
    118     public void editTable(Restaurant restaurant, long tableId, int noSeats) {
    119         RestaurantsTable resTable = findTableById(tableId);
    120         resTable.setRestaurant(restaurant);
    121         resTable.setNoSeats(noSeats);
    122         em.persist(resTable);
    123     }
    124 
    125     @Override
    126     @Transactional
    127     public void deleteTable(long tableId) {
    128         RestaurantsTable rt  = findTableById(tableId);
     95
     96    @Override
     97    @Transactional
     98    public void deleteTable(RestaurantsTable rt) {
    12999        em.persist(rt);
    130100    }
    131101
    132102    @Override
    133     public List<Restaurant> getRestaurantsByUser(long userId) {
    134         User u = em.find(User.class, userId);
     103    public List<Restaurant> getRestaurantsByUser(User u) {
    135104        return em.createQuery("select r from Restaurant r where r.restaurantOwner = :u").setParameter("u", u).getResultList();
    136     }
    137 
    138     @Override
    139     @Transactional
    140     public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo, int noSeats) {
    141         RestaurantsAvailible ra = new RestaurantsAvailible(restaurantsTable, hourFrom, hourTo, noSeats);
    142         em.persist(ra);
    143105    }
    144106
     
    151113    @Override
    152114    @Transactional
    153     public void createTableAvailable(RestaurantsTable restaurantsTable, Date hourFrom, Date hourTo){
    154         RestaurantsAvailible rta = new RestaurantsAvailible(restaurantsTable, hourFrom, hourTo);
    155         em.persist(rta);
    156     }
    157 
    158     @Override
    159     @Transactional
    160     public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats) {
    161         RestaurantsTable rt = findTableById(tableId);
    162         rt.setRestaurant(restaurant);
    163         rt.setNoSeats(noSeats);
    164         em.persist(rt);
    165     }
    166 
    167     @Override
    168     @Transactional
    169     public void deleteTableAvailable(long tableId) {
    170         RestaurantsAvailible ra = findAvailableReservationByID(tableId);
     115    public void saveTableAvailable(RestaurantsAvailible ra){
     116        em.persist(ra);
     117    }
     118
     119    @Override
     120    @Transactional
     121    public void deleteTableAvailable(RestaurantsAvailible ra) {
    171122        em.remove(ra);
    172123    }
     
    183134    }
    184135
    185     @Override
    186     @Transactional
    187     public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user) {
    188         RestaurantReservations r = findReservationByID(restaurantsTableId);
    189         r.setTable(rt);
    190         r.setTimeFrom(hourFrom);
    191         r.setTimeTo(hourTo);
    192         r.setNoSeats(noSeats);
    193         r.setUser(user);
    194         em.persist(r);
    195     }
    196 
    197     @Override
    198     @Transactional
    199     public void deleteReservation(long restaurantsTableId) {
    200         RestaurantReservations r = findReservationByID(restaurantsTableId);
     136
     137    @Override
     138    @Transactional
     139    public void deleteReservation(RestaurantReservations r) {
    201140        em.remove(r);
    202141    }
     
    259198
    260199    }
     200
     201    @Override
     202    public List<MenuImages> getMenuImages(long menuId) {
     203        return em.createQuery("select ri from MenuImages ri where ri.menu.id = :menuId").setParameter("menuId", menuId).getResultList();
     204    }
     205
     206    @Override
     207    public List<MenuImages> getMenuImagesByRestaurant(Restaurant resta) {
     208        return em.createQuery("select mi from MenuImages mi where mi.menu.restaurant = :restaurant")
     209                .setParameter("restaurant", resta)
     210                .getResultList();
     211    }
     212
     213    @Transactional
     214    @Override
     215    public void addMenuImage(MenuImages menuImages) {
     216        em.persist(menuImages);
     217    }
     218
     219    @Override
     220    public Menu findMenuId(Long menuId) {
     221        return em.find(Menu.class, menuId);
     222    }
     223
     224    @Override
     225    @Transactional
     226    public void saveReservation(RestaurantReservations restaurantReservations) {
     227        em.persist(restaurantReservations);
     228    }
    261229}
  • src/main/java/com/tourMate/dao/impl/ReviewDaoImpl.java

    r5528b99 r07f4e8b  
    2525
    2626    @Override
    27     public void deleteReview(long id) {
    28         Reviews review = findReviewById(id);
     27    public void deleteReview(Reviews review) {
    2928        em.remove(review);
    3029    }
     
    3635
    3736    @Override
    38     public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport) {
    39         Reviews review = findReviewById(id);
    40         review.setDescription(description);
    41         review.setHotel(hotel);
    42         review.setRestaurant(restaurant);
    43         review.setTitle(title);
    44         review.setNumStar(numStar);
    45         review.setTransport(transport);
     37    public void editReview(Reviews review) {
    4638        em.persist(review);
    4739    }
  • src/main/java/com/tourMate/dao/impl/TransportDaoImpl.java

    r5528b99 r07f4e8b  
    1010import org.springframework.stereotype.Service;
    1111
    12 import java.util.Collection;
    1312import java.util.Date;
    1413import java.util.List;
     
    2221    @Override
    2322    @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);
    26         Transport t=new Transport(transportName,carBrand,carType,carManufacturedYear,noPassengers,noBags,EMBG,u,carPlate);
     23    public void createTransport(Transport t) {
    2724        em.persist(t);
    2825    }
     
    3027    @Override
    3128    @Transactional
    32     public void deleteTransport(long transportId) {
    33         Transport t=getTransportById(transportId);
     29    public void deleteTransport(Transport t) {
    3430        em.remove(t);
    3531    }
     
    4137
    4238    @Override
    43     public List<TransportDto> getTransportsByUser(long userId) {
    44         User u = em.find(User.class, userId);
     39    public List<TransportDto> getTransportsByUser(User u) {
    4540        List<Transport> transports = em.createQuery("select t from Transport t where t.owner = :u").setParameter("u", u).getResultList();
    4641        return transports.stream().map(x -> new TransportDto(
     
    6257                        y.getFreeSpace(),
    6358                        y.getTime(),
    64                         y.getRoutes()
    65                 )).toList()
     59                        y.getRoutes(),
     60                        y.getRoutes().stream()
     61                                .mapToDouble(TransportRoute::getPrice)
     62                                .max().orElse(0)
     63                )).toList(),
     64                x.getAvailableRoutes().stream()
     65                        .flatMapToDouble(y -> y.getRoutes()
     66                                .stream()
     67                                .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0)
    6668        )).toList();
    6769    }
    6870
    6971    @Override
    70     public List<RouteListingDto> getRoutesForTransport(long transportId) {
    71         Transport t = em.find(Transport.class, transportId);
     72    public List<RouteListingDto> getRoutesForTransport(Transport t) {
    7273        List<TransportAvailible> transportsAvailible = em.createQuery("select ta from TransportAvailible ta where ta.transport = :transport").setParameter("transport", t).getResultList();
    7374        return transportsAvailible.stream().map(x -> new RouteListingDto(
     
    7879                x.getFreeSpace(),
    7980                x.getTime(),
    80                 x.getRoutes()
     81                x.getRoutes(),
     82                x.getRoutes().stream()
     83                        .mapToDouble(TransportRoute::getPrice)
     84                        .max().orElse(0)
    8185        )).toList();
    8286    }
     
    103107                        y.getFreeSpace(),
    104108                        y.getTime(),
    105                         y.getRoutes()
    106                 )).toList());
    107     }
    108 
     109                        y.getRoutes(),
     110                        y.getRoutes().stream()
     111                                .mapToDouble(TransportRoute::getPrice)
     112                                .max().orElse(0)
     113                )).toList(),
     114                x.getAvailableRoutes().stream()
     115                        .flatMapToDouble(y -> y.getRoutes()
     116                                                        .stream()
     117                                                        .mapToDouble(TransportRoute::getPrice)).max().orElseGet(() -> 0));
     118    }
     119
     120    @Override
    109121    public Transport getTransportById(long transportId)
    110122    {
     
    114126    @Override
    115127    @Transactional
    116     public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) {
    117         Transport t=getTransportById(transportID);
    118         t.setTransportName(transportName);
    119         t.setCarBrand(carBrand);
    120         t.setCarType(carType);
    121         t.setCarManufacturedYear(carManufacturedYear);
    122         t.setNoPassengers(noPassengers);
    123         t.setNoBags(noBags);
    124         t.setEMBG(EMBG);
    125         t.setOwner(owner);
    126         t.setCarPlate(carPlate);
     128    public void editTransport(Transport t) {
    127129        em.persist(t);
    128130    }
     
    150152
    151153    @Override
    152     public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date) {
     154    public List<TransportRoute> getTransportsAvailableByFilters(String fromL, String toL, Date date, int numPassengers) {
    153155        System.out.println(fromL + " " + toL);
    154         return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol").setParameter("froml", fromL).
    155                 setParameter("tol", toL).getResultList();
     156        return em.createQuery("select h from TransportRoute h where h.from = :froml and h.to = :tol and h.freeSpace >= :nump")
     157                .setParameter("froml", fromL)
     158                .setParameter("tol", toL)
     159                .setParameter("nump", numPassengers)
     160                .getResultList();
    156161    }
    157162
     
    168173    @Override
    169174    @Transactional
    170     public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes) {
    171         TransportAvailible ta=new TransportAvailible(transport,departureLocation,arrivalLocation,date,noSeats,departureHour);
     175    public void createTransportAvailable(TransportAvailible ta) {
    172176        em.persist(ta);
    173         List<TransportRoute> routes1 = routes.stream().toList();
    174         routes.forEach(x -> {
    175             createTransportRoute(ta, x.getFrom(), x.getTo(), x.getPrice(), x.getDeparture(), x.getArrival(), x.getFreeSpace(), x.getOrder());
    176         });
    177     }
    178 
    179     @Override
    180     @Transactional
    181     public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour)
    182     {
    183 //        TransportReservation tr=findTransportReservationByID(reservationID);
    184 //        tr.setTransport(transport);
    185 //        tr.setDepartureLocation(departureLocation);
    186 //        tr.setArrivalLocation(arrivalLocation);
    187 //        tr.setDate(date);
    188 //        tr.setNoSeats(noSeats);
    189 //        tr.setUser(user);
    190 //        tr.setDepartureHour(departureHour);
    191 //        em.persist(tr);
    192     }
    193 
    194     @Override
    195     public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour) {
    196         TransportAvailible ta=findTransportAvailableByID(availableID);
    197         ta.setTransport(transport);
    198         ta.setFrom(departureLocation);
    199         ta.setTo(arrivalLocation);
    200         ta.setDate(date);
    201         ta.setFreeSpace(noSeats);
    202         ta.setTime(departureHour);
     177
     178    }
     179
     180    @Override
     181    public void editTransportAvailable(TransportAvailible ta) {
    203182        em.persist(ta);
    204183    }
     
    224203    }
    225204
     205    @Transactional
     206    @Override
     207    public void saveReservation(TransportReservation transportReservation) {
     208        em.persist(transportReservation);
     209    }
     210
    226211    @Override
    227212    public List<TransportReservation> findReservationByUser(User user) {
     
    235220    @Override
    236221    @Transactional
    237     public void deleteTransportReservation(long reservationID) {
    238         TransportReservation tr=findTransportReservationByID(reservationID);
     222    public void deleteTransportReservation(TransportReservation tr) {
    239223        em.remove(tr);
    240224    }
     
    242226    @Override
    243227    @Transactional
    244     public void deleteTransportAvailable(long availableID) {
    245         TransportAvailible ta=findTransportAvailableByID(availableID);
     228    public void deleteTransportAvailable(TransportAvailible ta) {
    246229        em.remove(ta);
    247230    }
    248231
    249232    @Override
    250     public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) {
    251         TransportRoute tr = new TransportRoute(parentRoute, from, to, price, departure, arrival, freeSpace, order);
     233    @Transactional
     234    public void createTransportRoute(TransportRoute tr) {
    252235        em.persist(tr);
    253236    }
    254237
    255238    @Override
    256     public void deleteTransportRoute(long transportRouteId) {
    257         TransportRoute tr = findTransportRouteById(transportRouteId);
     239    public void deleteTransportRoute(TransportRoute tr) {
    258240        em.remove(tr);
    259241    }
    260242
    261243    @Override
    262     public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) {
    263         TransportRoute tr = findTransportRouteById(transportRouteId);
    264         tr.setParentRoute(parentRoute);
    265         tr.setFrom(from);
    266         tr.setTo(to);
    267         tr.setPrice(price);
    268         tr.setDeparture(departure);
    269         tr.setArrival(arrival);
    270         tr.setFreeSpace(freeSpace);
    271         tr.setOrder(order);
     244    public void editTransportRoute(TransportRoute tr) {
    272245        em.persist(tr);
    273246
    274247    }
    275248
     249    @Override
     250    public List<TransportReservation> findTransportReservationByTransportId(Transport t) {
     251        return em.createQuery("SELECT tr from TransportReservation tr where tr.transportRoute.parentRoute.transport= :transport")
     252                .setParameter("transport", t)
     253                .getResultList();
     254    }
     255
    276256
    277257}
  • src/main/java/com/tourMate/dao/impl/UsersDaoImpl.java

    r5528b99 r07f4e8b  
    2828    @Override
    2929    public void createUser(String name, String surname, String email, Date birthDate, String address, String contact) {
    30         Role r = em.find(Role.class, 1);
     30        Role r = em.find(Role.class, 2);
    3131        User user = new User(name, surname, email, passwordEncoder.encode("password"), birthDate, address, contact, r);
    3232        em.persist(user);
     
    7474    }
    7575
     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    }
     87
     88    @Override
     89    public Role findById(Long id) {
     90        return em.find(Role.class, id);
     91    }
     92
     93    @Override
     94    @Transactional
     95    public void updateUser(User s) {
     96        em.persist(s);
     97    }
    7698
    7799
  • src/main/java/com/tourMate/dto/HotelReservationUserDto.java

    r5528b99 r07f4e8b  
    77
    88public class HotelReservationUserDto {
     9    private Long reservationId;
    910    private User user;
    1011    private HotelRoom hotelRoom;
     
    2021    private Boolean reviewed;
    2122
    22     public HotelReservationUserDto(User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numBeds, String hotelName, String hotelLocation, String hotelAddress, Long hotelId, Boolean reviewed) {
     23    public HotelReservationUserDto(Long reservationId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numBeds, String hotelName, String hotelLocation, String hotelAddress, Long hotelId, Boolean reviewed) {
     24        this.reservationId = reservationId;
    2325        this.user = user;
    2426        this.hotelRoom = hotelRoom;
     
    3133        this.hotelId = hotelId;
    3234        this.reviewed = reviewed;
     35    }
     36
     37    public Long getReservationId() {
     38        return reservationId;
    3339    }
    3440
  • src/main/java/com/tourMate/dto/RestaurantDto.java

    r5528b99 r07f4e8b  
    55import java.util.ArrayList;
    66import java.util.Collection;
     7import java.util.List;
    78
    89public class RestaurantDto {
     
    1415    private String restaurantEdbs;
    1516    private Collection<Menu> menus = new ArrayList<Menu>();
     17    private Collection<MenuImages> menuImages;
    1618    private Collection<RestaurantsAvailible> tables;
    1719    private Collection<Reviews> reviews;
    1820    private double averageScore;
    1921    private Collection<RestaurantImages> images;
    20     public RestaurantDto(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, Collection<Menu> menus, Collection<RestaurantsAvailible> tables, Collection<Reviews> reviews, double averageScore, Collection<RestaurantImages> images) {
     22
     23    public RestaurantDto(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, Collection<Menu> menus, Collection<RestaurantsAvailible> tables, Collection<Reviews> reviews, double averageScore, Collection<RestaurantImages> images, Collection<MenuImages> menuImages) {
    2124        this.restaurantID = restaurantID;
    2225        this.restaurantName = restaurantName;
     
    3033        this.averageScore = averageScore;
    3134        this.images = images;
     35        this.menuImages = menuImages;
     36    }
     37    public Collection<MenuImages> getMenuImages() {
     38        return menuImages;
    3239    }
    3340
     
    119126        this.images = images;
    120127    }
     128
    121129}
  • src/main/java/com/tourMate/dto/RestaurantReservationUserDto.java

    r5528b99 r07f4e8b  
    88
    99public class RestaurantReservationUserDto {
     10    private Long reservationId;
    1011    private User user;
    1112    private RestaurantsTable restaurantsTable;
     
    2122    private Boolean reviewed;
    2223
    23     public RestaurantReservationUserDto(User user, RestaurantsTable restaurantsTable, Date dateFrom, Date dateTo, Integer numPeople, String restaurantName, String restaurantLocation, String restaurantAddress, Long restaurantId, Boolean reviewed) {
     24    public RestaurantReservationUserDto(Long reservationId, User user, RestaurantsTable restaurantsTable, Date dateFrom, Date dateTo, Integer numPeople, String restaurantName, String restaurantLocation, String restaurantAddress, Long restaurantId, Boolean reviewed) {
     25        this.reservationId = reservationId;
    2426        this.user = user;
    2527        this.restaurantsTable = restaurantsTable;
     
    3234        this.restaurantId = restaurantId;
    3335        this.reviewed = reviewed;
     36    }
     37
     38    public Long getReservationId() {
     39        return reservationId;
    3440    }
    3541
  • src/main/java/com/tourMate/dto/RouteListingDto.java

    r5528b99 r07f4e8b  
    1818    private Date time;
    1919    private Collection<String> routes;
     20    private Double maxPrice;
    2021
    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) {
    2223        this.transportAvailibleId = transportAvailibleId;
    2324        this.from = from;
     
    2728        this.time = time;
    2829        this.routes = routes.stream().map(x -> x.getFrom()).distinct().skip(1).toList();
     30        this.maxPrice = maxPrice;
    2931    }
    3032
     
    8486        this.routes = routes;
    8587    }
     88
     89    public Double getMaxPrice() {
     90        return maxPrice;
     91    }
    8692}
  • src/main/java/com/tourMate/dto/TransportDto.java

    r5528b99 r07f4e8b  
    1616    private User owner;
    1717    private String carPlate;
     18    private Double maxPrice;
    1819    private Collection<RouteListingDto> availableRoutes;
    1920
    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) {
    2122        this.transportID = transportID;
    2223        this.transportName = transportName;
     
    3031        this.carPlate = carPlate;
    3132        this.availableRoutes = availableRoutes;
     33        this.maxPrice = maxPrice;
    3234    }
    3335
  • src/main/java/com/tourMate/dto/TransportReservationUserDto.java

    r5528b99 r07f4e8b  
    1010
    1111public class TransportReservationUserDto {
     12    private Long reservationId;
    1213    private User user;
    1314    private TransportRoute transportRoute;
     
    1920    private Boolean reviewed;
    2021
    21     public TransportReservationUserDto(User user, TransportRoute transportRoute, Long transportId, Integer numPeople, String carBrand, String carType, User owner, Boolean reviewed) {
     22    public TransportReservationUserDto(Long reservationId, User user, TransportRoute transportRoute, Long transportId, Integer numPeople, String carBrand, String carType, User owner, Boolean reviewed) {
     23        this.reservationId = reservationId;
    2224        this.user = user;
    2325        this.transportRoute = transportRoute;
     
    2830        this.owner = owner;
    2931        this.reviewed = reviewed;
     32    }
     33    public Long getReservationId() {
     34        return reservationId;
    3035    }
    3136
  • src/main/java/com/tourMate/entities/Business.java

    r5528b99 r07f4e8b  
    8888    }
    8989
    90     @OneToOne(fetch = FetchType.LAZY)
     90    @OneToOne(fetch = FetchType.EAGER)
    9191    @JoinColumn(name = "owner_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_biznis_kon_korisnik"))
    9292    public User getUser() {
     
    107107        this.approved = approved;
    108108    }
     109
    109110}
  • src/main/java/com/tourMate/entities/HotelRoom.java

    r5528b99 r07f4e8b  
    1 <<<<<<< HEAD
    21package com.tourMate.entities;
    32
     
    160159    }
    161160}
    162 =======
    163 package com.tourMate.entities;
    164 
    165 import jakarta.persistence.*;
    166 import com.fasterxml.jackson.annotation.JsonIgnore;
    167 
    168 import javax.validation.constraints.NotNull;
    169 
    170 @Entity
    171 @Table(name="hotel_rooms", schema = "public")
    172 public class HotelRoom {
    173     private long hotelRoomId;
    174     @JsonIgnore
    175     private Hotels hotel;
    176     private String hotelRoomDescription;
    177     @Enumerated(EnumType.STRING)
    178     private String hotelRoomName;
    179     private double price;
    180     private Boolean kitchenAvailable;
    181     private Boolean airConditioning;
    182     private Boolean balcony;
    183 
    184     public HotelRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, double price, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony) {
    185         this.hotelRoomId = hotelRoomId;
    186         this.hotel = hotel;
    187         this.hotelRoomDescription = hotelRoomDescription;
    188         this.hotelRoomName = hotelRoomName;
    189         this.price = price;
    190         this.kitchenAvailable = kitchenAvailable;
    191         this.airConditioning = airConditioning;
    192         this.balcony = balcony;
    193     }
    194 
    195     public HotelRoom(Hotels hotel, String hotelRoomDescription, String type,
    196                      Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {
    197         this.hotel = hotel;
    198         this.hotelRoomDescription = hotelRoomDescription;
    199         this.hotelRoomName = type;
    200         this.kitchenAvailable = kitchenAvailable;
    201         this.airConditioning = airConditioning;
    202         this.balcony = balcony;
    203         this.price = price;
    204     }
    205 
    206     public HotelRoom(String hotelRoomDescription, String type,
    207                      Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {
    208         this.hotel = hotel;
    209         this.hotelRoomDescription = hotelRoomDescription;
    210         this.hotelRoomName = type;
    211         this.kitchenAvailable = kitchenAvailable;
    212         this.airConditioning = airConditioning;
    213         this.balcony = balcony;
    214         this.price = price;
    215     }
    216 
    217     public HotelRoom() {
    218 
    219     }
    220 
    221     @Id
    222     @GeneratedValue(strategy = GenerationType.IDENTITY)
    223     @Column(name = "room_id",unique = true,nullable = false)
    224     public long getHotelRoomId() {
    225         return hotelRoomId;
    226     }
    227 
    228     public void setHotelRoomId(long hotelRoomId) {
    229         this.hotelRoomId = hotelRoomId;
    230     }
    231 
    232     @ManyToOne(fetch = FetchType.LAZY)
    233     @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_room_kon_hotel"))
    234     public Hotels getHotel() {
    235         return hotel;
    236     }
    237 
    238     public void setHotel(Hotels hotelId) {
    239         this.hotel = hotelId;
    240     }
    241 
    242     @Column(name="hotel_room_description",unique = false,nullable = false)
    243     @NotNull
    244     public String getHotelRoomDescription() {
    245         return hotelRoomDescription;
    246     }
    247 
    248     public void setHotelRoomDescription(String hotelRoomDescription) {
    249         this.hotelRoomDescription = hotelRoomDescription;
    250     }
    251 
    252     @Column(name="hotel_room_price",unique = false,nullable = false)
    253     @NotNull
    254     public double getPrice() {
    255         return price;
    256     }
    257 
    258     @Column(name="hotel_room_name",unique = false,nullable = false)
    259     @NotNull
    260     public String getHotelRoomName() {
    261         return hotelRoomName;
    262     }
    263 
    264 
    265     public void setHotelRoomName(String name) {
    266         this.hotelRoomName = name;
    267     }
    268     public void setPrice(double type) {
    269         this.price = type;
    270     }
    271     @Column(name="hotel_room_kitchen",unique = false,nullable = false)
    272     @NotNull
    273     public Boolean getKitchenAvailable() {
    274         return kitchenAvailable;
    275     }
    276 
    277     public void setKitchenAvailable(Boolean kitchenAvailable) {
    278         this.kitchenAvailable = kitchenAvailable;
    279     }
    280     @Column(name="hotel_room_ac",unique = false,nullable = false)
    281     @NotNull
    282     public Boolean getAirConditioning() {
    283         return airConditioning;
    284     }
    285 
    286     public void setAirConditioning(Boolean airConditioning) {
    287         this.airConditioning = airConditioning;
    288     }
    289     @Column(name="hotel_room_balcony",unique = false,nullable = false)
    290     @NotNull
    291     public Boolean getBalcony() {
    292         return balcony;
    293     }
    294 
    295     public void setBalcony(Boolean balcony) {
    296         this.balcony = balcony;
    297     }
    298 }
    299 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
  • src/main/java/com/tourMate/entities/HotelRoomReservations.java

    r5528b99 r07f4e8b  
    4343    }
    4444
    45     @ManyToOne(fetch = FetchType.LAZY)
     45    @ManyToOne(fetch = FetchType.EAGER)
    4646    @JoinColumn(name = "room_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_room"))
    4747    public HotelRoom getHotelRoom() {
     
    5959    }
    6060
    61     @OneToOne(fetch = FetchType.LAZY)
     61    @OneToOne(fetch = FetchType.EAGER)
    6262    @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_roomres_kon_user"))
    6363    public User getUser() {
  • src/main/java/com/tourMate/entities/RestaurantImages.java

    r5528b99 r07f4e8b  
    3131    }
    3232
    33     @ManyToOne(fetch = FetchType.LAZY)
     33    @ManyToOne(fetch = FetchType.EAGER)
    3434    @JoinColumn(name="restaurant_id",unique = false,nullable = false,foreignKey = @ForeignKey(name = "fk_ref_od_restimg_kon_restoran"))
    3535    public Restaurant getRestaurant() {
  • src/main/java/com/tourMate/entities/RestaurantReservations.java

    r5528b99 r07f4e8b  
    8282    }
    8383
    84     @ManyToOne(fetch = FetchType.LAZY)
     84    @ManyToOne(fetch = FetchType.EAGER)
    8585    @JoinColumn(name = "user_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_rezervacija_restoran_kon_korisnik"))
    8686    public User getUser() {
  • src/main/java/com/tourMate/entities/Reviews.java

    r5528b99 r07f4e8b  
    7575
    7676    @ManyToOne(fetch = FetchType.LAZY)
    77     @JoinColumn(name = "hotel_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))
     77    @JoinColumn(name = "hotel_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_hotel"))
    7878    public Hotels getHotel () {
    7979        return hotel;
     
    8585
    8686    @ManyToOne(fetch = FetchType.LAZY)
    87     @JoinColumn(name = "restaurant_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))
     87    @JoinColumn(name = "restaurant_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_restorani"))
    8888    public Restaurant getRestaurant () {
    8989        return restaurant;
     
    9595
    9696    @ManyToOne(fetch = FetchType.LAZY)
    97     @JoinColumn(name = "transport_id", unique = false, nullable = false, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))
     97    @JoinColumn(name = "transport_id", unique = false, nullable = true, foreignKey = @ForeignKey(name = "fk_ref_od_review_kon_transport"))
    9898    public Transport getTransport () {
    9999        return transport;
  • src/main/java/com/tourMate/entities/User.java

    r5528b99 r07f4e8b  
    5252    private Role role;
    5353    @Column(name = "locked", unique = false, nullable = false)
    54     boolean locked;
     54    boolean locked = false;
    5555
    5656    @Column(name = "enabled", unique = false, nullable = false)
     
    9696    }
    9797
     98    public boolean isLocked() {
     99        return locked;
     100    }
    98101
    99102    public long getUserID() {
     
    162165    @Override
    163166    public boolean isAccountNonLocked() {
    164         return true;
     167        return locked;
    165168    }
    166169
  • src/main/java/com/tourMate/services/BusinessManager.java

    r5528b99 r07f4e8b  
    88    public void createBusiness(Business business, long userId);
    99    public List<Business> getUnapprovedBusinessesOfUser(long userId);
    10     public void deleteBusiness(long businessId);
    11     public List<Business> getCreatedBusinesses();
     10
     11    void deleteBusiness(long businessId);
     12
     13    public List<Business> getUnapprovedBusinesses();
     14    public void approveBusiness(Long businessId);
    1215    public Business findBusinessById (long businessId);
    13     public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved);
    1416    public boolean hasBusiness(long userId);
     17
     18    void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved);
    1519}
  • src/main/java/com/tourMate/services/HotelManager.java

    r5528b99 r07f4e8b  
    22
    33import com.tourMate.dto.HotelDto;
     4import com.tourMate.dto.HotelReservationDto;
     5import com.tourMate.dto.HotelReservationUserDto;
    46import com.tourMate.entities.*;
    5 import org.springframework.web.multipart.MultipartFile;
    67
    78import java.util.Date;
    89import java.util.List;
    9 import java.util.Map;
    1010
    1111public interface HotelManager {
     
    2424    public List<HotelRoom> getRoomsOfHotel (long hotelId);
    2525    public HotelRoom findRoomById (long hotelRoomId);
    26 <<<<<<< HEAD
    2726    public List<HotelRoomImages> getRoomImages(Long hotelRoom);
    2827    public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds);
    29 =======
    30     public List<HotelRoomImages> getRoomImages(HotelRoom hotelRoom);
    31     public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
    32 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    3328    public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price);
    3429    public void deleteRoom(long hotelRoomId);
    35     public List<HotelRoomAvailable> getRoomsAvailable(Long id);
    3630    public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
    3731    public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds);
     
    4034    public HotelRoomAvailable findAvailibleRoomById(long hotelRoomAvailableId);
    4135    public List<HotelRoomAvailable> getRoomsAvailibility();
     36    public List<HotelRoomAvailable> getRoomsAvailableById(Long id);
    4237    public List<HotelRoomAvailable> getRoomsAvailibilityByHotel(Hotels hotel);
    43     public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds);
     38    public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible);
    4439    public void createReservation(Long userId, Long hotelRoomId, Long hotelRoomAvailableId, Date dateFrom, Date dateTo, Integer numberOfBeds);
    4540    public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds);
    4641    public void deleteReservation(long hotelRoomReservedId);
     42    public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId);
     43    public List<HotelReservationUserDto> findValidHotelReservationsByUser(Long userId);
    4744    public HotelRoomReservations findReservationById(long hotelRoomReservedId);
    4845    public List<HotelRoomReservations> findReservationByUser(User user);
     
    5451
    5552    void addRoomImage(Long id, List<String> filesToAdd);
     53    void setReservationReviewed(Long reservationId);
    5654}
  • src/main/java/com/tourMate/services/RestaurantManager.java

    r5528b99 r07f4e8b  
    22
    33import com.tourMate.dto.RestaurantDto;
     4import com.tourMate.dto.RestaurantReservationDto;
    45import com.tourMate.dto.RestaurantReservationUserDto;
    56import com.tourMate.entities.*;
     
    1011public interface RestaurantManager {
    1112    public void createRestaurant(Restaurant restaurant, long userId);
    12     public void deleteRestaurant(long restaurantID);
     13
    1314    public void addMenuToRestaurant(long restaurantId, Menu menu);
     15
    1416    public List<Restaurant> getRestaurantsByUser(long userId);
    15     void deleteHotel(long restaurantID);
     17    public void deleteRestaurant(Long restaurantID);
     18
     19    void deleteRestaurant(long restaurantID);
    1620
    1721    public List<Restaurant> getRestaurants();
    18     public Restaurant findRestaurantByID (long restaurantID);
     22
     23    public Restaurant findRestaurantByID(long restaurantID);
     24
    1925    public void addRestaurantImage(Long restaurant, List<String> url);
     26
    2027    public void removeRestaurantImage(long restaurantImageId);
     28
    2129    public RestaurantImages findRestaurantImageById(long restaurantImageId);
    2230
    2331    public List<RestaurantImages> getRestaurantImages(long restaurantID);
     32
    2433    public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner);
     34
     35    void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user);
     36
    2537    public List<RestaurantsTable> getRestaurantTables(long restaurantID);
    26     public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats );
     38
     39    public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats);
     40
    2741    public RestaurantsTable findTableById(long tableId);
     42
    2843    public void createTable(Long restaurantId, int noSeats);
     44
    2945    public void editTable(Restaurant restaurant, long tableId, int noSeats);
     46
    3047    public void deleteTable(long tableId);
    3148
    32     public void createTableAvailable(Long rt, Date hourFrom, Date hourTo);
     49    public void createTableAvailable(Long rt, Date hourFrom, Date hourTo, int numTables);
    3350
    3451    public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats);
     52
    3553    public void deleteTableAvailable(long tableId);
    36     public List<RestaurantsTable> getTablesAvailability();
     54
    3755    public List<RestaurantsAvailible> getTablesAvailabilityById(Long id);
    38     public void createReservation(Restaurant restaurant, int noSeats);
     56
     57    RestaurantsAvailible findAvailableReservationByID(long tableId);
    3958
    4059    void createReservation(RestaurantsTable rt, Date dateFrom, Date dateTo, User user);
    4160
    42     public void editReservation(long tableId, Restaurant restaurant, int noSeats);
    4361    public void deleteReservation(long tableId);
     62
    4463    public RestaurantReservations findReservationByID(long tableId);
    45     public List<RestaurantReservations> findAvailableReservationByID();
    4664
    47     List<RestaurantReservations> findAvailableReservationByID(long reservationId);
     65//    List<RestaurantReservations> findAvailableReservationByID(long reservationId);
    4866
    4967    public List<RestaurantReservations> findReservationByUser(User user);
    50     public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant);
     68
     69    public List<RestaurantReservationDto> findReservationByRestaurant(Long restaurant);
     70
    5171    public List<RestaurantReservations> getReservations();
     72
    5273    public List<Restaurant> searchByRestaurantName(String restaurantName);
     74
    5375    public List<Restaurant> searchByRestaurantLocation(String restaurantLocation);
     76
    5477    public List<RestaurantsTable> searchByNoSeats(int noSeats);
    5578
     
    6184
    6285    List<RestaurantReservationUserDto> findPastRestaurantReservationsByUser(Long userId);
     86
     87    List<MenuImages> getMenuImages(Long id);
     88
     89    void addMenuImage(Long restaurant, List<String> url);
     90
     91    Menu findMenuById(Long menuId);
     92
     93    void setReservationReviewed(Long reservationId);
     94
     95    List<MenuImages> getMenuImagesByRestaurant(long restaurantId);
    6396}
  • src/main/java/com/tourMate/services/ReviewManager.java

    r5528b99 r07f4e8b  
    99public interface ReviewManager{
    1010
    11     public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport);
     11    public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport, Long reservationId);
    1212    public void deleteReview(long id);
    1313    public Reviews findReviewById(long id);
  • src/main/java/com/tourMate/services/TransportManager.java

    r5528b99 r07f4e8b  
    1313public interface TransportManager {
    1414
    15     public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate);
     15    public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate);
    1616
    1717    public void deleteTransport(long transportId);
     
    3030    public TransportReservation findTransportReservationByID(long reservationID);
    3131
     32    List<TransportReservation> findTransportReservationByTransportId(long reservationID);
     33
    3234    public List<TransportReservation> getTransportReservations();
    3335
     
    3537    public Transport getTransportById(long transportId);
    3638
    37 <<<<<<< HEAD
    3839    List<Reviews> getReviewsForTransport(long transportId);
    3940
    4041    public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date, int numPassengers);
    41 =======
    42     public List<TransportListingDto> getTransportsAvailableByFilters (String from, String to, Date date);
    43 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    4442
    4543    public List<TransportReservation> getTransportsReservationsByUserID(long userID);
     
    4846
    4947    public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes);
    50 
    51     public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour);
    52 
    5348    public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour);
    5449
     
    6762
    6863    List<TransportReservationUserDto> findPastTransportReservationsByUser(Long userId);
     64
     65    void setReservationReviewed(Long reservationId);
    6966}
    7067
  • src/main/java/com/tourMate/services/UsersManager.java

    r5528b99 r07f4e8b  
    1616
    1717    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);
     20
     21    void unlock(Long id);
    1822}
  • src/main/java/com/tourMate/services/impl/BusinessManagerImpl.java

    r5528b99 r07f4e8b  
    22
    33import com.tourMate.dao.BusinessDao;
     4import com.tourMate.dao.UsersDao;
    45import com.tourMate.entities.Business;
     6import com.tourMate.entities.Role;
    57import com.tourMate.entities.User;
    68import com.tourMate.services.BusinessManager;
     9import com.tourMate.services.UsersManager;
    710import org.springframework.beans.factory.annotation.Autowired;
    811import org.springframework.stereotype.Service;
     
    1619    @Autowired
    1720    BusinessDao businessDao;
     21    @Autowired
     22    UsersDao usersDao;
     23    @Autowired
     24    UsersManager usersManager;
    1825
    1926    @Override
    2027    public void createBusiness(Business business, long userId) {
    21         businessDao.createBusiness(business, userId);
     28        User u = usersManager.findUserByID(userId);
     29        business.setUser(u);
     30        businessDao.createBusiness(business);
    2231    }
    2332
    2433    @Override
    2534    public List<Business> getUnapprovedBusinessesOfUser(long userId) {
    26         return businessDao.getUnapprovedBusinessesOfUser(userId);
     35        User u = usersManager.findUserByID(userId);
     36        return businessDao.getUnapprovedBusinessesOfUser(u);
    2737    }
    2838
    2939    @Override
    3040    public void deleteBusiness(long businessId) {
    31         businessDao.deleteBusiness(businessId);
     41        Business business = businessDao.findBusinessById(businessId);
     42        businessDao.deleteBusiness(business);
    3243
    3344    }
    3445
    3546    @Override
    36     public boolean hasBusiness(long userId){
    37         return businessDao.hasBusiness(userId);
     47    public List<Business> getUnapprovedBusinesses() {
     48        return businessDao.getUnapprovedBusinesses();
    3849    }
    3950
    4051    @Override
    41     public List<Business> getCreatedBusinesses() {
    42         return businessDao.getCreatedBusinesses();
     52    public void approveBusiness(Long businessId) {
     53        Business b = findBusinessById(businessId);
     54        b.setApproved(true);
     55        businessDao.approveBusiness(b);
     56        changeUserRoleBusiness(b.getUser().getUserID());
     57    }
     58
     59    private void changeUserRoleBusiness(Long userId)
     60    {
     61        User u = usersDao.findUserByID(userId);
     62        Role r = usersDao.findById(3L);
     63        u.setRole(r);
     64        usersDao.updateUser(u);
     65    }
     66
     67    @Override
     68    public boolean hasBusiness(long userId){
     69        User u = usersManager.findUserByID(userId);
     70        return businessDao.hasBusiness(u);
    4371    }
    4472
     
    5078    @Override
    5179    public void editBusiness(long businessId, String name, String phone, String address, String edbs, User user, boolean approved) {
    52         businessDao.editBusiness(businessId, name, phone, address, edbs, user, approved);
     80        Business business = findBusinessById(businessId);
     81        business.setName(name);
     82        business.setPhone(phone);
     83        business.setAddress(address);
     84        business.setEdbs(edbs);
     85        business.setUser(user);
     86        business.setApproved(approved);
     87        businessDao.editBusiness(business);
    5388    }
    5489
  • src/main/java/com/tourMate/services/impl/HotelManagerImpl.java

    r5528b99 r07f4e8b  
    44import com.tourMate.dao.UsersDao;
    55import com.tourMate.dto.HotelDto;
     6import com.tourMate.dto.HotelReservationDto;
     7import com.tourMate.dto.HotelReservationUserDto;
    68import com.tourMate.entities.*;
    79import com.tourMate.services.HotelManager;
     10import com.tourMate.services.UsersManager;
    811import org.springframework.beans.factory.annotation.Autowired;
    912import org.springframework.stereotype.Service;
    10 import org.springframework.web.multipart.MultipartFile;
    1113
    1214import java.time.Duration;
    13 import java.util.Collection;
    1415import java.util.Date;
    1516import java.util.List;
     
    2425    @Autowired
    2526    UsersDao usersDao;
    26 
     27    @Autowired
     28    UsersManager usersManager;
    2729
    2830    @Override
     
    3335    @Override
    3436    public void createHotel(Hotels hotels, long userId) {
    35         hotelDao.createHotel(hotels, userId);
     37        User u = usersManager.findUserByID(userId);
     38        hotels.setOwner(u);
     39        hotelDao.createHotel(hotels);
    3640    }
    3741
     
    3943    @Override
    4044    public List<Hotels> getHotels() {
    41         List<Hotels> hoteli = hotelDao.getHotels();
    4245        return hotelDao.getHotels();
    4346    }
     
    4548    @Override
    4649    public List<Hotels> getHotelsForUser(long userId) {
    47         return hotelDao.getHotelsForUser(userId);
     50        User u = usersManager.findUserByID(userId);
     51        return hotelDao.getHotelsForUser(u);
    4852    }
    4953
     
    5559    @Override
    5660    public void editHotel(long hotelId, String hotelName, String hotelDescripiton, String hotelLocation, String hotelEDBS, Boolean parking, Boolean petFriendly, Boolean internetAvailable) {
    57         hotelDao.editHotel(hotelId, hotelName, hotelDescripiton, hotelLocation, hotelEDBS, parking, petFriendly, internetAvailable);
     61        Hotels hotel = hotelDao.findHotelByID(hotelId);
     62        hotel.setHotelName(hotelName);
     63        hotel.setHotelDescripiton(hotelDescripiton);
     64        hotel.setHotelLocation(hotelLocation);
     65        hotel.setHotelEDBS(hotelEDBS);
     66        hotel.setParking(parking);
     67        hotel.setPetFriendly(petFriendly);
     68        hotel.setInternetAvailable(internetAvailable);
     69        hotelDao.editHotel(hotel);
    5870    }
    5971
    6072    @Override
    6173    public void deleteHotel(long hotelId) {
    62         hotelDao.deleteHotel(hotelId);
     74        Hotels h = findHotelByID(hotelId);
     75        hotelDao.deleteHotel(h);
    6376    }
    6477
     
    7689    @Override
    7790    public List<HotelRoom> getRoomsOfHotel(long hotelId) {
    78         return hotelDao.getRoomsOfHotel(hotelId);
     91        Hotels h = findHotelByID(hotelId);
     92        return hotelDao.getRoomsOfHotel(h);
    7993    }
    8094
     
    99113    @Override
    100114    public void deleteHotelImage(long hotelImageId){
    101         hotelDao.deleteHotelImage(hotelImageId);
     115        HotelsImages hotelsImages = findHotelImageById(hotelImageId);
     116        hotelDao.deleteHotelImage(hotelsImages);
    102117    }
    103118
     
    108123
    109124    @Override
    110     public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {
    111         hotelDao.createRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price);
     125    public void createRoom(Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price, int numOfBeds) {
     126        HotelRoom hotelRoom = new HotelRoom(hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price, numOfBeds);
     127        hotelDao.createRoom(hotelRoom);
    112128    }
    113129
    114130    @Override
    115131    public void editRoom(long hotelRoomId, Hotels hotel, String hotelRoomDescription, String hotelRoomName, Boolean kitchenAvailable, Boolean airConditioning, Boolean balcony, double price) {
    116         hotelDao.editRoom(hotelRoomId, hotel, hotelRoomDescription, hotelRoomName, kitchenAvailable, airConditioning, balcony, price);
     132        HotelRoom hr = findRoomById(hotelRoomId);
     133        hr.setHotel(hotel);
     134        hr.setHotelRoomDescription(hotelRoomDescription);
     135        hr.setHotelRoomName(hotelRoomName);
     136        hr.setKitchenAvailable(kitchenAvailable);
     137        hr.setAirConditioning(airConditioning);
     138        hr.setBalcony(balcony);
     139        hr.setPrice(price);
     140        hotelDao.editRoom(hr);
    117141    }
    118142
    119143    @Override
    120144    public void deleteRoom(long hotelRoomId) {
    121         hotelDao.deleteRoom(hotelRoomId);
    122     }
    123 
    124     @Override
    125     public List<HotelRoomAvailable> getRoomsAvailable(Long id) {
     145        HotelRoom hr = findRoomById(hotelRoomId);
     146        hotelDao.deleteRoom(hr);
     147    }
     148
     149
     150    @Override
     151    public List<HotelRoomAvailable> getRoomsAvailableById(Long id) {
    126152        return hotelDao.getRoomsAvailable(id);
    127153    }
     
    129155    @Override
    130156    public void createRoomAvailible(HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) {
    131         hotelDao.createRoomAvailible(hotelRoom, dateFrom, dateTo, numberOfBeds);
     157        HotelRoomAvailable hra = new HotelRoomAvailable(hotelRoom, dateFrom, dateTo, numberOfBeds);
     158        hotelDao.createRoomAvailible(hra);
    132159    }
    133160
    134161    @Override
    135162    public void editRoomAvailible(long hotelRoomAvailableId, HotelRoom hotelRoom, Date dateFrom, Date dateTo, int numberOfBeds) {
    136         hotelDao.editRoomAvailible(hotelRoomAvailableId, hotelRoom, dateFrom, dateTo, numberOfBeds);
     163        HotelRoomAvailable hr = findAvailibleRoomById(hotelRoomAvailableId);
     164        hr.setHotelRoom(hotelRoom);
     165        hr.setDateFrom(dateFrom);
     166        hr.setDateTo(dateTo);
     167        hr.setNumberOfBeds(numberOfBeds);
     168        hotelDao.editRoomAvailible(hr);
    137169    }
    138170
     
    142174        roomAvailable.setNumberOfBeds(numberOfBeds-1);
    143175        HotelRoom room = hotelDao.findRoomById(hotelRoomId);
    144         hotelDao.createRoomAvailible(room, roomAvailable.getDateFrom(), from, 1);
    145         hotelDao.createRoomAvailible(room, to, roomAvailable.getDateTo(), 1);
     176        HotelRoomAvailable hra = new HotelRoomAvailable(room,roomAvailable.getDateFrom(),from,1);
     177        hotelDao.createRoomAvailible(hra);
     178        HotelRoomAvailable hra1 = new HotelRoomAvailable(room,to,roomAvailable.getDateTo(),1);
     179        hotelDao.createRoomAvailible(hra1);
    146180    }
    147181
    148182    @Override
    149183    public void deleteRoomAvailible(long hotelRoomAvailableId) {
    150         hotelDao.deleteRoomAvailible(hotelRoomAvailableId);
     184        HotelRoomAvailable hra = findAvailibleRoomById(hotelRoomAvailableId);
     185        hotelDao.deleteRoomAvailible(hra);
    151186    }
    152187
     
    167202
    168203    @Override
    169     public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds) {
     204    public List<HotelDto> getRoomsAvailibilityByDateAndLocation(String hotelLocation, Date dateFrom, Date dateTo, int numberOfBeds, Boolean flexible) {
    170205        long numberOfNights = Duration.between(dateFrom.toInstant(), dateTo.toInstant()).toDays();
    171         List<HotelRoomAvailable> roomsAvailible = hotelDao.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numberOfBeds);
     206        List<HotelRoomAvailable> roomsAvailible = hotelDao.getRoomsAvailibilityByDateAndLocation(hotelLocation, dateFrom, dateTo, numberOfBeds, flexible);
    172207        Map<Hotels, List<HotelRoomAvailable>> roomsByHotels = roomsAvailible.stream().collect(Collectors.groupingBy(x -> x.getHotelRoom().getHotel()));
    173208        List<HotelDto> hotelsList = roomsByHotels.keySet().stream()
     
    195230        HotelRoom room = hotelDao.findRoomById(hotelRoomId);
    196231        User user = usersDao.findUserByID(userId);
    197         hotelDao.createReservation(user, room, dateFrom, dateTo, numberOfBeds);
     232        HotelRoomReservations r = new HotelRoomReservations(user, room, dateFrom, dateTo, numberOfBeds);
    198233        editRoomAvailibleReservation(hotelRoomAvailableId, hotelRoomId, dateFrom, dateTo, numberOfBeds);
     234        hotelDao.createReservation(r);
     235
    199236    }
    200237
    201238    @Override
    202239    public void editReservation(long hotelRoomReservedId, User user, HotelRoom hotelRoom, Date dateFrom, Date dateTo, Integer numberOfBeds) {
    203         hotelDao.editReservation(hotelRoomReservedId, user, hotelRoom, dateFrom, dateTo, numberOfBeds);
     240        HotelRoomReservations hr = findReservationById(hotelRoomReservedId);
     241        hr.setUser(user);
     242        hr.setHotelRoom(hotelRoom);
     243        hr.setDateFrom(dateFrom);
     244        hr.setDateTo(dateTo);
     245        hr.setNumberOfBeds(numberOfBeds);
     246        hotelDao.editReservation(hr);
    204247    }
    205248
    206249    @Override
    207250    public void deleteReservation(long hotelRoomReservedId) {
    208         hotelDao.deleteReservation(hotelRoomReservedId);
    209     }
    210 
    211     @Override
    212 <<<<<<< HEAD
     251        HotelRoomReservations r = findReservationById(hotelRoomReservedId);
     252        HotelRoomAvailable hra = new HotelRoomAvailable(r.getHotelRoom(), r.getDateFrom(), r.getDateTo(), r.getNumberOfBeds());
     253        hotelDao.createRoomAvailible(hra);
     254        hotelDao.deleteReservation(r);
     255    }
     256
     257    @Override
    213258    public List<HotelReservationDto> findVaidReseravtionsByHotel(Long hotelId) {
    214259        Hotels hotel = findHotelByID(hotelId);
     
    230275        List<HotelRoomReservations> reservations = hotelDao.findReservationByUser(u);
    231276        return reservations.stream().map(x -> new HotelReservationUserDto(
     277                x.getHotelRoomReservedId(),
    232278                x.getUser(),
    233279                x.getHotelRoom(),
     
    244290
    245291    @Override
    246 =======
    247 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    248292    public HotelRoomReservations findReservationById(long hotelRoomReservedId) {
    249293        return hotelDao.findReservationById(hotelRoomReservedId);
     
    276320        List<HotelRoomReservations> reservations = hotelDao.findPastReservationByUser(u);
    277321        return reservations.stream().map(x -> new HotelReservationUserDto(
     322                x.getHotelRoomReservedId(),
    278323                x.getUser(),
    279324                x.getHotelRoom(),
     
    294339        filesToAdd.stream().map(file -> new HotelRoomImages(hr, file)).forEach(x -> hotelDao.addRoomImage(x));
    295340    }
     341
     342    @Override
     343    public void setReservationReviewed(Long reservationId) {
     344        HotelRoomReservations hotelRoomReservations = findReservationById(reservationId);
     345        hotelRoomReservations.setReviewed(true);
     346        hotelDao.saveReservation(hotelRoomReservations);
     347    }
    296348}
  • src/main/java/com/tourMate/services/impl/ImageManagerImpl.java

    r5528b99 r07f4e8b  
    5656            hotelManager.addRoomImage(id, filesToAdd);
    5757        }
     58        else if(type.equals("menu"))
     59        {
     60            restaurantManager.addMenuImage(id, filesToAdd);
     61        }
    5862
    5963        return filesToAdd;
  • src/main/java/com/tourMate/services/impl/MenuManagerImpl.java

    r5528b99 r07f4e8b  
    1717    @Override
    1818    public void createMenu(String name, String ingredients, double price) {
    19         menuDao.createMenu(name, ingredients, price);
     19        menuDao.createMenu(new Menu(name, ingredients, price));
    2020    }
    2121
    2222    @Override
    2323    public void deleteMenu(long menuId) {
    24         menuDao.deleteMenu(menuId);
     24        Menu menu = findMenuById(menuId);
     25        menuDao.deleteMenu(menu);
    2526    }
    2627
     
    3738    @Override
    3839    public void editMenu(long menuId, String name, String ingredients, double price) {
    39         menuDao.editMenu(menuId, name, ingredients, price);
     40        Menu menu = findMenuById(menuId);
     41        menu.setName(name);
     42        menu.setIngredients(ingredients);
     43        menu.setPrice(price);
     44        menuDao.editMenu(menu);
    4045    }
    4146}
  • src/main/java/com/tourMate/services/impl/RestaurantManagerImpl.java

    r5528b99 r07f4e8b  
    33import com.tourMate.dao.RestaurantDao;
    44import com.tourMate.dto.RestaurantDto;
     5import com.tourMate.dto.RestaurantReservationDto;
    56import com.tourMate.dto.RestaurantReservationUserDto;
    67import com.tourMate.services.RestaurantManager;
     
    2223    @Autowired
    2324    UsersManager usersManager;
     25
    2426    @Override
    2527    public void createRestaurant(Restaurant restaurant, long userId) {
    26         restaurantDao.createRestaurant(restaurant, userId);
    27     }
    28 
    29 
     28        User u = usersManager.findUserByID(userId);
     29        Restaurant r = new Restaurant(restaurant.getRestaurantName(), restaurant.getRestaurantLocation(), restaurant.getCousineType(), restaurant.getRestaurantDescription(), restaurant.getRestaurantEdbs(), u);
     30        restaurantDao.createRestaurant(r);
     31    }
     32
     33    @Override
     34    public void deleteRestaurant(Long restaurantID) {
     35        Restaurant r = findRestaurantByID(restaurantID);
     36        restaurantDao.deleteRestaurant(r);
     37    }
     38
     39    @Override
     40    public void addMenuToRestaurant(long restaurantId, Menu menu) {
     41        Restaurant r = findRestaurantByID(restaurantId);
     42        menu.setRestaurant(r);
     43        restaurantDao.addMenuToRestaurant(menu);
     44    }
     45
     46    @Override
     47    public List<Restaurant> getRestaurantsByUser(long userId) {
     48        User u = usersManager.findUserByID(userId);
     49        return restaurantDao.getRestaurantsByUser(u);
     50    }
    3051
    3152    @Override
    3253    public void deleteRestaurant(long restaurantID) {
    33         restaurantDao.deleteRestaurant(restaurantID);
    34     }
    35 
    36     @Override
    37     public void addMenuToRestaurant(long restaurantId, Menu menu) {
    38         restaurantDao.addMenuToRestaurant(restaurantId, menu);
    39     }
    40 
    41     @Override
    42     public List<Restaurant> getRestaurantsByUser(long userId) {
    43         return restaurantDao.getRestaurantsByUser(userId);
    44     }
    45 
    46     @Override
    47     public void deleteHotel(long restaurantID) {
    48         restaurantDao.deleteRestaurant(restaurantID);
     54        Restaurant r = findRestaurantByID(restaurantID);
     55        restaurantDao.deleteRestaurant(r);
    4956    }
    5057
     
    6774    @Override
    6875    public void removeRestaurantImage(long restaurantImageId) {
    69         restaurantDao.removeRestaurantImage(restaurantImageId);
     76        RestaurantImages restaurantImage = findRestaurantImageById(restaurantImageId);
     77        restaurantDao.removeRestaurantImage(restaurantImage);
    7078    }
    7179
     
    8189
    8290    @Override
    83     public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats){
     91    public List<RestaurantDto> getTablesByDateAndLocation(String restaurantLocation, Date hourFrom, Date hourTo, int noSeats) {
    8492        List<RestaurantsAvailible> restaurantsAvailibles = restaurantDao.getTablesByDateAndLocation(restaurantLocation, hourFrom, hourTo, noSeats);
    8593        Map<Restaurant, List<RestaurantsAvailible>> tablesByRestaurants = restaurantsAvailibles.stream().collect(Collectors.groupingBy(x -> x.getRestaurantTable().getRestaurant()));
     
    96104                        getReviewsForRestaurant(x.getRestaurantID()),
    97105                        getReviewsForRestaurant(x.getRestaurantID()).stream().mapToDouble(Reviews::getNumStar).average().orElse(0),
    98                         getRestaurantImages(x.getRestaurantID())
     106                        getRestaurantImages(x.getRestaurantID()),
     107                        getMenuImagesByRestaurant(x.getRestaurantID())
    99108                )).toList();
    100109        return restaurantsList;
     
    103112    @Override
    104113    public void editRestaurant(long restaurantID, String restaurantName, String restaurantLocation, String cousineType, String restaurantDescription, String restaurantEdbs, User restaurantOwner) {
    105         restaurantDao.editRestaurant(restaurantID, restaurantName, restaurantLocation, cousineType, restaurantDescription, restaurantEdbs, restaurantOwner);
     114        Restaurant res = findRestaurantByID(restaurantID);
     115        res.setRestaurantName(restaurantName);
     116        res.setRestaurantLocation(restaurantLocation);
     117        res.setRestaurantEdbs(restaurantEdbs);
     118        res.setRestaurantDescription(restaurantDescription);
     119        res.setRestaurantOwner(restaurantOwner);
     120        res.setCousineType(cousineType);
     121        restaurantDao.createRestaurant(res);
     122    }
     123
     124    @Override
     125    public void editReservation(long restaurantsTableId, RestaurantsTable rt, Date hourFrom, Date hourTo, int noSeats, User user){
     126        RestaurantReservations r = findReservationByID(restaurantsTableId);
     127        r.setTable(rt);
     128        r.setTimeFrom(hourFrom);
     129        r.setTimeTo(hourTo);
     130        r.setNoSeats(noSeats);
     131        r.setUser(user);
     132        restaurantDao.saveReservation(r);
    106133    }
    107134
     
    119146    public void createTable(Long restaurantId, int noSeats) {
    120147        Restaurant r = restaurantDao.findRestaurantByID(restaurantId);
    121         restaurantDao.createTable(r, noSeats);
     148        RestaurantsTable restaurantsTable = new RestaurantsTable(r, noSeats);
     149        restaurantDao.saveTable(restaurantsTable);
    122150    }
    123151
    124152    @Override
    125153    public void editTable(Restaurant restaurant, long tableId, int noSeats) {
    126         restaurantDao.editTable(restaurant, tableId, noSeats);
     154        RestaurantsTable resTable = findTableById(tableId);
     155        resTable.setRestaurant(restaurant);
     156        resTable.setNoSeats(noSeats);
     157        restaurantDao.saveTable(resTable);
    127158    }
    128159
    129160    @Override
    130161    public void deleteTable(long tableId) {
    131         restaurantDao.deleteTable(tableId);
    132     }
    133 
    134     @Override
    135     public void createTableAvailable(Long rt, Date hourFrom, Date hourTo) {
     162        RestaurantsTable rt = findTableById(tableId);
     163        restaurantDao.deleteTable(rt);
     164    }
     165
     166    @Override
     167    public void createTableAvailable(Long rt, Date hourFrom, Date hourTo, int numTables) {
    136168        RestaurantsTable rtabl = findTableById(rt);
    137         restaurantDao.createTableAvailable(rtabl, hourFrom, hourTo);
    138     }
    139 
    140     @Override
    141     public List<RestaurantsAvailible> getTablesAvailabilityById(Long id)
    142     {
     169        RestaurantsAvailible ra = new RestaurantsAvailible(rtabl, hourFrom, hourTo, numTables);
     170        restaurantDao.saveTableAvailable(ra);
     171    }
     172
     173    @Override
     174    public List<RestaurantsAvailible> getTablesAvailabilityById(Long id) {
    143175        return restaurantDao.getTablesAvailabilityById(id);
    144176    }
     
    146178    @Override
    147179    public void editTableAvailable(long tableId, Restaurant restaurant, int noSeats) {
    148         restaurantDao.editTableAvailable(tableId, restaurant, noSeats);
     180        RestaurantsTable rt = findTableById(tableId);
     181        rt.setRestaurant(restaurant);
     182        rt.setNoSeats(noSeats);
     183        restaurantDao.saveTable(rt);
    149184    }
    150185
    151186    @Override
    152187    public void deleteTableAvailable(long tableId) {
    153         restaurantDao.deleteTableAvailable(tableId);
    154     }
    155 
    156     @Override
    157     public List<RestaurantsTable> getTablesAvailability() {
    158         return null;
    159     }
    160 
    161     @Override
    162     public void createReservation(Restaurant restaurant, int noSeats) {
    163 
     188        RestaurantsAvailible ra = findAvailableReservationByID(tableId);
     189        restaurantDao.deleteTableAvailable(ra);
     190    }
     191
     192    @Override
     193    public RestaurantsAvailible findAvailableReservationByID(long tableId){
     194        return restaurantDao.findAvailableReservationByID(tableId);
    164195    }
    165196
     
    170201    }
    171202
    172     @Override
    173     public void editReservation(long tableId, Restaurant restaurant, int noSeats) {
    174         //restaurantDao.editReservation(tableId, restaurant, noSeats);
    175     }
    176203
    177204    @Override
    178205    public void deleteReservation(long tableId) {
    179         restaurantDao.deleteReservation(tableId);
     206        RestaurantReservations r = findReservationByID(tableId);
     207        RestaurantsAvailible ra = new RestaurantsAvailible(r.getTable(), r.getTimeFrom(), r.getTimeTo(), r.getNoSeats());
     208        restaurantDao.saveTableAvailable(ra);
     209        restaurantDao.deleteReservation(r);
    180210    }
    181211
    182212    @Override
    183213    public RestaurantReservations findReservationByID(long tableId) {
    184         //return restaurantDao.findReservationByID(tableId);
    185         return null;
    186     }
    187 
    188     @Override
    189     public List<RestaurantReservations> findAvailableReservationByID() {
    190         return null;
    191     }
    192 
    193     @Override
    194     public List<RestaurantReservations> findAvailableReservationByID(long reservationId) {
    195         return null;
    196         // return restaurantDao.findAvailableReservationByID(reservationId);
     214        return restaurantDao.findReservationByID(tableId);
     215        //return null;
    197216    }
    198217
     
    203222
    204223    @Override
    205     public List<RestaurantReservations> findReservationByRestaurant(Restaurant restaurant) {
    206         return restaurantDao.findReservationByRestaurant(restaurant);
     224    public List<RestaurantReservationDto> findReservationByRestaurant(Long restaurant) {
     225        Restaurant r = findRestaurantByID(restaurant);
     226        List<RestaurantReservations> res = restaurantDao.findReservationByRestaurant(r);
     227        return res.stream().map(x -> new RestaurantReservationDto(
     228                x.getUser(),
     229                x.getTable(),
     230                x.getTimeFrom(),
     231                x.getTimeTo()
     232        )).collect(Collectors.toList());
    207233    }
    208234
     
    251277    }
    252278
    253     public void editTableAvailability(RestaurantsAvailible restaurantsAvailible, RestaurantsTable table, Date dateFrom, Date dateTo)
    254     {
     279    public void editTableAvailability(RestaurantsAvailible restaurantsAvailible, RestaurantsTable table, Date dateFrom, Date dateTo) {
    255280        restaurantsAvailible.setNumTables(restaurantsAvailible.getNumTables() - 1);
    256         restaurantDao.createTableAvailable(table, restaurantsAvailible.getHourFrom(), dateFrom, 1);
    257         restaurantDao.createTableAvailable(table, dateTo, restaurantsAvailible.getHourTo(), 1);
     281        RestaurantsAvailible ra1 = new RestaurantsAvailible(table, restaurantsAvailible.getHourFrom(), dateFrom, 1);
     282        RestaurantsAvailible ra2 = new RestaurantsAvailible(table, dateTo, restaurantsAvailible.getHourTo(), 1);
     283
     284        restaurantDao.saveTableAvailable(ra1);
     285        restaurantDao.saveTableAvailable(ra2);
    258286    }
    259287
     
    263291        List<RestaurantReservations> reservations = restaurantDao.findReservationByUser(u);
    264292        return reservations.stream().map(x -> new RestaurantReservationUserDto(
     293                x.getReservationId(),
    265294                x.getUser(),
    266295                x.getTable(),
     
    281310        List<RestaurantReservations> reservations = restaurantDao.findPastReservationsByUser(u);
    282311        return reservations.stream().map(x -> new RestaurantReservationUserDto(
     312                x.getReservationId(),
    283313                x.getUser(),
    284314                x.getTable(),
     
    293323        )).toList();
    294324    }
     325
     326    @Override
     327    public List<MenuImages> getMenuImages(Long id) {
     328        return restaurantDao.getMenuImages(id);
     329    }
     330
     331    @Override
     332    public void addMenuImage(Long menuId, List<String> url) {
     333        Menu r = restaurantDao.findMenuId(menuId);
     334        url.stream().map(file -> new MenuImages(r, file)).forEach(x -> restaurantDao.addMenuImage(x));
     335    }
     336
     337    @Override
     338    public Menu findMenuById(Long menuId) {
     339        return restaurantDao.findMenuId(menuId);
     340    }
     341
     342    @Override
     343    public void setReservationReviewed(Long reservationId) {
     344        RestaurantReservations restaurantReservations = findReservationByID(reservationId);
     345        restaurantReservations.setReviewed(true);
     346        restaurantDao.saveReservation(restaurantReservations);
     347    }
     348
     349    @Override
     350    public List<MenuImages> getMenuImagesByRestaurant(long restaurantId) {
     351        Restaurant r = findRestaurantByID(restaurantId);
     352        return restaurantDao.getMenuImagesByRestaurant(r);
     353    }
    295354}
  • src/main/java/com/tourMate/services/impl/ReviewManagerImpl.java

    r5528b99 r07f4e8b  
    33import com.tourMate.dao.ReviewDao;
    44import com.tourMate.dao.ReviewManager;
    5 import com.tourMate.entities.Hotels;
    6 import com.tourMate.entities.Restaurant;
    7 import com.tourMate.entities.Reviews;
    8 import com.tourMate.entities.Transport;
     5import com.tourMate.entities.*;
    96import com.tourMate.services.HotelManager;
    107import com.tourMate.services.RestaurantManager;
     
    2926
    3027    @Override
    31     public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport) {
     28    public void createReview(String title, int numStar, String description, Long hotel, Long restaurant, Long transport, Long reservationId) {
    3229        Hotels h = null;
    3330        Restaurant r = null;
     
    3633        {
    3734            h = hotelManager.findHotelByID(hotel);
     35            hotelManager.setReservationReviewed(reservationId);
    3836        }
    3937        if(restaurant != null)
    4038        {
    4139            r = restaurantManager.findRestaurantByID(restaurant);
     40            restaurantManager.setReservationReviewed(reservationId);
    4241        }
    4342        if(transport != null)
    4443        {
    4544            t = transportManager.getTransportById(transport);
     45            transportManager.setReservationReviewed(reservationId);
    4646        }
    4747        Reviews review = new Reviews (title, numStar, description, h, r, t);
     
    5151    @Override
    5252    public void deleteReview(long id) {
    53         reviewDao.deleteReview(id);
     53        Reviews review = findReviewById(id);
     54        reviewDao.deleteReview(review);
    5455    }
    5556
     
    6162    @Override
    6263    public void editReview(long id, String title, String description, int numStar, Hotels hotel, Restaurant restaurant, Transport transport) {
    63         reviewDao.editReview(id, title, description, numStar, hotel, restaurant, transport);
     64        Reviews review = findReviewById(id);
     65        review.setDescription(description);
     66        review.setHotel(hotel);
     67        review.setRestaurant(restaurant);
     68        review.setTitle(title);
     69        review.setNumStar(numStar);
     70        review.setTransport(transport);
     71        reviewDao.editReview(review);
    6472    }
    6573
  • src/main/java/com/tourMate/services/impl/TransportManagerImpl.java

    r5528b99 r07f4e8b  
    2424    UsersManager usersManager;
    2525
    26     @Override
    27     public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) {
    28         transportDao.createTransport(transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, owner, carPlate);
     26
     27    @Override
     28    public void createTransport(String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, Long userId, String carPlate) {
     29        User u = usersManager.findUserByID(userId);
     30        Transport t=new Transport(transportName,carBrand,carType,carManufacturedYear,noPassengers,noBags,EMBG,u,carPlate);
     31        transportDao.createTransport(t);
    2932    }
    3033
    3134    @Override
    3235    public void deleteTransport(long transportId) {
    33         transportDao.deleteTransport(transportId);
     36        Transport t=getTransportById(transportId);
     37        transportDao.deleteTransport(t);
    3438    }
    3539
     
    4145    @Override
    4246    public List<TransportDto> getTransportsByUser(long userId) {
    43         return transportDao.getTransportsByUser(userId);
     47        User u = usersManager.findUserByID(userId);
     48        return transportDao.getTransportsByUser(u);
    4449    }
    4550
    4651    @Override
    4752    public List<RouteListingDto> getRoutesForTransport(long transportId) {
    48         return transportDao.getRoutesForTransport(transportId);
     53        Transport t = getTransportById(transportId);
     54        return transportDao.getRoutesForTransport(t);
    4955    }
    5056
     
    6167    @Override
    6268    public void editTransport(long transportID, String transportName, String carBrand, String carType, int carManufacturedYear, int noPassengers, int noBags, long EMBG, User owner, String carPlate) {
    63         transportDao.editTransport(transportID, transportName, carBrand, carType, carManufacturedYear, noPassengers, noBags, EMBG, owner, carPlate);
     69        Transport t=getTransportById(transportID);
     70        t.setTransportName(transportName);
     71        t.setCarBrand(carBrand);
     72        t.setCarType(carType);
     73        t.setCarManufacturedYear(carManufacturedYear);
     74        t.setNoPassengers(noPassengers);
     75        t.setNoBags(noBags);
     76        t.setEMBG(EMBG);
     77        t.setOwner(owner);
     78        t.setCarPlate(carPlate);
     79        transportDao.editTransport(t);
    6480    }
    6581
     
    7894
    7995    @Override
     96    public List<TransportReservation> findTransportReservationByTransportId(long reservationID) {
     97        Transport t = getTransportById(reservationID);
     98        return transportDao.findTransportReservationByTransportId(t);
     99    }
     100
     101    @Override
    80102    public List<TransportReservation> getTransportReservations() {
    81103        return transportDao.getTransportReservations();
     
    93115
    94116    @Override
    95 <<<<<<< HEAD
    96117    public List<Reviews> getReviewsForTransport(long transportId) {
    97118        Transport transport = getTransportById(transportId);
     
    102123    public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date, int numPassengers) {
    103124        List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date, numPassengers);
    104 =======
    105     public List<TransportListingDto> getTransportsAvailableByFilters(String from, String to, Date date) {
    106         List<TransportRoute> transportAvailable = transportDao.getTransportsAvailableByFilters(from, to, date);
    107 >>>>>>> parent of ac19a0c (authContext impl, admin panel impl, search bar fixes, reservations listings impl)
    108125        Map<TransportAvailible, List<TransportRoute>> transportsByTransporter = transportAvailable.stream().collect(Collectors.groupingBy(x -> x.getParentRoute()));
    109126        List<TransportListingDto> transportList = transportsByTransporter.keySet().stream().toList().stream()
     
    136153    @Override
    137154    public void createTransportAvailable(Transport transport, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour, Collection<TransportRoute> routes) {
    138         transportDao.createTransportAvailable(transport, departureLocation, arrivalLocation, date, noSeats, departureHour, routes);
    139     }
    140 
    141     @Override
    142     public void editTransportReservation(Transport transport, long reservationID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, User user, Date departureHour) {
    143         transportDao.editTransportReservation(transport, reservationID, departureLocation, arrivalLocation, date, noSeats, user, departureHour);
     155        TransportAvailible ta=new TransportAvailible(transport,departureLocation,arrivalLocation,date,noSeats,departureHour);
     156        transportDao.createTransportAvailable(ta);
     157        routes.forEach(x -> {
     158            TransportRoute tr = new TransportRoute(ta, x.getFrom(), x.getTo(), x.getPrice(), x.getDeparture(), x.getArrival(), x.getFreeSpace(), x.getOrder());
     159            transportDao.createTransportRoute(tr);
     160        });
    144161    }
    145162
    146163    @Override
    147164    public void editTransportAvailable(Transport transport, long availableID, String departureLocation, String arrivalLocation, Date date, Integer noSeats, Date departureHour) {
    148         transportDao.editTransportAvailable(transport, availableID, departureLocation, arrivalLocation, date, noSeats, departureHour);
     165        TransportAvailible ta=findTransportAvailableByID(availableID);
     166        ta.setTransport(transport);
     167        ta.setFrom(departureLocation);
     168        ta.setTo(arrivalLocation);
     169        ta.setDate(date);
     170        ta.setFreeSpace(noSeats);
     171        ta.setTime(departureHour);
     172        transportDao.editTransportAvailable(ta);
    149173    }
    150174
    151175    @Override
    152176    public void deleteTransportReservation(long reservationID) {
    153         transportDao.deleteTransportReservation(reservationID);
     177        TransportReservation tr=findTransportReservationByID(reservationID);
     178        transportDao.deleteTransportReservation(tr);
    154179    }
    155180
    156181    @Override
    157182    public void deleteTransportAvailable(long availableID) {
    158         transportDao.deleteTransportAvailable(availableID);
     183        TransportAvailible ta=findTransportAvailableByID(availableID);
     184        transportDao.deleteTransportAvailable(ta);
    159185    }
    160186
    161187    @Override
    162188    public void createTransportRoute(TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) {
    163         transportDao.createTransportRoute(parentRoute, from, to, price, departure, arrival, freeSpace, order);
     189        TransportRoute tr = new TransportRoute(parentRoute, from, to, price, departure, arrival, freeSpace, order);
     190
     191        transportDao.createTransportRoute(tr);
    164192    }
    165193
    166194    @Override
    167195    public void deleteTransportRoute(long transportRouteId) {
    168         transportDao.deleteTransportRoute(transportRouteId);
     196        TransportRoute tr = transportDao.findTransportRouteById(transportRouteId);
     197        transportDao.deleteTransportRoute(tr);
    169198    }
    170199
    171200    @Override
    172201    public void editTransportRoute(long transportRouteId, TransportAvailible parentRoute, String from, String to, double price, Date departure, Date arrival, int freeSpace, int order) {
    173         transportDao.editTransportRoute(transportRouteId, parentRoute, from, to, price, departure, arrival, freeSpace, order);
     202        TransportRoute tr = transportDao.findTransportRouteById(transportRouteId);
     203        tr.setParentRoute(parentRoute);
     204        tr.setFrom(from);
     205        tr.setTo(to);
     206        tr.setPrice(price);
     207        tr.setDeparture(departure);
     208        tr.setArrival(arrival);
     209        tr.setFreeSpace(freeSpace);
     210        tr.setOrder(order);
     211        transportDao.editTransportRoute(tr);
    174212    }
    175213
     
    179217        List<TransportReservation> reservations = transportDao.findReservationByUser(u);
    180218        return reservations.stream().map(x -> new TransportReservationUserDto(
     219                x.getReservationID(),
    181220                x.getUser(),
    182221                x.getTransportRoute(),
     
    195234        List<TransportReservation> reservations = transportDao.findPastReservationByUser(u);
    196235        return reservations.stream().map(x -> new TransportReservationUserDto(
     236                x.getReservationID(),
    197237                x.getUser(),
    198238                x.getTransportRoute(),
     
    206246    }
    207247
     248    @Override
     249    public void setReservationReviewed(Long reservationId) {
     250        TransportReservation transportReservation = findTransportReservationByID(reservationId);
     251        transportReservation.setReviewed(true);
     252        transportDao.saveReservation(transportReservation);
     253    }
     254
    208255}
    209256
  • src/main/java/com/tourMate/services/impl/UsersManagerImpl.java

    r5528b99 r07f4e8b  
    4545
    4646    @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
     58    public void unlock(Long id) {
     59        User u = findUserByID(id);
     60        u.setLocked(!u.isLocked());
     61        u.setEnabled(true);
     62        usersDao.updateUser(u);
     63    }
     64
     65    @Override
    4766    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    4867        return usersDao.findUserByUsername(username);
Note: See TracChangeset for help on using the changeset viewer.