This commit is contained in:
Iliyan Angelov
2025-11-16 15:12:43 +02:00
parent 824eec6190
commit 93d4c1df80
54 changed files with 1606 additions and 1612 deletions

View File

@@ -1,8 +1,8 @@
/**
* Example: Cách sử dụng useAuthStore trong components
* Example: How to use useAuthStore in components
*
* File này chỉ để tham khảo, không được sử dụng
* trong production
* This file is for reference only, should not be used
* in production
*/
import { useNavigate } from 'react-router-dom';
@@ -23,7 +23,7 @@ export const LoginExample = () => {
await login({ email, password });
navigate('/dashboard');
} catch (error) {
// Error đã được xử lý trong store
// Error has been handled in store
console.error('Login failed:', error);
}
};
@@ -38,7 +38,7 @@ export const LoginExample = () => {
)}
disabled={isLoading}
>
{isLoading ? 'Đang xử lý...' : 'Đăng nhập'}
{isLoading ? 'Processing...' : 'Login'}
</button>
</div>
);
@@ -70,7 +70,7 @@ export const RegisterExample = () => {
onClick={handleRegister}
disabled={isLoading}
>
{isLoading ? 'Đang xử lý...' : 'Đăng ký'}
{isLoading ? 'Processing...' : 'Register'}
</button>
);
};
@@ -82,13 +82,13 @@ export const UserProfileExample = () => {
const { userInfo, isAuthenticated } = useAuthStore();
if (!isAuthenticated) {
return <p>Vui lòng đăng nhập</p>;
return <p>Please login</p>;
}
return (
<div>
<h2>Thông tin người dùng</h2>
<p>Tên: {userInfo?.name}</p>
<h2>User Information</h2>
<p>Name: {userInfo?.name}</p>
<p>Email: {userInfo?.email}</p>
<p>Role: {userInfo?.role}</p>
{userInfo?.avatar && (
@@ -118,7 +118,7 @@ export const LogoutButtonExample = () => {
onClick={handleLogout}
disabled={isLoading}
>
{isLoading ? 'Đang xử lý...' : 'Đăng xuất'}
{isLoading ? 'Processing...' : 'Logout'}
</button>
);
};
@@ -134,7 +134,7 @@ export const ForgotPasswordExample = () => {
) => {
try {
await forgotPassword({ email });
// Toast sẽ hiển thị thông báo thành công
// Toast will display success message
} catch (error) {
console.error('Forgot password failed:', error);
}
@@ -147,7 +147,7 @@ export const ForgotPasswordExample = () => {
}
disabled={isLoading}
>
Gửi email đt lại mật khẩu
Send password reset email
</button>
);
};
@@ -185,7 +185,7 @@ export const ResetPasswordExample = () => {
}
disabled={isLoading}
>
Đt lại mật khẩu
Reset Password
</button>
);
};
@@ -222,14 +222,14 @@ export const AuthStateCheckExample = () => {
} = useAuthStore();
if (isLoading) {
return <p>Đang tải...</p>;
return <p>Loading...</p>;
}
if (!isAuthenticated || !token) {
return <p>Bạn chưa đăng nhập</p>;
return <p>You are not logged in</p>;
}
return <p>Bạn đã đăng nhập</p>;
return <p>You are logged in</p>;
};
// ============================================
@@ -250,7 +250,7 @@ export const UpdateUserInfoExample = () => {
return (
<button onClick={handleUpdateProfile}>
Cập nhật thông tin
Update Information
</button>
);
};
@@ -270,7 +270,7 @@ export const ErrorHandlingExample = () => {
onClick={clearError}
className="mt-2 text-sm text-red-600"
>
Đóng
Close
</button>
</div>
);