Refactor: Update Protobuf references to CMSMicroservice across multiple components
- Changed Protobuf imports from FrontOffice.BFF to CMSMicroservice in Profile components (EditAddressDialog, Index, PaymentCallback, Personal, Settings). - Updated CheckoutSummary, OrderDetail, OrderTracking, and Orders pages to use new UserOrder Protobuf definitions. - Refactored WalletService, PackageService, and other utility services to align with new Protobuf structure. - Adjusted appsettings.json for local development URL. - Removed unused validators and simplified validation logic in AuthDialog. - Enhanced ClubMembershipContractDialog to utilize new OtpToken service for OTP handling.
This commit is contained in:
@@ -61,7 +61,7 @@ else
|
||||
__builder.AddContent(4, "لطفاً شماره موبایل خود را وارد کنید تا رمز پویا ارسال شود.");
|
||||
__builder.CloseComponent();
|
||||
|
||||
<MudForm @ref="_phoneForm" Model="_phoneRequest" Validation="@(_phoneRequestValidator.ValidateValue)">
|
||||
<MudForm @ref="_phoneForm" Model="_phoneRequest">
|
||||
<MudTextField @bind-Value="_phoneRequest.Mobile"
|
||||
For="@(() => _phoneRequest.Mobile)"
|
||||
Label="شماره موبایل"
|
||||
@@ -118,7 +118,7 @@ else
|
||||
وارد کنید.
|
||||
</MudText>
|
||||
|
||||
<MudForm @ref="_verifyForm" Model="_verifyRequest" Validation="@(_verifyRequestValidator.ValidateValue)">
|
||||
<MudForm @ref="_verifyForm" Model="_verifyRequest">
|
||||
<MudTextField @bind-Value="_verifyRequest.Code"
|
||||
For="@(() => _verifyRequest.Code)"
|
||||
Label="رمز پویا"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Blazored.LocalStorage;
|
||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||
using FrontOffice.BFF.User.Protobuf.Validator;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
using FrontOffice.Main.Utilities;
|
||||
using Grpc.Core;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -25,11 +24,9 @@ public partial class AuthDialog : IDisposable
|
||||
|
||||
public AuthStep _currentStep = AuthStep.Phone;
|
||||
|
||||
private readonly CreateNewOtpTokenRequestValidator _phoneRequestValidator = new();
|
||||
private readonly CreateNewOtpTokenRequest _phoneRequest = new();
|
||||
private MudForm? _phoneForm;
|
||||
|
||||
private readonly VerifyOtpTokenRequestValidator _verifyRequestValidator = new();
|
||||
private readonly VerifyOtpTokenRequest _verifyRequest = new();
|
||||
private MudForm? _verifyForm;
|
||||
|
||||
@@ -105,10 +102,10 @@ public partial class AuthDialog : IDisposable
|
||||
|
||||
try
|
||||
{
|
||||
var validationResult = _phoneRequestValidator.Validate(_phoneRequest);
|
||||
if (!validationResult.IsValid)
|
||||
var validationResult = true; // _phoneRequestValidator.Validate(_phoneRequest);
|
||||
if (!validationResult)
|
||||
{
|
||||
_errorMessage = string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
_errorMessage = "لطفاً شماره تلفن معتبر وارد کنید."; // string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,10 +186,10 @@ public partial class AuthDialog : IDisposable
|
||||
_verifyRequest.ParentReferralCode = storedReferralCode;
|
||||
}
|
||||
|
||||
var validationResult = _verifyRequestValidator.Validate(_verifyRequest);
|
||||
if (!validationResult.IsValid)
|
||||
var validationResult = true; // _verifyRequestValidator.Validate(_verifyRequest);
|
||||
if (!validationResult)
|
||||
{
|
||||
_errorMessage = string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
_errorMessage = "لطفاً کد تأیید معتبر وارد کنید."; // string.Join(" ", validationResult.Errors.Select(e => e.ErrorMessage).Distinct());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
@using FrontOffice.BFF.ClubMembership.Protobuf.Protos.ClubMembership
|
||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
||||
@using CMSMicroservice.Protobuf.Protos.OtpToken
|
||||
@using Blazored.LocalStorage
|
||||
@using FrontOffice.Main.Utilities
|
||||
@using MudBlazor
|
||||
@inject ClubMembershipContract.ClubMembershipContractClient ClubMembershipClient
|
||||
@inject OtpTokenContract.OtpTokenContractClient OtpTokenClient
|
||||
@inject ILocalStorageService LocalStorage
|
||||
@inject AuthService AuthService
|
||||
@inject ISnackbar Snackbar
|
||||
@@ -129,23 +131,25 @@
|
||||
_isLoading = true;
|
||||
try
|
||||
{
|
||||
var response = await ClubMembershipClient.RequestClubContractOtpAsync(
|
||||
new RequestClubContractOtpRequest
|
||||
var response = await OtpTokenClient.CreateNewOtpTokenAsync(
|
||||
new CMSMicroservice.Protobuf.Protos.OtpToken.CreateNewOtpTokenRequest
|
||||
{
|
||||
SignGuid = _signGuid.ToString()
|
||||
Mobile = await GetUserMobileAsync(),
|
||||
Purpose = "ClubContract"
|
||||
});
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
_step = ContractStep.EnterOtp;
|
||||
_remainingSeconds = response.RemainingSeconds > 0 ? response.RemainingSeconds : 120;
|
||||
_remainingSeconds = 120; // Default 2 minutes
|
||||
StartCountdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(response.Message, Severity.Error);
|
||||
Snackbar.Add(response.Message ?? "ارسال رمز پویا با خطا مواجه شد.", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ارسال کد: {ex.Message}", Severity.Error);
|
||||
@@ -162,9 +166,11 @@
|
||||
_isLoading = true;
|
||||
try
|
||||
{
|
||||
var userId = await GetCurrentUserIdAsync();
|
||||
var response = await ClubMembershipClient.AcceptClubMembershipContractAsync(
|
||||
new AcceptClubMembershipContractRequest
|
||||
new CMSMicroservice.Protobuf.Protos.ClubMembership.AcceptClubMembershipContractRequest
|
||||
{
|
||||
UserId = userId,
|
||||
OtpCode = _otpCode,
|
||||
SignGuid = _signGuid.ToString(),
|
||||
ContractHtml = GetClubContractHtml()
|
||||
@@ -172,21 +178,16 @@
|
||||
|
||||
if (response.Success)
|
||||
{
|
||||
// ذخیره توکن جدید
|
||||
if (!string.IsNullOrEmpty(response.Token))
|
||||
{
|
||||
await LocalStorage.SetItemAsync(TokenStorageKey, response.Token);
|
||||
await AuthService.InitUserAuthInfo();
|
||||
}
|
||||
|
||||
_step = ContractStep.Success;
|
||||
StopCountdown();
|
||||
Snackbar.Add("قرارداد باشگاه مشتریان با موفقیت امضا شد.", Severity.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(response.Message, Severity.Error);
|
||||
Snackbar.Add(response.Message ?? "امضای قرارداد با خطا مواجه شد.", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"خطا در ثبت قرارداد: {ex.Message}", Severity.Error);
|
||||
@@ -233,8 +234,7 @@
|
||||
|
||||
private string GetClubContractHtml()
|
||||
{
|
||||
return @"
|
||||
<div style='direction: rtl; font-family: Tahoma, sans-serif; line-height: 2; text-align: justify;'>
|
||||
return $@"<div style='direction: rtl; font-family: Tahoma, sans-serif; line-height: 2; text-align: justify;'>
|
||||
<h2 style='text-align: center; margin-bottom: 20px;'>قرارداد عضویت در باشگاه مشتریان کارابازار</h2>
|
||||
|
||||
<p><strong>ماده ۱ - تعاریف</strong></p>
|
||||
@@ -265,7 +265,21 @@
|
||||
<p>۶-۱. در صورت بروز اختلاف، طرفین ابتدا از طریق مذاکره اقدام به حل و فصل خواهند کرد.</p>
|
||||
<p>۶-۲. در صورت عدم توافق، مراجع قضایی صلاحیتدار رسیدگی خواهند کرد.</p>
|
||||
|
||||
<p style='text-align: center; margin-top: 30px;'><strong>شناسه قرارداد: " + _signGuid + @"</strong></p>
|
||||
<p style='text-align: center; margin-top: 30px;'><strong>شناسه قرارداد: {_signGuid}</strong></p>
|
||||
</div>";
|
||||
}
|
||||
|
||||
private async Task<string> GetUserMobileAsync()
|
||||
{
|
||||
// Get user mobile from auth service or localStorage
|
||||
var userInfo = await AuthService.GetUserAuthInfo();
|
||||
return userInfo?.MobileNumber ?? "";
|
||||
}
|
||||
|
||||
private async Task<long> GetCurrentUserIdAsync()
|
||||
{
|
||||
// Get current user ID from auth service
|
||||
var userInfo = await AuthService.GetUserAuthInfo();
|
||||
return userInfo?.UserId ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user