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/Hooks
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • 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,
Note: See TracChangeset for help on using the changeset viewer.