Skip to content

Commit e51c719

Browse files
authored
Merge pull request #24 from Dialogue-Bot/DIAL-20-refesh-token-bot-client-serrver
feat: add missing lang some component
2 parents fbd9d21 + 50aa161 commit e51c719

File tree

11 files changed

+81
-23
lines changed

11 files changed

+81
-23
lines changed

client/src/components/pages/channels/data-toolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const DataToolbar = () => {
3838
<Trans
3939
i18nKey="channel:add_channel_description"
4040
components={{
41-
a: <Link to="/channels" />,
41+
a: <Link to="/channels" className="link" />,
4242
}}
4343
/>
4444
</SheetDescription>

client/src/components/pages/channels/row-action.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import { useDeleteChannel, useUpdateChannel } from '@/hooks/channel';
1818
import { useBodyOverflow } from '@/hooks/use-body-overflow';
1919
import { TChannelWithChannelType } from '@/types/channel';
2020
import { Row } from '@tanstack/react-table';
21-
import { Link, MoreHorizontal } from 'lucide-react';
21+
import { MoreHorizontal } from 'lucide-react';
2222
import { useState } from 'react';
2323
import { Trans, useTranslation } from 'react-i18next';
24+
import { Link } from 'react-router-dom';
2425

2526
type Props = {
2627
row: Row<TChannelWithChannelType>;
@@ -72,7 +73,7 @@ const RowActions = ({ row }: Props) => {
7273
<Trans
7374
i18nKey="channel:update_channel_description"
7475
components={{
75-
a: <Link to="/channels" />,
76+
a: <Link to="/channels" className="link" />,
7677
}}
7778
/>
7879
</SheetDescription>

client/src/components/ui/confirm.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
AlertDialogTitle,
1111
AlertDialogTrigger,
1212
} from './alert-dialog';
13+
import { useTranslation } from 'react-i18next';
1314

1415
export type ConfirmProps = {
1516
onConfirm?: (close: () => void) => void;
@@ -26,20 +27,23 @@ export function Confirm({
2627
children,
2728
onCancel,
2829
onConfirm,
29-
textCancel = 'Huỷ bỏ',
30-
textConfirm = 'Xác nhận',
30+
textCancel,
31+
textConfirm,
3132
description,
32-
title = 'Bạn có chắc chắn?',
33+
title,
3334
isLoading,
3435
}: ConfirmProps) {
3536
const [isOpen, setIsOpen] = useState(false);
37+
const { t } = useTranslation('common');
3638

3739
return (
3840
<AlertDialog onOpenChange={setIsOpen} open={isOpen}>
3941
<AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
4042
<AlertDialogContent>
4143
<AlertDialogHeader>
42-
<AlertDialogTitle>{title}</AlertDialogTitle>
44+
<AlertDialogTitle>
45+
{title ? title : t('dialog_confirm_title')}
46+
</AlertDialogTitle>
4347
{description ? (
4448
<AlertDialogDescription>{description}</AlertDialogDescription>
4549
) : null}
@@ -52,7 +56,7 @@ export function Confirm({
5256
onCancel?.();
5357
}}
5458
>
55-
{textCancel}
59+
{textCancel ? textCancel : t('cancel')}
5660
</AlertDialogCancel>
5761
<AlertDialogAction
5862
isLoading={isLoading}
@@ -62,7 +66,7 @@ export function Confirm({
6266
});
6367
}}
6468
>
65-
{textConfirm}
69+
{textConfirm ? textConfirm : t('confirm')}
6670
</AlertDialogAction>
6771
</AlertDialogFooter>
6872
</AlertDialogContent>

client/src/components/ui/data-table/data-table-pagination.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from '../select';
1515
import { Button } from '../button';
1616
import { Confirm } from '../confirm';
17+
import { useTranslation } from 'react-i18next';
1718

1819
interface DataTablePaginationProps<TData> {
1920
table: Table<TData>;
@@ -26,29 +27,35 @@ export function DataTablePagination<TData>({
2627
onDelete,
2728
isLoadingDelete,
2829
}: DataTablePaginationProps<TData>) {
30+
const { t } = useTranslation('dataTable');
2931
return (
3032
<div className="flex items-center justify-between px-2">
3133
<div className="flex items-center gap-2">
3234
<div className="flex-1 text-sm text-muted-foreground whitespace-nowrap">
33-
{table.getFilteredSelectedRowModel().rows.length} trên{' '}
34-
{table.getFilteredRowModel().rows.length} dòng được chọn.
35+
{t('row_selected', {
36+
selected: table.getFilteredSelectedRowModel().rows.length,
37+
total: table.getFilteredRowModel().rows.length,
38+
})}
3539
</div>
3640
{onDelete && table.getFilteredSelectedRowModel().rows.length ? (
3741
<Confirm
38-
description="Hành động này không thể hoàn tác. Bạn có chắc chắn muốn xoá?"
42+
description={t('remove_confirm_desc')}
3943
isLoading={isLoadingDelete}
4044
onConfirm={onDelete}
41-
title="Xoá những dòng đã chọn?"
45+
title={t('remove_confirm_title')}
4246
>
4347
<span className=" text-sm text-red-500 cursor-pointer">
44-
Xoá {table.getFilteredSelectedRowModel().rows.length} dòng
48+
{t('remove_row', {
49+
selected:
50+
table.getFilteredSelectedRowModel().rows.length,
51+
})}
4552
</span>
4653
</Confirm>
4754
) : null}
4855
</div>
4956
<div className="flex items-center space-x-6 lg:space-x-8">
5057
<div className="flex items-center space-x-2">
51-
<p className="text-sm font-medium">Dòng trên trang</p>
58+
<p className="text-sm font-medium">{t('row_per_page')}:</p>
5259
<Select
5360
onValueChange={(value) => {
5461
table.setPageSize(Number(value));
@@ -70,8 +77,10 @@ export function DataTablePagination<TData>({
7077
</Select>
7178
</div>
7279
<div className="flex w-[100px] items-center justify-center text-sm font-medium whitespace-nowrap">
73-
Trang {table.getState().pagination.pageIndex + 1} trên{' '}
74-
{table.getPageCount()}
80+
{t('page_of', {
81+
current: table.getState().pagination.pageIndex + 1,
82+
total: table.getPageCount(),
83+
})}
7584
</div>
7685
<div className="flex items-center space-x-2">
7786
<Button

client/src/components/ui/data-table/data-table.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
TableRow,
2929
} from '../table';
3030
import { DataTablePagination } from './data-table-pagination';
31+
import { useTranslation } from 'react-i18next';
3132

3233
interface DataTableProps<TData, TValue> {
3334
columns: ColumnDef<TData, TValue>[];
@@ -56,6 +57,7 @@ export function DataTable<TData, TValue>({
5657
[]
5758
);
5859
const [sorting, setSorting] = React.useState<SortingState>([]);
60+
const { t } = useTranslation(['dataTable']);
5961

6062
const { state, ..._opts } = opts || {};
6163

@@ -135,7 +137,7 @@ export function DataTable<TData, TValue>({
135137
className="h-24 text-center"
136138
colSpan={columns.length}
137139
>
138-
Không có kết quả.
140+
{t('no_data')}
139141
</TableCell>
140142
</TableRow>
141143
)}

client/src/constants/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const ROUTES = {
5454
},
5555
SETTING: {
5656
INDEX: '/settings',
57-
MAIL: '/settings/email',
57+
MAIL: '/settings/mail',
5858
PROFILES: '/settings/profiles',
5959
},
6060
},

client/src/i18n/resources.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import tableColEn from '@/locales/en/table-cols.json';
2121
import tableColVi from '@/locales/vi/table-cols.json';
2222
import channelEn from '@/locales/en/channel.json';
2323
import channelVi from '@/locales/vi/channel.json';
24+
import tableEn from '@/locales/en/table.json';
25+
import tableVi from '@/locales/vi/table.json';
2426

2527
const resources = {
2628
[ELang.EN]: {
@@ -35,6 +37,7 @@ const resources = {
3537
mail: mailEN,
3638
tableCols: tableColEn,
3739
channel: channelEn,
40+
dataTable: tableEn,
3841
},
3942
[ELang.VI]: {
4043
common: commonVI,
@@ -48,6 +51,7 @@ const resources = {
4851
mail: mailVI,
4952
tableCols: tableColVi,
5053
channel: channelVi,
54+
dataTable: tableVi,
5155
},
5256
} as const;
5357

client/src/locales/en/common.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@
1818
"channels": "Channels",
1919
"search": "Search",
2020
"row_actions": {
21-
"update": "Cập nhật",
22-
"delete": "Xóa"
21+
"update": "Update",
22+
"delete": "Delete"
2323
},
2424
"remove": "Remove",
25-
"cancel": "Cancel"
25+
"cancel": "Cancel",
26+
"submit": "Submit",
27+
"yes": "Yes",
28+
"no": "No",
29+
"ok": "OK",
30+
"dialog_confirm_title": "Confirm",
31+
"dialog_confirm_desc": "Are you sure?",
32+
"confirm": "Confirm"
2633
}

client/src/locales/en/table.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"asc": "Asc",
3+
"desc": "Desc",
4+
"hide_column": "Hide column",
5+
"row_selected": "{{selected}} of {{total}} row(s) selected",
6+
"row_per_page": "Rows per page",
7+
"page_of": "Page {{current}} of {{total}}",
8+
"remove_row": "Remove {{selected}} row(s)",
9+
"no_data": "No data available!",
10+
"remove_confirm_title": "Remove selected rows?",
11+
"remove_confirm_desc": "This action cannot be undone. Are you sure?"
12+
}

client/src/locales/vi/common.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,12 @@
2121
"delete": "Xóa"
2222
},
2323
"remove": "Xóa",
24-
"cancel": "Hủy"
24+
"cancel": "Hủy",
25+
"submit": "Xác nhận",
26+
"yes": "",
27+
"no": "Không",
28+
"ok": "OK",
29+
"dialog_confirm_title": "Xác nhận",
30+
"dialog_confirm_desc": "Bạn có chắc chắn không?",
31+
"confirm": "Xác nhận"
2532
}

0 commit comments

Comments
 (0)