Files
pos-system/apps/web-client-tpos-net/src/WebClientTpos.Client/Pages/Pos/PosBase.cs

61 lines
1.9 KiB
C#

using Microsoft.AspNetCore.Components;
namespace WebClientTpos.Client.Pages.Pos;
/// <summary>
/// EN: Base class for all POS pages — shift state, offline detection, cart management.
/// VI: Lớp cơ sở cho tất cả trang POS — trạng thái ca, phát hiện offline, quản lý giỏ hàng.
/// </summary>
public abstract class PosBase : ComponentBase
{
[Inject] protected NavigationManager NavigationManager { get; set; } = default!;
/// <summary>
/// EN: Whether POS is in offline mode.
/// VI: POS có đang ở chế độ offline không.
/// </summary>
protected bool IsOffline { get; set; } = false;
/// <summary>
/// EN: Current shift ID.
/// VI: ID ca làm việc hiện tại.
/// </summary>
protected string? CurrentShiftId { get; set; }
/// <summary>
/// EN: Staff name (logged-in user).
/// VI: Tên nhân viên (người đăng nhập).
/// </summary>
protected string StaffName { get; set; } = string.Empty;
/// <summary>
/// EN: Store name.
/// VI: Tên cửa hàng.
/// </summary>
protected string StoreName { get; set; } = string.Empty;
/// <summary>
/// EN: Whether a shift is currently active.
/// VI: Ca làm việc có đang hoạt động không.
/// </summary>
protected bool HasActiveShift => !string.IsNullOrEmpty(CurrentShiftId);
/// <summary>
/// EN: Format Vietnamese currency for POS display (compact).
/// VI: Định dạng tiền tệ VND cho POS (gọn).
/// </summary>
protected static string FormatPrice(decimal price)
{
return price.ToString("N0") + "₫";
}
/// <summary>
/// EN: Navigate to POS sub-page.
/// VI: Điều hướng đến trang con POS.
/// </summary>
protected void NavigateTo(string path)
{
NavigationManager.NavigateTo($"/pos/{path}");
}
}