128 lines
4.5 KiB
C#
128 lines
4.5 KiB
C#
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
|
using FrontOffice.Main.Utilities;
|
|
using Microsoft.AspNetCore.Components;
|
|
using MudBlazor;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace FrontOffice.Main.Pages;
|
|
|
|
public partial class Index:IDisposable
|
|
{
|
|
[Inject] private PackageContract.PackageContractClient PackageClient { get; set; } = default!;
|
|
[Inject] private MobileNumberEncryptor Encryptor { get; set; }
|
|
private string? _email;
|
|
private bool _isLoadingPackages;
|
|
private List<Pack> _packs = new();
|
|
[Inject] private AuthService AuthService { get; set; } = default!;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
MainService.OnChangeHandler +=async () =>
|
|
{
|
|
await InvokeAsync(StateHasChanged);
|
|
};
|
|
// await LoadPackagesAsync();
|
|
|
|
//string mobileNumber = "09387342688";
|
|
|
|
//// انکریپت کردن
|
|
//string encrypted = Encryptor.EncryptMobileNumber(mobileNumber);
|
|
//Console.WriteLine($"Encrypted: {encrypted}");
|
|
|
|
//// دیکریپت کردن برای تست
|
|
//string decrypted = Encryptor.DecryptMobileNumber(encrypted);
|
|
//Console.WriteLine($"Decrypted: {decrypted}");
|
|
}
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (await AuthService.IsAuthenticatedAsync())
|
|
{
|
|
if ((await AuthService.IsCompleteRegisterAsync()))
|
|
{
|
|
Navigation.NavigateTo(RouteConstants.Profile.Index);
|
|
}
|
|
else
|
|
{
|
|
Navigation.NavigateTo(RouteConstants.Registration.Wizard);
|
|
}
|
|
}
|
|
await base.OnAfterRenderAsync(firstRender);
|
|
}
|
|
|
|
// private async Task LoadPackagesAsync()
|
|
// {
|
|
// _isLoadingPackages = true;
|
|
// try
|
|
// {
|
|
// var response = await PackageClient.GetAllPackageByFilterAsync(request: new());
|
|
// if (response?.Models?.Any() == true)
|
|
// {
|
|
// _packs = response.Models.Select(p => new Pack(
|
|
// Id: p.Id,
|
|
// Title: p.Title,
|
|
// Body: p.Description,
|
|
// Image: UrlUtility.DownloadUrl + p.ImagePath,
|
|
// Price: p.Price
|
|
// )).ToList();
|
|
// }
|
|
// else
|
|
// _packs = new List<Pack>();
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// Snackbar.Add($"خطا در بارگذاری پکیجها: {ex.Message}", Severity.Error);
|
|
// // Fallback to empty list
|
|
// _packs = new List<Pack>();
|
|
// }
|
|
// finally
|
|
// {
|
|
// _isLoadingPackages = false;
|
|
// await InvokeAsync(StateHasChanged);
|
|
// }
|
|
// }
|
|
|
|
private void JoinWaitlist()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(_email))
|
|
{
|
|
Snackbar.Add("لطفاً ایمیل معتبر وارد کنید.", Severity.Warning);
|
|
return;
|
|
}
|
|
|
|
Snackbar.Add("به لیست انتظار «کارا بازار سلامت» اضافه شدید.", Severity.Success);
|
|
_email = string.Empty;
|
|
}
|
|
|
|
private void NavigateToPackage(long packageId)
|
|
{
|
|
Navigation.NavigateTo($"{RouteConstants.Package.Detail}{packageId}");
|
|
}
|
|
|
|
private void NavigateToRegistrationWizard()
|
|
{
|
|
Navigation.NavigateTo(RouteConstants.Registration.Wizard);
|
|
}
|
|
|
|
private record Pack(long Id, string Title, string Body, string Image, long Price);
|
|
|
|
private record Plan(string Name, string Price, bool Highlight, IEnumerable<string> Features);
|
|
|
|
private record QA(string Q, string A);
|
|
|
|
private readonly List<QA> _faqs = new()
|
|
{
|
|
new("دامنهٔ اختصاصی دارم؛ قابل اتصال است؟", "بله، پشت دامنه و گواهی SSL خودتان مستقر میشود."),
|
|
new("با دیتابیس خودم کار میکند؟", "کاملاً. SQL Server، PostgreSQL و MySQL پشتیبانی میشود."),
|
|
new("چه درگاههایی پشتیبانی میشود؟", "Stripe و PayPal یا درگاه اختصاصی از طریق وبهوکها."),
|
|
new("میتوانم دادهها را خروجی بگیرم؟", "هر زمان از داشبورد ادمین خروجی CSV/Excel بگیرید."),
|
|
};
|
|
|
|
public void Dispose()
|
|
{
|
|
MainService.OnChangeHandler -=async () =>
|
|
{
|
|
await InvokeAsync(StateHasChanged);
|
|
};
|
|
}
|
|
} |