Compare commits
No commits in common. "6218b6f5d8c2af6e112232920e16ef597726aab1" and "9f530204faf6275fd2607d437a8a99092a309df7" have entirely different histories.
6218b6f5d8
...
9f530204fa
@ -77,6 +77,5 @@
|
||||
"dry-wash.notFound.button.back": "Back to Home",
|
||||
"dry-wash.errorBoundary.title": "Something went wrong",
|
||||
"dry-wash.errorBoundary.description": "We are already working on fixing the issue",
|
||||
"dry-wash.errorBoundary.button.reload": "Reload Page",
|
||||
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}"
|
||||
"dry-wash.errorBoundary.button.reload": "Reload Page"
|
||||
}
|
||||
|
@ -8,14 +8,8 @@ enum ArmEndpoints {
|
||||
const armService = () => {
|
||||
const endpoint = getConfigValue('dry-wash.api');
|
||||
|
||||
const fetchOrders = async ({ date }: { date: Date }) => {
|
||||
const response = await fetch(`${endpoint}${ArmEndpoints.ORDERS}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ date }),
|
||||
});
|
||||
const fetchOrders = async () => {
|
||||
const response = await fetch(`${endpoint}${ArmEndpoints.ORDERS}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch orders: ${response.status}`);
|
||||
|
@ -1,31 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Box, Button, Text } from '@chakra-ui/react';
|
||||
import { ArrowBackIcon, ArrowForwardIcon } from '@chakra-ui/icons';
|
||||
|
||||
interface DateNavigatorProps {
|
||||
currentDate: Date;
|
||||
onPreviousDate: () => void;
|
||||
onNextDate: () => void;
|
||||
}
|
||||
|
||||
const DateNavigator = ({
|
||||
currentDate,
|
||||
onPreviousDate,
|
||||
onNextDate,
|
||||
}: DateNavigatorProps) => {
|
||||
return (
|
||||
<Box display='flex' alignItems='center' justifyContent='flex-start' mb='5'>
|
||||
<Button onClick={onPreviousDate}>
|
||||
<ArrowBackIcon />
|
||||
</Button>
|
||||
<Text mx='4' fontSize='lg' fontWeight='bold'>
|
||||
{currentDate.toLocaleDateString()}
|
||||
</Text>
|
||||
<Button onClick={onNextDate}>
|
||||
<ArrowForwardIcon />
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default DateNavigator;
|
@ -1 +0,0 @@
|
||||
export { default } from './DateNavigator';
|
@ -13,12 +13,10 @@ import {
|
||||
useToast,
|
||||
} from '@chakra-ui/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import OrderItem from '../OrderItem';
|
||||
import { OrderProps } from '../OrderItem/OrderItem';
|
||||
import { armService } from '../../api/arm';
|
||||
import DateNavigator from '../DateNavigator';
|
||||
|
||||
const TABLE_HEADERS = [
|
||||
'carNumber' as const,
|
||||
@ -41,14 +39,13 @@ const Orders = () => {
|
||||
const [orders, setOrders] = useState<OrderProps[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [currentDate, setCurrentDate] = useState(new Date());
|
||||
|
||||
useEffect(() => {
|
||||
const loadOrders = async () => {
|
||||
setLoading(true);
|
||||
|
||||
try {
|
||||
const data = await fetchOrders({ date: currentDate });
|
||||
const data = await fetchOrders();
|
||||
setOrders(data.body);
|
||||
} catch (err) {
|
||||
setError(err.message);
|
||||
@ -65,26 +62,13 @@ const Orders = () => {
|
||||
};
|
||||
|
||||
loadOrders();
|
||||
}, [toast, t, currentDate]);
|
||||
}, [toast, t]);
|
||||
|
||||
return (
|
||||
<Box p='8'>
|
||||
<Heading size='lg' mb='5'>
|
||||
{t('title')}
|
||||
</Heading>
|
||||
|
||||
<DateNavigator
|
||||
currentDate={currentDate}
|
||||
onPreviousDate={() =>
|
||||
setCurrentDate((prevDate) =>
|
||||
dayjs(prevDate).subtract(1, 'day').toDate(),
|
||||
)
|
||||
}
|
||||
onNextDate={() =>
|
||||
setCurrentDate((prevDate) => dayjs(prevDate).add(1, 'day').toDate())
|
||||
}
|
||||
/>
|
||||
|
||||
<Table variant='simple' colorScheme='blackAlpha'>
|
||||
<Thead>
|
||||
<Tr>
|
||||
|
@ -2,15 +2,11 @@ import React from 'react';
|
||||
import { Text, Button, Center, VStack, Heading } from '@chakra-ui/react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Player } from '@lottiefiles/react-lottie-player';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import i18next from 'i18next';
|
||||
|
||||
import animate from '../../assets/animation/notFound.json';
|
||||
|
||||
const NotFound = () => {
|
||||
const { t } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash',
|
||||
});
|
||||
|
||||
return (
|
||||
<Center minH='100vh'>
|
||||
<VStack spacing={4} textAlign='center'>
|
||||
@ -25,8 +21,12 @@ const NotFound = () => {
|
||||
maxWidth: '450px',
|
||||
}}
|
||||
/>
|
||||
<Heading fontSize='xl'>{t(`notFound.title`)}</Heading>
|
||||
<Text fontSize='lg'>{t(`notFound.description`)}</Text>
|
||||
<Heading fontSize='xl'>
|
||||
{i18next.t(`dry-wash.arm.notFound.title`)}
|
||||
</Heading>
|
||||
<Text fontSize='lg'>
|
||||
{i18next.t(`dry-wash.arm.notFound.description`)}
|
||||
</Text>
|
||||
<Button
|
||||
as={Link}
|
||||
to='/dry-wash'
|
||||
@ -34,7 +34,7 @@ const NotFound = () => {
|
||||
size='lg'
|
||||
variant='outline'
|
||||
>
|
||||
{t(`notFound.button.back`)}
|
||||
{i18next.t(`dry-wash.arm.notFound.button.back`)}
|
||||
</Button>
|
||||
</VStack>
|
||||
</Center>
|
||||
|
@ -23,7 +23,7 @@ router.get('/arm/masters', (req, res) => {
|
||||
);
|
||||
});
|
||||
|
||||
router.post('/arm/orders', (req, res) => {
|
||||
router.get('/arm/orders', (req, res) => {
|
||||
res
|
||||
.status(/error/.test(STUBS.orders) ? 500 : 200)
|
||||
.send(
|
||||
|
Loading…
Reference in New Issue
Block a user