feat: integrate d3-org-chart for network visualization and add SignalR token notification service
This commit is contained in:
@@ -58,6 +58,11 @@
|
||||
<div class="d-flex align-center gap-2">
|
||||
@if (_isAuthenticated)
|
||||
{
|
||||
<MudBadge Content="@_cartCount" Color="Color.Error" Overlap="true" Visible="@(_cartCount > 0)">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.ShoppingCart" Color="Color.Inherit"
|
||||
Href="@(RouteConstants.Store.Cart)" />
|
||||
</MudBadge>
|
||||
|
||||
<MudMenu Icon="@Icons.Material.Filled.Person" Color="Color.Inherit" Size="Size.Medium">
|
||||
<MudMenuItem OnClick="NavigateToProfile" Disabled="@(!AuthService.IsCompleteRegister())">
|
||||
پروفایل
|
||||
|
||||
@@ -6,7 +6,7 @@ using MudBlazor;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace FrontOffice.Main.Shared;
|
||||
public partial class MainLayout
|
||||
public partial class MainLayout : IDisposable
|
||||
{
|
||||
private const string TokenStorageKey = "auth:token";
|
||||
|
||||
@@ -15,10 +15,12 @@ public partial class MainLayout
|
||||
private bool _drawerOpen;
|
||||
private bool _isAuthenticated;
|
||||
private string? _email;
|
||||
private int _cartCount;
|
||||
|
||||
[Inject] private ILocalStorageService LocalStorage { get; set; } = default!;
|
||||
[Inject] private AuthService AuthService { get; set; } = default!;
|
||||
[Inject] private AuthDialogService AuthDialogService { get; set; } = default!;
|
||||
[Inject] private CartService CartService { get; set; } = default!;
|
||||
|
||||
private void ToggleTheme() => _isDark = !_isDark;
|
||||
private void ToggleDrawer() => _drawerOpen = !_drawerOpen;
|
||||
@@ -33,10 +35,23 @@ public partial class MainLayout
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync("changeNavBgOnBodyScroll", "top", null, 1);
|
||||
await CheckAuthStatus();
|
||||
|
||||
if (_isAuthenticated)
|
||||
{
|
||||
CartService.OnChange += OnCartChanged;
|
||||
_cartCount = CartService.Count;
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCartChanged()
|
||||
{
|
||||
_cartCount = CartService.Count;
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
private async Task CheckAuthStatus()
|
||||
{
|
||||
_isAuthenticated = await AuthService.IsAuthenticatedAsync();
|
||||
@@ -64,6 +79,12 @@ public partial class MainLayout
|
||||
{
|
||||
await AuthService.LogoutAsync();
|
||||
_isAuthenticated = false;
|
||||
_cartCount = 0;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
CartService.OnChange -= OnCartChanged;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user