Compare commits
19 Commits
fix/arm-or
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
351420bc62 | ||
|
61b042eee6 | ||
|
ac006267a2 | ||
|
63d9d069c0 | ||
c83ebf02bc | |||
|
1968df7bb3 | ||
|
811e0e3f24 | ||
a2ffd6f38f | |||
|
20017cad3c | ||
|
de54ac6669 | ||
|
eda869622e | ||
|
7b3889aa02 | ||
|
cee124fca5 | ||
|
b77eccc8e8 | ||
|
ebfaa7ea8f | ||
|
0027cc09b1 | ||
|
dd612d662c | ||
|
69251745fa | ||
|
253e3b3856 |
@ -64,7 +64,7 @@
|
|||||||
"dry-wash.arm.order.status.complete": "Completed",
|
"dry-wash.arm.order.status.complete": "Completed",
|
||||||
"dry-wash.arm.order.status.pending": "Pending",
|
"dry-wash.arm.order.status.pending": "Pending",
|
||||||
"dry-wash.arm.order.status.working": "Working",
|
"dry-wash.arm.order.status.working": "Working",
|
||||||
"dry-wash.arm.order.status.cancelled": "Canceled",
|
"dry-wash.arm.order.status.canceled": "Canceled",
|
||||||
"dry-wash.arm.order.status.placeholder": "Select status",
|
"dry-wash.arm.order.status.placeholder": "Select status",
|
||||||
"dry-wash.arm.order.master.placeholder": "Select master",
|
"dry-wash.arm.order.master.placeholder": "Select master",
|
||||||
"dry-wash.arm.order.table.header.carNumber": "Car Number",
|
"dry-wash.arm.order.table.header.carNumber": "Car Number",
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"dry-wash.arm.order.status.complete": "Завершено",
|
"dry-wash.arm.order.status.complete": "Завершено",
|
||||||
"dry-wash.arm.order.status.pending": "В ожидании",
|
"dry-wash.arm.order.status.pending": "В ожидании",
|
||||||
"dry-wash.arm.order.status.working": "В работе",
|
"dry-wash.arm.order.status.working": "В работе",
|
||||||
"dry-wash.arm.order.status.cancelled": "Отменено",
|
"dry-wash.arm.order.status.canceled": "Отменено",
|
||||||
"dry-wash.arm.order.status.placeholder": "Выберите статус",
|
"dry-wash.arm.order.status.placeholder": "Выберите статус",
|
||||||
"dry-wash.arm.order.master.placeholder": "Выберите мастера",
|
"dry-wash.arm.order.master.placeholder": "Выберите мастера",
|
||||||
"dry-wash.arm.order.table.header.carNumber": "Номер машины",
|
"dry-wash.arm.order.table.header.carNumber": "Номер машины",
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
import { Box, Button, Heading, HStack, Divider, Flex } from '@chakra-ui/react';
|
|
||||||
import React from 'react';
|
|
||||||
import { useLocation, Link } from 'react-router-dom';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
import { URLs } from '../../__data__/urls';
|
|
||||||
|
|
||||||
const Header = () => {
|
|
||||||
const location = useLocation();
|
|
||||||
const isActive = (keyword: string) => location.pathname.includes(keyword);
|
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
|
||||||
keyPrefix: 'dry-wash.arm.master.sideBar',
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box as='header' bg='gray.50' boxShadow='md' px={6} py={4} w='100%'>
|
|
||||||
<Flex gap={50} align='center'>
|
|
||||||
<Heading color='green' size='lg'>
|
|
||||||
{t('title')}
|
|
||||||
</Heading>
|
|
||||||
<HStack spacing={4}>
|
|
||||||
{URLs.armOrder.isOn && (
|
|
||||||
<Button
|
|
||||||
as={Link}
|
|
||||||
to={URLs.armOrder.url}
|
|
||||||
colorScheme={isActive(URLs.armOrder.url) ? 'green' : 'blue'}
|
|
||||||
variant={isActive(URLs.armOrder.url) ? 'outline' : 'ghost'}
|
|
||||||
>
|
|
||||||
{t('orders')}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
<Divider orientation='vertical' height='30px' />
|
|
||||||
{URLs.armMaster.isOn && (
|
|
||||||
<Button
|
|
||||||
as={Link}
|
|
||||||
to={URLs.armMaster.url}
|
|
||||||
colorScheme={isActive(URLs.armMaster.url) ? 'green' : 'blue'}
|
|
||||||
variant={isActive(URLs.armMaster.url) ? 'outline' : 'ghost'}
|
|
||||||
data-testid='master-button'
|
|
||||||
>
|
|
||||||
{t('master')}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</HStack>
|
|
||||||
</Flex>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Header;
|
|
@ -1 +0,0 @@
|
|||||||
export { default } from './Header';
|
|
@ -2,10 +2,10 @@ import { Box, Flex } from '@chakra-ui/react';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||||
|
|
||||||
|
import Sidebar from '../Sidebar';
|
||||||
import Orders from '../Orders';
|
import Orders from '../Orders';
|
||||||
import Masters from '../Masters';
|
import Masters from '../Masters';
|
||||||
import { URLs } from '../../__data__/urls';
|
import { URLs } from '../../__data__/urls';
|
||||||
import Header from '../Header';
|
|
||||||
|
|
||||||
const LayoutArm = () => {
|
const LayoutArm = () => {
|
||||||
let defaultRedirect = null;
|
let defaultRedirect = null;
|
||||||
@ -17,8 +17,8 @@ const LayoutArm = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex flexDirection='column' h='100vh'>
|
<Flex h='100vh'>
|
||||||
<Header />
|
<Sidebar />
|
||||||
<Box flex='1' bg='gray.50'>
|
<Box flex='1' bg='gray.50'>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route index element={<Navigate to={defaultRedirect} replace />} />
|
<Route index element={<Navigate to={defaultRedirect} replace />} />
|
||||||
|
@ -2,17 +2,16 @@ import React, { ChangeEvent, useState } from 'react';
|
|||||||
import { Td, Tr, Link, Select } from '@chakra-ui/react';
|
import { Td, Tr, Link, Select } from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { ViewIcon } from '@chakra-ui/icons';
|
|
||||||
|
|
||||||
import { getTimeSlot } from '../../lib';
|
import { getTimeSlot } from '../../lib';
|
||||||
import { useUpdateOrdersMutation } from '../../__data__/service/api';
|
import { useUpdateOrdersMutation } from '../../__data__/service/api';
|
||||||
import { OrderArm, Status, statuses } from '../../models/api';
|
import { OrderArm, Status, statuses } from '../../models/api';
|
||||||
import PopoverTemplate from '../PopoverTemplate';
|
|
||||||
|
|
||||||
const statusColors: Record<Status, string> = {
|
const statusColors: Record<Status, string> = {
|
||||||
pending: 'yellow.100',
|
pending: 'yellow.100',
|
||||||
progress: 'blue.100',
|
progress: 'blue.100',
|
||||||
cancelled: 'red.100',
|
working: 'orange.100',
|
||||||
|
canceled: 'red.100',
|
||||||
complete: 'green.100',
|
complete: 'green.100',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ const OrderItem = ({
|
|||||||
|
|
||||||
const [statusSelect, setStatus] = useState(status);
|
const [statusSelect, setStatus] = useState(status);
|
||||||
const bgColor = statusColors[statusSelect];
|
const bgColor = statusColors[statusSelect];
|
||||||
const [masterSelectId, setMasterSelectId] = useState(master);
|
const [masterSelect, setMaster] = useState(master?.name);
|
||||||
|
|
||||||
const handelChangeMasters = (e: ChangeEvent<HTMLSelectElement>) => {
|
const handelChangeMasters = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
const masterName = e.target.value;
|
const masterName = e.target.value;
|
||||||
@ -44,7 +43,7 @@ const OrderItem = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (selectedMaster) {
|
if (selectedMaster) {
|
||||||
setMasterSelectId(selectedMaster.id);
|
setMaster(masterName);
|
||||||
updateOrders({ id, master: selectedMaster.id });
|
updateOrders({ id, master: selectedMaster.id });
|
||||||
} else {
|
} else {
|
||||||
console.error('Master not found');
|
console.error('Master not found');
|
||||||
@ -57,10 +56,6 @@ const OrderItem = ({
|
|||||||
setStatus(status);
|
setStatus(status);
|
||||||
};
|
};
|
||||||
|
|
||||||
const masterSelectChange = allMasters.find(
|
|
||||||
(master) => master.id === masterSelectId,
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr>
|
<Tr>
|
||||||
<Td>{carNumber}</Td>
|
<Td>{carNumber}</Td>
|
||||||
@ -84,7 +79,7 @@ const OrderItem = ({
|
|||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<Select
|
<Select
|
||||||
value={masterSelectChange?.name}
|
value={masterSelect}
|
||||||
onChange={handelChangeMasters}
|
onChange={handelChangeMasters}
|
||||||
placeholder={t(`master.placeholder`)}
|
placeholder={t(`master.placeholder`)}
|
||||||
>
|
>
|
||||||
@ -98,9 +93,7 @@ const OrderItem = ({
|
|||||||
<Td>
|
<Td>
|
||||||
<Link href='tel:'>{phone}</Link>
|
<Link href='tel:'>{phone}</Link>
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>{location}</Td>
|
||||||
<PopoverTemplate trigger={<ViewIcon />} description={location} />
|
|
||||||
</Td>
|
|
||||||
</Tr>
|
</Tr>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Popover,
|
|
||||||
PopoverArrow,
|
|
||||||
PopoverBody,
|
|
||||||
PopoverCloseButton,
|
|
||||||
PopoverContent,
|
|
||||||
PopoverHeader,
|
|
||||||
PopoverTrigger,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
title?: string;
|
|
||||||
description: string;
|
|
||||||
trigger?: React.ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
const PopoverTemplate = ({ title, description, trigger }: Props) => {
|
|
||||||
return (
|
|
||||||
<Popover>
|
|
||||||
<PopoverTrigger>
|
|
||||||
<Button>{trigger}</Button>
|
|
||||||
</PopoverTrigger>
|
|
||||||
<PopoverContent>
|
|
||||||
<PopoverArrow />
|
|
||||||
<PopoverCloseButton />
|
|
||||||
{title && <PopoverHeader>{title}!</PopoverHeader>}
|
|
||||||
<PopoverBody mr={5}>{description}</PopoverBody>
|
|
||||||
</PopoverContent>
|
|
||||||
</Popover>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default PopoverTemplate;
|
|
@ -1 +0,0 @@
|
|||||||
export { default } from './PopoverTemplate';
|
|
61
src/components/Sidebar/Sidebar.tsx
Normal file
61
src/components/Sidebar/Sidebar.tsx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { Box, Button, Heading, VStack, Divider } from '@chakra-ui/react';
|
||||||
|
import React from 'react';
|
||||||
|
import { useLocation, Link } from 'react-router-dom';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { URLs } from '../../__data__/urls';
|
||||||
|
|
||||||
|
const Sidebar = () => {
|
||||||
|
const location = useLocation();
|
||||||
|
const isActive = (keyword: string) => location.pathname.includes(keyword);
|
||||||
|
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.arm.master.sideBar',
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
borderRight='1px solid black'
|
||||||
|
bg='gray.50'
|
||||||
|
color='white'
|
||||||
|
w='250px'
|
||||||
|
p='5'
|
||||||
|
pt='8'
|
||||||
|
>
|
||||||
|
<Heading color='green' size='lg' mb='5'>
|
||||||
|
{t('title')}
|
||||||
|
</Heading>
|
||||||
|
|
||||||
|
<VStack align='start' spacing='4'>
|
||||||
|
<Divider />
|
||||||
|
{URLs.armOrder.isOn && (
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
to={URLs.armOrder.url}
|
||||||
|
w='100%'
|
||||||
|
colorScheme={isActive(URLs.armOrder.url) ? 'green' : 'blue'}
|
||||||
|
variant={isActive(URLs.armOrder.url) ? 'solid' : 'ghost'}
|
||||||
|
>
|
||||||
|
{t('orders')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Divider />
|
||||||
|
{URLs.armMaster.isOn && (
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
to={URLs.armMaster.url}
|
||||||
|
w='100%'
|
||||||
|
colorScheme={isActive(URLs.armMaster.url) ? 'green' : 'blue'}
|
||||||
|
variant={isActive(URLs.armMaster.url) ? 'solid' : 'ghost'}
|
||||||
|
data-testid='master-button'
|
||||||
|
>
|
||||||
|
{t('master')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Divider />
|
||||||
|
</VStack>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Sidebar;
|
1
src/components/Sidebar/index.ts
Normal file
1
src/components/Sidebar/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { default } from './Sidebar';
|
@ -38,7 +38,8 @@ type GetArrItemType<ArrType> =
|
|||||||
export const statuses = [
|
export const statuses = [
|
||||||
'pending' as const,
|
'pending' as const,
|
||||||
'progress' as const,
|
'progress' as const,
|
||||||
'cancelled' as const,
|
'working' as const,
|
||||||
|
'canceled' as const,
|
||||||
'complete' as const,
|
'complete' as const,
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ export type OrderArm = {
|
|||||||
status?: GetArrItemType<typeof statuses>;
|
status?: GetArrItemType<typeof statuses>;
|
||||||
phone?: string;
|
phone?: string;
|
||||||
location?: string;
|
location?: string;
|
||||||
master: string | [];
|
master: Master;
|
||||||
notes: '';
|
notes: '';
|
||||||
allMasters: Master[];
|
allMasters: Master[];
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -9,8 +9,12 @@
|
|||||||
"orderDate": "2024-11-24T08:41:46.366Z",
|
"orderDate": "2024-11-24T08:41:46.366Z",
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"phone": "79001234563",
|
"phone": "79001234563",
|
||||||
"location": "55.779905316526424,49.12446113769528 Республика Татарстан (Татарстан),н Казань, ул. Баумана, 1",
|
"location": "Казань, ул. Баумана, 1",
|
||||||
"master": "4545423234",
|
"master": {
|
||||||
|
"name": "Олег Макаров",
|
||||||
|
"phone": "79001234567",
|
||||||
|
"id": "23423442"
|
||||||
|
},
|
||||||
"notes": ""
|
"notes": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -21,7 +25,7 @@
|
|||||||
"orderDate": "2024-11-24T07:40:46.366Z",
|
"orderDate": "2024-11-24T07:40:46.366Z",
|
||||||
"status": "progress",
|
"status": "progress",
|
||||||
"phone": "79001234567",
|
"phone": "79001234567",
|
||||||
"location": "55.779905316526424,49.12446113769528 Республика Татарстан (Татарстан), Казань, озеро Нижний Кабан",
|
"location": "Казань, ул. Баумана, 43",
|
||||||
"master": [],
|
"master": [],
|
||||||
"notes": ""
|
"notes": ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user