feat: add multilingualism (#35)

This commit is contained in:
2024-11-23 15:19:44 +03:00
parent a63304b5e4
commit 4e8bc2fca5
11 changed files with 175 additions and 102 deletions

View File

@@ -1,8 +1,26 @@
import React, { useState } from 'react';
import { Td, Tr, Link, Select } from '@chakra-ui/react';
import i18next from 'i18next';
import { useTranslation } from 'react-i18next';
const statuses = ['pending', 'progress', 'working', 'canceled', 'complete'];
const statuses = [
'pending' as const,
'progress' as const,
'working' as const,
'canceled' as const,
'complete' as const,
];
type GetArrItemType<ArrType> =
ArrType extends Array<infer ItemType> ? ItemType : never;
export type OrderProps = {
carNumber?: string;
washTime?: string;
orderDate?: string;
status?: GetArrItemType<typeof statuses>;
phone?: string;
location?: string;
};
const OrderItem = ({
carNumber,
@@ -11,7 +29,11 @@ const OrderItem = ({
status,
phone,
location,
}) => {
}: OrderProps) => {
const { t } = useTranslation('~', {
keyPrefix: 'dry-wash.arm.order',
});
const [statusSelect, setStatus] = useState(status);
return (
@@ -22,12 +44,12 @@ const OrderItem = ({
<Td>
<Select
value={statusSelect}
onChange={(e) => setStatus(e.target.value)}
placeholder={i18next.t(`dry-wash.arm.order.status.placeholder`)}
onChange={(e) => setStatus(e.target.value as OrderProps['status'])}
placeholder={t(`status.placeholder`)}
>
{statuses.map((status) => (
<option key={status} value={status}>
{i18next.t(`dry-wash.arm.order.status.${status}`)}
{t(`status.${status}`)}
</option>
))}
</Select>