u
This commit is contained in:
@@ -8,16 +8,52 @@
|
|||||||
<!-- Profile Header -->
|
<!-- Profile Header -->
|
||||||
<MudItem xs="12">
|
<MudItem xs="12">
|
||||||
<MudPaper Elevation="4" Class="mud-elevation-4 pa-6 rounded-2xl mud-theme-surface">
|
<MudPaper Elevation="4" Class="mud-elevation-4 pa-6 rounded-2xl mud-theme-surface">
|
||||||
|
<MudStack Spacing="4">
|
||||||
<MudStack Row="true" Spacing="3" AlignItems="AlignItems.Center">
|
<MudStack Row="true" Spacing="3" AlignItems="AlignItems.Center">
|
||||||
<MudAvatar Size="Size.Large" Color="Color.Primary">
|
<MudAvatar Size="Size.Large" Color="Color.Primary">
|
||||||
<MudIcon Icon="@Icons.Material.Filled.Person" Size="Size.Large" />
|
<MudIcon Icon="@Icons.Material.Filled.Person" Size="Size.Large" />
|
||||||
</MudAvatar>
|
</MudAvatar>
|
||||||
<div>
|
<div>
|
||||||
<MudText Typo="Typo.h5" Class="mud-typography-subtitle1">@_userProfile.FirstName @_userProfile.LastName</MudText>
|
<MudText Typo="Typo.h5" Class="mud-typography-subtitle1">@($"{_userProfile.FirstName} {_userProfile.LastName}")</MudText>
|
||||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">@_userProfile.Mobile</MudText>
|
<MudText Typo="Typo.body2" Class="mud-text-secondary">@(_userProfile.Mobile)</MudText>
|
||||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">عضو از @(_userProfile.MobileVerifiedAt?.ToDateTime().MiladiToJalali())</MudText>
|
<MudText Typo="Typo.caption" Class="mud-text-secondary">عضو از @(_userProfile.MobileVerifiedAt?.ToDateTime().MiladiToJalali())</MudText>
|
||||||
</div>
|
</div>
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
|
<!-- Referral Code Section -->
|
||||||
|
<MudDivider />
|
||||||
|
<MudStack Spacing="3">
|
||||||
|
<MudStack Row="true" AlignItems="AlignItems.Center">
|
||||||
|
<MudText Typo="Typo.subtitle1" Class="mud-typography-subtitle1">کد دعوت شما</MudText>
|
||||||
|
<MudSpacer />
|
||||||
|
<MudButton Variant="Variant.Filled"
|
||||||
|
Color="Color.Primary"
|
||||||
|
StartIcon="@Icons.Material.Filled.Share"
|
||||||
|
OnClick="ShareReferralCode">
|
||||||
|
اشتراکگذاری
|
||||||
|
</MudButton>
|
||||||
|
</MudStack>
|
||||||
|
<MudText Typo="Typo.body2" Class="mud-text-secondary">
|
||||||
|
این کد را با دوستان خود به اشتراک بگذارید تا از خریدهای آنها پاداش دریافت کنید.
|
||||||
|
</MudText>
|
||||||
|
|
||||||
|
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
|
||||||
|
<MudTextField @bind-Value="_userProfile.ReferralCode"
|
||||||
|
Label="کد دعوت"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
ReadOnly="true"
|
||||||
|
Class="flex-grow-1"
|
||||||
|
Adornment="Adornment.End"
|
||||||
|
AdornmentIcon="@Icons.Material.Filled.ContentCopy"
|
||||||
|
OnAdornmentClick="CopyReferralCode" />
|
||||||
|
</MudStack>
|
||||||
|
|
||||||
|
@if (!string.IsNullOrWhiteSpace(_copyMessage))
|
||||||
|
{
|
||||||
|
<MudText Typo="Typo.caption" Color="Color.Success">@(_copyMessage)</MudText>
|
||||||
|
}
|
||||||
|
</MudStack>
|
||||||
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
@@ -187,4 +223,4 @@
|
|||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
</MudGrid>
|
</MudGrid>
|
||||||
</MudContainer>
|
</MudContainer>
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
|
|
||||||
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
using FrontOffice.BFF.User.Protobuf.Protos.User;
|
||||||
using FrontOffice.Main.Utilities;
|
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.JSInterop;
|
||||||
using MudBlazor;
|
using MudBlazor;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Severity = MudBlazor.Severity;
|
using Severity = MudBlazor.Severity;
|
||||||
@@ -22,6 +21,8 @@ public partial class Index
|
|||||||
private bool _isPersonalSaving;
|
private bool _isPersonalSaving;
|
||||||
private bool _isSettingsSaving;
|
private bool _isSettingsSaving;
|
||||||
|
|
||||||
|
private string _copyMessage = string.Empty;
|
||||||
|
|
||||||
private readonly UserProfileValidator _personalValidator = new();
|
private readonly UserProfileValidator _personalValidator = new();
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
@@ -35,12 +36,21 @@ public partial class Index
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadUserProfile()
|
private async Task LoadUserProfile()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
_userProfile = await UserContract.GetUserAsync(request: new());
|
_userProfile = await UserContract.GetUserAsync(request: new());
|
||||||
_updateUserRequest = _userProfile.Adapt<UpdateUserRequest>();
|
_updateUserRequest = _userProfile.Adapt<UpdateUserRequest>();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Handle the case when user is not authenticated or API fails
|
||||||
|
_userProfile = new GetUserResponse();
|
||||||
|
}
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task LoadAccountSettings()
|
private async Task LoadAccountSettings()
|
||||||
{
|
{
|
||||||
// TODO: Load settings from API
|
// TODO: Load settings from API
|
||||||
@@ -117,6 +127,48 @@ public partial class Index
|
|||||||
Snackbar.Add("تغییرات تنظیمات لغو شد.", Severity.Info);
|
Snackbar.Add("تغییرات تنظیمات لغو شد.", Severity.Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CopyReferralCode()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", $"{Navigation.BaseUri}?ref={_userProfile.ReferralCode}");
|
||||||
|
_copyMessage = "کد دعوت کپی شد!";
|
||||||
|
Snackbar.Add("کد دعوت در کلیپبورد کپی شد.", Severity.Success);
|
||||||
|
|
||||||
|
// Clear message after 3 seconds
|
||||||
|
await Task.Delay(3000);
|
||||||
|
_copyMessage = string.Empty;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Snackbar.Add("خطا در کپی کردن کد دعوت.", Severity.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ShareReferralCode()
|
||||||
|
{
|
||||||
|
var shareText = $"کد دعوت من در فرصت: {_userProfile.ReferralCode}\nبرای عضویت از این لینک استفاده کنید: {Navigation.BaseUri}?ref={_userProfile.ReferralCode}";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Try to use Web Share API if available
|
||||||
|
await JSRuntime.InvokeVoidAsync("navigator.share",
|
||||||
|
new
|
||||||
|
{
|
||||||
|
title = "کد دعوت فرصت",
|
||||||
|
text = shareText,
|
||||||
|
url = $"{Navigation.BaseUri}?ref={_userProfile.ReferralCode}"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Fallback: copy to clipboard
|
||||||
|
await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", $"{Navigation.BaseUri}?ref={_userProfile.ReferralCode}");
|
||||||
|
Snackbar.Add("لینک دعوت در کلیپبورد کپی شد.", Severity.Success);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class UserProfile
|
public class UserProfile
|
||||||
{
|
{
|
||||||
[Required(ErrorMessage = "نام الزامی است")]
|
[Required(ErrorMessage = "نام الزامی است")]
|
||||||
|
|||||||
Reference in New Issue
Block a user