This commit is contained in:
MeysamMoghaddam
2025-10-20 21:02:13 +03:30
parent 4c022f18c6
commit 59e58abaf9
2 changed files with 22 additions and 2 deletions

View File

@@ -44,7 +44,11 @@
<MudHidden Breakpoint="Breakpoint.SmAndUp" Invert="true"> <MudHidden Breakpoint="Breakpoint.SmAndUp" Invert="true">
@if (_isAuthenticated) @if (_isAuthenticated)
{ {
<MudButton Variant="Variant.Outlined" Color="Color.Inherit" OnClick="NavigateToProfile">پروفایل</MudButton> <MudMenu Icon="@Icons.Material.Filled.Person" Color="Color.Inherit" Size="Size.Medium">
<MudMenuItem OnClick="NavigateToProfile">پروفایل</MudMenuItem>
<MudDivider />
<MudMenuItem OnClick="Logout">خروج از حساب</MudMenuItem>
</MudMenu>
} }
else else
{ {
@@ -60,7 +64,7 @@
<!-- Mobile Drawer --> <!-- Mobile Drawer -->
<MudDrawer @bind-Open="_drawerOpen" Anchor="Anchor.Right" Elevation="1" Variant="DrawerVariant.Temporary" Class="pa-4"> <MudDrawer @bind-Open="_drawerOpen" Anchor="Anchor.Right" Elevation="1" Variant="DrawerVariant.Temporary" Class="pa-4">
<MudStack Spacing="2"> <MudStack Spacing="2">
<MudLink Href="@(RouteConstants.FAQ.Index)" Typo="Typo.subtitle1" OnClick="() => _drawerOpen=false">سوالات متداول</MudLink> <MudLink Href="@(RouteConstants.FAQ.Index)" Typo="Typo.subtitle1" OnClick="() => _drawerOpen=false">سوالات متداول</MudLink>
<MudLink Href="@(RouteConstants.About.Index)" Typo="Typo.subtitle1" OnClick="() => _drawerOpen=false">درباره ما</MudLink> <MudLink Href="@(RouteConstants.About.Index)" Typo="Typo.subtitle1" OnClick="() => _drawerOpen=false">درباره ما</MudLink>
<MudLink Href="@(RouteConstants.Contact.Index)" Typo="Typo.subtitle1" OnClick="() => _drawerOpen=false">ارتباط با ما</MudLink> <MudLink Href="@(RouteConstants.Contact.Index)" Typo="Typo.subtitle1" OnClick="() => _drawerOpen=false">ارتباط با ما</MudLink>
@@ -69,6 +73,7 @@
@if (_isAuthenticated) @if (_isAuthenticated)
{ {
<MudButton Href="/profile" Color="Color.Primary" OnClick="() => _drawerOpen=false">پروفایل</MudButton> <MudButton Href="/profile" Color="Color.Primary" OnClick="() => _drawerOpen=false">پروفایل</MudButton>
<MudButton Variant="Variant.Text" Color="Color.Error" OnClick="() => { _drawerOpen=false; Logout(); }">خروج از حساب</MudButton>
} }
else else
{ {

View File

@@ -57,4 +57,19 @@ public partial class MainLayout
{ {
Navigation.NavigateTo(RouteConstants.Profile.Index); Navigation.NavigateTo(RouteConstants.Profile.Index);
} }
private async Task Logout()
{
await LocalStorage.RemoveItemAsync(TokenStorageKey);
await LocalStorage.RemoveItemAsync("auth:phone-number");
await LocalStorage.RemoveItemAsync("auth:redirect");
await LocalStorage.RemoveItemAsync("referral:code");
_isAuthenticated = false;
Snackbar.Add("با موفقیت از حساب کاربری خارج شدید.", Severity.Success);
StateHasChanged();
// Navigate to home page
Navigation.NavigateTo(RouteConstants.Main.MainPage);
}
} }