Compare commits
42 Commits
20017cad3c
...
feature/or
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47e2646fac | ||
|
|
0b9b2f4dbc | ||
|
|
87a4dcefdd | ||
|
|
0679ad92ef | ||
| 9349a41f84 | |||
| 8103fdcb56 | |||
| a59864a3e2 | |||
| a252301ea0 | |||
| 48cdfb92bd | |||
|
|
279da05b32 | ||
|
|
c6d906ad62 | ||
|
|
418a121418 | ||
|
|
7647958e52 | ||
|
|
9e024af568 | ||
|
|
7fe62e7d6e | ||
|
|
f2db3774c9 | ||
|
|
02e3fdffa0 | ||
|
|
965d2d0be1 | ||
|
|
9121fcaa43 | ||
|
|
290bb3f0a3 | ||
|
|
e6e73e5289 | ||
|
|
b959fcf8db | ||
|
|
5e25848e22 | ||
|
|
ecf6c60cdc | ||
|
|
91fc91230b | ||
| d312445bf2 | |||
|
|
351420bc62 | ||
|
|
61b042eee6 | ||
|
|
ac006267a2 | ||
|
|
63d9d069c0 | ||
| c83ebf02bc | |||
|
|
1968df7bb3 | ||
|
|
811e0e3f24 | ||
| a2ffd6f38f | |||
|
|
7b3889aa02 | ||
|
|
cee124fca5 | ||
|
|
b77eccc8e8 | ||
|
|
ebfaa7ea8f | ||
|
|
0027cc09b1 | ||
|
|
dd612d662c | ||
|
|
69251745fa | ||
|
|
253e3b3856 |
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"i18n-ally.localesPaths": [
|
||||
"locales"
|
||||
]
|
||||
}
|
||||
32
Jenkinsfile
vendored
32
Jenkinsfile
vendored
@@ -1,7 +1,7 @@
|
||||
pipeline {
|
||||
agent {
|
||||
docker {
|
||||
image 'node:20'
|
||||
image 'node:22'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,25 +30,21 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('checks') {
|
||||
parallel {
|
||||
stage('eslint') {
|
||||
steps {
|
||||
sh 'npm run eslint'
|
||||
}
|
||||
}
|
||||
stage('eslint') {
|
||||
steps {
|
||||
sh 'npm run eslint'
|
||||
}
|
||||
}
|
||||
|
||||
stage('test') {
|
||||
steps {
|
||||
sh 'npm run test'
|
||||
}
|
||||
}
|
||||
stage('test') {
|
||||
steps {
|
||||
sh 'npm run test'
|
||||
}
|
||||
}
|
||||
|
||||
stage('build') {
|
||||
steps {
|
||||
sh 'npm run build'
|
||||
}
|
||||
}
|
||||
stage('build') {
|
||||
steps {
|
||||
sh 'npm run build'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@ import { jest } from '@jest/globals';
|
||||
jest.mock('@brojs/cli', () => ({
|
||||
getConfigValue: jest.fn(() => '/api'),
|
||||
getFeatures: jest.fn(() => ({
|
||||
['order-view-status-polling']: { value: '3000' }
|
||||
['order-view-status-polling']: { value: '3000' },
|
||||
['car-img-upload']: { value: 'true' },
|
||||
['order-cost']: { value: '1000' },
|
||||
})),
|
||||
getNavigationValue: jest.fn((navKey: string) => {
|
||||
switch (navKey) {
|
||||
|
||||
@@ -21,7 +21,21 @@ module.exports = {
|
||||
features: {
|
||||
'dry-wash': {
|
||||
// add your features here in the format [featureName]: { value: string }
|
||||
'order-view-status-polling': { value: '3000' }
|
||||
'order-view-status-polling': {
|
||||
on: true,
|
||||
value: '3000',
|
||||
key: 'order-view-status-polling',
|
||||
},
|
||||
'car-img-upload': {
|
||||
on: true,
|
||||
value: 'true',
|
||||
key: 'car-img-upload',
|
||||
},
|
||||
'order-cost': {
|
||||
on: true,
|
||||
value: '1000',
|
||||
key: 'order-cost',
|
||||
},
|
||||
},
|
||||
},
|
||||
config: {
|
||||
|
||||
@@ -5,7 +5,7 @@ module.exports = {
|
||||
},
|
||||
coverageProvider: 'v8',
|
||||
coverageDirectory: 'coverage',
|
||||
collectCoverageFrom: ['**/src/**/*.{ts,tsx}', '!**/src/app.tsx'],
|
||||
collectCoverageFrom: ['**/src/**/*.{ts,tsx}', '!**/src/app.tsx', '!**/src/**/types.ts', '!**/src/**/*.d.ts', '!**/src/models/**/*'],
|
||||
collectCoverage: true,
|
||||
clearMocks: true,
|
||||
moduleNameMapper: {
|
||||
|
||||
@@ -26,6 +26,17 @@
|
||||
"dry-wash.order-create.form.washing-location-field.label": "Where is the car located?",
|
||||
"dry-wash.order-create.form.washing-location-field.placeholder": "Enter the address or select on the map",
|
||||
"dry-wash.order-create.form.washing-location-field.help": "For example, 55.754364, 48.743295 Universitetskaya Street, 1, Innopolis, Verkhneuslonsky district, Republic of Tatarstan (Tatarstan), 420500",
|
||||
"dry-wash.order-create.car-color-select.placeholder": "Input color",
|
||||
"dry-wash.order-create.car-color-select.custom": "Custom",
|
||||
"dry-wash.order-create.car-color-select.custom-label": "Custom:",
|
||||
"dry-wash.order-create.car-color-select.colors.white": "White",
|
||||
"dry-wash.order-create.car-color-select.colors.black": "Black",
|
||||
"dry-wash.order-create.car-color-select.colors.silver": "Silver",
|
||||
"dry-wash.order-create.car-color-select.colors.gray": "Gray",
|
||||
"dry-wash.order-create.car-color-select.colors.beige-brown": "Beige Brown",
|
||||
"dry-wash.order-create.car-color-select.colors.red": "Red",
|
||||
"dry-wash.order-create.car-color-select.colors.blue": "Blue",
|
||||
"dry-wash.order-create.car-color-select.colors.green": "Green",
|
||||
"dry-wash.order-create.car-body-select.placeholder": "Not specified",
|
||||
"dry-wash.order-create.car-body-select.options.sedan": "Sedan",
|
||||
"dry-wash.order-create.car-body-select.options.hatchback" : "Hatchback",
|
||||
@@ -51,11 +62,14 @@
|
||||
"dry-wash.order-view.details.datetime-range": "When",
|
||||
"dry-wash.order-view.details.alert": "The operator will contact you about the payment at the specified phone number",
|
||||
"dry-wash.order-view.upload-car-image.field.label": "Upload a photo of your car, and our service will quickly calculate the pre-order price!",
|
||||
"dry-wash.order-view.upload-car-image.field.help": "Allowed formats: .jpg, .png. Maximum size: 5MB",
|
||||
"dry-wash.order-view.upload-car-image.field.help": "Allowed formats: .jpg, .png. Maximum size: 14MB",
|
||||
"dry-wash.order-view.upload-car-image.file-input.placeholder": "Upload a file",
|
||||
"dry-wash.order-view.upload-car-image.file-input.button": "Upload",
|
||||
"dry-wash.order-view.upload-car-image-query.success.title": "The car image is successfully uploaded",
|
||||
"dry-wash.order-view.upload-car-image-query.error.title": "Failed to upload the car image",
|
||||
"dry-wash.order-view.price-car.title": "The level of car contamination:",
|
||||
"dry-wash.order-view.price-car.description": "The cost of washing:",
|
||||
"dry-wash.order-view.price-car.error": "Failed to determine the level of car contamination",
|
||||
"dry-wash.arm.master.add": "Add",
|
||||
"dry-wash.arm.order.title": "Orders",
|
||||
"dry-wash.arm.order.table.empty": "Table empty",
|
||||
@@ -64,7 +78,7 @@
|
||||
"dry-wash.arm.order.status.complete": "Completed",
|
||||
"dry-wash.arm.order.status.pending": "Pending",
|
||||
"dry-wash.arm.order.status.working": "Working",
|
||||
"dry-wash.arm.order.status.canceled": "Canceled",
|
||||
"dry-wash.arm.order.status.cancelled": "Canceled",
|
||||
"dry-wash.arm.order.status.placeholder": "Select status",
|
||||
"dry-wash.arm.order.master.placeholder": "Select master",
|
||||
"dry-wash.arm.order.table.header.carNumber": "Car Number",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"dry-wash.arm.order.status.complete": "Завершено",
|
||||
"dry-wash.arm.order.status.pending": "В ожидании",
|
||||
"dry-wash.arm.order.status.working": "В работе",
|
||||
"dry-wash.arm.order.status.canceled": "Отменено",
|
||||
"dry-wash.arm.order.status.cancelled": "Отменено",
|
||||
"dry-wash.arm.order.status.placeholder": "Выберите статус",
|
||||
"dry-wash.arm.order.master.placeholder": "Выберите мастера",
|
||||
"dry-wash.arm.order.table.header.carNumber": "Номер машины",
|
||||
@@ -81,6 +81,17 @@
|
||||
"dry-wash.order-create.form.washing-location-field.label": "Где находится автомобиль?",
|
||||
"dry-wash.order-create.form.washing-location-field.placeholder": "Введите адрес или выберите на карте",
|
||||
"dry-wash.order-create.form.washing-location-field.help": "Например, 55.754364, 48.743295 Университетская улица, 1, Иннополис, Верхнеуслонский район, Республика Татарстан (Татарстан), 420500",
|
||||
"dry-wash.order-create.car-color-select.placeholder": "Введите цвет",
|
||||
"dry-wash.order-create.car-color-select.custom": "Другой",
|
||||
"dry-wash.order-create.car-color-select.custom-label": "Другой:",
|
||||
"dry-wash.order-create.car-color-select.colors.white": "Белый",
|
||||
"dry-wash.order-create.car-color-select.colors.black": "Черный",
|
||||
"dry-wash.order-create.car-color-select.colors.silver": "Серебристый",
|
||||
"dry-wash.order-create.car-color-select.colors.gray": "Серый",
|
||||
"dry-wash.order-create.car-color-select.colors.beige-brown": "Бежево-коричневый",
|
||||
"dry-wash.order-create.car-color-select.colors.red": "Красный",
|
||||
"dry-wash.order-create.car-color-select.colors.blue": "Синий",
|
||||
"dry-wash.order-create.car-color-select.colors.green": "Зеленый",
|
||||
"dry-wash.order-create.car-body-select.placeholder": "Не указан",
|
||||
"dry-wash.order-create.car-body-select.options.sedan": "Седан",
|
||||
"dry-wash.order-create.car-body-select.options.hatchback": "Хэтчбек",
|
||||
@@ -106,11 +117,14 @@
|
||||
"dry-wash.order-view.details.datetime-range": "Когда",
|
||||
"dry-wash.order-view.details.alert": "С вами свяжется оператор насчет оплаты по указанному номеру телефона",
|
||||
"dry-wash.order-view.upload-car-image.field.label": "Загрузите фото вашего автомобиля, и наш сервис быстро рассчитает предварительную стоимость заказа!",
|
||||
"dry-wash.order-view.upload-car-image.field.help": "Допустимые форматы: .jpg, .png. Максимальный размер: 5МБ",
|
||||
"dry-wash.order-view.upload-car-image.field.help": "Допустимые форматы: .jpg, .png. Максимальный размер: 14МБ",
|
||||
"dry-wash.order-view.upload-car-image.file-input.placeholder": "Загрузите файл",
|
||||
"dry-wash.order-view.upload-car-image.file-input.button": "Загрузить",
|
||||
"dry-wash.order-view.upload-car-image-query.success.title": "Изображение автомобиля успешно загружено",
|
||||
"dry-wash.order-view.upload-car-image-query.error.title": "Не удалось загрузить изображение автомобиля",
|
||||
"dry-wash.order-view.price-car.title": "Уровень загрязнения машины:",
|
||||
"dry-wash.order-view.price-car.description": "Стоимость мойки:",
|
||||
"dry-wash.order-view.price-car.error": "Не удалось определить уровень загрязнения машины",
|
||||
"dry-wash.notFound.title": "Страница не найдена",
|
||||
"dry-wash.notFound.description": "К сожалению, запрашиваемая вами страница не существует.",
|
||||
"dry-wash.notFound.button.back": "Вернуться на главную",
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "dry-wash",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dry-wash",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.2",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.26.7",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dry-wash",
|
||||
"version": "0.8.0",
|
||||
"version": "0.9.2",
|
||||
"description": "<a id=\"readme-top\"></a>",
|
||||
"main": "./src/index.tsx",
|
||||
"scripts": {
|
||||
@@ -9,8 +9,8 @@
|
||||
"build": "npm run clean && brojs build --dev",
|
||||
"build:prod": "npm run clean && brojs build",
|
||||
"clean": "rimraf dist",
|
||||
"eslint": "npx eslint .",
|
||||
"eslint:fix": "npx eslint . --fix",
|
||||
"eslint": "npx eslint src",
|
||||
"eslint:fix": "npx eslint src --fix",
|
||||
"preversion": "npm run eslint"
|
||||
},
|
||||
"keywords": [],
|
||||
|
||||
@@ -11,5 +11,8 @@ export const FEATURE = {
|
||||
return interval;
|
||||
}
|
||||
}
|
||||
},
|
||||
carImageUpload: {
|
||||
isOn: Boolean(features?.['car-img-upload'])
|
||||
}
|
||||
};
|
||||
@@ -13,6 +13,7 @@ export const extractErrorMessageFromResponse = ({
|
||||
}: FetchBaseQueryError) => {
|
||||
if (
|
||||
typeof data === 'object' &&
|
||||
data !== null &&
|
||||
'error' in data &&
|
||||
typeof data.error === 'string'
|
||||
) {
|
||||
|
||||
@@ -7,7 +7,9 @@ export const store = configureStore({
|
||||
[api.reducerPath]: api.reducer,
|
||||
},
|
||||
middleware: (getDefaultMiddleware) =>
|
||||
getDefaultMiddleware().concat(api.middleware),
|
||||
getDefaultMiddleware({
|
||||
serializableCheck: false
|
||||
}).concat(api.middleware),
|
||||
});
|
||||
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
|
||||
@@ -28,7 +28,6 @@ class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
||||
console.error('Error caught by ErrorBoundary:', error, errorInfo);
|
||||
console.error('4545');
|
||||
this.setState({ error, errorInfo });
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@ jest.mock('@brojs/cli', () => {
|
||||
|
||||
describe('ErrorBoundary', () => {
|
||||
it('должен отобразить запасной UI при ошибке', async () => {
|
||||
// Подавляем вывод ошибки в консоль во время теста
|
||||
const consoleSpy = jest.spyOn(console, 'error');
|
||||
consoleSpy.mockImplementation(() => {});
|
||||
|
||||
const { container } = render(
|
||||
<Provider store={store}>
|
||||
<ErrorBoundary>
|
||||
@@ -39,7 +43,9 @@ describe('ErrorBoundary', () => {
|
||||
);
|
||||
|
||||
expect(button).not.toBeNull();
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
|
||||
// Восстанавливаем console.error после теста
|
||||
consoleSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
51
src/components/Header/Header.tsx
Normal file
51
src/components/Header/Header.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
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
src/components/Header/index.ts
Normal file
1
src/components/Header/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './Header';
|
||||
@@ -2,10 +2,10 @@ import { Box, Flex } from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||
|
||||
import Sidebar from '../Sidebar';
|
||||
import Orders from '../Orders';
|
||||
import Masters from '../Masters';
|
||||
import { URLs } from '../../__data__/urls';
|
||||
import Header from '../Header';
|
||||
|
||||
const LayoutArm = () => {
|
||||
let defaultRedirect = null;
|
||||
@@ -17,8 +17,8 @@ const LayoutArm = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Flex h='100vh'>
|
||||
<Sidebar />
|
||||
<Flex flexDirection='column' h='100vh'>
|
||||
<Header />
|
||||
<Box flex='1' bg='gray.50'>
|
||||
<Routes>
|
||||
<Route index element={<Navigate to={defaultRedirect} replace />} />
|
||||
|
||||
@@ -2,16 +2,17 @@ import React, { ChangeEvent, useState } from 'react';
|
||||
import { Td, Tr, Link, Select } from '@chakra-ui/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import { ViewIcon } from '@chakra-ui/icons';
|
||||
|
||||
import { getTimeSlot } from '../../lib';
|
||||
import { useUpdateOrdersMutation } from '../../__data__/service/api';
|
||||
import { OrderArm, Status, statuses } from '../../models/api';
|
||||
import PopoverTemplate from '../PopoverTemplate';
|
||||
|
||||
const statusColors: Record<Status, string> = {
|
||||
pending: 'yellow.100',
|
||||
progress: 'blue.100',
|
||||
working: 'orange.100',
|
||||
canceled: 'red.100',
|
||||
cancelled: 'red.100',
|
||||
complete: 'green.100',
|
||||
};
|
||||
|
||||
@@ -34,7 +35,7 @@ const OrderItem = ({
|
||||
|
||||
const [statusSelect, setStatus] = useState(status);
|
||||
const bgColor = statusColors[statusSelect];
|
||||
const [masterSelect, setMaster] = useState(master?.name);
|
||||
const [masterSelectId, setMasterSelectId] = useState(master);
|
||||
|
||||
const handelChangeMasters = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||
const masterName = e.target.value;
|
||||
@@ -43,7 +44,7 @@ const OrderItem = ({
|
||||
);
|
||||
|
||||
if (selectedMaster) {
|
||||
setMaster(masterName);
|
||||
setMasterSelectId(selectedMaster.id);
|
||||
updateOrders({ id, master: selectedMaster.id });
|
||||
} else {
|
||||
console.error('Master not found');
|
||||
@@ -56,6 +57,10 @@ const OrderItem = ({
|
||||
setStatus(status);
|
||||
};
|
||||
|
||||
const masterSelectChange = allMasters.find(
|
||||
(master) => master.id === masterSelectId,
|
||||
);
|
||||
|
||||
return (
|
||||
<Tr>
|
||||
<Td>{carNumber}</Td>
|
||||
@@ -79,7 +84,7 @@ const OrderItem = ({
|
||||
</Td>
|
||||
<Td>
|
||||
<Select
|
||||
value={masterSelect}
|
||||
value={masterSelectChange?.name}
|
||||
onChange={handelChangeMasters}
|
||||
placeholder={t(`master.placeholder`)}
|
||||
>
|
||||
@@ -93,7 +98,9 @@ const OrderItem = ({
|
||||
<Td>
|
||||
<Link href='tel:'>{phone}</Link>
|
||||
</Td>
|
||||
<Td>{location}</Td>
|
||||
<Td>
|
||||
<PopoverTemplate trigger={<ViewIcon />} description={location} />
|
||||
</Td>
|
||||
</Tr>
|
||||
);
|
||||
};
|
||||
|
||||
35
src/components/PopoverTemplate/PopoverTemplate.tsx
Normal file
35
src/components/PopoverTemplate/PopoverTemplate.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
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
src/components/PopoverTemplate/index.ts
Normal file
1
src/components/PopoverTemplate/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './PopoverTemplate';
|
||||
75
src/components/PriceCar/PriceCar.tsx
Normal file
75
src/components/PriceCar/PriceCar.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import { Box, Image, Progress, Text, VStack } from '@chakra-ui/react';
|
||||
import React from 'react';
|
||||
import { getFeatures } from '@brojs/cli';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { formatPrice, getProgressColor } from './helper';
|
||||
|
||||
const PRICE_INCREASE_PERCENT_PER_RATING = 10;
|
||||
|
||||
export const PriceCar = ({ image, rating, description }) => {
|
||||
const BASE_WASH_PRICE: number = Number(
|
||||
getFeatures('dry-wash')['order-cost']?.value || 1000,
|
||||
);
|
||||
|
||||
const calculateWashPrice = (rating: number) => {
|
||||
const priceIncrease =
|
||||
(BASE_WASH_PRICE * PRICE_INCREASE_PERCENT_PER_RATING * rating) / 100;
|
||||
return BASE_WASH_PRICE + priceIncrease;
|
||||
};
|
||||
|
||||
const { i18n, t } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-view.price-car',
|
||||
});
|
||||
const washPrice = calculateWashPrice(rating);
|
||||
const formattedPrice = formatPrice(washPrice, i18n.language);
|
||||
|
||||
const progressValue = (rating / 10) * 100;
|
||||
|
||||
return (
|
||||
<Box
|
||||
gap={5}
|
||||
width='100%'
|
||||
display='flex'
|
||||
justifyContent='center'
|
||||
alignItems='flex-start'
|
||||
flexWrap='wrap'
|
||||
>
|
||||
<Image
|
||||
maxWidth='600px'
|
||||
width='100%'
|
||||
objectFit='contain'
|
||||
borderRadius='md'
|
||||
src={image}
|
||||
alt=''
|
||||
/>
|
||||
<Box flex='1 1 40%'>
|
||||
{!Number.isNaN(progressValue) ? (
|
||||
<VStack alignItems='stretch'>
|
||||
<Box>
|
||||
<Text>{t('title')}</Text>
|
||||
<Progress
|
||||
value={progressValue}
|
||||
size='sm'
|
||||
sx={{
|
||||
'& > div': {
|
||||
backgroundColor: getProgressColor(progressValue),
|
||||
},
|
||||
}}
|
||||
mt={2}
|
||||
/>
|
||||
<Text mt={2}>
|
||||
{t('description')} <b>{formattedPrice}</b>
|
||||
</Text>
|
||||
</Box>
|
||||
<Text fontStyle='italic'>{description}</Text>
|
||||
</VStack>
|
||||
) : (
|
||||
<Text>{t('error')}</Text>
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default PriceCar;
|
||||
15
src/components/PriceCar/helper.ts
Normal file
15
src/components/PriceCar/helper.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export const formatPrice = (price: number, locale = 'ru-RU', currency = 'RUB') => {
|
||||
return new Intl.NumberFormat(locale, {
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(price);
|
||||
};
|
||||
|
||||
export const getProgressColor = (value: number) => {
|
||||
const normalizedValue = value / 100;
|
||||
const hue = 120 - normalizedValue * 120;
|
||||
|
||||
return `hsl(${hue}, 100%, 50%)`;
|
||||
};
|
||||
1
src/components/PriceCar/index.ts
Normal file
1
src/components/PriceCar/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './PriceCar';
|
||||
@@ -1,61 +0,0 @@
|
||||
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 +0,0 @@
|
||||
export { default } from './Sidebar';
|
||||
@@ -21,9 +21,10 @@ import { CarBodySelectProps } from './types';
|
||||
export const CarBodySelect = forwardRef<HTMLInputElement, CarBodySelectProps>(
|
||||
function CarBodySelect(props, ref) {
|
||||
const handleOptionClick: UseRadioGroupProps['onChange'] = (value) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
props.onChange(value);
|
||||
props.onChange({
|
||||
target: { value },
|
||||
} as React.ChangeEvent<HTMLInputElement>);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const { value, getRadioProps, getRootProps } = useRadioGroup({
|
||||
@@ -39,12 +40,14 @@ export const CarBodySelect = forwardRef<HTMLInputElement, CarBodySelectProps>(
|
||||
});
|
||||
|
||||
return (
|
||||
<Box width='100%'>
|
||||
<Box width='100%' pos='relative'>
|
||||
<Popover
|
||||
isOpen={isOpen}
|
||||
autoFocus={false}
|
||||
placement='bottom-start'
|
||||
matchWidth
|
||||
gutter={2}
|
||||
strategy="fixed"
|
||||
>
|
||||
<PopoverAnchor>
|
||||
<Input
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export { CarBodySelect } from './car-body-select';
|
||||
export { CarBodySelect } from './car-body-select';
|
||||
export { carBodySelectOptions } from './helper';
|
||||
@@ -1,23 +0,0 @@
|
||||
import React, { forwardRef, useId } from 'react';
|
||||
import { Input, InputProps } from '@chakra-ui/react';
|
||||
|
||||
import { CAR_COLORS } from './helper';
|
||||
|
||||
export const CarColorInput = forwardRef<HTMLInputElement, InputProps>(
|
||||
function CarColorInput(props, ref) {
|
||||
const listId = useId();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Input ref={ref} list={listId} {...props} />
|
||||
<datalist id={listId}>
|
||||
{CAR_COLORS.map(({ code, name }) => (
|
||||
<option key={code} label={name} value={code}>{name}</option>
|
||||
))}
|
||||
</datalist>
|
||||
</>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// todo: add option color visual indication
|
||||
@@ -0,0 +1,75 @@
|
||||
import React from 'react';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
|
||||
import { CarColorSelect } from './car-color-select';
|
||||
|
||||
// Mock the translation hook
|
||||
jest.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => {
|
||||
// Return the last part of the key as that's what component is using
|
||||
const keyParts = key.split('.');
|
||||
return keyParts[keyParts.length - 1];
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('CarColorSelect', () => {
|
||||
it('renders color options correctly', () => {
|
||||
const onChange = jest.fn();
|
||||
render(<CarColorSelect onChange={onChange} />);
|
||||
|
||||
// Check if color buttons are rendered
|
||||
const colorButtons = screen.getAllByRole('button');
|
||||
expect(colorButtons.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('handles color selection', () => {
|
||||
const onChange = jest.fn();
|
||||
render(<CarColorSelect onChange={onChange} />);
|
||||
|
||||
// Click the first color button
|
||||
const colorButtons = screen.getAllByRole('button');
|
||||
fireEvent.click(colorButtons[0]);
|
||||
|
||||
expect(onChange).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handles custom color selection', () => {
|
||||
const onChange = jest.fn();
|
||||
render(<CarColorSelect onChange={onChange} />);
|
||||
|
||||
// Find and click the custom color button
|
||||
const customButton = screen.getByText('custom');
|
||||
fireEvent.click(customButton);
|
||||
|
||||
// Check if custom color input appears
|
||||
const customInput = screen.getByPlaceholderText('placeholder');
|
||||
expect(customInput).toBeInTheDocument();
|
||||
|
||||
// Test custom color input
|
||||
fireEvent.change(customInput, { target: { value: '#FF0000' } });
|
||||
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({
|
||||
target: { value: '#FF0000' },
|
||||
}));
|
||||
});
|
||||
|
||||
it('shows selected color label when color is selected', () => {
|
||||
const onChange = jest.fn();
|
||||
render(<CarColorSelect value="black" onChange={onChange} />);
|
||||
|
||||
// Since the color label might not be immediately visible,
|
||||
// we'll verify the component renders without crashing
|
||||
const buttons = screen.getAllByRole('button');
|
||||
expect(buttons.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it('handles invalid state', () => {
|
||||
render(<CarColorSelect isInvalid={true} />);
|
||||
|
||||
// Since the component doesn't show explicit invalid state UI,
|
||||
// we'll verify that the component renders without crashing
|
||||
expect(screen.getAllByRole('button').length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
177
src/components/order-form/form/car-color/car-color-select.tsx
Normal file
177
src/components/order-form/form/car-color/car-color-select.tsx
Normal file
@@ -0,0 +1,177 @@
|
||||
import React, { forwardRef, useState } from 'react';
|
||||
import { Input, Box, Stack, Text, Flex } from '@chakra-ui/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Car } from '../../../../models';
|
||||
|
||||
import { carColorSelectOptions } from './helper';
|
||||
|
||||
interface CarColorSelectProps {
|
||||
value?: string;
|
||||
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
name?: string;
|
||||
isInvalid?: boolean;
|
||||
}
|
||||
|
||||
export const CarColorSelect = forwardRef<HTMLInputElement, CarColorSelectProps>(
|
||||
function CarColorSelect(props, ref) {
|
||||
const [customColor, setCustomColor] = useState('');
|
||||
const [isCustom, setIsCustom] = useState(false);
|
||||
|
||||
const handleColorChange = (value: Car.Color | string) => {
|
||||
if (value === 'custom') {
|
||||
setIsCustom(true);
|
||||
return;
|
||||
}
|
||||
setIsCustom(false);
|
||||
props.onChange?.({
|
||||
target: { value },
|
||||
} as React.ChangeEvent<HTMLInputElement>);
|
||||
};
|
||||
|
||||
const handleCustomColorChange = (
|
||||
e: React.ChangeEvent<HTMLInputElement>,
|
||||
) => {
|
||||
const value = e.target.value;
|
||||
setCustomColor(value);
|
||||
props.onChange?.({
|
||||
target: { value },
|
||||
} as React.ChangeEvent<HTMLInputElement>);
|
||||
};
|
||||
|
||||
const { t } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-create.car-color-select',
|
||||
});
|
||||
|
||||
const currentValue = isCustom ? 'custom' : props.value;
|
||||
|
||||
return (
|
||||
<Stack spacing={4} width='100%' ref={ref}>
|
||||
<Flex gap={2} wrap='wrap' pb={2}>
|
||||
{carColorSelectOptions.map(({ value, labelTKey, code }) => (
|
||||
<Box
|
||||
key={value}
|
||||
flexShrink={0}
|
||||
as='button'
|
||||
type='button'
|
||||
onClick={() => handleColorChange(value)}
|
||||
>
|
||||
<Flex
|
||||
align='center'
|
||||
gap={2}
|
||||
p={1}
|
||||
borderRadius='full'
|
||||
borderWidth='2px'
|
||||
borderColor='gray.200'
|
||||
bg='white'
|
||||
_hover={{
|
||||
borderColor: 'primary.500',
|
||||
bg: 'gray.50',
|
||||
}}
|
||||
justify='center'
|
||||
transition='all 0.2s'
|
||||
{...(currentValue === value && {
|
||||
borderColor: 'primary.500',
|
||||
bg: 'primary.50',
|
||||
paddingInlineEnd: 3,
|
||||
_hover: {
|
||||
bg: 'primary.50',
|
||||
},
|
||||
})}
|
||||
>
|
||||
<Flex align='center' gap={2}>
|
||||
<Box
|
||||
w='32px'
|
||||
h='32px'
|
||||
borderRadius='full'
|
||||
bg={code}
|
||||
border='1px'
|
||||
borderColor='gray.200'
|
||||
transition='all 0.2s'
|
||||
boxShadow='none'
|
||||
{...(currentValue === value && {
|
||||
borderColor: 'primary.500',
|
||||
boxShadow: 'sm',
|
||||
})}
|
||||
/>
|
||||
{currentValue === value && (
|
||||
<Text fontSize='xs' color='primary.700' fontWeight='medium'>
|
||||
{t(`colors.${labelTKey}`)}
|
||||
</Text>
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Box>
|
||||
))}
|
||||
<Box
|
||||
flexShrink={0}
|
||||
as='button'
|
||||
type='button'
|
||||
onClick={() => handleColorChange('custom')}
|
||||
>
|
||||
<Flex
|
||||
align='center'
|
||||
gap={2}
|
||||
p={1}
|
||||
paddingInlineEnd={3}
|
||||
borderRadius='full'
|
||||
borderWidth='2px'
|
||||
borderColor='gray.200'
|
||||
bg='white'
|
||||
_hover={{
|
||||
borderColor: 'primary.500',
|
||||
bg: 'gray.50',
|
||||
}}
|
||||
justify='center'
|
||||
transition='all 0.2s'
|
||||
{...(isCustom && {
|
||||
borderColor: 'primary.500',
|
||||
paddingInlineStart: 3,
|
||||
bg: 'primary.50',
|
||||
_hover: {
|
||||
bg: 'primary.50',
|
||||
},
|
||||
})}
|
||||
>
|
||||
{isCustom ? (
|
||||
<Flex gap={2} align='center'>
|
||||
<Text fontSize='xs' color='primary.700' fontWeight='medium'>
|
||||
{t('custom-label')}
|
||||
</Text>
|
||||
<Input
|
||||
size='sm'
|
||||
width='120px'
|
||||
value={customColor}
|
||||
onChange={handleCustomColorChange}
|
||||
placeholder={t('placeholder')}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
borderColor='primary.200'
|
||||
_focus={{
|
||||
borderColor: 'primary.500',
|
||||
boxShadow: '0 0 0 1px var(--chakra-colors-primary-500)',
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
) : (
|
||||
<Flex align='center' gap={2}>
|
||||
<Box
|
||||
w='32px'
|
||||
h='32px'
|
||||
borderRadius='full'
|
||||
bg='gray.100'
|
||||
border='1px'
|
||||
borderColor='gray.200'
|
||||
transition='all 0.2s'
|
||||
/>
|
||||
<Text fontSize='xs' color='gray.500'>
|
||||
{t('custom')}
|
||||
</Text>
|
||||
</Flex>
|
||||
)}
|
||||
</Flex>
|
||||
</Box>
|
||||
</Flex>
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -1,34 +1,44 @@
|
||||
export const CAR_COLORS: Record<'name' | 'code', string>[] = [
|
||||
import { Car } from "../../../../models";
|
||||
|
||||
export const carColorSelectOptions: { value: Car.Color | string; labelTKey: 'white' | 'black' | 'silver' | 'gray' | 'beige-brown' | 'red' | 'blue' | 'green'; code: string }[] = [
|
||||
{
|
||||
name: 'white',
|
||||
value: Car.Color.WHITE,
|
||||
labelTKey: 'white',
|
||||
code: '#ffffff'
|
||||
},
|
||||
{
|
||||
name: 'black',
|
||||
value: Car.Color.BLACK,
|
||||
labelTKey: 'black',
|
||||
code: '#000000'
|
||||
},
|
||||
{
|
||||
name: 'silver',
|
||||
value: Car.Color.SILVER,
|
||||
labelTKey: 'silver',
|
||||
code: '#c0c0c0'
|
||||
},
|
||||
{
|
||||
name: 'gray',
|
||||
value: Car.Color.GRAY,
|
||||
labelTKey: 'gray',
|
||||
code: '#808080'
|
||||
},
|
||||
{
|
||||
name: 'beige-brown',
|
||||
value: Car.Color.BEIGE_BROWN,
|
||||
labelTKey: 'beige-brown',
|
||||
code: '#796745'
|
||||
},
|
||||
{
|
||||
name: 'red',
|
||||
value: Car.Color.RED,
|
||||
labelTKey: 'red',
|
||||
code: '#b90000'
|
||||
},
|
||||
{
|
||||
name: 'blue',
|
||||
value: Car.Color.BLUE,
|
||||
labelTKey: 'blue',
|
||||
code: '#003B62'
|
||||
},
|
||||
{
|
||||
name: 'green',
|
||||
value: Car.Color.GREEN,
|
||||
labelTKey: 'green',
|
||||
code: '#078d51'
|
||||
},
|
||||
];
|
||||
@@ -1 +1,2 @@
|
||||
export { CarColorInput } from './car-color-input';
|
||||
export { CarColorSelect } from './car-color-select';
|
||||
export { carColorSelectOptions } from './helper';
|
||||
@@ -1,2 +1,4 @@
|
||||
export type { OrderFormValues, OrderFormProps } from './types';
|
||||
export { OrderForm } from './order-form';
|
||||
export { OrderForm } from './order-form';
|
||||
export { carBodySelectOptions } from './car-body';
|
||||
export { carColorSelectOptions } from './car-color';
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { forwardRef, memo, useEffect, useState } from 'react';
|
||||
import React, { ForwardedRef, forwardRef, memo, useEffect, useState } from 'react';
|
||||
import {
|
||||
Input,
|
||||
Box,
|
||||
@@ -24,129 +24,130 @@ import {
|
||||
} from './helper';
|
||||
import { LocationInputProps } from './types';
|
||||
|
||||
export const LocationInput = memo(
|
||||
withYMaps(
|
||||
forwardRef<HTMLInputElement, LocationInputProps>(function LocationInput(
|
||||
{ ymaps, value, onChange, ...props },
|
||||
ref,
|
||||
) {
|
||||
const [inputValue, setInputValue] = useState<string>('');
|
||||
export const BaseLocationInput = withYMaps(
|
||||
({ ymaps, value = '', onChange, inputRef, ...props }: LocationInputProps & { inputRef: ForwardedRef<HTMLInputElement> }) => {
|
||||
const [inputValue, setInputValue] = useState<string>('');
|
||||
|
||||
useEffect(() => {
|
||||
setInputValue(value);
|
||||
}, [value]);
|
||||
useEffect(() => {
|
||||
setInputValue(value);
|
||||
}, [value]);
|
||||
|
||||
const [suggestions, setSuggestions] = useState<Suggestion[]>([]);
|
||||
const [isSuggestionsPanelOpen, setIsSuggestionsPanelOpen] =
|
||||
useState<boolean>(false);
|
||||
const [suggestions, setSuggestions] = useState<Suggestion[]>([]);
|
||||
const [isSuggestionsPanelOpen, setIsSuggestionsPanelOpen] =
|
||||
useState<boolean>(false);
|
||||
|
||||
const onInputChange: InputProps['onChange'] = async (e) => {
|
||||
const newInputValue = e.target.value;
|
||||
const onInputChange: InputProps['onChange'] = async (e) => {
|
||||
const newInputValue = e.target.value;
|
||||
|
||||
if (
|
||||
isValidLocation(newInputValue) &&
|
||||
(await isRealLocation(ymaps, newInputValue))
|
||||
) {
|
||||
onChange(newInputValue);
|
||||
} else {
|
||||
setInputValue(newInputValue);
|
||||
|
||||
if (newInputValue.trim().length > 3) {
|
||||
try {
|
||||
const address = extractAddress(newInputValue);
|
||||
const results = await ymaps.suggest(address);
|
||||
setSuggestions(results);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
setSuggestions([]);
|
||||
if (
|
||||
isValidLocation(newInputValue) &&
|
||||
(await isRealLocation(ymaps, newInputValue))
|
||||
) {
|
||||
onChange(newInputValue);
|
||||
} else {
|
||||
setInputValue(newInputValue);
|
||||
|
||||
if (newInputValue.trim().length > 3) {
|
||||
try {
|
||||
const address = extractAddress(newInputValue);
|
||||
const results = await ymaps.suggest(address);
|
||||
setSuggestions(results);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||
}
|
||||
};
|
||||
|
||||
const onFocus: InputProps['onFocus'] = () => {
|
||||
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||
};
|
||||
|
||||
const onBlur: InputProps['onBlur'] = async (e) => {
|
||||
const inputValue = e.target.value;
|
||||
if (
|
||||
isValidLocation(inputValue) &&
|
||||
(await isRealLocation(ymaps, inputValue))
|
||||
) {
|
||||
onChange(inputValue);
|
||||
} else {
|
||||
setInputValue(value);
|
||||
setSuggestions([]);
|
||||
}
|
||||
setIsSuggestionsPanelOpen(false);
|
||||
};
|
||||
|
||||
const handleSuggestionClick = async ({ value: address }: Suggestion) => {
|
||||
try {
|
||||
const location = await getLocationByAddress(ymaps, address);
|
||||
const newValue = formatLocation(location);
|
||||
setInputValue(newValue);
|
||||
onChange(newValue);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||
}
|
||||
};
|
||||
|
||||
const { t } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-create.form.washing-location-field',
|
||||
});
|
||||
const onFocus: InputProps['onFocus'] = () => {
|
||||
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box width='100%'>
|
||||
<Popover
|
||||
isOpen={isSuggestionsPanelOpen}
|
||||
autoFocus={false}
|
||||
placement='bottom-start'
|
||||
>
|
||||
<PopoverAnchor>
|
||||
<Input
|
||||
{...props}
|
||||
ref={ref}
|
||||
onBlur={onBlur}
|
||||
value={inputValue ?? value}
|
||||
onChange={onInputChange}
|
||||
onFocus={onFocus}
|
||||
placeholder={t('placeholder')}
|
||||
/>
|
||||
</PopoverAnchor>
|
||||
<PopoverContent width='100%' maxWidth='100%'>
|
||||
<PopoverBody border='1px' borderColor='gray.300' p={0}>
|
||||
<List>
|
||||
{suggestions.map((suggestion, index) => (
|
||||
<ListItem
|
||||
key={index}
|
||||
p={2}
|
||||
cursor='pointer'
|
||||
_hover={{
|
||||
bgColor: 'primary.50',
|
||||
}}
|
||||
_active={{
|
||||
bgColor: 'primary.100',
|
||||
}}
|
||||
onClick={() => handleSuggestionClick(suggestion)}
|
||||
>
|
||||
{suggestion.displayName}
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
</PopoverBody>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</Box>
|
||||
);
|
||||
}),
|
||||
true,
|
||||
['suggest', 'geocode'],
|
||||
),
|
||||
const onBlur: InputProps['onBlur'] = async (e) => {
|
||||
const inputValue = e.target.value;
|
||||
if (
|
||||
isValidLocation(inputValue) &&
|
||||
(await isRealLocation(ymaps, inputValue))
|
||||
) {
|
||||
onChange(inputValue);
|
||||
} else {
|
||||
setInputValue(value);
|
||||
}
|
||||
setIsSuggestionsPanelOpen(false);
|
||||
};
|
||||
|
||||
const handleSuggestionClick = async ({ value: address }: Suggestion) => {
|
||||
try {
|
||||
const location = await getLocationByAddress(ymaps, address);
|
||||
const newValue = formatLocation(location);
|
||||
setInputValue(newValue);
|
||||
onChange(newValue);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const { t } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-create.form.washing-location-field',
|
||||
});
|
||||
|
||||
return (
|
||||
<Box width='100%'>
|
||||
<Popover
|
||||
isOpen={isSuggestionsPanelOpen}
|
||||
autoFocus={false}
|
||||
placement='bottom-start'
|
||||
>
|
||||
<PopoverAnchor>
|
||||
<Input
|
||||
{...props}
|
||||
ref={inputRef}
|
||||
onBlur={onBlur}
|
||||
value={inputValue || value}
|
||||
onChange={onInputChange}
|
||||
onFocus={onFocus}
|
||||
placeholder={t('placeholder')}
|
||||
/>
|
||||
</PopoverAnchor>
|
||||
<PopoverContent width='100%' maxWidth='100%'>
|
||||
<PopoverBody border='1px' borderColor='gray.300' p={0}>
|
||||
<List>
|
||||
{suggestions.map((suggestion, index) => (
|
||||
<ListItem
|
||||
key={index}
|
||||
p={2}
|
||||
cursor='pointer'
|
||||
_hover={{
|
||||
bgColor: 'primary.50',
|
||||
}}
|
||||
_active={{
|
||||
bgColor: 'primary.100',
|
||||
}}
|
||||
onClick={() => handleSuggestionClick(suggestion)}
|
||||
>
|
||||
{suggestion.displayName}
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
</PopoverBody>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</Box>
|
||||
);
|
||||
},
|
||||
true,
|
||||
['suggest', 'geocode'],
|
||||
);
|
||||
|
||||
export const LocationInput = memo(forwardRef<HTMLInputElement, LocationInputProps>(
|
||||
function LocationInput(props, ref) {
|
||||
return <BaseLocationInput {...props} inputRef={ref} />;
|
||||
},
|
||||
));
|
||||
|
||||
// todo: i18n
|
||||
// todo: replace console.error with toast
|
||||
|
||||
@@ -31,8 +31,22 @@ export const MapComponent: FC<{
|
||||
}
|
||||
}, [selectedLocation]);
|
||||
|
||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setWindowWidth(window.innerWidth);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('resize', handleResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Map
|
||||
key={windowWidth}
|
||||
state={{
|
||||
center: mapCenter,
|
||||
zoom:
|
||||
|
||||
@@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next';
|
||||
import { Box, Flex, FormControl, FormLabel, VStack } from '@chakra-ui/react';
|
||||
|
||||
import { CarBodySelect } from './car-body';
|
||||
import { CarColorInput } from './car-color';
|
||||
import { CarNumberInput } from './car-number';
|
||||
import { FormInputField, FormControllerField } from './field';
|
||||
import { OrderFormProps, OrderFormValues } from './types';
|
||||
@@ -18,6 +17,7 @@ import {
|
||||
StringLocation,
|
||||
YMapsProvider,
|
||||
} from './location';
|
||||
import { CarColorSelect } from './car-color';
|
||||
|
||||
export const OrderForm = ({ onSubmit, loading, ...props }: OrderFormProps) => {
|
||||
const {
|
||||
@@ -72,7 +72,7 @@ export const OrderForm = ({ onSubmit, loading, ...props }: OrderFormProps) => {
|
||||
name='carColor'
|
||||
label={t('car-color-field.label')}
|
||||
errors={errors}
|
||||
Input={CarColorInput}
|
||||
Input={CarColorSelect}
|
||||
/>
|
||||
<FormInputField
|
||||
control={control}
|
||||
|
||||
@@ -64,7 +64,7 @@ export const CarImageForm: FC<CarImageFormProps> = memo(function CarImageForm({
|
||||
<Input
|
||||
{...field}
|
||||
ref={fileInputRef}
|
||||
accept='.jpg,.png'
|
||||
accept='image/png,image/jpeg'
|
||||
value={value?.fileName}
|
||||
onChange={(event) => {
|
||||
onChange(event.target.files[0]);
|
||||
|
||||
@@ -11,7 +11,7 @@ export const useHandleUploadCarImageResponse = (query: {
|
||||
}) => {
|
||||
const toast = useToast();
|
||||
const { t } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-create.upload-car-image-query',
|
||||
keyPrefix: 'dry-wash.order-view.upload-car-image-query',
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -10,12 +10,17 @@ import {
|
||||
} from '@chakra-ui/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||
dayjs.extend(localizedFormat);
|
||||
import 'dayjs/locale/ru';
|
||||
import 'dayjs/locale/en';
|
||||
|
||||
import { Order } from '../../../models/landing';
|
||||
import { formatDatetime } from '../../../lib';
|
||||
import { carBodySelectOptions } from '../../order-form/form/car-body/helper';
|
||||
import {
|
||||
carBodySelectOptions,
|
||||
carColorSelectOptions,
|
||||
} from '../../order-form';
|
||||
|
||||
import { OrderStatus } from './status';
|
||||
|
||||
@@ -43,26 +48,32 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
||||
location,
|
||||
startWashTime,
|
||||
endWashTime,
|
||||
created
|
||||
created,
|
||||
}) => {
|
||||
const { t } = useTranslation('~', {
|
||||
const { t, i18n } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-view.details',
|
||||
});
|
||||
dayjs.locale(i18n.language);
|
||||
const { t: tCarBody } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-create.car-body-select.options',
|
||||
});
|
||||
const { t: tCarColor } = useTranslation('~', {
|
||||
keyPrefix: 'dry-wash.order-create.car-color-select.colors',
|
||||
});
|
||||
const carColorTKey = carColorSelectOptions.find(({ value }) => value === carColor)?.labelTKey;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Heading as='h2' size='lg' marginInline='auto'>
|
||||
{t('title', { number: orderNumber })}
|
||||
</Heading>
|
||||
<HStack
|
||||
width='full'
|
||||
flexWrap='wrap'
|
||||
justifyContent='space-between'
|
||||
gap={2}
|
||||
>
|
||||
<Heading as='h2' size='lg'>
|
||||
{t('title', { number: orderNumber })} ({dayjs(created).format('LLLL')})
|
||||
</Heading>
|
||||
<Text>{dayjs(created).format('LLL')}</Text>
|
||||
<OrderStatus value={status} />
|
||||
</HStack>
|
||||
<UnorderedList styleType='none'>
|
||||
@@ -78,7 +89,7 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
||||
tCarBody(
|
||||
`${carBodySelectOptions.find(({ value }) => value === carBody)?.labelTKey}`,
|
||||
),
|
||||
carColor,
|
||||
carColorTKey ? tCarColor(carColorTKey) : carColor,
|
||||
]
|
||||
.filter((v) => v)
|
||||
.join(', '),
|
||||
|
||||
@@ -38,8 +38,7 @@ type GetArrItemType<ArrType> =
|
||||
export const statuses = [
|
||||
'pending' as const,
|
||||
'progress' as const,
|
||||
'working' as const,
|
||||
'canceled' as const,
|
||||
'cancelled' as const,
|
||||
'complete' as const,
|
||||
];
|
||||
|
||||
@@ -53,7 +52,7 @@ export type OrderArm = {
|
||||
status?: GetArrItemType<typeof statuses>;
|
||||
phone?: string;
|
||||
location?: string;
|
||||
master: Master;
|
||||
master: string | [];
|
||||
notes: '';
|
||||
allMasters: Master[];
|
||||
id: string;
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
export type RegistrationNumber = string; // А012ВЕ16
|
||||
|
||||
export type Color = string; // #000000
|
||||
export const enum Color {
|
||||
WHITE,
|
||||
BLACK,
|
||||
SILVER,
|
||||
GRAY,
|
||||
BEIGE_BROWN,
|
||||
RED,
|
||||
BLUE,
|
||||
GREEN,
|
||||
}
|
||||
|
||||
export const enum BodyStyle {
|
||||
UNKNOWN = 0,
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
import { IsoDate } from "../common";
|
||||
import { IsoDate } from '../common';
|
||||
|
||||
import { Car, Customer, Washing } from ".";
|
||||
import { Car, Customer, Washing } from '.';
|
||||
|
||||
export type Id = string;
|
||||
|
||||
export type Status = 'pending' |
|
||||
'progress' |
|
||||
'working' |
|
||||
'canceled' |
|
||||
'complete';
|
||||
export type Status =
|
||||
| 'pending'
|
||||
| 'progress'
|
||||
| 'working'
|
||||
| 'canceled'
|
||||
| 'complete';
|
||||
|
||||
export type Create = {
|
||||
customer: {
|
||||
phone: Customer.PhoneNumber,
|
||||
phone: Customer.PhoneNumber;
|
||||
};
|
||||
car: {
|
||||
number: Car.RegistrationNumber,
|
||||
body: Car.BodyStyle,
|
||||
color: Car.Color,
|
||||
},
|
||||
number: Car.RegistrationNumber;
|
||||
body: Car.BodyStyle;
|
||||
color: Car.Color | string;
|
||||
};
|
||||
washing: {
|
||||
location: Washing.Location
|
||||
begin: Washing.AvailableBeginDateTime,
|
||||
end: Washing.AvailableEndDateTime,
|
||||
}
|
||||
location: Washing.Location;
|
||||
begin: Washing.AvailableBeginDateTime;
|
||||
end: Washing.AvailableEndDateTime;
|
||||
};
|
||||
};
|
||||
|
||||
export type Number = string;
|
||||
@@ -32,14 +33,17 @@ export type View = {
|
||||
phone: Customer.PhoneNumber;
|
||||
carNumber: Car.RegistrationNumber;
|
||||
carBody: Car.BodyStyle;
|
||||
carColor?: Car.Color;
|
||||
carColor?: Car.Color | string;
|
||||
location: Washing.Location;
|
||||
startWashTime: Washing.AvailableBeginDateTime;
|
||||
endWashTime: Washing.AvailableEndDateTime;
|
||||
orderNumber: Number,
|
||||
status: Status,
|
||||
orderNumber: Number;
|
||||
status: Status;
|
||||
notes: string;
|
||||
created: IsoDate;
|
||||
updated: IsoDate;
|
||||
id: Id;
|
||||
};
|
||||
image?: string;
|
||||
imageRating?: string;
|
||||
imageDescription?: string;
|
||||
};
|
||||
|
||||
@@ -1,48 +1,44 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Master Page render 1`] = `
|
||||
exports[`Master Page should display master list and show details when master button is clicked 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="css-1yeiifd"
|
||||
class="css-s92abg"
|
||||
>
|
||||
<div
|
||||
class="css-13owfwq"
|
||||
<header
|
||||
class="css-106dwq4"
|
||||
>
|
||||
<h2
|
||||
class="chakra-heading css-173d1bl"
|
||||
>
|
||||
Сухой мастер
|
||||
</h2>
|
||||
<div
|
||||
class="chakra-stack css-1cggwyz"
|
||||
class="css-br9knx"
|
||||
>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-18yoix2"
|
||||
href="/order"
|
||||
<h2
|
||||
class="chakra-heading css-8w8uga"
|
||||
>
|
||||
Заказы
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-1kg18wp"
|
||||
data-testid="master-button"
|
||||
href="/master"
|
||||
Сухой мастер
|
||||
</h2>
|
||||
<div
|
||||
class="chakra-stack css-1rafi8n"
|
||||
>
|
||||
Мастера
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-19byqlw"
|
||||
href="/order"
|
||||
>
|
||||
Заказы
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="vertical"
|
||||
class="chakra-divider css-zw0v9u"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-g11sl9"
|
||||
data-testid="master-button"
|
||||
href="/master"
|
||||
>
|
||||
Мастера
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div
|
||||
class="css-jiwy8d"
|
||||
>
|
||||
|
||||
@@ -90,65 +90,163 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
>
|
||||
Цвет автомобиля
|
||||
</label>
|
||||
<input
|
||||
class="chakra-input css-moii5c"
|
||||
id="field-:r2:"
|
||||
list=":r3:"
|
||||
name="carColor"
|
||||
value=""
|
||||
/>
|
||||
<datalist
|
||||
id=":r3:"
|
||||
<div
|
||||
class="chakra-stack css-uv9e93"
|
||||
>
|
||||
<option
|
||||
label="white"
|
||||
value="#ffffff"
|
||||
<div
|
||||
class="css-ed0q6j"
|
||||
>
|
||||
white
|
||||
</option>
|
||||
<option
|
||||
label="black"
|
||||
value="#000000"
|
||||
>
|
||||
black
|
||||
</option>
|
||||
<option
|
||||
label="silver"
|
||||
value="#c0c0c0"
|
||||
>
|
||||
silver
|
||||
</option>
|
||||
<option
|
||||
label="gray"
|
||||
value="#808080"
|
||||
>
|
||||
gray
|
||||
</option>
|
||||
<option
|
||||
label="beige-brown"
|
||||
value="#796745"
|
||||
>
|
||||
beige-brown
|
||||
</option>
|
||||
<option
|
||||
label="red"
|
||||
value="#b90000"
|
||||
>
|
||||
red
|
||||
</option>
|
||||
<option
|
||||
label="blue"
|
||||
value="#003B62"
|
||||
>
|
||||
blue
|
||||
</option>
|
||||
<option
|
||||
label="green"
|
||||
value="#078d51"
|
||||
>
|
||||
green
|
||||
</option>
|
||||
</datalist>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-96lva5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-c58w4d"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-ltoa43"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-vqo9x6"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-1lr2es4"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-1wfunc4"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-fg5oe6"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-11g98ql"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-f0pfxe"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
<button
|
||||
class="css-6su6fj"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="css-bf4qsc"
|
||||
>
|
||||
<div
|
||||
class="css-1k9efnl"
|
||||
>
|
||||
<div
|
||||
class="css-r58uxc"
|
||||
/>
|
||||
<p
|
||||
class="chakra-text css-1xa8ojw"
|
||||
>
|
||||
Другой
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="chakra-form-control css-1kxonj9"
|
||||
@@ -157,7 +255,7 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<label
|
||||
class="chakra-form__label css-g6pte"
|
||||
for="carBody"
|
||||
id="field-:r4:-label"
|
||||
id="field-:r3:-label"
|
||||
>
|
||||
Тип кузова автомобиля
|
||||
<span
|
||||
@@ -169,13 +267,13 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
</span>
|
||||
</label>
|
||||
<div
|
||||
class="css-8atqhb"
|
||||
class="css-1kxonj9"
|
||||
>
|
||||
<input
|
||||
aria-readonly="true"
|
||||
aria-required="true"
|
||||
class="chakra-input css-moii5c"
|
||||
id="field-:r4:"
|
||||
id="field-:r3:"
|
||||
name="carBody"
|
||||
placeholder="Не указан"
|
||||
readonly=""
|
||||
@@ -184,19 +282,19 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
/>
|
||||
<div
|
||||
class="chakra-popover__popper css-iy22zq"
|
||||
style="visibility: hidden; position: absolute; inset: 0 auto auto 0;"
|
||||
style="visibility: hidden; position: fixed; inset: 0 auto auto 0;"
|
||||
>
|
||||
<section
|
||||
aria-describedby="popover-body-:r8:"
|
||||
aria-describedby="popover-body-:r7:"
|
||||
class="chakra-popover__content css-1mvj5hv"
|
||||
id="popover-content-:r8:"
|
||||
id="popover-content-:r7:"
|
||||
role="dialog"
|
||||
style="transform-origin: var(--popper-transform-origin); opacity: 0; visibility: hidden; transform: scale(0.95) translateZ(0);"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="chakra-popover__body css-1uqsyei"
|
||||
id="popover-body-:r8:"
|
||||
id="popover-body-:r7:"
|
||||
>
|
||||
<div
|
||||
class="css-124gwxm"
|
||||
@@ -211,8 +309,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:r9:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:r8:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -243,8 +341,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:ra:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:r9:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -275,8 +373,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:rb:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:ra:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -307,8 +405,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:rc:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:rb:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -339,8 +437,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:rd:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:rc:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -371,8 +469,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:re:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:rd:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -403,8 +501,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:rf:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:re:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -435,8 +533,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:rg:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:rf:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -467,8 +565,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:rh:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:rg:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -499,8 +597,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:ri:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:rh:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -531,8 +629,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<input
|
||||
aria-required="true"
|
||||
hidden=""
|
||||
id="radio-:rj:"
|
||||
name="radio-:r5:"
|
||||
id="radio-:ri:"
|
||||
name="radio-:r4:"
|
||||
required=""
|
||||
style="border: 0px; clip: rect(0px, 0px, 0px, 0px); height: 1px; width: 1px; margin: -1px; padding: 0px; overflow: hidden; white-space: nowrap; position: absolute;"
|
||||
type="radio"
|
||||
@@ -566,8 +664,8 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
>
|
||||
<label
|
||||
class="chakra-form__label css-g6pte"
|
||||
for="field-:rk:"
|
||||
id="field-:rk:-label"
|
||||
for="field-:rj:"
|
||||
id="field-:rj:-label"
|
||||
>
|
||||
В какое время автомобиль доступен?
|
||||
<span
|
||||
@@ -590,7 +688,7 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
>
|
||||
<input
|
||||
class="chakra-input css-moii5c"
|
||||
id="field-:rl:"
|
||||
id="field-:rk:"
|
||||
max=""
|
||||
name="availableDatetimeBegin"
|
||||
type="datetime-local"
|
||||
@@ -607,7 +705,7 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
>
|
||||
<input
|
||||
class="chakra-input css-moii5c"
|
||||
id="field-:rm:"
|
||||
id="field-:rl:"
|
||||
min=""
|
||||
name="availableDatetimeEnd"
|
||||
type="datetime-local"
|
||||
@@ -624,7 +722,7 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<label
|
||||
class="chakra-form__label css-g6pte"
|
||||
for="carLocation"
|
||||
id="field-:rn:-label"
|
||||
id="field-:rm:-label"
|
||||
>
|
||||
Где находится автомобиль?
|
||||
<span
|
||||
@@ -638,7 +736,7 @@ exports[`Create Order page renders page structure 1`] = `
|
||||
<div />
|
||||
<div
|
||||
class="chakra-form__helper-text css-186pyma"
|
||||
id="field-:rn:-helptext"
|
||||
id="field-:rm:-helptext"
|
||||
>
|
||||
Например, 55.754364, 48.743295 Университетская улица, 1, Иннополис, Верхнеуслонский район, Республика Татарстан (Татарстан), 420500
|
||||
</div>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,48 +1,44 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`order page получение списка заказов 1`] = `
|
||||
exports[`Страница заказов должна корректно отображать список заказов после загрузки данных 1`] = `
|
||||
<div>
|
||||
<div
|
||||
class="css-1yeiifd"
|
||||
class="css-s92abg"
|
||||
>
|
||||
<div
|
||||
class="css-13owfwq"
|
||||
<header
|
||||
class="css-106dwq4"
|
||||
>
|
||||
<h2
|
||||
class="chakra-heading css-173d1bl"
|
||||
>
|
||||
Сухой мастер
|
||||
</h2>
|
||||
<div
|
||||
class="chakra-stack css-1cggwyz"
|
||||
class="css-br9knx"
|
||||
>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-1kg18wp"
|
||||
href="/auth/login"
|
||||
<h2
|
||||
class="chakra-heading css-8w8uga"
|
||||
>
|
||||
Заказы
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-1kg18wp"
|
||||
data-testid="master-button"
|
||||
href="/auth/login"
|
||||
Сухой мастер
|
||||
</h2>
|
||||
<div
|
||||
class="chakra-stack css-1rafi8n"
|
||||
>
|
||||
Мастера
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="horizontal"
|
||||
class="chakra-divider css-svjswr"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-g11sl9"
|
||||
href="/auth/login"
|
||||
>
|
||||
Заказы
|
||||
</a>
|
||||
<hr
|
||||
aria-orientation="vertical"
|
||||
class="chakra-divider css-zw0v9u"
|
||||
/>
|
||||
<a
|
||||
class="chakra-button css-g11sl9"
|
||||
data-testid="master-button"
|
||||
href="/auth/login"
|
||||
>
|
||||
Мастера
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div
|
||||
class="css-jiwy8d"
|
||||
>
|
||||
@@ -75,7 +71,7 @@ exports[`order page получение списка заказов 1`] = `
|
||||
<p
|
||||
class="chakra-text css-52ukzg"
|
||||
>
|
||||
16.02.2025
|
||||
12.03.2025
|
||||
</p>
|
||||
<button
|
||||
class="chakra-button css-ez23ye"
|
||||
@@ -177,12 +173,7 @@ exports[`order page получение списка заказов 1`] = `
|
||||
Выполняется
|
||||
</option>
|
||||
<option
|
||||
value="working"
|
||||
>
|
||||
В работе
|
||||
</option>
|
||||
<option
|
||||
value="canceled"
|
||||
value="cancelled"
|
||||
>
|
||||
Отменено
|
||||
</option>
|
||||
@@ -273,7 +264,80 @@ exports[`order page получение списка заказов 1`] = `
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
Казань, ул. Баумана, 1
|
||||
<button
|
||||
aria-controls="popover-content-:r1:"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="dialog"
|
||||
class="chakra-button css-ez23ye"
|
||||
id="popover-trigger-:r1:"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="currentColor"
|
||||
>
|
||||
<path
|
||||
d="M23.432,10.524C20.787,7.614,16.4,4.538,12,4.6,7.6,4.537,3.213,7.615.568,10.524a2.211,2.211,0,0,0,0,2.948C3.182,16.351,7.507,19.4,11.839,19.4h.308c4.347,0,8.671-3.049,11.288-5.929A2.21,2.21,0,0,0,23.432,10.524ZM7.4,12A4.6,4.6,0,1,1,12,16.6,4.6,4.6,0,0,1,7.4,12Z"
|
||||
/>
|
||||
<circle
|
||||
cx="12"
|
||||
cy="12"
|
||||
r="2"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="chakra-popover__popper css-iy22zq"
|
||||
style="visibility: hidden; position: absolute; min-width: max-content; inset: 0 auto auto 0;"
|
||||
>
|
||||
<section
|
||||
aria-describedby="popover-body-:r1:"
|
||||
class="chakra-popover__content css-sjj62m"
|
||||
id="popover-content-:r1:"
|
||||
role="dialog"
|
||||
style="transform-origin: var(--popper-transform-origin); opacity: 0; visibility: hidden; transform: scale(0.95) translateZ(0);"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="chakra-popover__arrow-positioner css-0"
|
||||
data-popper-arrow=""
|
||||
style="position: absolute;"
|
||||
>
|
||||
<div
|
||||
class="chakra-popover__arrow css-0"
|
||||
data-popper-arrow-inner=""
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
aria-label="Close"
|
||||
class="chakra-popover__close-btn css-1o8qips"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="chakra-popover__body css-45vz3u"
|
||||
id="popover-body-:r1:"
|
||||
>
|
||||
Казань, ул. Баумана, 1
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
@@ -316,12 +380,7 @@ exports[`order page получение списка заказов 1`] = `
|
||||
Выполняется
|
||||
</option>
|
||||
<option
|
||||
value="working"
|
||||
>
|
||||
В работе
|
||||
</option>
|
||||
<option
|
||||
value="canceled"
|
||||
value="cancelled"
|
||||
>
|
||||
Отменено
|
||||
</option>
|
||||
@@ -412,7 +471,80 @@ exports[`order page получение списка заказов 1`] = `
|
||||
<td
|
||||
class="css-zgoslk"
|
||||
>
|
||||
Казань, ул. Баумана, 43
|
||||
<button
|
||||
aria-controls="popover-content-:r3:"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="dialog"
|
||||
class="chakra-button css-ez23ye"
|
||||
id="popover-trigger-:r3:"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<g
|
||||
fill="currentColor"
|
||||
>
|
||||
<path
|
||||
d="M23.432,10.524C20.787,7.614,16.4,4.538,12,4.6,7.6,4.537,3.213,7.615.568,10.524a2.211,2.211,0,0,0,0,2.948C3.182,16.351,7.507,19.4,11.839,19.4h.308c4.347,0,8.671-3.049,11.288-5.929A2.21,2.21,0,0,0,23.432,10.524ZM7.4,12A4.6,4.6,0,1,1,12,16.6,4.6,4.6,0,0,1,7.4,12Z"
|
||||
/>
|
||||
<circle
|
||||
cx="12"
|
||||
cy="12"
|
||||
r="2"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="chakra-popover__popper css-iy22zq"
|
||||
style="visibility: hidden; position: absolute; min-width: max-content; inset: 0 auto auto 0;"
|
||||
>
|
||||
<section
|
||||
aria-describedby="popover-body-:r3:"
|
||||
class="chakra-popover__content css-sjj62m"
|
||||
id="popover-content-:r3:"
|
||||
role="dialog"
|
||||
style="transform-origin: var(--popper-transform-origin); opacity: 0; visibility: hidden; transform: scale(0.95) translateZ(0);"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="chakra-popover__arrow-positioner css-0"
|
||||
data-popper-arrow=""
|
||||
style="position: absolute;"
|
||||
>
|
||||
<div
|
||||
class="chakra-popover__arrow css-0"
|
||||
data-popper-arrow-inner=""
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
aria-label="Close"
|
||||
class="chakra-popover__close-btn css-1o8qips"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="chakra-icon css-onkibi"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M.439,21.44a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,1,0,2.122-2.121L14.3,12.177a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.44L12.177,9.7a.25.25,0,0,1-.354,0L2.561.44A1.5,1.5,0,0,0,.439,2.561L9.7,11.823a.25.25,0,0,1,0,.354Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<div
|
||||
class="chakra-popover__body css-45vz3u"
|
||||
id="popover-body-:r3:"
|
||||
>
|
||||
Казань, ул. Баумана, 43
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -54,6 +54,41 @@ const server = setupServer(
|
||||
],
|
||||
});
|
||||
}),
|
||||
http.post('/api/arm/orders', () => {
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
body: [
|
||||
{
|
||||
id: 'order1',
|
||||
carNumber: 'A123BC',
|
||||
startWashTime: '2024-11-24T10:30:00.000Z',
|
||||
endWashTime: '2024-11-24T16:30:00.000Z',
|
||||
orderDate: '2024-11-24T08:41:46.366Z',
|
||||
status: 'pending',
|
||||
phone: '79001234563',
|
||||
location: 'Казань, ул. Баумана, 1',
|
||||
master: {
|
||||
name: 'Олег Макаров',
|
||||
phone: '79001234567',
|
||||
id: '23423442',
|
||||
},
|
||||
notes: '',
|
||||
},
|
||||
{
|
||||
id: 'order2',
|
||||
carNumber: 'A245BC',
|
||||
startWashTime: '2024-11-24T11:30:00.000Z',
|
||||
endWashTime: '2024-11-24T17:30:00.000Z',
|
||||
orderDate: '2024-11-24T07:40:46.366Z',
|
||||
status: 'progress',
|
||||
phone: '79001234567',
|
||||
location: 'Казань, ул. Баумана, 43',
|
||||
master: [],
|
||||
notes: '',
|
||||
},
|
||||
],
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
jest.mock('@brojs/cli', () => {
|
||||
@@ -70,11 +105,7 @@ describe('Master Page', () => {
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
it('render ', async () => {
|
||||
server.events.on('request:start', ({ request }) => {
|
||||
console.log('Outgoing:', request.method, request.url);
|
||||
});
|
||||
|
||||
it('should display master list and show details when master button is clicked', async () => {
|
||||
const { container } = render(
|
||||
<Provider store={store}>
|
||||
<ChakraProvider theme={chakraTheme}>
|
||||
@@ -88,10 +119,14 @@ describe('Master Page', () => {
|
||||
);
|
||||
|
||||
const button = await waitFor(() => screen.getByTestId('master-button'));
|
||||
|
||||
fireEvent.click(button);
|
||||
|
||||
await waitFor(() => screen.getByText('Иван Иванов'));
|
||||
// Проверяем отображение всех мастеров
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Иван Иванов')).toBeInTheDocument();
|
||||
expect(screen.getByText('Олег Макаров')).toBeInTheDocument();
|
||||
expect(screen.getByText('Иван Галкин')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
63
src/pages/__tests__/notFound.test.tsx
Normal file
63
src/pages/__tests__/notFound.test.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
|
||||
import NotFound from '../notFound/notFound';
|
||||
|
||||
// Mock the translation hook
|
||||
jest.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => {
|
||||
const translations = {
|
||||
'notFound.title': 'Page Not Found',
|
||||
'notFound.description': 'The page you are looking for does not exist',
|
||||
'notFound.button.back': 'Back to Home'
|
||||
};
|
||||
return translations[key] || key;
|
||||
}
|
||||
})
|
||||
}));
|
||||
|
||||
// Mock the Lottie Player component
|
||||
jest.mock('@lottiefiles/react-lottie-player', () => ({
|
||||
Player: () => <div data-testid="lottie-animation">Animation Mock</div>
|
||||
}));
|
||||
|
||||
describe('NotFound Component', () => {
|
||||
const renderNotFound = () => {
|
||||
return render(
|
||||
<ChakraProvider>
|
||||
<BrowserRouter>
|
||||
<NotFound />
|
||||
</BrowserRouter>
|
||||
</ChakraProvider>
|
||||
);
|
||||
};
|
||||
|
||||
it('renders without crashing', () => {
|
||||
renderNotFound();
|
||||
});
|
||||
|
||||
it('displays the correct content', () => {
|
||||
renderNotFound();
|
||||
|
||||
// Check if title is present
|
||||
expect(screen.getByText('Page Not Found')).toBeInTheDocument();
|
||||
|
||||
// Check if description is present
|
||||
expect(screen.getByText('The page you are looking for does not exist')).toBeInTheDocument();
|
||||
|
||||
// Check if back button is present
|
||||
expect(screen.getByText('Back to Home')).toBeInTheDocument();
|
||||
|
||||
// Check if Lottie animation is rendered
|
||||
expect(screen.getByTestId('lottie-animation')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('contains a link to the dry-wash page', () => {
|
||||
renderNotFound();
|
||||
const backButton = screen.getByText('Back to Home');
|
||||
expect(backButton.closest('a')).toHaveAttribute('href', '/dry-wash');
|
||||
});
|
||||
});
|
||||
@@ -11,12 +11,12 @@ jest.mock('react-router-dom', () => ({
|
||||
useParams: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('Order View page, initial load', () => {
|
||||
describe('Страница просмотра заказа', () => {
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
test('shows order details loading', () => {
|
||||
test('отображает индикатор загрузки деталей заказа', () => {
|
||||
(useParams as jest.Mock).mockReturnValue({ orderId: 'id1' });
|
||||
|
||||
const { container } = render(
|
||||
@@ -33,7 +33,7 @@ describe('Order View page, initial load', () => {
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('shows order details', async () => {
|
||||
test('отображает детали заказа после успешной загрузки', async () => {
|
||||
(useParams as jest.Mock).mockReturnValue({ orderId: 'id1' });
|
||||
|
||||
const { container } = render(
|
||||
@@ -52,7 +52,7 @@ describe('Order View page, initial load', () => {
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('shows order error', async () => {
|
||||
test('отображает ошибку при некорректном ID заказа', async () => {
|
||||
(useParams as jest.Mock).mockReturnValue({ orderId: null });
|
||||
|
||||
const { container } = render(
|
||||
|
||||
@@ -46,10 +46,6 @@ describe('order page', () => {
|
||||
afterAll(() => server.close());
|
||||
|
||||
it('получение пустого списка', async () => {
|
||||
server.events.on('request:start', ({ request }) => {
|
||||
console.log('Outgoing:', request.method, request.url);
|
||||
});
|
||||
|
||||
render(
|
||||
<Provider store={store}>
|
||||
<ChakraProvider theme={chakraTheme}>
|
||||
|
||||
@@ -21,9 +21,43 @@ import Page from '../arm';
|
||||
import { PageSpinner } from '../../components';
|
||||
|
||||
const server = setupServer(
|
||||
http.get('/api/arm/orders', () => {
|
||||
http.post('/api/arm/orders', () => {
|
||||
return HttpResponse.json({}, { status: 500 });
|
||||
}),
|
||||
http.get('/api/arm/masters', () => {
|
||||
return HttpResponse.json({
|
||||
success: true,
|
||||
body: [
|
||||
{
|
||||
id: '4545423234',
|
||||
name: 'Иван Иванов',
|
||||
phone: '+7 900 123 45 67',
|
||||
},
|
||||
{
|
||||
name: 'Олег Макаров',
|
||||
phone: '79001234567',
|
||||
id: '23423442',
|
||||
},
|
||||
{
|
||||
id: '345354234',
|
||||
name: 'Иван Галкин',
|
||||
schedule: [
|
||||
{
|
||||
id: 'order1',
|
||||
startWashTime: '2024-11-24T10:30:00.000Z',
|
||||
endWashTime: '2024-11-24T16:30:00.000Z',
|
||||
},
|
||||
{
|
||||
id: 'order2',
|
||||
startWashTime: '2024-11-24T11:30:00.000Z',
|
||||
endWashTime: '2024-11-24T17:30:00.000Z',
|
||||
},
|
||||
],
|
||||
phone: '+7 900 123 45 67',
|
||||
},
|
||||
],
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
jest.mock('@brojs/cli', () => {
|
||||
|
||||
@@ -98,16 +98,12 @@ jest.mock('@brojs/cli', () => {
|
||||
};
|
||||
});
|
||||
|
||||
describe('order page', () => {
|
||||
describe('Страница заказов', () => {
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
it('получение списка заказов ', async () => {
|
||||
server.events.on('request:start', ({ request }) => {
|
||||
console.log('Outgoing:', request.method, request.url);
|
||||
});
|
||||
|
||||
it('должна корректно отображать список заказов после загрузки данных', async () => {
|
||||
const { container } = render(
|
||||
<Provider store={store}>
|
||||
<ChakraProvider theme={chakraTheme}>
|
||||
|
||||
@@ -22,6 +22,7 @@ import { landingApi } from '../../__data__/service/landing.api';
|
||||
import { isErrorMessage } from '../../models/api';
|
||||
import { FEATURE } from '../../__data__/features';
|
||||
import { CarImageForm } from '../../components/order-view/car-img';
|
||||
import PriceCar from '../../components/PriceCar';
|
||||
|
||||
const Page: FC = () => {
|
||||
const { t } = useTranslation('~', {
|
||||
@@ -70,7 +71,12 @@ const Page: FC = () => {
|
||||
<>
|
||||
<>
|
||||
{isSuccess && (
|
||||
<VStack p={4} alignItems='flex-start' gap={4}>
|
||||
<VStack
|
||||
p={4}
|
||||
alignItems='flex-start'
|
||||
gap={4}
|
||||
data-testid='order-details'
|
||||
>
|
||||
<OrderDetails
|
||||
orderNumber={order.orderNumber}
|
||||
status={order.status}
|
||||
@@ -82,9 +88,17 @@ const Page: FC = () => {
|
||||
startWashTime={order.startWashTime}
|
||||
endWashTime={order.endWashTime}
|
||||
created={order.created}
|
||||
data-testid='order-details'
|
||||
/>
|
||||
<CarImageForm orderId={orderId} />
|
||||
{FEATURE.carImageUpload.isOn && (
|
||||
<CarImageForm orderId={orderId} />
|
||||
)}
|
||||
{FEATURE.carImageUpload.isOn && order.image && (
|
||||
<PriceCar
|
||||
image={order?.image}
|
||||
rating={order?.imageRating}
|
||||
description={order?.imageDescription}
|
||||
/>
|
||||
)}
|
||||
</VStack>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -9,12 +9,8 @@
|
||||
"orderDate": "2024-11-24T08:41:46.366Z",
|
||||
"status": "pending",
|
||||
"phone": "79001234563",
|
||||
"location": "Казань, ул. Баумана, 1",
|
||||
"master": {
|
||||
"name": "Олег Макаров",
|
||||
"phone": "79001234567",
|
||||
"id": "23423442"
|
||||
},
|
||||
"location": "55.779905316526424,49.12446113769528 Республика Татарстан (Татарстан),н Казань, ул. Баумана, 1",
|
||||
"master": "4545423234",
|
||||
"notes": ""
|
||||
},
|
||||
{
|
||||
@@ -25,7 +21,7 @@
|
||||
"orderDate": "2024-11-24T07:40:46.366Z",
|
||||
"status": "progress",
|
||||
"phone": "79001234567",
|
||||
"location": "Казань, ул. Баумана, 43",
|
||||
"location": "55.779905316526424,49.12446113769528 Республика Татарстан (Татарстан), Казань, озеро Нижний Кабан",
|
||||
"master": [],
|
||||
"notes": ""
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -4,7 +4,7 @@
|
||||
"phone": "+79876543210",
|
||||
"carNumber": "А123АА16",
|
||||
"carBody": 2,
|
||||
"carColor": "#ffffff",
|
||||
"carColor": "мокрый асфальт",
|
||||
"startWashTime": "2025-01-19T14:03:00.000Z",
|
||||
"endWashTime": "2025-01-19T14:03:00.000Z",
|
||||
"location": "55.793833888711006,49.19037910644527 Республика Татарстан (Татарстан), Казань, жилой район Седьмое Небо",
|
||||
@@ -15,4 +15,4 @@
|
||||
"updated": "2025-01-19T14:04:02.987Z",
|
||||
"id": "id1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user