Last change
on this file since efaa053 was 07f4e8b, checked in by darsov2 <62809499+darsov2@…>, 8 months ago |
prefinal fixes
|
-
Property mode
set to
100644
|
File size:
795 bytes
|
Rev | Line | |
---|
[e6c2521] | 1 | import React from "react";
|
---|
| 2 |
|
---|
| 3 | import axios from "../../../axios.js";
|
---|
| 4 | import { useNavigate } from "react-router-dom";
|
---|
| 5 |
|
---|
| 6 | const useCreateHotel = () => {
|
---|
| 7 |
|
---|
| 8 | const createHotel = async (hotel, edit) => {
|
---|
| 9 | console.log({hotel})
|
---|
| 10 | console.log(hotel)
|
---|
[07f4e8b] | 11 | console.log("vo createhotel")
|
---|
[e6c2521] | 12 |
|
---|
| 13 | if(!edit)
|
---|
| 14 | {
|
---|
| 15 | await axios
|
---|
| 16 | .post(`/hotel/add`, hotel, {
|
---|
| 17 | params: {
|
---|
[07f4e8b] | 18 | userId: JSON.parse(localStorage.getItem("user")).userId
|
---|
[e6c2521] | 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 |
|
---|
| 51 | export default useCreateHotel; |
---|
Note:
See
TracBrowser
for help on using the repository browser.