Merge branch 'feature/order'
This commit is contained in:
commit
0b9d8c9fb6
@ -3,7 +3,9 @@ import { jest } from '@jest/globals';
|
|||||||
jest.mock('@brojs/cli', () => ({
|
jest.mock('@brojs/cli', () => ({
|
||||||
getConfigValue: jest.fn(() => '/api'),
|
getConfigValue: jest.fn(() => '/api'),
|
||||||
getFeatures: jest.fn(() => ({
|
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) => {
|
getNavigationValue: jest.fn((navKey: string) => {
|
||||||
switch (navKey) {
|
switch (navKey) {
|
||||||
|
@ -5,7 +5,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
coverageProvider: 'v8',
|
coverageProvider: 'v8',
|
||||||
coverageDirectory: 'coverage',
|
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,
|
collectCoverage: true,
|
||||||
clearMocks: true,
|
clearMocks: true,
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
|
@ -67,6 +67,9 @@
|
|||||||
"dry-wash.order-view.upload-car-image.file-input.button": "Upload",
|
"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.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.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.master.add": "Add",
|
||||||
"dry-wash.arm.order.title": "Orders",
|
"dry-wash.arm.order.title": "Orders",
|
||||||
"dry-wash.arm.order.table.empty": "Table empty",
|
"dry-wash.arm.order.table.empty": "Table empty",
|
||||||
|
@ -122,6 +122,9 @@
|
|||||||
"dry-wash.order-view.upload-car-image.file-input.button": "Загрузить",
|
"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.success.title": "Изображение автомобиля успешно загружено",
|
||||||
"dry-wash.order-view.upload-car-image-query.error.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.title": "Страница не найдена",
|
||||||
"dry-wash.notFound.description": "К сожалению, запрашиваемая вами страница не существует.",
|
"dry-wash.notFound.description": "К сожалению, запрашиваемая вами страница не существует.",
|
||||||
"dry-wash.notFound.button.back": "Вернуться на главную",
|
"dry-wash.notFound.button.back": "Вернуться на главную",
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import { Box, Image, Progress, Text } from '@chakra-ui/react';
|
import { Box, Image, Progress, Text, VStack } from '@chakra-ui/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { getFeatures } from '@brojs/cli';
|
import { getFeatures } from '@brojs/cli';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
const PRICE_INCREASE_PERCENT_PER_RATING = 10; // 10% за каждый балл
|
import { formatPrice, getProgressColor } from './helper';
|
||||||
|
|
||||||
|
const PRICE_INCREASE_PERCENT_PER_RATING = 10;
|
||||||
|
|
||||||
export const PriceCar = ({ image, rating, description }) => {
|
export const PriceCar = ({ image, rating, description }) => {
|
||||||
const BASE_WASH_PRICE: number = Number(
|
const BASE_WASH_PRICE: number = Number(
|
||||||
@ -15,33 +18,56 @@ export const PriceCar = ({ image, rating, description }) => {
|
|||||||
return BASE_WASH_PRICE + priceIncrease;
|
return BASE_WASH_PRICE + priceIncrease;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { i18n, t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.order-view.price-car',
|
||||||
|
});
|
||||||
const washPrice = calculateWashPrice(rating);
|
const washPrice = calculateWashPrice(rating);
|
||||||
|
const formattedPrice = formatPrice(washPrice, i18n.language);
|
||||||
|
|
||||||
const progressValue = (rating / 10) * 100;
|
const progressValue = (rating / 10) * 100;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
alignItems='center'
|
|
||||||
gap={5}
|
gap={5}
|
||||||
width='100%'
|
width='100%'
|
||||||
display='flex'
|
display='flex'
|
||||||
flexDirection='column'
|
justifyContent='center'
|
||||||
|
alignItems='flex-start'
|
||||||
|
flexWrap='wrap'
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
maxWidth='600px'
|
maxWidth='600px'
|
||||||
|
width='100%'
|
||||||
objectFit='contain'
|
objectFit='contain'
|
||||||
borderRadius='md'
|
borderRadius='md'
|
||||||
src={image}
|
src={image}
|
||||||
alt='Car Image'
|
alt=''
|
||||||
/>
|
/>
|
||||||
{rating ? (
|
<Box flex='1 1 40%'>
|
||||||
<Box width='100%' maxW='600px'>
|
{!Number.isNaN(progressValue) ? (
|
||||||
<Text>Рейтинг загрязнения машины:</Text>
|
<VStack alignItems='stretch'>
|
||||||
<Progress value={progressValue} size='sm' colorScheme='red' mt={2} />
|
<Box>
|
||||||
<Text mt={2}>Стоимость мойки: {washPrice.toFixed(2)} руб.</Text>
|
<Text>{t('title')}</Text>
|
||||||
</Box>
|
<Progress
|
||||||
) : (
|
value={progressValue}
|
||||||
<Text>Не удалость определить уровень загрязнения машины</Text>
|
size='sm'
|
||||||
)}
|
sx={{
|
||||||
<Text>{description}</Text>
|
'& > 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>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
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%)`;
|
||||||
|
};
|
@ -40,12 +40,14 @@ export const CarBodySelect = forwardRef<HTMLInputElement, CarBodySelectProps>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box width='100%'>
|
<Box width='100%' pos='relative'>
|
||||||
<Popover
|
<Popover
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
autoFocus={false}
|
autoFocus={false}
|
||||||
placement='bottom-start'
|
placement='bottom-start'
|
||||||
matchWidth
|
matchWidth
|
||||||
|
gutter={2}
|
||||||
|
strategy="fixed"
|
||||||
>
|
>
|
||||||
<PopoverAnchor>
|
<PopoverAnchor>
|
||||||
<Input
|
<Input
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export { CarBodySelect } from './car-body-select';
|
export { CarBodySelect } from './car-body-select';
|
||||||
|
export { carBodySelectOptions } from './helper';
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
@ -1,14 +1,10 @@
|
|||||||
import React, { forwardRef, useState } from 'react';
|
import React, { forwardRef, useState } from 'react';
|
||||||
import {
|
import { Input, Box, Stack, Text, Flex } from '@chakra-ui/react';
|
||||||
Input,
|
|
||||||
Box,
|
|
||||||
Stack,
|
|
||||||
Text,
|
|
||||||
Flex,
|
|
||||||
} from '@chakra-ui/react';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { CAR_COLORS } from './helper';
|
import { Car } from '../../../../models';
|
||||||
|
|
||||||
|
import { carColorSelectOptions } from './helper';
|
||||||
|
|
||||||
interface CarColorSelectProps {
|
interface CarColorSelectProps {
|
||||||
value?: string;
|
value?: string;
|
||||||
@ -18,11 +14,11 @@ interface CarColorSelectProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const CarColorSelect = forwardRef<HTMLInputElement, CarColorSelectProps>(
|
export const CarColorSelect = forwardRef<HTMLInputElement, CarColorSelectProps>(
|
||||||
function CarColorSelect(props) {
|
function CarColorSelect(props, ref) {
|
||||||
const [customColor, setCustomColor] = useState('');
|
const [customColor, setCustomColor] = useState('');
|
||||||
const [isCustom, setIsCustom] = useState(false);
|
const [isCustom, setIsCustom] = useState(false);
|
||||||
|
|
||||||
const handleColorChange = (value: string) => {
|
const handleColorChange = (value: Car.Color | string) => {
|
||||||
if (value === 'custom') {
|
if (value === 'custom') {
|
||||||
setIsCustom(true);
|
setIsCustom(true);
|
||||||
return;
|
return;
|
||||||
@ -33,7 +29,9 @@ export const CarColorSelect = forwardRef<HTMLInputElement, CarColorSelectProps>(
|
|||||||
} as React.ChangeEvent<HTMLInputElement>);
|
} as React.ChangeEvent<HTMLInputElement>);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCustomColorChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleCustomColorChange = (
|
||||||
|
e: React.ChangeEvent<HTMLInputElement>,
|
||||||
|
) => {
|
||||||
const value = e.target.value;
|
const value = e.target.value;
|
||||||
setCustomColor(value);
|
setCustomColor(value);
|
||||||
props.onChange?.({
|
props.onChange?.({
|
||||||
@ -48,107 +46,124 @@ export const CarColorSelect = forwardRef<HTMLInputElement, CarColorSelectProps>(
|
|||||||
const currentValue = isCustom ? 'custom' : props.value;
|
const currentValue = isCustom ? 'custom' : props.value;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing={4} width="100%">
|
<Stack spacing={4} width='100%' ref={ref}>
|
||||||
<Flex gap={3} wrap="nowrap" overflowX="auto" pb={2}>
|
<Flex gap={2} wrap='wrap' pb={2}>
|
||||||
{CAR_COLORS.map(({ name, code }) => (
|
{carColorSelectOptions.map(({ value, labelTKey, code }) => (
|
||||||
<Box
|
<Box
|
||||||
key={name}
|
key={value}
|
||||||
flexShrink={0}
|
flexShrink={0}
|
||||||
as="button"
|
as='button'
|
||||||
type="button"
|
type='button'
|
||||||
onClick={() => handleColorChange(name)}
|
onClick={() => handleColorChange(value)}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
align="center"
|
align='center'
|
||||||
gap={2}
|
gap={2}
|
||||||
p={2}
|
p={1}
|
||||||
borderRadius="full"
|
borderRadius='full'
|
||||||
borderWidth="2px"
|
borderWidth='2px'
|
||||||
borderColor={currentValue === name ? 'primary.500' : 'gray.200'}
|
borderColor='gray.200'
|
||||||
bg={currentValue === name ? 'primary.50' : 'white'}
|
bg='white'
|
||||||
_hover={{
|
_hover={{
|
||||||
borderColor: 'primary.500',
|
borderColor: 'primary.500',
|
||||||
bg: currentValue === name ? 'primary.50' : 'gray.50'
|
bg: 'gray.50',
|
||||||
}}
|
}}
|
||||||
minW={currentValue === name ? '120px' : 'auto'}
|
justify='center'
|
||||||
h="48px"
|
transition='all 0.2s'
|
||||||
justify="center"
|
{...(currentValue === value && {
|
||||||
transition="all 0.2s"
|
borderColor: 'primary.500',
|
||||||
|
bg: 'primary.50',
|
||||||
|
paddingInlineEnd: 3,
|
||||||
|
_hover: {
|
||||||
|
bg: 'primary.50',
|
||||||
|
},
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
<Flex align="center" gap={2}>
|
<Flex align='center' gap={2}>
|
||||||
<Box
|
<Box
|
||||||
w="32px"
|
w='32px'
|
||||||
h="32px"
|
h='32px'
|
||||||
borderRadius="full"
|
borderRadius='full'
|
||||||
bg={code}
|
bg={code}
|
||||||
border="1px"
|
border='1px'
|
||||||
borderColor={currentValue === name ? 'primary.500' : 'gray.200'}
|
borderColor='gray.200'
|
||||||
transition="all 0.2s"
|
transition='all 0.2s'
|
||||||
boxShadow={currentValue === name ? 'sm' : 'none'}
|
boxShadow='none'
|
||||||
|
{...(currentValue === value && {
|
||||||
|
borderColor: 'primary.500',
|
||||||
|
boxShadow: 'sm',
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
{currentValue === name && (
|
{currentValue === value && (
|
||||||
<Text fontSize="xs" color="primary.700" fontWeight="medium">
|
<Text fontSize='xs' color='primary.700' fontWeight='medium'>
|
||||||
{t(`colors.${name}`)}
|
{t(`colors.${labelTKey}`)}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
<Box
|
<Box
|
||||||
flexShrink={0}
|
flexShrink={0}
|
||||||
as="button"
|
as='button'
|
||||||
type="button"
|
type='button'
|
||||||
onClick={() => handleColorChange('custom')}
|
onClick={() => handleColorChange('custom')}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
align="center"
|
align='center'
|
||||||
gap={2}
|
gap={2}
|
||||||
p={2}
|
p={1}
|
||||||
borderRadius="full"
|
paddingInlineEnd={3}
|
||||||
borderWidth="2px"
|
borderRadius='full'
|
||||||
borderColor={isCustom ? 'primary.500' : 'gray.200'}
|
borderWidth='2px'
|
||||||
bg={isCustom ? 'primary.50' : 'white'}
|
borderColor='gray.200'
|
||||||
_hover={{
|
bg='white'
|
||||||
|
_hover={{
|
||||||
borderColor: 'primary.500',
|
borderColor: 'primary.500',
|
||||||
bg: isCustom ? 'primary.50' : 'gray.50'
|
bg: 'gray.50',
|
||||||
}}
|
}}
|
||||||
minW={isCustom ? '200px' : 'auto'}
|
justify='center'
|
||||||
h="48px"
|
transition='all 0.2s'
|
||||||
justify="center"
|
{...(isCustom && {
|
||||||
transition="all 0.2s"
|
borderColor: 'primary.500',
|
||||||
|
paddingInlineStart: 3,
|
||||||
|
bg: 'primary.50',
|
||||||
|
_hover: {
|
||||||
|
bg: 'primary.50',
|
||||||
|
},
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
{isCustom ? (
|
{isCustom ? (
|
||||||
<Flex gap={2} align="center">
|
<Flex gap={2} align='center'>
|
||||||
<Text fontSize="xs" color="primary.700" fontWeight="medium">
|
<Text fontSize='xs' color='primary.700' fontWeight='medium'>
|
||||||
{t('custom-label')}
|
{t('custom-label')}
|
||||||
</Text>
|
</Text>
|
||||||
<Input
|
<Input
|
||||||
size="sm"
|
size='sm'
|
||||||
width="120px"
|
width='120px'
|
||||||
value={customColor}
|
value={customColor}
|
||||||
onChange={handleCustomColorChange}
|
onChange={handleCustomColorChange}
|
||||||
placeholder={t('placeholder')}
|
placeholder={t('placeholder')}
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
borderColor="primary.200"
|
borderColor='primary.200'
|
||||||
_focus={{
|
_focus={{
|
||||||
borderColor: 'primary.500',
|
borderColor: 'primary.500',
|
||||||
boxShadow: '0 0 0 1px var(--chakra-colors-primary-500)'
|
boxShadow: '0 0 0 1px var(--chakra-colors-primary-500)',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
) : (
|
) : (
|
||||||
<Flex align="center" gap={2}>
|
<Flex align='center' gap={2}>
|
||||||
<Box
|
<Box
|
||||||
w="32px"
|
w='32px'
|
||||||
h="32px"
|
h='32px'
|
||||||
borderRadius="full"
|
borderRadius='full'
|
||||||
bg="gray.100"
|
bg='gray.100'
|
||||||
border="1px"
|
border='1px'
|
||||||
borderColor="gray.200"
|
borderColor='gray.200'
|
||||||
transition="all 0.2s"
|
transition='all 0.2s'
|
||||||
/>
|
/>
|
||||||
<Text fontSize="xs" color="gray.500">
|
<Text fontSize='xs' color='gray.500'>
|
||||||
{t('custom')}
|
{t('custom')}
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
@ -159,4 +174,4 @@ export const CarColorSelect = forwardRef<HTMLInputElement, CarColorSelectProps>(
|
|||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,34 +1,44 @@
|
|||||||
export const CAR_COLORS = [
|
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'
|
code: '#ffffff'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'black',
|
value: Car.Color.BLACK,
|
||||||
|
labelTKey: 'black',
|
||||||
code: '#000000'
|
code: '#000000'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'silver',
|
value: Car.Color.SILVER,
|
||||||
|
labelTKey: 'silver',
|
||||||
code: '#c0c0c0'
|
code: '#c0c0c0'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'gray',
|
value: Car.Color.GRAY,
|
||||||
|
labelTKey: 'gray',
|
||||||
code: '#808080'
|
code: '#808080'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'beige-brown',
|
value: Car.Color.BEIGE_BROWN,
|
||||||
|
labelTKey: 'beige-brown',
|
||||||
code: '#796745'
|
code: '#796745'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'red',
|
value: Car.Color.RED,
|
||||||
|
labelTKey: 'red',
|
||||||
code: '#b90000'
|
code: '#b90000'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'blue',
|
value: Car.Color.BLUE,
|
||||||
|
labelTKey: 'blue',
|
||||||
code: '#003B62'
|
code: '#003B62'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'green',
|
value: Car.Color.GREEN,
|
||||||
|
labelTKey: 'green',
|
||||||
code: '#078d51'
|
code: '#078d51'
|
||||||
},
|
},
|
||||||
] as const satisfies { name: string; code: string }[];
|
];
|
@ -1 +1,2 @@
|
|||||||
export { CarColorSelect } from './car-color-select';
|
export { CarColorSelect } from './car-color-select';
|
||||||
|
export { carColorSelectOptions } from './helper';
|
@ -1,2 +1,4 @@
|
|||||||
export type { OrderFormValues, OrderFormProps } from './types';
|
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 {
|
import {
|
||||||
Input,
|
Input,
|
||||||
Box,
|
Box,
|
||||||
@ -24,129 +24,130 @@ import {
|
|||||||
} from './helper';
|
} from './helper';
|
||||||
import { LocationInputProps } from './types';
|
import { LocationInputProps } from './types';
|
||||||
|
|
||||||
export const LocationInput = memo(
|
export const BaseLocationInput = withYMaps(
|
||||||
withYMaps(
|
({ ymaps, value = '', onChange, inputRef, ...props }: LocationInputProps & { inputRef: ForwardedRef<HTMLInputElement> }) => {
|
||||||
forwardRef<HTMLInputElement, LocationInputProps>(function LocationInput(
|
const [inputValue, setInputValue] = useState<string>('');
|
||||||
{ ymaps, value, onChange, ...props },
|
|
||||||
ref,
|
|
||||||
) {
|
|
||||||
const [inputValue, setInputValue] = useState<string>('');
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setInputValue(value);
|
setInputValue(value);
|
||||||
}, [value]);
|
}, [value]);
|
||||||
|
|
||||||
const [suggestions, setSuggestions] = useState<Suggestion[]>([]);
|
const [suggestions, setSuggestions] = useState<Suggestion[]>([]);
|
||||||
const [isSuggestionsPanelOpen, setIsSuggestionsPanelOpen] =
|
const [isSuggestionsPanelOpen, setIsSuggestionsPanelOpen] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
|
|
||||||
const onInputChange: InputProps['onChange'] = async (e) => {
|
const onInputChange: InputProps['onChange'] = async (e) => {
|
||||||
const newInputValue = e.target.value;
|
const newInputValue = e.target.value;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isValidLocation(newInputValue) &&
|
isValidLocation(newInputValue) &&
|
||||||
(await isRealLocation(ymaps, newInputValue))
|
(await isRealLocation(ymaps, newInputValue))
|
||||||
) {
|
) {
|
||||||
onChange(newInputValue);
|
onChange(newInputValue);
|
||||||
} else {
|
} else {
|
||||||
setInputValue(newInputValue);
|
setInputValue(newInputValue);
|
||||||
|
|
||||||
if (newInputValue.trim().length > 3) {
|
if (newInputValue.trim().length > 3) {
|
||||||
try {
|
try {
|
||||||
const address = extractAddress(newInputValue);
|
const address = extractAddress(newInputValue);
|
||||||
const results = await ymaps.suggest(address);
|
const results = await ymaps.suggest(address);
|
||||||
setSuggestions(results);
|
setSuggestions(results);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setSuggestions([]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
} else {
|
||||||
setInputValue(value);
|
setSuggestions([]);
|
||||||
}
|
}
|
||||||
setIsSuggestionsPanelOpen(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSuggestionClick = async ({ value: address }: Suggestion) => {
|
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||||
try {
|
}
|
||||||
const location = await getLocationByAddress(ymaps, address);
|
};
|
||||||
const newValue = formatLocation(location);
|
|
||||||
setInputValue(newValue);
|
|
||||||
onChange(newValue);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const { t } = useTranslation('~', {
|
const onFocus: InputProps['onFocus'] = () => {
|
||||||
keyPrefix: 'dry-wash.order-create.form.washing-location-field',
|
setIsSuggestionsPanelOpen(suggestions.length > 1);
|
||||||
});
|
};
|
||||||
|
|
||||||
return (
|
const onBlur: InputProps['onBlur'] = async (e) => {
|
||||||
<Box width='100%'>
|
const inputValue = e.target.value;
|
||||||
<Popover
|
if (
|
||||||
isOpen={isSuggestionsPanelOpen}
|
isValidLocation(inputValue) &&
|
||||||
autoFocus={false}
|
(await isRealLocation(ymaps, inputValue))
|
||||||
placement='bottom-start'
|
) {
|
||||||
>
|
onChange(inputValue);
|
||||||
<PopoverAnchor>
|
} else {
|
||||||
<Input
|
setInputValue(value);
|
||||||
{...props}
|
}
|
||||||
ref={ref}
|
setIsSuggestionsPanelOpen(false);
|
||||||
onBlur={onBlur}
|
};
|
||||||
value={inputValue ?? value}
|
|
||||||
onChange={onInputChange}
|
const handleSuggestionClick = async ({ value: address }: Suggestion) => {
|
||||||
onFocus={onFocus}
|
try {
|
||||||
placeholder={t('placeholder')}
|
const location = await getLocationByAddress(ymaps, address);
|
||||||
/>
|
const newValue = formatLocation(location);
|
||||||
</PopoverAnchor>
|
setInputValue(newValue);
|
||||||
<PopoverContent width='100%' maxWidth='100%'>
|
onChange(newValue);
|
||||||
<PopoverBody border='1px' borderColor='gray.300' p={0}>
|
} catch (error) {
|
||||||
<List>
|
console.error(error);
|
||||||
{suggestions.map((suggestion, index) => (
|
}
|
||||||
<ListItem
|
};
|
||||||
key={index}
|
|
||||||
p={2}
|
const { t } = useTranslation('~', {
|
||||||
cursor='pointer'
|
keyPrefix: 'dry-wash.order-create.form.washing-location-field',
|
||||||
_hover={{
|
});
|
||||||
bgColor: 'primary.50',
|
|
||||||
}}
|
return (
|
||||||
_active={{
|
<Box width='100%'>
|
||||||
bgColor: 'primary.100',
|
<Popover
|
||||||
}}
|
isOpen={isSuggestionsPanelOpen}
|
||||||
onClick={() => handleSuggestionClick(suggestion)}
|
autoFocus={false}
|
||||||
>
|
placement='bottom-start'
|
||||||
{suggestion.displayName}
|
>
|
||||||
</ListItem>
|
<PopoverAnchor>
|
||||||
))}
|
<Input
|
||||||
</List>
|
{...props}
|
||||||
</PopoverBody>
|
ref={inputRef}
|
||||||
</PopoverContent>
|
onBlur={onBlur}
|
||||||
</Popover>
|
value={inputValue || value}
|
||||||
</Box>
|
onChange={onInputChange}
|
||||||
);
|
onFocus={onFocus}
|
||||||
}),
|
placeholder={t('placeholder')}
|
||||||
true,
|
/>
|
||||||
['suggest', 'geocode'],
|
</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: i18n
|
||||||
// todo: replace console.error with toast
|
// todo: replace console.error with toast
|
||||||
|
@ -31,8 +31,22 @@ export const MapComponent: FC<{
|
|||||||
}
|
}
|
||||||
}, [selectedLocation]);
|
}, [selectedLocation]);
|
||||||
|
|
||||||
|
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
||||||
|
useEffect(() => {
|
||||||
|
const handleResize = () => {
|
||||||
|
setWindowWidth(window.innerWidth);
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('resize', handleResize);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Map
|
<Map
|
||||||
|
key={windowWidth}
|
||||||
state={{
|
state={{
|
||||||
center: mapCenter,
|
center: mapCenter,
|
||||||
zoom:
|
zoom:
|
||||||
|
@ -10,12 +10,17 @@ import {
|
|||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
||||||
dayjs.extend(localizedFormat);
|
dayjs.extend(localizedFormat);
|
||||||
|
import 'dayjs/locale/ru';
|
||||||
|
import 'dayjs/locale/en';
|
||||||
|
|
||||||
import { Order } from '../../../models/landing';
|
import { Order } from '../../../models/landing';
|
||||||
import { formatDatetime } from '../../../lib';
|
import { formatDatetime } from '../../../lib';
|
||||||
import { carBodySelectOptions } from '../../order-form/form/car-body/helper';
|
import {
|
||||||
|
carBodySelectOptions,
|
||||||
|
carColorSelectOptions,
|
||||||
|
} from '../../order-form';
|
||||||
|
|
||||||
import { OrderStatus } from './status';
|
import { OrderStatus } from './status';
|
||||||
|
|
||||||
@ -43,26 +48,32 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
|||||||
location,
|
location,
|
||||||
startWashTime,
|
startWashTime,
|
||||||
endWashTime,
|
endWashTime,
|
||||||
created
|
created,
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation('~', {
|
const { t, i18n } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.order-view.details',
|
keyPrefix: 'dry-wash.order-view.details',
|
||||||
});
|
});
|
||||||
|
dayjs.locale(i18n.language);
|
||||||
const { t: tCarBody } = useTranslation('~', {
|
const { t: tCarBody } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.order-create.car-body-select.options',
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Heading as='h2' size='lg' marginInline='auto'>
|
||||||
|
{t('title', { number: orderNumber })}
|
||||||
|
</Heading>
|
||||||
<HStack
|
<HStack
|
||||||
width='full'
|
width='full'
|
||||||
flexWrap='wrap'
|
flexWrap='wrap'
|
||||||
justifyContent='space-between'
|
justifyContent='space-between'
|
||||||
gap={2}
|
gap={2}
|
||||||
>
|
>
|
||||||
<Heading as='h2' size='lg'>
|
<Text>{dayjs(created).format('LLL')}</Text>
|
||||||
{t('title', { number: orderNumber })} ({dayjs(created).format('LLLL')})
|
|
||||||
</Heading>
|
|
||||||
<OrderStatus value={status} />
|
<OrderStatus value={status} />
|
||||||
</HStack>
|
</HStack>
|
||||||
<UnorderedList styleType='none'>
|
<UnorderedList styleType='none'>
|
||||||
@ -78,7 +89,7 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
|||||||
tCarBody(
|
tCarBody(
|
||||||
`${carBodySelectOptions.find(({ value }) => value === carBody)?.labelTKey}`,
|
`${carBodySelectOptions.find(({ value }) => value === carBody)?.labelTKey}`,
|
||||||
),
|
),
|
||||||
carColor,
|
carColorTKey ? tCarColor(carColorTKey) : carColor,
|
||||||
]
|
]
|
||||||
.filter((v) => v)
|
.filter((v) => v)
|
||||||
.join(', '),
|
.join(', '),
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
export type RegistrationNumber = string; // А012ВЕ16
|
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 {
|
export const enum BodyStyle {
|
||||||
UNKNOWN = 0,
|
UNKNOWN = 0,
|
||||||
|
@ -18,7 +18,7 @@ export type Create = {
|
|||||||
car: {
|
car: {
|
||||||
number: Car.RegistrationNumber;
|
number: Car.RegistrationNumber;
|
||||||
body: Car.BodyStyle;
|
body: Car.BodyStyle;
|
||||||
color: Car.Color;
|
color: Car.Color | string;
|
||||||
};
|
};
|
||||||
washing: {
|
washing: {
|
||||||
location: Washing.Location;
|
location: Washing.Location;
|
||||||
@ -33,7 +33,7 @@ export type View = {
|
|||||||
phone: Customer.PhoneNumber;
|
phone: Customer.PhoneNumber;
|
||||||
carNumber: Car.RegistrationNumber;
|
carNumber: Car.RegistrationNumber;
|
||||||
carBody: Car.BodyStyle;
|
carBody: Car.BodyStyle;
|
||||||
carColor?: Car.Color;
|
carColor?: Car.Color | string;
|
||||||
location: Washing.Location;
|
location: Washing.Location;
|
||||||
startWashTime: Washing.AvailableBeginDateTime;
|
startWashTime: Washing.AvailableBeginDateTime;
|
||||||
endWashTime: Washing.AvailableEndDateTime;
|
endWashTime: Washing.AvailableEndDateTime;
|
||||||
|
@ -36,12 +36,6 @@ exports[`Master Page should display master list and show details when master but
|
|||||||
>
|
>
|
||||||
Мастера
|
Мастера
|
||||||
</a>
|
</a>
|
||||||
<a
|
|
||||||
class="chakra-button css-19byqlw"
|
|
||||||
href="/map"
|
|
||||||
>
|
|
||||||
Карта заказов
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
@ -94,14 +94,14 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
class="chakra-stack css-uv9e93"
|
class="chakra-stack css-uv9e93"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-dbqfkc"
|
class="css-ed0q6j"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
class="css-6su6fj"
|
class="css-6su6fj"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -117,7 +117,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -133,7 +133,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -149,7 +149,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -165,7 +165,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -181,7 +181,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -197,7 +197,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -213,7 +213,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-11g98ql"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -229,7 +229,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1nsxgdr"
|
class="css-bf4qsc"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="css-1k9efnl"
|
class="css-1k9efnl"
|
||||||
@ -267,7 +267,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
<div
|
<div
|
||||||
class="css-8atqhb"
|
class="css-1kxonj9"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
aria-readonly="true"
|
aria-readonly="true"
|
||||||
@ -282,7 +282,7 @@ exports[`Create Order page renders page structure 1`] = `
|
|||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
class="chakra-popover__popper css-iy22zq"
|
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
|
<section
|
||||||
aria-describedby="popover-body-:r7:"
|
aria-describedby="popover-body-:r7:"
|
||||||
|
File diff suppressed because one or more lines are too long
@ -36,12 +36,6 @@ exports[`Страница заказов должна корректно ото
|
|||||||
>
|
>
|
||||||
Мастера
|
Мастера
|
||||||
</a>
|
</a>
|
||||||
<a
|
|
||||||
class="chakra-button css-g11sl9"
|
|
||||||
href="/auth/login"
|
|
||||||
>
|
|
||||||
Карта заказов
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@ -77,7 +71,7 @@ exports[`Страница заказов должна корректно ото
|
|||||||
<p
|
<p
|
||||||
class="chakra-text css-52ukzg"
|
class="chakra-text css-52ukzg"
|
||||||
>
|
>
|
||||||
09.03.2025
|
12.03.2025
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
class="chakra-button css-ez23ye"
|
class="chakra-button css-ez23ye"
|
||||||
@ -270,9 +264,13 @@ exports[`Страница заказов должна корректно ото
|
|||||||
<td
|
<td
|
||||||
class="css-zgoslk"
|
class="css-zgoslk"
|
||||||
>
|
>
|
||||||
<a
|
<button
|
||||||
|
aria-controls="popover-content-:r1:"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-haspopup="dialog"
|
||||||
class="chakra-button css-ez23ye"
|
class="chakra-button css-ez23ye"
|
||||||
href="/auth/login/arm//auth/login?lat=55.78&lon=49.12¤tDate=Sun Mar 09 2025 11:23:09 GMT+0300 (Moscow Standard Time)"
|
id="popover-trigger-:r1:"
|
||||||
|
type="button"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class="chakra-icon css-onkibi"
|
class="chakra-icon css-onkibi"
|
||||||
@ -292,7 +290,54 @@ exports[`Страница заказов должна корректно ото
|
|||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr
|
<tr
|
||||||
@ -426,9 +471,13 @@ exports[`Страница заказов должна корректно ото
|
|||||||
<td
|
<td
|
||||||
class="css-zgoslk"
|
class="css-zgoslk"
|
||||||
>
|
>
|
||||||
<a
|
<button
|
||||||
|
aria-controls="popover-content-:r3:"
|
||||||
|
aria-expanded="false"
|
||||||
|
aria-haspopup="dialog"
|
||||||
class="chakra-button css-ez23ye"
|
class="chakra-button css-ez23ye"
|
||||||
href="/auth/login/arm//auth/login?lat=55.78&lon=49.12¤tDate=Sun Mar 09 2025 11:23:09 GMT+0300 (Moscow Standard Time)"
|
id="popover-trigger-:r3:"
|
||||||
|
type="button"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class="chakra-icon css-onkibi"
|
class="chakra-icon css-onkibi"
|
||||||
@ -448,7 +497,54 @@ exports[`Страница заказов должна корректно ото
|
|||||||
/>
|
/>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
});
|
@ -4,7 +4,7 @@
|
|||||||
"phone": "+79876543210",
|
"phone": "+79876543210",
|
||||||
"carNumber": "А123АА16",
|
"carNumber": "А123АА16",
|
||||||
"carBody": 2,
|
"carBody": 2,
|
||||||
"carColor": "#ffffff",
|
"carColor": 5,
|
||||||
"startWashTime": "2025-01-19T14:03:00.000Z",
|
"startWashTime": "2025-01-19T14:03:00.000Z",
|
||||||
"endWashTime": "2025-01-19T14:03:00.000Z",
|
"endWashTime": "2025-01-19T14:03:00.000Z",
|
||||||
"location": "55.793833888711006,49.19037910644527 Республика Татарстан (Татарстан), Казань, жилой район Седьмое Небо",
|
"location": "55.793833888711006,49.19037910644527 Республика Татарстан (Татарстан), Казань, жилой район Седьмое Небо",
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"phone": "+79876543210",
|
"phone": "+79876543210",
|
||||||
"carNumber": "А123АА16",
|
"carNumber": "А123АА16",
|
||||||
"carBody": 2,
|
"carBody": 2,
|
||||||
"carColor": "#ffffff",
|
"carColor": "мокрый асфальт",
|
||||||
"startWashTime": "2025-01-19T14:03:00.000Z",
|
"startWashTime": "2025-01-19T14:03:00.000Z",
|
||||||
"endWashTime": "2025-01-19T14:03:00.000Z",
|
"endWashTime": "2025-01-19T14:03:00.000Z",
|
||||||
"location": "55.793833888711006,49.19037910644527 Республика Татарстан (Татарстан), Казань, жилой район Седьмое Небо",
|
"location": "55.793833888711006,49.19037910644527 Республика Татарстан (Татарстан), Казань, жилой район Седьмое Небо",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user