diff --git a/src/JobsJobsJobs/Client/AppState.cs b/src/JobsJobsJobs/Client/AppState.cs index 8e4e00b..7a06ab8 100644 --- a/src/JobsJobsJobs/Client/AppState.cs +++ b/src/JobsJobsJobs/Client/AppState.cs @@ -4,6 +4,7 @@ using NodaTime; using System; using System.Collections.Generic; using System.Net.Http; +using System.Reflection; using System.Threading.Tasks; namespace JobsJobsJobs.Client @@ -18,6 +19,17 @@ namespace JobsJobsJobs.Client /// public class AppState { + /// + /// The application version, as a nice display string + /// + public static Lazy Version => new Lazy(() => + { + var version = Assembly.GetExecutingAssembly().GetName().Version!; + var display = $"v{version.Major}.{version.Minor}"; + if (version.Build > 0) display += $".{version.Build}"; + return display; + }); + public event Action OnChange = () => { }; private UserInfo? _user = null; diff --git a/src/JobsJobsJobs/Client/Pages/SuccessStory/ListStories.razor b/src/JobsJobsJobs/Client/Pages/SuccessStory/ListStories.razor index 6ddebe0..d7fc10f 100644 --- a/src/JobsJobsJobs/Client/Pages/SuccessStory/ListStories.razor +++ b/src/JobsJobsJobs/Client/Pages/SuccessStory/ListStories.razor @@ -13,6 +13,7 @@ Story From + Found Here? Recorded On @@ -21,13 +22,30 @@ { - View + @if (story.HasStory) + { + View + } + else + { + None + } @if (story.CitizenId == state.User!.Id) { - ~ Edit + ~ Edit } @story.CitizenName + + @if (story.FromHere) + { + Yes + } + else + { + No + } + } diff --git a/src/JobsJobsJobs/Client/Pages/SuccessStory/ViewStory.razor b/src/JobsJobsJobs/Client/Pages/SuccessStory/ViewStory.razor new file mode 100644 index 0000000..53eedad --- /dev/null +++ b/src/JobsJobsJobs/Client/Pages/SuccessStory/ViewStory.razor @@ -0,0 +1,19 @@ +@page "/success-story/view/{Id}" +@inject HttpClient http +@inject AppState state + + + + +

@Citizen.DisplayName’s Success Story

+

+ @if (Story.FromHere) + { +

Found via Jobs, Jobs, Jobs

+ } +
+ @if (Story.Story != null) + { +
@(new MarkupString(Story.Story.ToHtml()))
+ } +
diff --git a/src/JobsJobsJobs/Client/Pages/SuccessStory/ViewStory.razor.cs b/src/JobsJobsJobs/Client/Pages/SuccessStory/ViewStory.razor.cs new file mode 100644 index 0000000..115abfd --- /dev/null +++ b/src/JobsJobsJobs/Client/Pages/SuccessStory/ViewStory.razor.cs @@ -0,0 +1,69 @@ +using Microsoft.AspNetCore.Components; +using System.Collections.Generic; +using System.Threading.Tasks; +using Domain = JobsJobsJobs.Shared; + +namespace JobsJobsJobs.Client.Pages.SuccessStory +{ + public partial class ViewStory : ComponentBase + { + /// + /// The ID of the success story to display + /// + [Parameter] + public string Id { get; set; } = default!; + + /// + /// The success story to be displayed + /// + private Domain.Success Story { get; set; } = default!; + + /// + /// The citizen who authorized this success story + /// + private Domain.Citizen Citizen { get; set; } = default!; + + /// + /// Retrieve the success story + /// + /// The error collection via which errors will be reported + public async Task RetrieveStory(ICollection errors) + { + ServerApi.SetJwt(http, state); + var story = await ServerApi.RetrieveOne(http, $"success/{Id}"); + + if (story.IsOk) + { + if (story.Ok == null) + { + errors.Add($"Success story {Id} not found"); + } + else + { + Story = story.Ok; + var citizen = await ServerApi.RetrieveOne(http, $"citizen/get/{Story.CitizenId}"); + if (citizen.IsOk) + { + if (citizen.Ok == null) + { + errors.Add($"Citizen ID {Story.CitizenId} not found"); + } + else + { + Citizen = citizen.Ok; + } + } + else + { + errors.Add(citizen.Error); + } + } + } + else + { + errors.Add(story.Error); + } + + } + } +} diff --git a/src/JobsJobsJobs/Client/ServerApi.cs b/src/JobsJobsJobs/Client/ServerApi.cs index b55ace3..f02a944 100644 --- a/src/JobsJobsJobs/Client/ServerApi.cs +++ b/src/JobsJobsJobs/Client/ServerApi.cs @@ -29,7 +29,6 @@ namespace JobsJobsJobs.Client /// static ServerApi() { - var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase diff --git a/src/JobsJobsJobs/Client/Shared/Loading.razor.cs b/src/JobsJobsJobs/Client/Shared/Loading.razor.cs index 0dbaa78..37f812c 100644 --- a/src/JobsJobsJobs/Client/Shared/Loading.razor.cs +++ b/src/JobsJobsJobs/Client/Shared/Loading.razor.cs @@ -1,7 +1,5 @@ using Microsoft.AspNetCore.Components; -using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; namespace JobsJobsJobs.Client.Shared diff --git a/src/JobsJobsJobs/Client/Shared/MainLayout.razor b/src/JobsJobsJobs/Client/Shared/MainLayout.razor index e9b1b78..9847e9c 100644 --- a/src/JobsJobsJobs/Client/Shared/MainLayout.razor +++ b/src/JobsJobsJobs/Client/Shared/MainLayout.razor @@ -1,7 +1,6 @@ @inherits LayoutComponentBase -@using System.Reflection -@inject IJSRuntime js @using Blazored.Toast.Configuration +@inject IJSRuntime js