source: frontend/src/Components/Hooks/Hotel/useCreateHotel.js@ ac19a0c

Last change on this file since ac19a0c was ac19a0c, checked in by darsov2 <62809499+darsov2@…>, 6 months ago

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

  • Property mode set to 100644
File size: 795 bytes
Line 
1import React from "react";
2
3import axios from "../../../axios.js";
4import { useNavigate } from "react-router-dom";
5
6const useCreateHotel = () => {
7
8 const createHotel = async (hotel, edit) => {
9 console.log({hotel})
10 console.log(hotel)
11 console.log("vo createhotel")
12
13 if(!edit)
14 {
15 await axios
16 .post(`/hotel/add`, hotel, {
17 params: {
18 userId: JSON.parse(localStorage.getItem("user")).userId
19 }
20 })
21 .then((res) => {
22 //history.push('/hotel');
23 })
24 .catch((err) => {
25 console.log(err);
26 })
27 .finally(() => {
28 });
29 }
30 else
31 {
32 await axios
33 .post(`/hotel/edit`, hotel)
34 .then((res) => {
35 })
36 .catch((err) => {
37 console.log(err);
38 })
39 .finally(() => {
40 });
41 }
42
43 }
44
45 return {
46 createHotel
47 };
48
49}
50
51export default useCreateHotel;
Note: See TracBrowser for help on using the repository browser.