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