source: sources/client/src/hooks/useGetSessionOverInfo.js

Last change on this file was bc20307, checked in by Tasevski2 <39170279+Tasevski2@…>, 2 years ago

Push before video

  • Property mode set to 100644
File size: 1009 bytes
Line 
1import { useState } from 'react';
2import axios from 'axios';
3
4const useGetSessionOverInfo = () => {
5 const [isLoading, setIsLoading] = useState(false);
6 const [totalPrice, setTotalPrice] = useState(null);
7
8 const getSessionInfoOver = async () => {
9 setIsLoading(true);
10 await axios
11 .get(`/parkingSession/end/calculate`)
12 .then((res) => {
13 // setTimeAndSessionPrice({totalTime: res.data.totalTime, totalPrice: res.data.totalPrice});
14 setTotalPrice(res.data);
15 })
16 .catch((err) => {
17 // setAlert({
18 // type: 'error',
19 // msg: 'Проблеми со серверот!', // TODO change msg to err.message
20 // });
21 })
22 .finally(() => {
23 setIsLoading(false);
24 });
25 };
26
27 return {
28 getSessionInfoOver,
29 isLoading,
30 totalPrice,
31 };
32};
33
34export default useGetSessionOverInfo;
Note: See TracBrowser for help on using the repository browser.