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

Last change on this file since 0f5aa27 was 07f4e8b, checked in by darsov2 <62809499+darsov2@…>, 10 months ago

prefinal fixes

  • 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.