using Microsoft.AspNetCore.Components;
using MudBlazor;

namespace BackOffice.Pages.Payment.Components;

public partial class TransactionDetailsDialog
{
    [CascadingParameter] 
    private IMudDialogInstance MudDialog { get; set; } = default!;

    [Parameter]
    public TransactionDetailsModel? Model { get; set; }

    private string StatusText => Model is null ? string.Empty : GetStatusText(Model.PaymentStatus);

    private void Close()
    {
        MudDialog.Cancel();
    }

    private static string GetStatusText(int status)
    {
        return status switch
        {
            0 => "در انتظار",
            1 => "موفق",
            2 => "ناموفق",
            3 => "بازگشت وجه",
            _ => "نامشخص"
        };
    }

    public class TransactionDetailsModel
    {
        public long Id { get; set; }
        public string? RefId { get; set; }
        public long Amount { get; set; }
        public int PaymentStatus { get; set; }
        public DateTime PaymentDate { get; set; }
        public string? BankReferenceId { get; set; }
        public string? TrackingCode { get; set; }
        public bool PaymentFailed { get; set; }
        public string? PaymentFailedReason { get; set; }
    }
}

