source: frontend/src/Components/Hooks/Transport/useCreateTransport.js@ 0f5aa27

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

prefinal fixes

  • Property mode set to 100644
File size: 1021 bytes
Line 
1import React from "react";
2import axios from "../../../axios";
3import { useHistory } from 'react-router-dom';
4
5const 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
44export default useCreateTransport;
Note: See TracBrowser for help on using the repository browser.