@page "/admin/system/themes/{Id:int}" @using Microsoft.AspNetCore.Authorization @using Moonlight.Shared @using LucideBlazor @using Moonlight.Frontend.Mappers @using Moonlight.Shared.Http.Requests.Themes @using Moonlight.Shared.Http.Responses.Themes @using ShadcnBlazor.Buttons @using ShadcnBlazor.Labels @using ShadcnBlazor.Cards @using ShadcnBlazor.Extras.Common @using ShadcnBlazor.Extras.Editors @using ShadcnBlazor.Extras.FormHandlers @using ShadcnBlazor.Extras.Toasts @using ShadcnBlazor.Inputs @using ShadcnBlazor.Switches @attribute [Authorize(Policy = Permissions.Themes.Edit)] @inject HttpClient HttpClient @inject NavigationManager Navigation @inject ToastService ToastService

Update theme

Update the theme
@code { [Parameter] public int Id { get; set; } private UpdateThemeDto Request; private ThemeDto Theme; private FormHandler Form; private Editor Editor; private async Task LoadAsync(LazyLoader _) { var theme = await HttpClient.GetFromJsonAsync($"api/admin/themes/{Id}"); Theme = theme!; Request = ThemeMapper.ToUpdate(Theme); } private async Task SubmitAsync() { Request.CssContent = await Editor.GetValueAsync(); await Form.SubmitAsync(); } private async Task OnSubmitAsync() { await HttpClient.PatchAsJsonAsync( $"/api/admin/themes/{Theme.Id}", Request, Constants.SerializerOptions ); await ToastService.SuccessAsync( "Theme update", $"Successfully updated theme {Request.Name}" ); Navigation.NavigateTo("/admin/system?tab=themes"); } }