[e6c2521] | 1 | import React, {useTransition} 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 {MdRestaurant} from "react-icons/md";
|
---|
| 6 | import AddNew from "./AddNew";
|
---|
| 7 | import ResourceListing from "./ResourceListing";
|
---|
| 8 | import {Link} from "react-router-dom";
|
---|
| 9 | import useGet from "../Hooks/useGet";
|
---|
| 10 |
|
---|
| 11 | function ResourcesTab(props) {
|
---|
[5528b99] | 12 | <<<<<<< HEAD
|
---|
[e6c2521] | 13 | const [activeTab, setActiveTab] = useState(props.tab);
|
---|
| 14 | const userId = JSON.parse(localStorage.getItem("user")).userId;
|
---|
| 15 | const {data, setData, isLoading, getData, setChanged} = useGet(`${props.tab}/user/${userId}`);
|
---|
| 16 |
|
---|
| 17 | const handleSelect = (eventKey) => {
|
---|
| 18 | setActiveTab(eventKey);
|
---|
| 19 | props.refresh(eventKey);
|
---|
| 20 | };
|
---|
| 21 |
|
---|
| 22 | return (
|
---|
| 23 | <Container className="rounded-5">
|
---|
| 24 | <Tab.Container
|
---|
| 25 | activeKey={activeTab}
|
---|
| 26 | onSelect={handleSelect}
|
---|
| 27 | className="bg-dark rounded-5"
|
---|
| 28 | >
|
---|
| 29 | <Nav
|
---|
| 30 | fill
|
---|
| 31 | variant="tabs"
|
---|
| 32 | className="bg-body rounded-top-5"
|
---|
| 33 | activeKey="/hotel"
|
---|
| 34 | id="tab_item"
|
---|
| 35 | >
|
---|
| 36 | <Nav.Item className="tab_item rounded-5">
|
---|
| 37 | <Nav.Link href="/resources/hotel" className="text-left rounded-5">
|
---|
[5528b99] | 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)
|
---|
[e6c2521] | 71 | <span className="ikona">
|
---|
| 72 | <FaHotel
|
---|
| 73 | color="#159895"
|
---|
| 74 | style={{lineHeight: "100em"}}
|
---|
| 75 | size={"1.5em"}
|
---|
| 76 | className="mx-3"
|
---|
| 77 | />
|
---|
| 78 | </span>
|
---|
| 79 | <span className="ikona">Сместувања</span>
|
---|
| 80 | </Nav.Link>
|
---|
| 81 | </Nav.Item>
|
---|
| 82 | <Nav.Item className="tab_item">
|
---|
| 83 | <Nav.Link href="/resources/restaurant">
|
---|
| 84 | <span className="ikona">
|
---|
| 85 | <MdRestaurant color="#159895" size={"1.5em"} className="mx-3"/>
|
---|
| 86 | </span>
|
---|
| 87 | <span className="ikona">Ресторани</span>
|
---|
| 88 | </Nav.Link>
|
---|
| 89 | </Nav.Item>
|
---|
| 90 | <Nav.Item className="tab_item rounded-5">
|
---|
| 91 | <Nav.Link
|
---|
| 92 | href="/resources/transport"
|
---|
| 93 | className="text-left rounded-5"
|
---|
| 94 | >
|
---|
| 95 | <span className="ikona">
|
---|
| 96 | <FaTaxi color="#159895" size={"1.5em"} className="mx-3"/>
|
---|
| 97 | </span>
|
---|
| 98 | <span className="ikona">Превоз</span>
|
---|
| 99 | </Nav.Link>
|
---|
| 100 | </Nav.Item>
|
---|
| 101 | </Nav>
|
---|
| 102 |
|
---|
[5528b99] | 103 | <<<<<<< HEAD
|
---|
[e6c2521] | 104 | <Tab.Content className="py-5 px-3 border rounded-bottom-5 bg-light">
|
---|
| 105 | <Tab.Pane eventKey="/hotel" key="hotelPane">
|
---|
| 106 | {props.tab == "/hotel" && !isLoading && data != null &&
|
---|
| 107 | data.map((hotel) => {
|
---|
| 108 | return (
|
---|
| 109 | //<Link style={{textDecoration: "none"}} key={hotel.hotelId} to={"/resources/hotel/" + hotel.hotelId}>
|
---|
| 110 | <ResourceListing
|
---|
| 111 | on
|
---|
| 112 | key={hotel.hotelId}
|
---|
| 113 | id={hotel.hotelId}
|
---|
| 114 | type="hotel"
|
---|
| 115 | data={hotel}
|
---|
| 116 | />
|
---|
| 117 | //</Link>
|
---|
| 118 | );
|
---|
| 119 | })}
|
---|
| 120 | <AddNew type="hotel" refresh={setChanged}/>
|
---|
| 121 | </Tab.Pane>
|
---|
| 122 | <Tab.Pane eventKey="/restaurant" key="restaurantPane">
|
---|
| 123 | {props.tab == "/restaurant" && !isLoading && data != null &&
|
---|
| 124 | data.map((restaurant) => {
|
---|
| 125 | return (
|
---|
| 126 | <ResourceListing
|
---|
| 127 | key={restaurant.restaurantID}
|
---|
| 128 | type="restaurant"
|
---|
| 129 | data={restaurant}
|
---|
| 130 | />);
|
---|
| 131 | })}
|
---|
| 132 | <AddNew type="restaurant" refresh={setChanged}/>
|
---|
| 133 | </Tab.Pane>
|
---|
| 134 | <Tab.Pane eventKey="/transport" key="transportPane">
|
---|
| 135 | {props.tab == "/transport" && !isLoading && data.length > 0 &&
|
---|
| 136 | data.map((transport) => {
|
---|
| 137 | return (
|
---|
| 138 | <ResourceListing
|
---|
| 139 | key={transport.transportId}
|
---|
| 140 | id={transport.transportId}
|
---|
| 141 | type="transport"
|
---|
| 142 | data={transport}
|
---|
| 143 | />
|
---|
| 144 | );
|
---|
| 145 | })}
|
---|
| 146 | <AddNew type="transport" refresh={setChanged}/>
|
---|
| 147 | </Tab.Pane>
|
---|
| 148 | </Tab.Content>
|
---|
| 149 | </Tab.Container>
|
---|
| 150 | </Container>
|
---|
| 151 | );
|
---|
[5528b99] | 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)
|
---|
[e6c2521] | 205 | }
|
---|
| 206 |
|
---|
| 207 | export default ResourcesTab;
|
---|