Compare commits
34 Commits
debug
...
feature/ma
| Author | SHA1 | Date | |
|---|---|---|---|
| fea4a54c83 | |||
| 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 | |||
|
|
20017cad3c | ||
|
|
de54ac6669 | ||
|
|
eda869622e |
@@ -16,12 +16,27 @@ module.exports = {
|
|||||||
'dry-wash.order.view': '/order/:orderId',
|
'dry-wash.order.view': '/order/:orderId',
|
||||||
'dry-wash.arm.master': 'master',
|
'dry-wash.arm.master': 'master',
|
||||||
'dry-wash.arm.order': 'order',
|
'dry-wash.arm.order': 'order',
|
||||||
|
'dry-wash.arm.map': 'map',
|
||||||
'dry-wash.arm': '/arm/*',
|
'dry-wash.arm': '/arm/*',
|
||||||
},
|
},
|
||||||
features: {
|
features: {
|
||||||
'dry-wash': {
|
'dry-wash': {
|
||||||
// add your features here in the format [featureName]: { value: string }
|
// 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: {
|
config: {
|
||||||
|
|||||||
@@ -50,6 +50,12 @@
|
|||||||
"dry-wash.order-view.details.location": "Where",
|
"dry-wash.order-view.details.location": "Where",
|
||||||
"dry-wash.order-view.details.datetime-range": "When",
|
"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.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.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.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",
|
||||||
@@ -58,7 +64,7 @@
|
|||||||
"dry-wash.arm.order.status.complete": "Completed",
|
"dry-wash.arm.order.status.complete": "Completed",
|
||||||
"dry-wash.arm.order.status.pending": "Pending",
|
"dry-wash.arm.order.status.pending": "Pending",
|
||||||
"dry-wash.arm.order.status.working": "Working",
|
"dry-wash.arm.order.status.working": "Working",
|
||||||
"dry-wash.arm.order.status.canceled": "Canceled",
|
"dry-wash.arm.order.status.cancelled": "Canceled",
|
||||||
"dry-wash.arm.order.status.placeholder": "Select status",
|
"dry-wash.arm.order.status.placeholder": "Select status",
|
||||||
"dry-wash.arm.order.master.placeholder": "Select master",
|
"dry-wash.arm.order.master.placeholder": "Select master",
|
||||||
"dry-wash.arm.order.table.header.carNumber": "Car Number",
|
"dry-wash.arm.order.table.header.carNumber": "Car Number",
|
||||||
@@ -105,5 +111,8 @@
|
|||||||
"dry-wash.errorBoundary.title": "Something went wrong",
|
"dry-wash.errorBoundary.title": "Something went wrong",
|
||||||
"dry-wash.errorBoundary.description": "We are already working on fixing the issue",
|
"dry-wash.errorBoundary.description": "We are already working on fixing the issue",
|
||||||
"dry-wash.errorBoundary.button.reload": "Reload Page",
|
"dry-wash.errorBoundary.button.reload": "Reload Page",
|
||||||
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}"
|
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}",
|
||||||
|
"dry-wash.arm.map.title": "Map of orders",
|
||||||
|
"dry-wash.arm.map.carNumber": "Car Number",
|
||||||
|
"dry-wash.arm.map.status": "Status"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"dry-wash.arm.order.status.complete": "Завершено",
|
"dry-wash.arm.order.status.complete": "Завершено",
|
||||||
"dry-wash.arm.order.status.pending": "В ожидании",
|
"dry-wash.arm.order.status.pending": "В ожидании",
|
||||||
"dry-wash.arm.order.status.working": "В работе",
|
"dry-wash.arm.order.status.working": "В работе",
|
||||||
"dry-wash.arm.order.status.canceled": "Отменено",
|
"dry-wash.arm.order.status.cancelled": "Отменено",
|
||||||
"dry-wash.arm.order.status.placeholder": "Выберите статус",
|
"dry-wash.arm.order.status.placeholder": "Выберите статус",
|
||||||
"dry-wash.arm.order.master.placeholder": "Выберите мастера",
|
"dry-wash.arm.order.master.placeholder": "Выберите мастера",
|
||||||
"dry-wash.arm.order.table.header.carNumber": "Номер машины",
|
"dry-wash.arm.order.table.header.carNumber": "Номер машины",
|
||||||
@@ -105,11 +105,20 @@
|
|||||||
"dry-wash.order-view.details.location": "Где",
|
"dry-wash.order-view.details.location": "Где",
|
||||||
"dry-wash.order-view.details.datetime-range": "Когда",
|
"dry-wash.order-view.details.datetime-range": "Когда",
|
||||||
"dry-wash.order-view.details.alert": "С вами свяжется оператор насчет оплаты по указанному номеру телефона",
|
"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.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.notFound.title": "Страница не найдена",
|
"dry-wash.notFound.title": "Страница не найдена",
|
||||||
"dry-wash.notFound.description": "К сожалению, запрашиваемая вами страница не существует.",
|
"dry-wash.notFound.description": "К сожалению, запрашиваемая вами страница не существует.",
|
||||||
"dry-wash.notFound.button.back": "Вернуться на главную",
|
"dry-wash.notFound.button.back": "Вернуться на главную",
|
||||||
"dry-wash.errorBoundary.title": "Что-то пошло не так",
|
"dry-wash.errorBoundary.title": "Что-то пошло не так",
|
||||||
"dry-wash.errorBoundary.description": "Мы уже работаем над исправлением проблемы",
|
"dry-wash.errorBoundary.description": "Мы уже работаем над исправлением проблемы",
|
||||||
"dry-wash.errorBoundary.button.reload": "Перезагрузить страницу",
|
"dry-wash.errorBoundary.button.reload": "Перезагрузить страницу",
|
||||||
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}"
|
"dry-wash.washTime.timeSlot": "{{start}} - {{end}}",
|
||||||
|
"dry-wash.arm.map.title": " Карта заказов",
|
||||||
|
"dry-wash.arm.map.carNumber": " Номер автомобиля",
|
||||||
|
"dry-wash.arm.map.status": "Статус"
|
||||||
}
|
}
|
||||||
|
|||||||
5
package-lock.json
generated
5
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "dry-wash",
|
"name": "dry-wash",
|
||||||
"version": "0.8.0",
|
"version": "0.9.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "dry-wash",
|
"name": "dry-wash",
|
||||||
"version": "0.8.0",
|
"version": "0.9.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.26.7",
|
"@babel/core": "^7.26.7",
|
||||||
@@ -3610,7 +3610,6 @@
|
|||||||
"version": "1.2.5",
|
"version": "1.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/@pbe/react-yandex-maps/-/react-yandex-maps-1.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/@pbe/react-yandex-maps/-/react-yandex-maps-1.2.5.tgz",
|
||||||
"integrity": "sha512-cBojin5e1fPx9XVCAqHQJsCnHGMeBNsP0TrNfpWCrPFfxb30ye+JgcGr2mn767Gbr1d+RufBLRiUcX2kaiAwjQ==",
|
"integrity": "sha512-cBojin5e1fPx9XVCAqHQJsCnHGMeBNsP0TrNfpWCrPFfxb30ye+JgcGr2mn767Gbr1d+RufBLRiUcX2kaiAwjQ==",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/yandex-maps": "2.1.29"
|
"@types/yandex-maps": "2.1.29"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dry-wash",
|
"name": "dry-wash",
|
||||||
"version": "0.8.0",
|
"version": "0.9.2",
|
||||||
"description": "<a id=\"readme-top\"></a>",
|
"description": "<a id=\"readme-top\"></a>",
|
||||||
"main": "./src/index.tsx",
|
"main": "./src/index.tsx",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -11,5 +11,8 @@ export const FEATURE = {
|
|||||||
return interval;
|
return interval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
carImageUpload: {
|
||||||
|
isOn: Boolean(features?.['car-img-upload'])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { GetOrder, CreateOrder } from "../../models/api";
|
import { GetOrder, CreateOrder, UploadCarImage } from "../../models/api";
|
||||||
|
|
||||||
import { api } from "./api";
|
import { api } from "./api";
|
||||||
import { extractBodyFromResponse, extractErrorMessageFromResponse } from "./utils";
|
import { extractBodyFromResponse, extractErrorMessageFromResponse } from "./utils";
|
||||||
@@ -19,5 +19,13 @@ export const landingApi = api.injectEndpoints({
|
|||||||
transformResponse: extractBodyFromResponse<CreateOrder.Response>,
|
transformResponse: extractBodyFromResponse<CreateOrder.Response>,
|
||||||
transformErrorResponse: extractErrorMessageFromResponse,
|
transformErrorResponse: extractErrorMessageFromResponse,
|
||||||
}),
|
}),
|
||||||
|
uploadCarImage: mutation<UploadCarImage.Response, UploadCarImage.Params>({
|
||||||
|
query: ({ orderId, body }) => ({
|
||||||
|
url: `/order/${orderId}/upload-car-img`,
|
||||||
|
body,
|
||||||
|
method: 'POST'
|
||||||
|
}),
|
||||||
|
transformErrorResponse: extractErrorMessageFromResponse,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
|
|||||||
import { BaseResponse } from '../../models/api';
|
import { BaseResponse } from '../../models/api';
|
||||||
|
|
||||||
export const extractBodyFromResponse = <Body>(response: BaseResponse<Body>) => {
|
export const extractBodyFromResponse = <Body>(response: BaseResponse<Body>) => {
|
||||||
|
console.log('response', response);
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
return response.body;
|
return response.body;
|
||||||
}
|
}
|
||||||
@@ -13,9 +14,10 @@ export const extractErrorMessageFromResponse = ({
|
|||||||
}: FetchBaseQueryError) => {
|
}: FetchBaseQueryError) => {
|
||||||
if (
|
if (
|
||||||
typeof data === 'object' &&
|
typeof data === 'object' &&
|
||||||
'message' in data &&
|
data !== null &&
|
||||||
typeof data.message === 'string'
|
'error' in data &&
|
||||||
|
typeof data.error === 'string'
|
||||||
) {
|
) {
|
||||||
return data.message;
|
return data.error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -33,6 +33,18 @@ export const URLs = {
|
|||||||
url: getNavigationValue('dry-wash.arm.order'),
|
url: getNavigationValue('dry-wash.arm.order'),
|
||||||
isOn: Boolean(getNavigationValue('dry-wash.arm.order')),
|
isOn: Boolean(getNavigationValue('dry-wash.arm.order')),
|
||||||
},
|
},
|
||||||
|
armMap: {
|
||||||
|
url: getNavigationValue('dry-wash.arm.map'),
|
||||||
|
isOn: Boolean(getNavigationValue('dry-wash.arm.map')),
|
||||||
|
getUrl({ lat, lon, currentDate }) {
|
||||||
|
return (
|
||||||
|
getFullUrls('/arm') +
|
||||||
|
'/' +
|
||||||
|
getNavigationValue('dry-wash.arm.map') +
|
||||||
|
`?lat=${lat}&lon=${lon}¤tDate=${currentDate}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
},
|
||||||
armBase: {
|
armBase: {
|
||||||
url: getFullUrls(getNavigationValue('dry-wash.arm')),
|
url: getFullUrls(getNavigationValue('dry-wash.arm')),
|
||||||
isOn: Boolean(getNavigationValue('dry-wash.arm')),
|
isOn: Boolean(getNavigationValue('dry-wash.arm')),
|
||||||
|
|||||||
63
src/components/Header/Header.tsx
Normal file
63
src/components/Header/Header.tsx
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
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>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{URLs.armMap.isOn && (
|
||||||
|
<Button
|
||||||
|
as={Link}
|
||||||
|
to={URLs.armMap.url}
|
||||||
|
colorScheme={isActive(URLs.armMap.url) ? 'green' : 'blue'}
|
||||||
|
variant={isActive(URLs.armMap.url) ? 'outline' : 'ghost'}
|
||||||
|
data-testid='master-button'
|
||||||
|
>
|
||||||
|
Карта заказов
|
||||||
|
</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,11 @@ import { Box, Flex } from '@chakra-ui/react';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||||
|
|
||||||
import Sidebar from '../Sidebar';
|
|
||||||
import Orders from '../Orders';
|
import Orders from '../Orders';
|
||||||
import Masters from '../Masters';
|
import Masters from '../Masters';
|
||||||
import { URLs } from '../../__data__/urls';
|
import { URLs } from '../../__data__/urls';
|
||||||
|
import Header from '../Header';
|
||||||
|
import OrdersMap from '../Map';
|
||||||
|
|
||||||
const LayoutArm = () => {
|
const LayoutArm = () => {
|
||||||
let defaultRedirect = null;
|
let defaultRedirect = null;
|
||||||
@@ -17,8 +18,8 @@ const LayoutArm = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex h='100vh'>
|
<Flex flexDirection='column' h='100vh'>
|
||||||
<Sidebar />
|
<Header />
|
||||||
<Box flex='1' bg='gray.50'>
|
<Box flex='1' bg='gray.50'>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route index element={<Navigate to={defaultRedirect} replace />} />
|
<Route index element={<Navigate to={defaultRedirect} replace />} />
|
||||||
@@ -28,6 +29,9 @@ const LayoutArm = () => {
|
|||||||
{URLs.armMaster.isOn && (
|
{URLs.armMaster.isOn && (
|
||||||
<Route path={URLs.armMaster.url} element={<Masters />} />
|
<Route path={URLs.armMaster.url} element={<Masters />} />
|
||||||
)}
|
)}
|
||||||
|
{URLs.armMap.isOn && (
|
||||||
|
<Route path={URLs.armMap.url} element={<OrdersMap />} />
|
||||||
|
)}
|
||||||
</Routes>
|
</Routes>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
82
src/components/Map/Map.tsx
Normal file
82
src/components/Map/Map.tsx
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import React, { useMemo } from 'react';
|
||||||
|
import { Box, Flex, Heading, Spinner } from '@chakra-ui/react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { YMaps, Map, Placemark } from '@pbe/react-yandex-maps';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { useGetOrdersQuery } from '../../__data__/service/api';
|
||||||
|
import getCoordinates from '../../utils/getCoordinates';
|
||||||
|
|
||||||
|
const OrdersMap = () => {
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.arm.map',
|
||||||
|
});
|
||||||
|
|
||||||
|
const location = useLocation();
|
||||||
|
const params = new URLSearchParams(location.search);
|
||||||
|
const latFromUrl = parseFloat(params.get('lat') || 55.78);
|
||||||
|
const lonFromUrl = parseFloat(params.get('lon') || 49.12);
|
||||||
|
const currentDate = useMemo(
|
||||||
|
() =>
|
||||||
|
params.get('currentDate')
|
||||||
|
? new Date(params.get('currentDate'))
|
||||||
|
: new Date(),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: ordersData,
|
||||||
|
isLoading,
|
||||||
|
isSuccess,
|
||||||
|
} = useGetOrdersQuery({ date: currentDate });
|
||||||
|
|
||||||
|
// Получаем координаты из location
|
||||||
|
const orders = ordersData
|
||||||
|
?.map((order) => {
|
||||||
|
const coords = getCoordinates(order.location);
|
||||||
|
return coords ? { ...order, ...coords } : null;
|
||||||
|
})
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box p='8'>
|
||||||
|
<Heading size='lg' mb='5'>
|
||||||
|
{t('title')}
|
||||||
|
</Heading>
|
||||||
|
|
||||||
|
{isLoading && (
|
||||||
|
<Flex justifyContent='center' alignItems='center'>
|
||||||
|
<Spinner size='lg' />
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isSuccess && (
|
||||||
|
<YMaps>
|
||||||
|
<Map
|
||||||
|
defaultState={{ center: [latFromUrl, lonFromUrl], zoom: 12 }}
|
||||||
|
width='100%'
|
||||||
|
height='70vh'
|
||||||
|
modules={['geoObject.addon.balloon']}
|
||||||
|
>
|
||||||
|
{orders.map(({ id, lat, lon, carNumber, status }) => (
|
||||||
|
<Placemark
|
||||||
|
key={id}
|
||||||
|
geometry={[lat, lon]}
|
||||||
|
options={{
|
||||||
|
preset: 'islands#blueAutoIcon',
|
||||||
|
iconColor: 'blue',
|
||||||
|
balloonPanelMaxMapArea: 0,
|
||||||
|
}}
|
||||||
|
properties={{
|
||||||
|
balloonContent: `<strong>${t('carNumber')}</strong> ${carNumber}<br/><strong>${t('status')}</strong> ${status}`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Map>
|
||||||
|
</YMaps>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OrdersMap;
|
||||||
1
src/components/Map/index.ts
Normal file
1
src/components/Map/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { default } from './Map';
|
||||||
@@ -1,17 +1,20 @@
|
|||||||
import React, { ChangeEvent, useState } from 'react';
|
import React, { ChangeEvent, useState } from 'react';
|
||||||
import { Td, Tr, Link, Select } from '@chakra-ui/react';
|
import { Td, Tr, Link, Select, Button } from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
import { ViewIcon } from '@chakra-ui/icons';
|
||||||
|
import { Link as LinkRouter } from 'react-router-dom';
|
||||||
|
|
||||||
import { getTimeSlot } from '../../lib';
|
import { getTimeSlot } from '../../lib';
|
||||||
import { useUpdateOrdersMutation } from '../../__data__/service/api';
|
import { useUpdateOrdersMutation } from '../../__data__/service/api';
|
||||||
import { OrderArm, Status, statuses } from '../../models/api';
|
import { OrderArm, Status, statuses } from '../../models/api';
|
||||||
|
import getCoordinates from '../../utils/getCoordinates';
|
||||||
|
import { URLs } from '../../__data__/urls';
|
||||||
|
|
||||||
const statusColors: Record<Status, string> = {
|
const statusColors: Record<Status, string> = {
|
||||||
pending: 'yellow.100',
|
pending: 'yellow.100',
|
||||||
progress: 'blue.100',
|
progress: 'blue.100',
|
||||||
working: 'orange.100',
|
cancelled: 'red.100',
|
||||||
canceled: 'red.100',
|
|
||||||
complete: 'green.100',
|
complete: 'green.100',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -26,6 +29,7 @@ const OrderItem = ({
|
|||||||
master,
|
master,
|
||||||
allMasters,
|
allMasters,
|
||||||
id,
|
id,
|
||||||
|
currentDate,
|
||||||
}: OrderArm) => {
|
}: OrderArm) => {
|
||||||
const [updateOrders] = useUpdateOrdersMutation();
|
const [updateOrders] = useUpdateOrdersMutation();
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
@@ -34,7 +38,7 @@ const OrderItem = ({
|
|||||||
|
|
||||||
const [statusSelect, setStatus] = useState(status);
|
const [statusSelect, setStatus] = useState(status);
|
||||||
const bgColor = statusColors[statusSelect];
|
const bgColor = statusColors[statusSelect];
|
||||||
const [masterSelect, setMaster] = useState(master?.name);
|
const [masterSelectId, setMasterSelectId] = useState(master);
|
||||||
|
|
||||||
const handelChangeMasters = (e: ChangeEvent<HTMLSelectElement>) => {
|
const handelChangeMasters = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
const masterName = e.target.value;
|
const masterName = e.target.value;
|
||||||
@@ -43,7 +47,7 @@ const OrderItem = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (selectedMaster) {
|
if (selectedMaster) {
|
||||||
setMaster(masterName);
|
setMasterSelectId(selectedMaster.id);
|
||||||
updateOrders({ id, master: selectedMaster.id });
|
updateOrders({ id, master: selectedMaster.id });
|
||||||
} else {
|
} else {
|
||||||
console.error('Master not found');
|
console.error('Master not found');
|
||||||
@@ -56,6 +60,12 @@ const OrderItem = ({
|
|||||||
setStatus(status);
|
setStatus(status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const masterSelectChange = allMasters.find(
|
||||||
|
(master) => master.id === masterSelectId,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { lat = 55.78, lon = 49.12 } = getCoordinates(location);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tr>
|
<Tr>
|
||||||
<Td>{carNumber}</Td>
|
<Td>{carNumber}</Td>
|
||||||
@@ -79,7 +89,7 @@ const OrderItem = ({
|
|||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<Select
|
<Select
|
||||||
value={masterSelect}
|
value={masterSelectChange?.name}
|
||||||
onChange={handelChangeMasters}
|
onChange={handelChangeMasters}
|
||||||
placeholder={t(`master.placeholder`)}
|
placeholder={t(`master.placeholder`)}
|
||||||
>
|
>
|
||||||
@@ -93,7 +103,14 @@ const OrderItem = ({
|
|||||||
<Td>
|
<Td>
|
||||||
<Link href='tel:'>{phone}</Link>
|
<Link href='tel:'>{phone}</Link>
|
||||||
</Td>
|
</Td>
|
||||||
<Td>{location}</Td>
|
<Td>
|
||||||
|
<Button
|
||||||
|
as={LinkRouter}
|
||||||
|
to={URLs.armMap.getUrl({ lat, lon, currentDate })}
|
||||||
|
>
|
||||||
|
<ViewIcon />
|
||||||
|
</Button>
|
||||||
|
</Td>
|
||||||
</Tr>
|
</Tr>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ const Orders = () => {
|
|||||||
key={index}
|
key={index}
|
||||||
{...order}
|
{...order}
|
||||||
status={order.status as OrderArm['status']}
|
status={order.status as OrderArm['status']}
|
||||||
|
currentDate={currentDate}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</Tbody>
|
</Tbody>
|
||||||
|
|||||||
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';
|
||||||
48
src/components/PriceCar/PriceCar.tsx
Normal file
48
src/components/PriceCar/PriceCar.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { Box, Image, Progress, Text } from '@chakra-ui/react';
|
||||||
|
import React from 'react';
|
||||||
|
import { getFeatures } from '@brojs/cli';
|
||||||
|
|
||||||
|
const PRICE_INCREASE_PERCENT_PER_RATING = 10; // 10% за каждый балл
|
||||||
|
|
||||||
|
export const PriceCar = ({ image, rating }) => {
|
||||||
|
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 washPrice = calculateWashPrice(rating);
|
||||||
|
const progressValue = (rating / 10) * 100;
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
alignItems='center'
|
||||||
|
gap={5}
|
||||||
|
width='100%'
|
||||||
|
display='flex'
|
||||||
|
flexDirection='column'
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
maxWidth='600px'
|
||||||
|
objectFit='contain'
|
||||||
|
borderRadius='md'
|
||||||
|
src={image}
|
||||||
|
alt='Car Image'
|
||||||
|
/>
|
||||||
|
{rating ? (
|
||||||
|
<Box width='100%' maxW='600px'>
|
||||||
|
<Text>Рейтинг загрязнения машины:</Text>
|
||||||
|
<Progress value={progressValue} size='sm' colorScheme='red' mt={2} />
|
||||||
|
<Text mt={2}>Стоимость мойки: {washPrice.toFixed(2)} руб.</Text>
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
<Text>Не удалость определить уровень загрязнения машины</Text>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PriceCar;
|
||||||
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';
|
|
||||||
102
src/components/order-view/car-img/car-img-form.tsx
Normal file
102
src/components/order-view/car-img/car-img-form.tsx
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import React, { FC, memo, useRef } from 'react';
|
||||||
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
FormControl,
|
||||||
|
FormErrorMessage,
|
||||||
|
FormHelperText,
|
||||||
|
FormLabel,
|
||||||
|
HStack,
|
||||||
|
Input,
|
||||||
|
} from '@chakra-ui/react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import { landingApi } from '../../../__data__/service/landing.api';
|
||||||
|
import { UploadCarImage } from '../../../models/api';
|
||||||
|
|
||||||
|
import { useHandleUploadCarImageResponse } from './helper';
|
||||||
|
|
||||||
|
type FormValues = {
|
||||||
|
carImg: File & {
|
||||||
|
fileName: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
type CarImageFormProps = {
|
||||||
|
orderId: UploadCarImage.Params['orderId'];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CarImageForm: FC<CarImageFormProps> = memo(function CarImageForm({
|
||||||
|
orderId,
|
||||||
|
}) {
|
||||||
|
const {
|
||||||
|
handleSubmit,
|
||||||
|
control,
|
||||||
|
formState: { errors, isSubmitting },
|
||||||
|
} = useForm<FormValues>({ shouldFocusError: true });
|
||||||
|
|
||||||
|
const [uploadCarImage, uploadCarImageMutation] =
|
||||||
|
landingApi.useUploadCarImageMutation();
|
||||||
|
useHandleUploadCarImageResponse(uploadCarImageMutation);
|
||||||
|
|
||||||
|
const onSubmit = (formData: FormValues) => {
|
||||||
|
const body = new FormData();
|
||||||
|
body.append('file', formData.carImg);
|
||||||
|
uploadCarImage({ orderId, body });
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileInputRef = useRef(null);
|
||||||
|
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.order-view.upload-car-image',
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form>
|
||||||
|
<FormControl>
|
||||||
|
<FormLabel htmlFor='carImg'>{t('field.label')}</FormLabel>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name='carImg'
|
||||||
|
render={({ field: { value, onChange, ...field } }) => {
|
||||||
|
return (
|
||||||
|
<HStack gap={0}>
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
ref={fileInputRef}
|
||||||
|
accept='image/png,image/jpeg'
|
||||||
|
value={value?.fileName}
|
||||||
|
onChange={(event) => {
|
||||||
|
onChange(event.target.files[0]);
|
||||||
|
handleSubmit(onSubmit)();
|
||||||
|
}}
|
||||||
|
type='file'
|
||||||
|
hidden
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
placeholder={t('file-input.placeholder')}
|
||||||
|
value={value?.name || ''}
|
||||||
|
readOnly
|
||||||
|
borderRightRadius={0}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
fileInputRef.current.click();
|
||||||
|
}}
|
||||||
|
isLoading={isSubmitting || uploadCarImageMutation.isLoading}
|
||||||
|
colorScheme='primary'
|
||||||
|
paddingInline={8}
|
||||||
|
borderLeftRadius={0}
|
||||||
|
>
|
||||||
|
{t('file-input.button')}
|
||||||
|
</Button>
|
||||||
|
</HStack>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<FormErrorMessage>{errors.carImg?.message}</FormErrorMessage>
|
||||||
|
<FormHelperText>{t('field.help')}</FormHelperText>
|
||||||
|
</FormControl>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
});
|
||||||
35
src/components/order-view/car-img/helper.ts
Normal file
35
src/components/order-view/car-img/helper.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useToast } from "@chakra-ui/react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import { isErrorMessage } from "../../../models/api";
|
||||||
|
|
||||||
|
export const useHandleUploadCarImageResponse = (query: {
|
||||||
|
isSuccess: boolean;
|
||||||
|
isError: boolean;
|
||||||
|
error?: unknown;
|
||||||
|
}) => {
|
||||||
|
const toast = useToast();
|
||||||
|
const { t } = useTranslation('~', {
|
||||||
|
keyPrefix: 'dry-wash.order-view.upload-car-image-query',
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (query.isError) {
|
||||||
|
toast({
|
||||||
|
status: 'error',
|
||||||
|
title: t('error.title'),
|
||||||
|
description: isErrorMessage(query.error) ? query.error : undefined,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [query.isError]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (query.isSuccess) {
|
||||||
|
toast({
|
||||||
|
status: 'success',
|
||||||
|
title: t('success.title'),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [query.isSuccess]);
|
||||||
|
};
|
||||||
1
src/components/order-view/car-img/index.ts
Normal file
1
src/components/order-view/car-img/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export { CarImageForm } from './car-img-form';
|
||||||
@@ -5,11 +5,13 @@ import {
|
|||||||
Heading,
|
Heading,
|
||||||
HStack,
|
HStack,
|
||||||
UnorderedList,
|
UnorderedList,
|
||||||
VStack,
|
|
||||||
ListItem,
|
ListItem,
|
||||||
Text,
|
Text,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||||
|
dayjs.extend(localizedFormat);
|
||||||
|
|
||||||
import { Order } from '../../../models/landing';
|
import { Order } from '../../../models/landing';
|
||||||
import { formatDatetime } from '../../../lib';
|
import { formatDatetime } from '../../../lib';
|
||||||
@@ -41,7 +43,7 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
|||||||
location,
|
location,
|
||||||
startWashTime,
|
startWashTime,
|
||||||
endWashTime,
|
endWashTime,
|
||||||
...props
|
created
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
keyPrefix: 'dry-wash.order-view.details',
|
keyPrefix: 'dry-wash.order-view.details',
|
||||||
@@ -51,7 +53,7 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VStack p={4} alignItems='flex-start' gap={4} {...props}>
|
<>
|
||||||
<HStack
|
<HStack
|
||||||
width='full'
|
width='full'
|
||||||
flexWrap='wrap'
|
flexWrap='wrap'
|
||||||
@@ -59,7 +61,7 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
|||||||
gap={2}
|
gap={2}
|
||||||
>
|
>
|
||||||
<Heading as='h2' size='lg'>
|
<Heading as='h2' size='lg'>
|
||||||
{t('title', { number: orderNumber })}
|
{t('title', { number: orderNumber })} ({dayjs(created).format('LLLL')})
|
||||||
</Heading>
|
</Heading>
|
||||||
<OrderStatus value={status} />
|
<OrderStatus value={status} />
|
||||||
</HStack>
|
</HStack>
|
||||||
@@ -105,7 +107,7 @@ export const OrderDetails: FC<OrderDetailsProps> = ({
|
|||||||
<AlertIcon />
|
<AlertIcon />
|
||||||
{t('alert')}
|
{t('alert')}
|
||||||
</Alert>
|
</Alert>
|
||||||
</VStack>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const isErrorMessage = (error: unknown): error is ErrorMessage => typeof
|
|||||||
|
|
||||||
type ErrorResponse = {
|
type ErrorResponse = {
|
||||||
success: false;
|
success: false;
|
||||||
message: ErrorMessage;
|
error: ErrorMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BaseResponse<Body> = SuccessResponse<Body> | ErrorResponse;
|
export type BaseResponse<Body> = SuccessResponse<Body> | ErrorResponse;
|
||||||
|
|||||||
@@ -21,14 +21,24 @@ export namespace CreateOrder {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export namespace UploadCarImage {
|
||||||
|
export type Response = void;
|
||||||
|
export type Params = {
|
||||||
|
orderId: Order.Id;
|
||||||
|
/**
|
||||||
|
* @example { file: File }
|
||||||
|
*/
|
||||||
|
body: FormData;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
type GetArrItemType<ArrType> =
|
type GetArrItemType<ArrType> =
|
||||||
ArrType extends Array<infer ItemType> ? ItemType : never;
|
ArrType extends Array<infer ItemType> ? ItemType : never;
|
||||||
|
|
||||||
export const statuses = [
|
export const statuses = [
|
||||||
'pending' as const,
|
'pending' as const,
|
||||||
'progress' as const,
|
'progress' as const,
|
||||||
'working' as const,
|
'cancelled' as const,
|
||||||
'canceled' as const,
|
|
||||||
'complete' as const,
|
'complete' as const,
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -42,8 +52,9 @@ export type OrderArm = {
|
|||||||
status?: GetArrItemType<typeof statuses>;
|
status?: GetArrItemType<typeof statuses>;
|
||||||
phone?: string;
|
phone?: string;
|
||||||
location?: string;
|
location?: string;
|
||||||
master: Master;
|
master: string | [];
|
||||||
notes: '';
|
notes: '';
|
||||||
allMasters: Master[];
|
allMasters: Master[];
|
||||||
id: string;
|
id: string;
|
||||||
|
currentDate: Date;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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 Id = string;
|
||||||
|
|
||||||
export type Status = 'pending' |
|
export type Status =
|
||||||
'progress' |
|
| 'pending'
|
||||||
'working' |
|
| 'progress'
|
||||||
'canceled' |
|
| 'working'
|
||||||
'complete';
|
| 'canceled'
|
||||||
|
| 'complete';
|
||||||
|
|
||||||
export type Create = {
|
export type Create = {
|
||||||
customer: {
|
customer: {
|
||||||
phone: Customer.PhoneNumber,
|
phone: Customer.PhoneNumber;
|
||||||
};
|
};
|
||||||
car: {
|
car: {
|
||||||
number: Car.RegistrationNumber,
|
number: Car.RegistrationNumber;
|
||||||
body: Car.BodyStyle,
|
body: Car.BodyStyle;
|
||||||
color: Car.Color,
|
color: Car.Color;
|
||||||
},
|
};
|
||||||
washing: {
|
washing: {
|
||||||
location: Washing.Location
|
location: Washing.Location;
|
||||||
begin: Washing.AvailableBeginDateTime,
|
begin: Washing.AvailableBeginDateTime;
|
||||||
end: Washing.AvailableEndDateTime,
|
end: Washing.AvailableEndDateTime;
|
||||||
}
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Number = string;
|
export type Number = string;
|
||||||
@@ -36,10 +37,12 @@ export type View = {
|
|||||||
location: Washing.Location;
|
location: Washing.Location;
|
||||||
startWashTime: Washing.AvailableBeginDateTime;
|
startWashTime: Washing.AvailableBeginDateTime;
|
||||||
endWashTime: Washing.AvailableEndDateTime;
|
endWashTime: Washing.AvailableEndDateTime;
|
||||||
orderNumber: Number,
|
orderNumber: Number;
|
||||||
status: Status,
|
status: Status;
|
||||||
notes: string;
|
notes: string;
|
||||||
created: IsoDate;
|
created: IsoDate;
|
||||||
updated: IsoDate;
|
updated: IsoDate;
|
||||||
id: Id;
|
id: Id;
|
||||||
|
image?: string;
|
||||||
|
imageRating?: string;
|
||||||
};
|
};
|
||||||
@@ -16,7 +16,6 @@ exports[`Страница просмотра заказа отображает
|
|||||||
</h2>
|
</h2>
|
||||||
<div
|
<div
|
||||||
class="chakra-stack css-1n38vgh"
|
class="chakra-stack css-1n38vgh"
|
||||||
created="2025-01-19T14:04:02.985Z"
|
|
||||||
data-testid="order-details"
|
data-testid="order-details"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
@@ -26,6 +25,9 @@ exports[`Страница просмотра заказа отображает
|
|||||||
class="chakra-heading css-1jb3vzl"
|
class="chakra-heading css-1jb3vzl"
|
||||||
>
|
>
|
||||||
Заказ №{{number}}
|
Заказ №{{number}}
|
||||||
|
(
|
||||||
|
Sunday, January 19, 2025 5:04 PM
|
||||||
|
)
|
||||||
</h2>
|
</h2>
|
||||||
<span
|
<span
|
||||||
class="css-6jfsiv"
|
class="css-6jfsiv"
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ exports[`Страница заказов должна корректно ото
|
|||||||
<p
|
<p
|
||||||
class="chakra-text css-52ukzg"
|
class="chakra-text css-52ukzg"
|
||||||
>
|
>
|
||||||
20.02.2025
|
23.02.2025
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
class="chakra-button css-ez23ye"
|
class="chakra-button css-ez23ye"
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import { Order } from '../../models/landing';
|
|||||||
import { landingApi } from '../../__data__/service/landing.api';
|
import { landingApi } from '../../__data__/service/landing.api';
|
||||||
import { isErrorMessage } from '../../models/api';
|
import { isErrorMessage } from '../../models/api';
|
||||||
import { FEATURE } from '../../__data__/features';
|
import { FEATURE } from '../../__data__/features';
|
||||||
|
import { CarImageForm } from '../../components/order-view/car-img';
|
||||||
|
import PriceCar from '../../components/PriceCar';
|
||||||
|
|
||||||
const Page: FC = () => {
|
const Page: FC = () => {
|
||||||
const { t } = useTranslation('~', {
|
const { t } = useTranslation('~', {
|
||||||
@@ -69,24 +71,43 @@ const Page: FC = () => {
|
|||||||
<>
|
<>
|
||||||
<>
|
<>
|
||||||
{isSuccess && (
|
{isSuccess && (
|
||||||
<OrderDetails
|
<VStack
|
||||||
orderNumber={order.orderNumber}
|
p={4}
|
||||||
status={order.status}
|
alignItems='flex-start'
|
||||||
phone={order.phone}
|
gap={4}
|
||||||
carNumber={order.carNumber}
|
|
||||||
carBody={order.carBody}
|
|
||||||
carColor={order.carColor}
|
|
||||||
location={order.location}
|
|
||||||
startWashTime={order.startWashTime}
|
|
||||||
endWashTime={order.endWashTime}
|
|
||||||
created={order.created}
|
|
||||||
data-testid='order-details'
|
data-testid='order-details'
|
||||||
/>
|
>
|
||||||
|
<OrderDetails
|
||||||
|
orderNumber={order.orderNumber}
|
||||||
|
status={order.status}
|
||||||
|
phone={order.phone}
|
||||||
|
carNumber={order.carNumber}
|
||||||
|
carBody={order.carBody}
|
||||||
|
carColor={order.carColor}
|
||||||
|
location={order.location}
|
||||||
|
startWashTime={order.startWashTime}
|
||||||
|
endWashTime={order.endWashTime}
|
||||||
|
created={order.created}
|
||||||
|
/>
|
||||||
|
{FEATURE.carImageUpload.isOn && (
|
||||||
|
<CarImageForm orderId={orderId} />
|
||||||
|
)}
|
||||||
|
{FEATURE.carImageUpload.isOn && order.image && (
|
||||||
|
<PriceCar
|
||||||
|
image={order?.image}
|
||||||
|
rating={order?.imageRating}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</VStack>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
<>
|
<>
|
||||||
{isError && (
|
{isError && (
|
||||||
<Alert status='error' alignItems='flex-start' data-testid='error'>
|
<Alert
|
||||||
|
status='error'
|
||||||
|
alignItems='flex-start'
|
||||||
|
data-testid='error'
|
||||||
|
>
|
||||||
<AlertIcon />
|
<AlertIcon />
|
||||||
<Box>
|
<Box>
|
||||||
<AlertTitle>
|
<AlertTitle>
|
||||||
|
|||||||
13
src/utils/getCoordinates.ts
Normal file
13
src/utils/getCoordinates.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const getCoordinates = (location: string) => {
|
||||||
|
if (!location) return null;
|
||||||
|
|
||||||
|
const [lat, lon] = location
|
||||||
|
.split(',')
|
||||||
|
.map((coord) => parseFloat(coord.trim()));
|
||||||
|
|
||||||
|
if (isNaN(lat) || isNaN(lon)) return null;
|
||||||
|
|
||||||
|
return { lat, lon };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getCoordinates;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-require-imports */
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
|
|
||||||
const STUBS = { masters: 'success', orders: 'success', orderCreate: 'success', orderView: 'success-pending' };
|
const STUBS = { masters: 'success', orders: 'success', orderCreate: 'success', orderView: 'success-pending', orderCarImg: 'success' };
|
||||||
|
|
||||||
router.get('/set/:name/:value', (req, res) => {
|
router.get('/set/:name/:value', (req, res) => {
|
||||||
const { name, value } = req.params;
|
const { name, value } = req.params;
|
||||||
@@ -15,28 +15,34 @@ router.get('/set/:name/:value', (req, res) => {
|
|||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
res.send(`<div>
|
res.send(`<div>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Мастера</legend>
|
<legend>Мастера</legend>
|
||||||
${generateRadioInput('masters', 'success')}
|
${generateRadioInput('masters', 'success')}
|
||||||
${generateRadioInput('masters', 'error')}
|
${generateRadioInput('masters', 'error')}
|
||||||
${generateRadioInput('masters', 'empty')}
|
${generateRadioInput('masters', 'empty')}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Заказы</legend>
|
<legend>Заказы</legend>
|
||||||
${generateRadioInput('orders', 'success')}
|
${generateRadioInput('orders', 'success')}
|
||||||
${generateRadioInput('orders', 'error')}
|
${generateRadioInput('orders', 'error')}
|
||||||
${generateRadioInput('orders', 'empty')}
|
${generateRadioInput('orders', 'empty')}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Лендинг - Сделать заказ</legend>
|
<legend>Лендинг - Сделать заказ</legend>
|
||||||
${generateRadioInput('orderCreate', 'success')}
|
${generateRadioInput('orderCreate', 'success')}
|
||||||
${generateRadioInput('orderCreate', 'error')}
|
${generateRadioInput('orderCreate', 'error')}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Лендинг - Детали заказа</legend>
|
<legend>Лендинг - Детали заказа</legend>
|
||||||
${generateRadioInput('orderView', 'success-pending')}
|
${generateRadioInput('orderView', 'success-pending')}
|
||||||
${generateRadioInput('orderView', 'success-working')}
|
${generateRadioInput('orderView', 'success-working')}
|
||||||
${generateRadioInput('orderView', 'error')}
|
${generateRadioInput('orderView', 'error')}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Лендинг - Детали заказа, фото машины</legend>
|
||||||
|
${generateRadioInput('orderCarImg', 'success')}
|
||||||
|
${generateRadioInput('orderCarImg', 'error-file-type')}
|
||||||
|
${generateRadioInput('orderCarImg', 'error-file-size')}
|
||||||
|
</fieldset>
|
||||||
</div>`);
|
</div>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,22 @@ router.post('/order/create', (req, res) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/order/:orderId/upload-car-img', (req, res) => {
|
||||||
|
const { orderId } = req.params;
|
||||||
|
const stubName = `${orderId}-${STUBS.orderCarImg}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
res
|
||||||
|
.status(/error/.test(stubName) ? 500 : 200)
|
||||||
|
.send(require(`../json/landing-order-car-image-upload/${stubName}.json`));
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
res
|
||||||
|
.status(500)
|
||||||
|
.send(commonError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
router.use('/admin', require('./admin'));
|
router.use('/admin', require('./admin'));
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -9,12 +9,8 @@
|
|||||||
"orderDate": "2024-11-24T08:41:46.366Z",
|
"orderDate": "2024-11-24T08:41:46.366Z",
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"phone": "79001234563",
|
"phone": "79001234563",
|
||||||
"location": "Казань, ул. Баумана, 1",
|
"location": "55.779905316526424,49.12446113769528 Республика Татарстан (Татарстан),н Казань, ул. Баумана, 1",
|
||||||
"master": {
|
"master": "4545423234",
|
||||||
"name": "Олег Макаров",
|
|
||||||
"phone": "79001234567",
|
|
||||||
"id": "23423442"
|
|
||||||
},
|
|
||||||
"notes": ""
|
"notes": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -25,7 +21,7 @@
|
|||||||
"orderDate": "2024-11-24T07:40:46.366Z",
|
"orderDate": "2024-11-24T07:40:46.366Z",
|
||||||
"status": "progress",
|
"status": "progress",
|
||||||
"phone": "79001234567",
|
"phone": "79001234567",
|
||||||
"location": "Казань, ул. Баумана, 43",
|
"location": "55.75060416346278,48.746329576898944 Республика Татарстан (Татарстан), Верхнеуслонский район, Иннополис",
|
||||||
"master": [],
|
"master": [],
|
||||||
"notes": ""
|
"notes": ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"error": "Invalid car image file size. Limit is 5MB"
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"error": "Invalid car image file type. Allowed types: jpg, png"
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"success": true
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"success": false,
|
"success": false,
|
||||||
"message": "Не удалось создать заказ"
|
"error": "Не удалось создать заказ"
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"success": false,
|
"success": false,
|
||||||
"message": "Не удалось загрузить детали заказа"
|
"error": "Не удалось загрузить детали заказа"
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user