Skip to content

Commit 019df4d

Browse files
committed
feat: update todo loading functionality with internationalization support
1 parent 5657162 commit 019df4d

5 files changed

Lines changed: 21 additions & 12 deletions

File tree

src/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
}
66

77
.todo {
8-
@apply bg-teal-100 p-2 rounded-md border border-teal-300 mt-4;
8+
@apply bg-blue-100 p-2 rounded-md border border-blue-300 mt-4 text-blue-800;
99
}

src/locales/common/en-US.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
22
currency: 'USD',
3-
submitBtn: 'Submit',
4-
cancelBtn: 'Cancel',
3+
loadTodos: 'Load Todos',
4+
loadTodosSuccess: 'Todos loaded successfully!',
55
};

src/locales/common/vi-VN.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
22
currency: 'VND',
3-
submitBtn: 'Xác nhận',
4-
cancelBtn: 'Hủy',
3+
loadTodos: 'Tải danh sách công việc',
4+
loadTodosSuccess: 'Tải danh sách công việc thành công!',
55
};

src/routes/index.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import i18n from '@/helpers/i18n';
12
import { useListTodos } from '@/services/hooks/todo/use-list-todos';
23
import type { TodoDto } from '@/types/dto/todo.dto';
34
import { createFileRoute } from '@tanstack/react-router';
4-
import { Button, Row } from 'antd';
5+
import { Button, Col, Row } from 'antd';
56
import { useState } from 'react';
67

78
export const Route = createFileRoute('/')({
@@ -17,10 +18,17 @@ function RouteComponent() {
1718
};
1819

1920
return (
20-
<Row className="p-4">
21-
<Button onClick={handleClick} variant="solid" color="primary">
22-
{isLoading ? 'Loading...' : 'Load Todos'}
23-
</Button>
21+
<Col className="p-4">
22+
<Row>
23+
<Button
24+
onClick={handleClick}
25+
variant="solid"
26+
color="primary"
27+
loading={isLoading}
28+
>
29+
{i18n.t('common:loadTodos')}
30+
</Button>
31+
</Row>
2432
{data && (
2533
<Row className="todo">
2634
{error && <p>{error.message}</p>}
@@ -29,6 +37,6 @@ function RouteComponent() {
2937
})}
3038
</Row>
3139
)}
32-
</Row>
40+
</Col>
3341
);
3442
}

src/services/hooks/todo/use-list-todos.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import api from '@/helpers/axios-instance';
2+
import i18n from '@/helpers/i18n';
23
import { endpoints } from '@/services/endpoints';
34
import { useToast } from '@/services/hooks/common/use-toast';
45
import type { TodoDto } from '@/types/dto/todo.dto';
@@ -16,7 +17,7 @@ export const useListTodos = (enabled: boolean) => {
1617

1718
useEffect(() => {
1819
if (isSuccess) {
19-
toast.success('Todos loaded successfully');
20+
toast.success(i18n.t('common:loadTodosSuccess'));
2021
}
2122
}, [isSuccess, toast]);
2223

0 commit comments

Comments
 (0)