diff --git a/src/JobsJobsJobs/Client/AppState.cs b/src/JobsJobsJobs/Client/AppState.cs index 62abfa9..90e9825 100644 --- a/src/JobsJobsJobs/Client/AppState.cs +++ b/src/JobsJobsJobs/Client/AppState.cs @@ -1,5 +1,8 @@ using JobsJobsJobs.Shared; using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; namespace JobsJobsJobs.Client { @@ -45,6 +48,33 @@ namespace JobsJobsJobs.Client } } + private IEnumerable? _continents = null; + + /// + /// Get a list of continents (only retrieves once per application load) + /// + /// The HTTP client to use to obtain continents the first time + /// The list of continents + /// If the continents cannot be loaded + public async Task> GetContinents(HttpClient http) + { + if (_continents == null) + { + ServerApi.SetJwt(http, this); + var continentResult = await ServerApi.RetrieveMany(http, "continent/all"); + + if (continentResult.IsOk) + { + _continents = continentResult.Ok; + } + else + { + throw new ApplicationException($"Could not load continents - {continentResult.Error}"); + } + } + return _continents; + } + public AppState() { } private void NotifyChanged() => OnChange.Invoke(); diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor b/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor index 0e5e79d..30f6e93 100644 --- a/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor +++ b/src/JobsJobsJobs/Client/Pages/Citizen/Dashboard.razor @@ -28,29 +28,30 @@ else started!

} - @{ - /** - This is phase 3 stuff...

There @(ProfileCount == 1 ? "is" : "are") @(ProfileCount == 0 ? "no" : ProfileCount) employment profile@(ProfileCount != 1 ? "s" : "") from citizens of Gitmo Nation. @if (ProfileCount > 0) { - Take a look around and see if you can help them find work! (coming soon) + Take a look around and see if you can help them find work! } -

*/ - } +

}
-

Phase 3 – What Works (In Progress ~~ Last Updated January 10th, 2021)

+

+ Phase 3 – What Works + (v0.8 – Last Updated January 19th, 2021) +

- 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. + The “View Profiles” link at the side now allows you to search for profiles by continent, the + citizen’s desire for remote work, a skill, or any text in their professional biography and experience. If you + find someone with whom you’d like to discuss potential opportunities, the name at the top of the profile links + to their No Agenda Social account, where you can use its features to get in touch.


-

Phase 2 – What Works (Last Updated January 8th, 2021)

+

Phase 2 – What Works (v0.7 – Last Updated January 8th, 2021)

If you’ve gotten this far, you’ve already passed Phase 1, which enabled users of diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor index cf938a1..d735359 100644 --- a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor +++ b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor @@ -28,9 +28,9 @@ @foreach (var (id, name) in Continents) - { - - } + { + + } ProfileForm.ContinentId) /> diff --git a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs index c26f519..583cb1d 100644 --- a/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs +++ b/src/JobsJobsJobs/Client/Pages/Citizen/EditProfile.razor.cs @@ -46,19 +46,12 @@ namespace JobsJobsJobs.Client.Pages.Citizen protected override async Task OnInitializedAsync() { ServerApi.SetJwt(http, state); - var continentTask = ServerApi.RetrieveMany(http, "continent/all"); + var continentTask = state.GetContinents(http); var profileTask = ServerApi.RetrieveProfile(http, state); await Task.WhenAll(continentTask, profileTask); - if (continentTask.Result.IsOk) - { - Continents = continentTask.Result.Ok; - } - else - { - ErrorMessages.Add(continentTask.Result.Error); - } + Continents = continentTask.Result; if (profileTask.Result.IsOk) { diff --git a/src/JobsJobsJobs/Client/Pages/Profile/Search.razor b/src/JobsJobsJobs/Client/Pages/Profile/Search.razor index 7de385c..2265f4e 100644 --- a/src/JobsJobsJobs/Client/Pages/Profile/Search.razor +++ b/src/JobsJobsJobs/Client/Pages/Profile/Search.razor @@ -1,5 +1,6 @@ @page "/profile/search" @inject HttpClient http +@inject NavigationManager nav @inject AppState state @@ -17,53 +18,7 @@

Enter one or more criteria to filter results, or just click “Search” to list all profiles.

} - -
-
- - - - @foreach (var (id, name) in Continents) - { - - } - -
-
-
- -
- - -
-
- - -
-
- - -
-
-
-
- - -
-
- - -
-
-
-
-
- -
-
-
+

@if (SearchResults.Any()) diff --git a/src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs b/src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs index 82724be..990a5d1 100644 --- a/src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs +++ b/src/JobsJobsJobs/Client/Pages/Profile/Search.razor.cs @@ -1,6 +1,7 @@ using JobsJobsJobs.Shared; using JobsJobsJobs.Shared.Api; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.WebUtilities; using System; using System.Collections.Generic; using System.Linq; @@ -43,19 +44,39 @@ namespace JobsJobsJobs.Client.Pages.Profile protected override async Task OnInitializedAsync() { - ServerApi.SetJwt(http, state); - var continentResult = await ServerApi.RetrieveMany(http, "continent/all"); + Continents = await state.GetContinents(http); - if (continentResult.IsOk) + // Determine if we have searched before + var query = QueryHelpers.ParseQuery(nav.ToAbsoluteUri(nav.Uri).Query); + + if (query.TryGetValue("Searched", out var searched)) { - Continents = continentResult.Ok; - } - else - { - ErrorMessages.Add(continentResult.Error); + Searched = Convert.ToBoolean(searched); + void setPart(string part, Action func) + { + if (query.TryGetValue(part, out var partValue)) func(partValue); + } + setPart("ContinentId", x => Criteria.ContinentId = x); + setPart("Skill", x => Criteria.Skill = x); + setPart("BioExperience", x => Criteria.BioExperience = x); + setPart("RemoteWork", x => Criteria.RemoteWork = x); + + await RetrieveProfiles(); } } + /// + /// Do a search + /// + /// This navigates with the parameters in the URL; this should trigger a search + private async Task DoSearch() + { + var query = SearchQuery(); + query.Add("Searched", "True"); + nav.NavigateTo(QueryHelpers.AddQueryString("/profile/search", query)); + await RetrieveProfiles(); + } + /// /// Retreive profiles matching the current search criteria /// @@ -64,7 +85,7 @@ namespace JobsJobsJobs.Client.Pages.Profile Searching = true; var searchResult = await ServerApi.RetrieveMany(http, - $"profile/search{SearchQuery()}"); + QueryHelpers.AddQueryString("profile/search", SearchQuery())); if (searchResult.IsOk) { @@ -93,22 +114,22 @@ namespace JobsJobsJobs.Client.Pages.Profile /// Create a search query string from the currently-entered criteria /// /// The query string for the currently-entered criteria - private string SearchQuery() + private IDictionary SearchQuery() { - if (Criteria.IsEmptySearch) return ""; + var dict = new Dictionary(); + if (Criteria.IsEmptySearch) return dict; - string part(string name, Func func) => - string.IsNullOrEmpty(func(Criteria)) ? "" : $"{name}={WebUtility.UrlEncode(func(Criteria))}"; - - IEnumerable parts() + void part(string name, Func func) { - yield return part("ContinentId", it => it.ContinentId); - yield return part("Skill", it => it.Skill); - yield return part("BioExperience", it => it.BioExperience); - yield return part("RemoteWork", it => it.RemoteWork); + if (!string.IsNullOrEmpty(func(Criteria))) dict.Add(name, func(Criteria)); } - return $"?{string.Join("&", parts().Where(it => !string.IsNullOrEmpty(it)).ToArray())}"; + part("ContinentId", it => it.ContinentId); + part("Skill", it => it.Skill); + part("BioExperience", it => it.BioExperience); + part("RemoteWork", it => it.RemoteWork); + + return dict; } } } diff --git a/src/JobsJobsJobs/Client/Shared/ProfileSearchForm.razor b/src/JobsJobsJobs/Client/Shared/ProfileSearchForm.razor new file mode 100644 index 0000000..6470f2d --- /dev/null +++ b/src/JobsJobsJobs/Client/Shared/ProfileSearchForm.razor @@ -0,0 +1,60 @@ +@using JobsJobsJobs.Shared.Api + + +
+
+ + + + @foreach (var (id, name) in Continents) + { + + } + +
+
+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+
+
+
+ +
+
+
+ +@code { + [Parameter] + public ProfileSearch Criteria { get; set; } = default!; + + [Parameter] + public EventCallback OnSearch { get; set; } = default!; + + [Parameter] + public IEnumerable Continents { get; set; } = default!; +}