Changeset 5528b99 for frontend/src/Components/Hooks
- Timestamp:
- 01/16/24 16:34:03 (10 months ago)
- Branches:
- master
- Children:
- 07f4e8b
- Parents:
- e6c2521
- Location:
- frontend/src/Components/Hooks
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
frontend/src/Components/Hooks/Hotel/useCreateHotel.js
re6c2521 r5528b99 6 6 const useCreateHotel = () => { 7 7 8 //const history = useNavigate(); 8 9 const createHotel = async (hotel, edit) => { 9 10 console.log({hotel}) 10 11 console.log(hotel) 11 console.log("vo createhotel")12 12 13 13 if(!edit) … … 16 16 .post(`/hotel/add`, hotel, { 17 17 params: { 18 userId: JSON.parse(localStorage.getItem("user")).userId18 userId: localStorage.getItem("userId") 19 19 } 20 20 }) -
frontend/src/Components/Hooks/Restaurant/useCreateRestaurant.js
re6c2521 r5528b99 15 15 .post(`/restaurant/add`, restaurant, { 16 16 params: { 17 userId: JSON.parse(localStorage.getItem('user')).userId,17 userId: localStorage.getItem('userId') 18 18 } 19 19 }) -
frontend/src/Components/Hooks/Transport/useCreateTransport.js
re6c2521 r5528b99 4 4 5 5 const useCreateTransport = () => { 6 const userId = JSON.parse(localStorage.getItem('user')).userId 6 7 7 const createTransport = async (transport, edit) => { 8 8 if(!edit) 9 9 { 10 10 await axios 11 .post(`/transport/add /` + userId, transport)11 .post(`/transport/add`, transport) 12 12 .then((res) => { 13 13 //history.push('/transport'); -
frontend/src/Components/Hooks/User/useLogin.js
re6c2521 r5528b99 4 4 import { Navigate, useAsyncValue, useNavigate } from "react-router-dom"; 5 5 import LoginForm from "../../Login/LoginForm.js"; 6 import {useAuth} from "../../Context/AuthContext";7 6 8 7 const useLogin = () => { 9 8 10 9 const navigator = useNavigate() 11 const Auth = useAuth();12 10 //const history = useNavigate(); 13 11 const login = async (loginData) => { … … 24 22 }) 25 23 .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 }41 24 const sessionId = res.data.auth.details.sessionId; 42 25 const userId = res.data.auth.principal.userID; 43 26 44 27 localStorage.setItem("sessionId", sessionId); 45 28 localStorage.setItem("userId", userId); -
frontend/src/Components/Hooks/useGet.js
re6c2521 r5528b99 11 11 console.log(localStorage.getItem("sessionId")) 12 12 console.log("url od get " + uurl) 13 <<<<<<< HEAD 13 14 await axios.get(uurl, {maxRedirects: 0}).then((res) => { 14 15 console.log(res); … … 22 23 // window.location.href = '/error' 23 24 }) 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) 24 33 .finally(() => { 25 34 setIsLoading(false); … … 31 40 getData(url); 32 41 }, [dep, url, changed]); 33 42 34 43 return { 35 44 data,
Note:
See TracChangeset
for help on using the changeset viewer.