Last change
on this file since 747e0ab was bc20307, checked in by Tasevski2 <39170279+Tasevski2@…>, 3 years ago |
Push before video
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | import { useContext } from 'react';
|
---|
2 | import axios from 'axios';
|
---|
3 | import { AccessoriesContext } from '../context/AccessoriesContext';
|
---|
4 |
|
---|
5 | const useUpdateUserProfile = () => {
|
---|
6 | const { setAlert, setIsBackdropLoaderOpen } =
|
---|
7 | useContext(AccessoriesContext);
|
---|
8 | const updateUserProfile = async ({ userData, id, successfulSave }) => {
|
---|
9 | setIsBackdropLoaderOpen(true);
|
---|
10 | await axios
|
---|
11 | .put(`/registriranParkirac/${id}`, userData)
|
---|
12 | .then((res) => {
|
---|
13 | setAlert({
|
---|
14 | type: 'success',
|
---|
15 | msg: `Успешно ажурирање на податоците!`,
|
---|
16 | });
|
---|
17 | successfulSave();
|
---|
18 | })
|
---|
19 | .catch((err) => {
|
---|
20 | // ALERT FOR ERROR WITH ERROR MSG
|
---|
21 | setAlert({
|
---|
22 | type: 'error',
|
---|
23 | msg: 'Проблеми со серверот!', // TODO change msg to err.message
|
---|
24 | });
|
---|
25 | })
|
---|
26 | .finally(() => {
|
---|
27 | setIsBackdropLoaderOpen(false);
|
---|
28 | });
|
---|
29 | };
|
---|
30 |
|
---|
31 | return {
|
---|
32 | updateUserProfile,
|
---|
33 | };
|
---|
34 | };
|
---|
35 |
|
---|
36 | export default useUpdateUserProfile;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.