Return all users with profiles (#3)
Also fixed server pre-rendering and added log off functionality
This commit is contained in:
@@ -44,6 +44,12 @@ else
|
||||
</ErrorList>
|
||||
}
|
||||
<hr>
|
||||
<h4>Phase 3 – What Works <small><em>(<span class="text-uppercase">In Progress</span> ~~ Last Updated January 10<sup>th</sup>, 2021)</em></small></h4>
|
||||
<p>
|
||||
The “View Profiles” link at the side does not have any search capabilities, but it does provide a list of
|
||||
citizens who have filled out profiles, along with a way to view those profiles.
|
||||
</p>
|
||||
<hr>
|
||||
<h4>Phase 2 – What Works <small><em>(Last Updated January 8<sup>th</sup>, 2021)</em></small></h4>
|
||||
<p>
|
||||
If you’ve gotten this far, you’ve already passed
|
||||
|
||||
13
src/JobsJobsJobs/Client/Pages/Citizen/LogOff.razor
Normal file
13
src/JobsJobsJobs/Client/Pages/Citizen/LogOff.razor
Normal file
@@ -0,0 +1,13 @@
|
||||
@page "/citizen/log-off"
|
||||
@inject NavigationManager nav
|
||||
@inject AppState state
|
||||
@inject IToastService toast
|
||||
@code {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
state.Jwt = "";
|
||||
state.User = null;
|
||||
toast.ShowSuccess("Have a Nice Day!", "Log Off Successful");
|
||||
nav.NavigateTo("/");
|
||||
}
|
||||
}
|
||||
44
src/JobsJobsJobs/Client/Pages/Profile/Search.razor
Normal file
44
src/JobsJobsJobs/Client/Pages/Profile/Search.razor
Normal file
@@ -0,0 +1,44 @@
|
||||
@page "/profile/search"
|
||||
@inject HttpClient http
|
||||
@inject AppState state
|
||||
|
||||
<PageTitle Title="Search Profiles" />
|
||||
<h3>Search Profiles</h3>
|
||||
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
@if (Searching)
|
||||
{
|
||||
<p>Searching profiles...</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (SearchResults.Any())
|
||||
{
|
||||
<table class="table table-sm table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Profile</th>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col" class="text-center">Seeking?</th>
|
||||
<th scope="col" class="text-center">Remote?</th>
|
||||
<th scope="col" class="text-center">Full-Time?</th>
|
||||
<th scope="col">Last Updated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var profile in SearchResults)
|
||||
{
|
||||
<tr>
|
||||
<td><a href="/profile/view/@profile.CitizenId">View</a></td>
|
||||
<td class=@IsSeeking(profile)>@profile.DisplayName</td>
|
||||
<td class="text-center">@YesOrNo(profile.SeekingEmployment)</td>
|
||||
<td class="text-center">@YesOrNo(profile.RemoteWork)</td>
|
||||
<td class="text-center">@YesOrNo(profile.FullTime)</td>
|
||||
<td><FullDate TheDate=@profile.LastUpdated /></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
}
|
||||
</ErrorList>
|
||||
89
src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs
Normal file
89
src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using JobsJobsJobs.Shared;
|
||||
using JobsJobsJobs.Shared.Api;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JobsJobsJobs.Client.Pages.Profile
|
||||
{
|
||||
public partial class Search : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether a search has been performed
|
||||
/// </summary>
|
||||
private bool Searched { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether a request for matching profiles is in progress
|
||||
/// </summary>
|
||||
private bool Searching { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Error messages encountered while searching for profiles
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// All continents
|
||||
/// </summary>
|
||||
private IEnumerable<Continent> Continents { get; set; } = Enumerable.Empty<Continent>();
|
||||
|
||||
/// <summary>
|
||||
/// The search results
|
||||
/// </summary>
|
||||
private IEnumerable<ProfileSearchResult> SearchResults { get; set; } = Enumerable.Empty<ProfileSearchResult>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
ServerApi.SetJwt(http, state);
|
||||
var continentResult = await ServerApi.RetrieveMany<Continent>(http, "continent/all");
|
||||
|
||||
if (continentResult.IsOk)
|
||||
{
|
||||
Continents = continentResult.Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(continentResult.Error);
|
||||
}
|
||||
|
||||
// TODO: remove this call once the filter is ready
|
||||
await RetrieveProfiles();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retreive profiles matching the current search criteria
|
||||
/// </summary>
|
||||
private async Task RetrieveProfiles()
|
||||
{
|
||||
Searching = true;
|
||||
|
||||
// TODO: send a filter with this request
|
||||
var searchResult = await ServerApi.RetrieveMany<ProfileSearchResult>(http, "profile/search");
|
||||
|
||||
if (searchResult.IsOk)
|
||||
{
|
||||
SearchResults = searchResult.Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(searchResult.Error);
|
||||
}
|
||||
|
||||
Searched = true;
|
||||
Searching = false;
|
||||
}
|
||||
|
||||
private static string? IsSeeking(ProfileSearchResult profile) =>
|
||||
profile.SeekingEmployment ? "font-weight-bold" : null;
|
||||
|
||||
/// <summary>
|
||||
/// Return "Yes" for true and "No" for false
|
||||
/// </summary>
|
||||
/// <param name="condition">The condition in question</param>
|
||||
/// <returns>"Yes" for true, "No" for false</returns>
|
||||
private static string YesOrNo(bool condition) => condition ? "Yes" : "No";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user