@page "/login" @using WebClientTpos.Shared.DTOs @using WebClientTpos.Shared @inject HttpClient Http @inject NavigationManager Navigation @inject IStringLocalizer L @* EN: Login page with email/password authentication. VI: Trang đăng nhập với xác thực email/mật khẩu. *@ @L["Auth_Login_Title"]

@L["Auth_Login_Title"]

@L["Auth_Login_Subtitle"]

@L["Auth_Login_ForgotPassword"]
@if (!string.IsNullOrEmpty(message)) {
@message
}
@code { private LoginDto loginModel = new(); private bool isSubmitting = false; private string message = ""; private bool success = false; /// /// EN: Handle login form submission. /// VI: Xử lý submit form đăng nhập. /// private async Task HandleLogin() { isSubmitting = true; message = ""; try { var response = await Http.PostAsJsonAsync("api/auth/login", loginModel); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadFromJsonAsync>(); if (result?.Success == true && result.Data != null) { success = true; message = string.Format(L["Auth_Login_Success"], result.Data.DisplayName); // EN: Redirect to home after 1 second // VI: Chuyển hướng về trang chủ sau 1 giây await Task.Delay(1000); Navigation.NavigateTo("/"); } else { success = false; message = L["Auth_Login_Error"]; } } else { success = false; message = L["Auth_Login_Error"]; } } catch (Exception ex) { success = false; message = $"{L["Common_Error"]}: {ex.Message}"; } finally { isSubmitting = false; } } }