- Added bilingual comments and metadata in `layout.tsx`, including application title and description in both English and Vietnamese. - Updated `page.tsx` to include bilingual loading messages, welcome prompts, and login instructions for improved user experience. - Enhanced `login/page.tsx` with bilingual labels and messages for form fields and error handling. - Improved `auth.api.ts` with detailed comments on authentication processes, including registration, login, logout, and token management. - Updated `auth.store.ts` to include bilingual comments for state management and authentication methods. - Enhanced API response types in `api.types.ts` with bilingual documentation for better clarity. - Improved user management routes and services in `user.controller.ts` and `user.service.ts` with bilingual comments for better maintainability.
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
'use client';
|
|
|
|
import { useAuthStore } from '@/stores/auth.store';
|
|
import { useEffect } from 'react';
|
|
|
|
/**
|
|
* EN: Home page component - main application entry point
|
|
* VI: Component trang chủ - điểm vào chính của ứng dụng
|
|
*/
|
|
export default function Home() {
|
|
// EN: Get authentication state from store
|
|
// VI: Lấy trạng thái xác thực từ store
|
|
const { user, isAuthenticated, isLoading, fetchUser } = useAuthStore();
|
|
|
|
// EN: Fetch user data on component mount if not authenticated
|
|
// VI: Fetch dữ liệu user khi component mount nếu chưa xác thực
|
|
useEffect(() => {
|
|
if (!isAuthenticated && !isLoading) {
|
|
fetchUser();
|
|
}
|
|
}, [isAuthenticated, isLoading, fetchUser]);
|
|
|
|
// EN: Show loading state while checking authentication
|
|
// VI: Hiển thị trạng thái loading trong khi kiểm tra xác thực
|
|
if (isLoading) {
|
|
return <div className="p-8">Loading... / Đang tải...</div>;
|
|
}
|
|
|
|
return (
|
|
// EN: Main content area with responsive padding
|
|
// VI: Khu vực nội dung chính với padding responsive
|
|
<main className="min-h-screen p-8">
|
|
<h1 className="text-4xl font-bold mb-4">GoodGo Platform / Nền tảng GoodGo</h1>
|
|
|
|
{/* EN: Conditional rendering based on authentication status / VI: Render có điều kiện dựa trên trạng thái xác thực */}
|
|
{isAuthenticated && user ? (
|
|
// EN: Authenticated user welcome message / VI: Thông báo chào mừng người dùng đã xác thực
|
|
<div>
|
|
<p>Welcome, {user.email}! / Chào mừng, {user.email}!</p>
|
|
<p>Role: {user.role} / Vai trò: {user.role}</p>
|
|
</div>
|
|
) : (
|
|
// EN: Login prompt for unauthenticated users / VI: Nhắc đăng nhập cho người dùng chưa xác thực
|
|
<div>
|
|
<p>Please log in to continue. / Vui lòng đăng nhập để tiếp tục.</p>
|
|
</div>
|
|
)}
|
|
</main>
|
|
);
|
|
}
|