Last change
on this file since efaa053 was 07f4e8b, checked in by darsov2 <62809499+darsov2@…>, 15 months ago |
prefinal fixes
|
-
Property mode
set to
100644
|
File size:
1009 bytes
|
Line | |
---|
1 | import React from "react";
|
---|
2 | import axios from "../../../axios";
|
---|
3 | import { useNavigate } from 'react-router-dom';
|
---|
4 |
|
---|
5 | const useCreateRestaurant = () => {
|
---|
6 |
|
---|
7 | const navigator = useNavigate();
|
---|
8 |
|
---|
9 | const createRestaurant = async (restaurant, edit) => {
|
---|
10 | console.log(restaurant)
|
---|
11 | if(!edit)
|
---|
12 | {
|
---|
13 | console.log(restaurant)
|
---|
14 | await axios
|
---|
15 | .post(`/restaurant/add`, restaurant, {
|
---|
16 | params: {
|
---|
17 | userId: JSON.parse(localStorage.getItem('user')).userId,
|
---|
18 | }
|
---|
19 | })
|
---|
20 | .then((res) => {
|
---|
21 | // console.log(res)
|
---|
22 | // window.location.reload()
|
---|
23 | })
|
---|
24 | .catch((err) => {
|
---|
25 | console.log(err);
|
---|
26 | })
|
---|
27 | .finally(() => {
|
---|
28 | });
|
---|
29 | }
|
---|
30 | else
|
---|
31 | {
|
---|
32 | await axios
|
---|
33 | .post(`/restaurant/edit`, restaurant)
|
---|
34 | .then((res) => {
|
---|
35 | console.log(res)
|
---|
36 | //window.location.reload()
|
---|
37 | //navigator("/resources/restaurant")
|
---|
38 | //history.push('/restaurant');
|
---|
39 | })
|
---|
40 | .catch((err) => {
|
---|
41 | console.log(err);
|
---|
42 | })
|
---|
43 | .finally(() => {
|
---|
44 | });
|
---|
45 | }
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | return {
|
---|
50 | createRestaurant
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | export default useCreateRestaurant; |
---|
Note:
See
TracBrowser
for help on using the repository browser.