35 lines
1019 B
C#
35 lines
1019 B
C#
using Elternbeirat.Contracts;
|
|
using Elternbeirat.PocketBase;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace Elternbeirat.Web.Features.Embeds;
|
|
|
|
public partial class FaqsEmbed
|
|
{
|
|
[LoggerMessage(Level = LogLevel.Warning, Message = "Could not load FAQs for an embed from PocketBase.")]
|
|
private static partial void LogLoadFailed(ILogger logger, Exception exception);
|
|
|
|
[Inject]
|
|
private PocketBaseClient PocketBase { get; set; } = default!;
|
|
|
|
[Inject]
|
|
private ILogger<FaqsEmbed> Logger { get; set; } = default!;
|
|
|
|
private IReadOnlyList<Faq> _faqs = [];
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
try
|
|
{
|
|
// Teaser: the first three questions, with a link to the full hub.
|
|
var faqs = await PocketBase.GetFaqsAsync();
|
|
_faqs = [.. faqs.Take(3)];
|
|
}
|
|
catch (HttpRequestException ex)
|
|
{
|
|
// Source unreachable -> show no teaser instead of a 500.
|
|
LogLoadFailed(Logger, ex);
|
|
}
|
|
}
|
|
}
|