89 lines
3.5 KiB
Plaintext
89 lines
3.5 KiB
Plaintext
@page "/profile"
|
|
@attribute [Authorize]
|
|
@inject HttpClient Http
|
|
@inject IDialogService DialogService
|
|
@using PlaylistShared.Pwa.Components.Profile.YandexAccount
|
|
@using PlaylistShared.Shared.Profile
|
|
|
|
<PageTitle>Профиль</PageTitle>
|
|
|
|
<MudContainer MaxWidth="MaxWidth.Small" Class="mt-8">
|
|
<MudText Typo="Typo.h4" Class="mb-6">Профиль</MudText>
|
|
|
|
<MudStack Spacing="4">
|
|
@*
|
|
<!-- Секция почты -->
|
|
<MudCard>
|
|
<MudCardContent>
|
|
<MudText Typo="Typo.h6" GutterBottom="true">Данные аккаунта</MudText>
|
|
<MudTextField @bind-Value="_email" Label="Электронная почта" ReadOnly="true" Variant="Variant.Outlined" Margin="Margin.Dense" />
|
|
<MudButton Variant="Variant.Text" Color="Color.Primary" Class="mt-2" Disabled="true">Сменить почту</MudButton>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
*@
|
|
|
|
<!-- Секция Яндекс.Музыки -->
|
|
<MudCard>
|
|
<MudCardContent>
|
|
<MudStack Row Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
|
|
<MudStack Spacing="0">
|
|
<MudText Typo="Typo.h6">Яндекс.Музыка</MudText>
|
|
<MudText Typo="Typo.body2" Color="@(_hasToken? Color.Success: Color.Error)">
|
|
@_statusText
|
|
</MudText>
|
|
</MudStack>
|
|
|
|
<MudMenu EndIcon="@Icons.Material.Filled.ArrowDropDown"
|
|
Label="@(_hasToken ? "Переподключить" : "Подключить")"
|
|
Variant="Variant.Outlined"
|
|
Dense
|
|
Color="Color.Primary">
|
|
<MudMenuItem OnClick="OpenTokenDialog">Token</MudMenuItem>
|
|
<MudMenuItem OnClick="OpenQrServerDialog">QR</MudMenuItem>
|
|
</MudMenu>
|
|
</MudStack>
|
|
</MudCardContent>
|
|
</MudCard>
|
|
</MudStack>
|
|
</MudContainer>
|
|
|
|
@code {
|
|
private string _email = "user@example.com";
|
|
private string _statusText = "Загрузка...";
|
|
private bool _hasToken;
|
|
|
|
protected override async Task OnInitializedAsync() => await LoadStatus();
|
|
|
|
private async Task LoadStatus()
|
|
{
|
|
try
|
|
{
|
|
var response = await Http.GetFromJsonAsync<ApiResponse<YandexTokenStatus>>("/api/yandexaccount/status");
|
|
if (response?.Success == true)
|
|
{
|
|
_hasToken = response.Data.HasToken;
|
|
_statusText = _hasToken ? "Аккаунт подключен" : "Аккаунт не подключен";
|
|
}
|
|
}
|
|
catch { _statusText = "Ошибка загрузки статуса"; }
|
|
}
|
|
|
|
private async Task OpenTokenDialog()
|
|
{
|
|
var options = new DialogOptions { CloseOnEscapeKey = true, MaxWidth = MaxWidth.Small, FullWidth = true };
|
|
var dialog = await DialogService.ShowAsync<YandexTokenDialog>("", options);
|
|
var result = await dialog.Result;
|
|
|
|
if (!result.Canceled) await LoadStatus();
|
|
}
|
|
|
|
private async Task OpenQrServerDialog()
|
|
{
|
|
var options = new DialogOptions { CloseOnEscapeKey = true, MaxWidth = MaxWidth.Small, FullWidth = true };
|
|
var dialog = await DialogService.ShowAsync<YandexQrServerDialog>("", options);
|
|
var result = await dialog.Result;
|
|
|
|
if (!result.Canceled) await LoadStatus();
|
|
}
|
|
}
|