diff --git a/src/components/order-view/details/car/car-details.tsx b/src/components/order-view/details/car/car-details.tsx new file mode 100644 index 0000000..f89028c --- /dev/null +++ b/src/components/order-view/details/car/car-details.tsx @@ -0,0 +1,29 @@ +import React from 'react'; +import { FC } from 'react'; +import { Flex, Image } from '@chakra-ui/react'; + +import { Order } from '../../../../models'; +import { + carBodySelectOptions, + carColorSelectOptions, +} from '../../../order-form'; + +import { LicensePlate } from './license-plate'; + +type Props = Pick; + +export const CarDetails: FC = ({ carNumber, carBody, carColor }) => { + const image = carBodySelectOptions.find(({ value }) => value === carBody).img; + const color = + carColorSelectOptions.find(({ value }) => value === carColor)?.code ?? + 'black'; + + return ( + +
+ +
+ +
+ ); +}; diff --git a/src/components/order-view/details/car/index.ts b/src/components/order-view/details/car/index.ts new file mode 100644 index 0000000..2a8d241 --- /dev/null +++ b/src/components/order-view/details/car/index.ts @@ -0,0 +1 @@ +export { CarDetails } from './car-details'; \ No newline at end of file diff --git a/src/components/order-view/details/car/license-plate/index.ts b/src/components/order-view/details/car/license-plate/index.ts new file mode 100644 index 0000000..800551b --- /dev/null +++ b/src/components/order-view/details/car/license-plate/index.ts @@ -0,0 +1 @@ +export { LicensePlate } from './license-plate'; \ No newline at end of file diff --git a/src/components/order-view/details/car/license-plate/license-plate.tsx b/src/components/order-view/details/car/license-plate/license-plate.tsx new file mode 100644 index 0000000..9fe6c62 --- /dev/null +++ b/src/components/order-view/details/car/license-plate/license-plate.tsx @@ -0,0 +1,52 @@ +import React, { FC } from 'react'; +import { Flex, HStack, Text } from '@chakra-ui/react'; + +import { Order } from '../../../../../models'; + +export const LicensePlate: FC> = ({ + carNumber, +}) => { + const firstLetter = carNumber.substring(0, 1); + const digits = carNumber.substring(1, 4); + const lastLetters = carNumber.substring(4, 6); + const region = carNumber.substring(6); + + return ( + + + {firstLetter} + {digits} + {lastLetters} + + + {region} + + + ); +}; diff --git a/src/components/order-view/details/order-details.tsx b/src/components/order-view/details/order-details.tsx index 5b39eaa..c82e3de 100644 --- a/src/components/order-view/details/order-details.tsx +++ b/src/components/order-view/details/order-details.tsx @@ -7,6 +7,7 @@ import { UnorderedList, ListItem, Text, + Flex, } from '@chakra-ui/react'; import { useTranslation } from 'react-i18next'; import dayjs from 'dayjs'; @@ -17,12 +18,10 @@ import 'dayjs/locale/en'; import { Order } from '../../../models/landing'; import { formatDatetime } from '../../../lib'; -import { - carBodySelectOptions, - carColorSelectOptions, -} from '../../order-form'; +import { carBodySelectOptions, carColorSelectOptions } from '../../order-form'; import { OrderStatus } from './status'; +import { CarDetails } from './car'; type OrderDetailsProps = Pick< Order.View, @@ -60,7 +59,9 @@ export const OrderDetails: FC = ({ const { t: tCarColor } = useTranslation('~', { keyPrefix: 'dry-wash.order-create.car-color-select.colors', }); - const carColorTKey = carColorSelectOptions.find(({ value }) => value === carColor)?.labelTKey; + const carColorTKey = carColorSelectOptions.find( + ({ value }) => value === carColor, + )?.labelTKey; return ( <> @@ -76,44 +77,43 @@ export const OrderDetails: FC = ({ {dayjs(created).format('LLL')} - - {[ - { - label: t('owner'), - value: phone, - }, - { - label: t('car'), - value: [ - carNumber, - tCarBody( - `${carBodySelectOptions.find(({ value }) => value === carBody)?.labelTKey}`, - ), - carColorTKey ? tCarColor(carColorTKey) : carColor, - ] - .filter((v) => v) - .join(', '), - }, - { - label: t('location'), - value: location, - }, - { - label: t('datetime-range'), - value: [ - formatDatetime(startWashTime), - formatDatetime(endWashTime), - ].join(' - '), - }, - ].map(({ label, value }, i) => ( - - {label}:{' '} - - {value} - - - ))} - + + + + {[ + { + label: t('car'), + value: `${tCarBody(carBodySelectOptions.find(({ value }) => value === carBody)?.labelTKey)} (${carColorTKey ? tCarColor(carColorTKey) : carColor})`, + }, + { + label: t('owner'), + value: phone, + }, + { + label: t('location'), + value: location, + }, + { + label: t('datetime-range'), + value: [ + formatDatetime(startWashTime), + formatDatetime(endWashTime), + ].join(' - '), + }, + ].map(({ label, value }, i) => ( + + + {label}: + {' '} + {value} + + ))} + + {t('alert')} diff --git a/src/pages/order-view/index.tsx b/src/pages/order-view/index.tsx index ee04a4c..eca1476 100644 --- a/src/pages/order-view/index.tsx +++ b/src/pages/order-view/index.tsx @@ -74,7 +74,7 @@ const Page: FC = () => {