Last change
on this file since 5528b99 was 5528b99, checked in by darsov2 <62809499+darsov2@…>, 9 months ago |
revert
|
-
Property mode
set to
100644
|
File size:
783 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 |
|
---|
[5528b99] | 8 | //const history = useNavigate();
|
---|
[e6c2521] | 9 | const createHotel = async (hotel, edit) => {
|
---|
| 10 | console.log({hotel})
|
---|
| 11 | console.log(hotel)
|
---|
| 12 |
|
---|
| 13 | if(!edit)
|
---|
| 14 | {
|
---|
| 15 | await axios
|
---|
| 16 | .post(`/hotel/add`, hotel, {
|
---|
| 17 | params: {
|
---|
[5528b99] | 18 | userId: localStorage.getItem("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.