import { useState } from 'react'; import { useLocation } from 'react-router-dom'; import FormBox from '../components/FormBox'; import Button from '../components/Button'; import Notification from '../components/Notification'; import { lockerService } from '../services/locker.service'; import { useToast } from '../hooks/useToast'; import { useLoading } from '../hooks/useLoading'; function CheckInOutLog() { const [time, setTime] = useState(null); const [checkType, setCheckType] = useState(''); const [notification, setNotification] = useState({ message: '', type: '' }); const location = useLocation(); const showToast = useToast(); const { setIsLoading } = useLoading(); const accountNumber = location.state?.accountNumber; const handleSubmit = async (e) => { e.preventDefault(); if (time === null || checkType === '') { showToast('Please fill in all fields', 'error'); return; } // Add your logic here try { setIsLoading(true); const response = await lockerService.checkInOut(accountNumber, time, checkType); if (response.status === 200) { setNotification({ message: response.data.message, type: 'success' }); } else { console.log(response); setNotification({ message: response.data.message, type: 'error' }); } } catch (error) { console.log(error); setNotification({ message: error.message, type: 'error' }); } finally { setIsLoading(false); } }; return (