From d7da2b56185dcfb2436bc052996f4f4e6cf91443 Mon Sep 17 00:00:00 2001
From: ilnaz <237x237@gmail.com>
Date: Sat, 9 Nov 2024 18:52:38 +0300
Subject: [PATCH] feat: add i18next for arm (#17)
---
locales/ru.json | 34 +++++++++++++++++--
.../MasterActionsMenu/MasterActionsMenu.tsx | 7 ++--
.../MasterDrawer.tsx | 26 ++++++++++----
.../{MasterModal => MasterDrawer}/index.ts | 0
src/components/Masters/Masters.tsx | 12 ++++---
src/components/OrderItem/OrderItem.tsx | 4 +--
src/components/Orders/Orders.tsx | 20 ++++++-----
src/components/Sidebar/Sidebar.tsx | 8 ++---
8 files changed, 78 insertions(+), 33 deletions(-)
rename src/components/{MasterModal => MasterDrawer}/MasterDrawer.tsx (64%)
rename src/components/{MasterModal => MasterDrawer}/index.ts (100%)
diff --git a/locales/ru.json b/locales/ru.json
index 43163f8..6f5e671 100644
--- a/locales/ru.json
+++ b/locales/ru.json
@@ -1,5 +1,33 @@
{
- "dry-wash.arm.masters.add": "Добавить",
- "dry-wash.order.status.progress": "Выполняется",
- "dry-wash.order.status.complete": "Завершено"
+ "dry-wash.arm.master.add": "Добавить",
+ "dry-wash.arm.order.title": "Заказы",
+ "dry-wash.arm.order.status.progress": "Выполняется",
+ "dry-wash.arm.order.status.complete": "Завершено",
+ "dry-wash.arm.order.status.pending": "в ожидании",
+ "dry-wash.arm.order.status.working": "В работе",
+ "dry-wash.arm.order.status.canceled": "Отменено",
+ "dry-wash.arm.order.status.placeholder": "Выберите статус",
+ "dry-wash.arm.order.table.header.carNumber": "Номер машины",
+ "dry-wash.arm.order.table.header.washingTime": "Время мойки",
+ "dry-wash.arm.order.table.header.orderDate": "Дата заказа",
+ "dry-wash.arm.order.table.header.status": "Статус",
+ "dry-wash.arm.order.table.header.telephone": "Телефон",
+ "dry-wash.arm.order.table.header.location": "Расположение",
+ "dry-wash.arm.master.title": "Мастера",
+ "dry-wash.arm.master.table.header.name": "Имя",
+ "dry-wash.arm.master.table.header.currentJob": "Актуальная занятость",
+ "dry-wash.arm.master.table.header.phone": "Телефон",
+ "dry-wash.arm.master.table.header.actions": "Действия",
+ "dry-wash.arm.master.table.actionsMenu.delete": "Удалить мастера",
+ "dry-wash.arm.master.drawer.title": "Добавить нового мастера",
+ "dry-wash.arm.master.drawer.inputName.label": "ФИО",
+ "dry-wash.arm.master.drawer.inputName.placeholder": "Введите ФИО",
+ "dry-wash.arm.master.drawer.inputPhone.label": "Номер телефона",
+ "dry-wash.arm.master.drawer.inputPhone.placeholder": "Введите номер телефона",
+ "dry-wash.arm.master.drawer.button.save": "Сохранить",
+ "dry-wash.arm.master.drawer.button.cancel": "Отменить",
+ "dry-wash.arm.master.sideBar.title": " Сухой мастер",
+ "dry-wash.arm.master.sideBar.title.master": "Мастера",
+ "dry-wash.arm.master.sideBar.title.orders": "Заказы"
+
}
diff --git a/src/components/MasterActionsMenu/MasterActionsMenu.tsx b/src/components/MasterActionsMenu/MasterActionsMenu.tsx
index d8097d0..6f5bd9a 100644
--- a/src/components/MasterActionsMenu/MasterActionsMenu.tsx
+++ b/src/components/MasterActionsMenu/MasterActionsMenu.tsx
@@ -7,15 +7,16 @@ import {
IconButton,
} from '@chakra-ui/react';
import { EditIcon } from '@chakra-ui/icons';
+import i18next from 'i18next';
const MasterActionsMenu = () => {
return (
);
diff --git a/src/components/MasterModal/MasterDrawer.tsx b/src/components/MasterDrawer/MasterDrawer.tsx
similarity index 64%
rename from src/components/MasterModal/MasterDrawer.tsx
rename to src/components/MasterDrawer/MasterDrawer.tsx
index a0644ed..03ed489 100644
--- a/src/components/MasterModal/MasterDrawer.tsx
+++ b/src/components/MasterDrawer/MasterDrawer.tsx
@@ -12,6 +12,7 @@ import {
DrawerHeader,
DrawerOverlay,
} from '@chakra-ui/react';
+import i18next from 'i18next';
const MasterDrawer = ({ isOpen, onClose }) => {
const [newMaster, setNewMaster] = useState({ name: '', phone: '' });
@@ -26,35 +27,46 @@ const MasterDrawer = ({ isOpen, onClose }) => {
- Добавить нового мастера
+
+ {i18next.t('dry-wash.arm.master.drawer.title')}
+
- ФИО
+
+ {i18next.t('dry-wash.arm.master.drawer.inputName.label')}
+
setNewMaster({ ...newMaster, name: e.target.value })
}
- placeholder='Введите ФИО'
+ placeholder={i18next.t(
+ 'dry-wash.arm.master.drawer.inputName.placeholder',
+ )}
/>
- Номер телефона
+
+ {' '}
+ {i18next.t('dry-wash.arm.master.drawer.inputPhone.label')}
+
setNewMaster({ ...newMaster, phone: e.target.value })
}
- placeholder='Введите номер телефона'
+ placeholder={i18next.t(
+ 'dry-wash.arm.master.drawer.inputPhone.placeholder',
+ )}
/>
diff --git a/src/components/MasterModal/index.ts b/src/components/MasterDrawer/index.ts
similarity index 100%
rename from src/components/MasterModal/index.ts
rename to src/components/MasterDrawer/index.ts
diff --git a/src/components/Masters/Masters.tsx b/src/components/Masters/Masters.tsx
index 6d0028d..581d6b5 100644
--- a/src/components/Masters/Masters.tsx
+++ b/src/components/Masters/Masters.tsx
@@ -13,10 +13,10 @@ import {
} from '@chakra-ui/react';
import { mastersData } from '../../mocks';
import MasterItem from '../MasterItem';
-import MasterDrawer from '../MasterModal';
+import MasterDrawer from '../MasterDrawer';
import i18next from 'i18next';
-const TABLE_HEADERS = ['Имя', 'Актуальная занятость', 'Телефон', 'Действия'];
+const TABLE_HEADERS = ['name', 'currentJob', 'phone', 'actions'];
const Masters = () => {
const { isOpen, onOpen, onClose } = useDisclosure();
@@ -24,16 +24,18 @@ const Masters = () => {
return (
- Мастера
+ {i18next.t('dry-wash.arm.master.title')}
{TABLE_HEADERS.map((name) => (
- {name} |
+
+ {i18next.t(`dry-wash.arm.master.table.header.${name}`)}
+ |
))}
diff --git a/src/components/OrderItem/OrderItem.tsx b/src/components/OrderItem/OrderItem.tsx
index bd6e826..64c5444 100644
--- a/src/components/OrderItem/OrderItem.tsx
+++ b/src/components/OrderItem/OrderItem.tsx
@@ -23,11 +23,11 @@ const OrderItem = ({
diff --git a/src/components/Orders/Orders.tsx b/src/components/Orders/Orders.tsx
index 9401731..1e9f258 100644
--- a/src/components/Orders/Orders.tsx
+++ b/src/components/Orders/Orders.tsx
@@ -2,26 +2,28 @@ import { Box, Heading, Table, Thead, Tbody, Tr, Th } from '@chakra-ui/react';
import React from 'react';
import { ordersData } from '../../mocks';
import OrderItem from '../OrderItem';
-
+import i18next from 'i18next';
const Orders = () => {
const TABLE_HEADERS = [
- 'Номер машины',
- 'Время мойки',
- 'Дата заказа',
- 'Статус',
- 'Телефон',
- 'Расположение',
+ 'carNumber',
+ 'washingTime',
+ 'orderDate',
+ 'status',
+ 'telephone',
+ 'location',
];
return (
- Заказы
+ {i18next.t('dry-wash.arm.order.title')}
{TABLE_HEADERS.map((name, key) => (
- {name} |
+
+ {i18next.t(`dry-wash.arm.order.table.header.${name}`)}
+ |
))}
diff --git a/src/components/Sidebar/Sidebar.tsx b/src/components/Sidebar/Sidebar.tsx
index a88e350..86f64f5 100644
--- a/src/components/Sidebar/Sidebar.tsx
+++ b/src/components/Sidebar/Sidebar.tsx
@@ -1,7 +1,7 @@
import { Box, Button, Heading, VStack } from '@chakra-ui/react';
import React from 'react';
import { Divider } from '@chakra-ui/react';
-
+import i18next from 'i18next';
const Sidebar = ({ onSelectPage }) => (
(
pt='8'
>
- Сухой мастер
+ {i18next.t(`dry-wash.arm.master.sideBar.title`)}
@@ -23,7 +23,7 @@ const Sidebar = ({ onSelectPage }) => (
colorScheme='green'
variant='ghost'
>
- Заказы
+ {i18next.t(`dry-wash.arm.master.sideBar.title.orders`)}