Ignore:
Timestamp:
01/13/24 23:19:50 (6 months ago)
Author:
darsov2 <62809499+darsov2@…>
Branches:
master
Children:
e85a562
Parents:
e9b4ba9
Message:

authContext impl, admin panel impl, search bar fixes, reservations listings impl

Location:
frontend/src/Components
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • frontend/src/Components/Forms/AddHotelForm.js

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

    re9b4ba9 rac19a0c  
    8585                  return prevState + 1;
    8686                })
     87                props.closeModal()
    8788              }}
    8889            >
  • frontend/src/Components/Forms/AddRoomForm.js

    re9b4ba9 rac19a0c  
    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/AddTransportForm.js

    re9b4ba9 rac19a0c  
    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/EditRoomForm.js

    re9b4ba9 rac19a0c  
    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                                 <th>Достапно од</th>
    45                                 <th>Достапно до</th>
    46                                 <th>Број на соби</th>
     46                                <th>Oд</th>
     47                                <th>До</th>
     48                                <th>Време на тргнување</th>
     49                                <th>Време на пристигнување</th>
     50                                <th>Цена</th>
    4751                            </tr>
    4852                            </thead>
  • frontend/src/Components/Hooks/Hotel/useCreateHotel.js

    re9b4ba9 rac19a0c  
    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

    re9b4ba9 rac19a0c  
    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/Transport/useCreateTransport.js

    re9b4ba9 rac19a0c  
    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

    re9b4ba9 rac19a0c  
    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/useGet.js

    re9b4ba9 rac19a0c  
    1212        console.log("url od get " + uurl)
    1313        await axios.
    14             get(uurl).then((res) => {
     14            get(uurl, {maxRedirects: 0}).then((res) => {
    1515                setData(res.data);
    16             }).catch((err) => {
    17                 console.log(err)
     16            }).catch((error) => {
     17                console.log(error)
    1818            })
    1919            .finally(() => {
     
    2626        getData(url);
    2727    }, [dep, url, changed]);
    28    
     28
    2929    return {
    3030        data,
  • frontend/src/Components/HotelEdit/HotelEditTab.js

    re9b4ba9 rac19a0c  
    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 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/Layout/Navbar/Navigation.js

    re9b4ba9 rac19a0c  
    77import useGet from "../../Hooks/useGet";
    88import axios from "../../../axios.js";
     9import {useAuth} from "../../Context/AuthContext";
    910//import logo from 'assets/images/logo.png';
    1011//src="https://upload.wikimedia.org/wikipedia/commons/0/08/Vergina_Sun_-_Golden_Larnax.png"
     
    1213function Navigation(props) {
    1314  const navigator = useNavigate();
    14 
    15   const { data, setData, isLoading, getData } = useGet("/username");
    16  
     15  const Auth = useAuth();
     16  const isLoggedIn = Auth.userIsAuthenticated();
    1717  return (
    1818    <>
     
    2424      >
    2525        <Container>
    26           <Navbar.Brand href="#home">
     26          <Navbar.Brand href="/home">
    2727            <span className="ikona">
    2828              <Image
     
    5050                Pricing
    5151              </Nav.Link>
    52               {!isLoading && !data && (
     52              {!isLoggedIn && (
    5353                <Button
    5454                  className="m-2"
     
    6262                </Button>
    6363              )}
    64               {!isLoading && data && (
     64              {isLoggedIn && (
    6565                <>
    6666                  <Nav.Link className="m-2" href="/profile">
    67                     {data}
     67                    {Auth.getUser().username}
    6868                  </Nav.Link>
    6969                  <Button
     
    7474                      await axios.get("/logout")
    7575                      .then((res) => {
    76                         console.log(res)
     76                        console.log(res);
     77                        Auth.userLogout();
    7778                      })
    7879                      .catch((err) => {
  • frontend/src/Components/Resources/AddNew.js

    re9b4ba9 rac19a0c  
    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

    re9b4ba9 rac19a0c  
    3131        </Modal.Header>
    3232        <Modal.Body>
    33             {props.type === "hotel" && <AddHotelForm/>}
     33            {props.type === "hotel" && <AddHotelForm refresh={props.refresh}/>}
    3434            {props.type === "room" && <EditRoomForm refresh={props.refresh} room={props.room}/>}
    3535            {props.type === "restaurant" && <AddRestaurantForm edit="false" refresh={props.refresh}/>}
  • frontend/src/Components/Resources/ResourceListing.js

    re9b4ba9 rac19a0c  
    66
    77const ResourceListing = (props) => {
    8  
    9     console.log("props " + props.id)
    10  
    118
    129    const type = props.type == "hotel" ? "сместувањето" : props.type == "restaurant" ? "ресторанот" : "превозот";
    1310    const name = props.type == "hotel" ? props.data.hotelName : props.type == "restaurant" ? props.data.restaurantName : props.data.transportName
    14     const id = props.type == "hotel" ? props.data.hotelId : props.type == "restaurant" ? props.data.resturantId : props.data.transportID
    15     return(<>
     11    const id = props.type == "hotel" ? props.data.hotelId : props.type == "restaurant" ? props.data.restaurantID : props.data.transportID
     12    console.log(props.data)
     13    return(<>
    1614    <a href={`${props.type}/${id}`} style={{textDecoration: "none", color:"black"}}>
    1715        <Container className="py-3 px-1 my-4"
  • frontend/src/Components/Resources/ResourcesTab.js

    re9b4ba9 rac19a0c  
    1111function ResourcesTab(props) {
    1212  const [activeTab, setActiveTab] = useState(props.tab);
    13   // const [changed, setChanged] = useState(0);
    14   const userId = localStorage.getItem("userId");
     13  const userId = JSON.parse(localStorage.getItem("user")).userId;
    1514  const { data, setData, isLoading, getData, setChanged } = useGet(`${props.tab}/user/${userId}`);
    1615
    1716  const handleSelect = (eventKey) => {
    1817    setActiveTab(eventKey);
    19     console.log(props.refresh);
    2018    props.refresh(eventKey);
    21     console.log("refresh" + eventKey);
    2219  };
    23 
    24   !isLoading && console.log(data);
    25   console.log(props.tab);
    2620
    2721  return (
     
    7872              data.map((hotel) => {
    7973                return (
    80                   <Link key={hotel.hotelId} to={"/resources/hotel/" + hotel.hotelId}>
     74                  <Link style={{textDecoration: "none"}} key={hotel.hotelId} to={"/resources/hotel/" + hotel.hotelId}>
    8175                    <ResourceListing
    8276                      key={hotel.hotelId}
     
    9387            {props.tab == "/restaurant" && !isLoading && data != null &&
    9488              data.map((restaurant) => {
    95                 console.log("mapiranje " + restaurant)
    9689                return (
    97                   <Link key={restaurant.restaurantId} to={"/resources/restaurant/" + restaurant.restaurantID}>
    9890                    <ResourceListing
    99                       key={restaurant.restaurantId}
     91                      key={restaurant.restaurantID}
    10092                      type="restaurant"
    10193                      data={restaurant}
    102                     />
    103                   </Link>
    104                 );
     94                    />);
    10595              })}
    10696            <AddNew type="restaurant" refresh={setChanged}/>
  • frontend/src/Components/RestaurantEdit/RestaurantEditTab.js

    re9b4ba9 rac19a0c  
    100100              return <MenuListing key={menu.menuId} data={menu} showModal={showModal}/>
    101101            })}
    102             {activeTab === '/hotel' && <EditModal show={show} handleClose={handleClose} type="menu" menu={modalData}></EditModal>}
     102            {activeTab === '/hotel' && <EditModal show={show} refresh={props.refresh} handleClose={handleClose} type="menu" menu={modalData}></EditModal>}
    103103            <AddNew Id={props.displayMenu.restaurantID} refresh={props.refresh} type="menu"/>
    104104          </Tab.Pane>
  • frontend/src/Components/SearchCriterias/SearchCriteriasBar.js

    re9b4ba9 rac19a0c  
    22import { Container, Form, Button, Row, Col } from "react-bootstrap";
    33import useFormData from "../Hooks/useFormData";
     4import SearchCriteriasHotel from "./SearchCriteriasHotel";
     5import SearchCriteriasTransport from "./SearchCriteriasTransport";
    46
    5 const SearchCriterias = (props) => {
     7const SearchCriteriasBar = (props) => {
    68
    7   const { formData, onFormChange, onCheckBoxChange, setFormData} = useFormData(props.criterias)
    8   console.log("KRITERIUMI")
    9   console.log(formData)
     9    const { criterias, type } = props
    1010
    11   return (
    12     <>
    13       <Container
    14         className="p-1 pb-0 mb-5 mt-3 rounded-2"
    15         style={{ backgroundColor: "#002B5B", width: "65%"}}
    16       >
    17         <Form className="rounded-5">
    18           <Row className="gx-1">
    19             <Col>
    20               <Form.Floating className="mb-3">
    21                 <Form.Control
    22                   size="md"
    23                   type="text"
    24                   placeholder="Каде ќе патувате?:"
    25                   id="location"
    26                   name="hotelLocation"
    27                   onChange={onFormChange}
    28                   value={formData.hotelLocation}
    29                 ></Form.Control>
    30                 <label htmlFor="location">Локација:</label>
    31               </Form.Floating>
    32             </Col>
    33             <Col>
    34               <Form.Floating className="mb-3">
    35                 <Form.Control
    36                   size="md"
    37                   type="date"
    38                   placeholder="Датум на пристигнување:"
    39                   id="dateFrom"
    40                   name="dateFrom"
    41                   onChange={onFormChange}
    42                   value={formData.dateFrom}
    43                 ></Form.Control>
    44                 <label htmlFor="dateFrom">Датум на пристигнување:</label>
    45               </Form.Floating>
    46             </Col>
    47             <Col>
    48               <Form.Floating className="mb-3">
    49                 <Form.Control
    50                   size="md"
    51                   type="date"
    52                   placeholder="Датум на заминување:"
    53                   id="dateTo"
    54                   name="dateTo"
    55                   onChange={onFormChange}
    56                   value={formData.dateTo}
    57                 ></Form.Control>
    58                 <label htmlFor="dateTo">Датум на заминување:</label>
    59               </Form.Floating>
    60             </Col>
    61             <Col>
    62               <Form.Floating className="mb-3">
    63                 <Form.Control
    64                   size="md"
    65                   type="number"
    66                   placeholder="Број на гости:"
    67                   id="floatingPassengers"
    68                   name="numBeds"
    69                   onChange={onFormChange}
    70                   value={formData.numBeds}
    71                 ></Form.Control>
    72                 <label htmlFor="floatingPassengers">Број на гости:</label>
    73               </Form.Floating>
    74             </Col>
    75             <Col>
    76               <Form.Group className="my-1">
    77                 <Button
    78                   type="submit"
    79                   style={{ backgroundColor: "#159895" }}
    80                   size="lg"
    81                   className="w-100"
    82                   onClick={(e) => {
    83                     e.preventDefault();
    84                     window.location.href = `/search/hotel/${formData.hotelLocation}/${formData.dateFrom}/${formData.dateTo}/${formData.numBeds}`
    85                   }}
    86                 >
    87                   <span className="ikona mx-3">Пребарај</span>
    88                 </Button>
    89               </Form.Group>
    90             </Col>
    91           </Row>
    92         </Form>
    93       </Container>
    94     </>
    95   );
    96 };
     11    return (
     12        <>
     13            {type === 'hotel' && <SearchCriteriasHotel criterias={criterias}/>}
     14            {type === 'transport' && <SearchCriteriasTransport criterias={criterias}/>}
     15        </>
     16    )
     17}
    9718
    98 export default SearchCriterias;
     19export default SearchCriteriasBar;
  • frontend/src/Components/Tab/TabFormTransport.js

    re9b4ba9 rac19a0c  
    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

    re9b4ba9 rac19a0c  
    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

    re9b4ba9 rac19a0c  
    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

    re9b4ba9 rac19a0c  
    1717    <>
    1818      <Row className="d-flex flex-row gap-0">
    19       {props.left === "true" && <Col className="d-flex flex-column justify-content-center col-auto" style={{paddingLeft: "2.6rem"}}>
     19      {props.left === "true" && <Col className="d-flex flex-column justify-content-center col-md-4" style={{paddingLeft: "2.6rem"}}>
    2020            <h5 style={{color: props.routes === "true" ? "white" : "" }} className="m-auto">{getTimeAsString(props.time)}</h5>
    2121        </Col>}
     
    3030        </Col>}
    3131      </Row>
    32       <Row>
    33       <Line left={props.left}> </Line>
    34       </Row>
     32        <Row className="d-flex flex-row gap-0">
     33            {props.left === "true" && <Col className="d-flex flex-column justify-content-center col-md-4" style={{paddingLeft: "2.6rem"}}>
     34
     35            </Col>}
     36            <Col md="auto">
     37                <Line left={props.left}> </Line>
     38            </Col>
     39            <Col className="d-flex flex-column justify-content-center">
     40            </Col>
     41            {props.left !== "true" && <Col className="d-flex flex-column justify-content-center">
     42
     43            </Col>}
     44        </Row>
     45      {/*<Row>*/}
     46      {/*<Line left={props.left}> </Line>*/}
     47      {/*</Row>*/}
    3548    </>
    3649  );
  • frontend/src/Components/TransportEdit/TransportEditTab.js

    re9b4ba9 rac19a0c  
    1212function TransportEditTab(props) {
    1313  const [activeTab, setActiveTab] = useState("/hotel");
    14   const link = "/transport/" + props.displayRoute.transportID + "/available";
    1514  console.log(props.displayRoute)
    16   const [changed, setChanged] = useState(0)
    17   const { data, setData, isLoading, getData } = useGet(link, changed);
    1815
    1916
  • frontend/src/Components/TransportEdit/TransportListing.js

    re9b4ba9 rac19a0c  
    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/useFormNested.js

    re9b4ba9 rac19a0c  
    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
Note: See TracChangeset for help on using the changeset viewer.