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