Display profile now works

wrapping up #2
This commit is contained in:
2021-01-07 22:49:10 -05:00
parent ef12da01dc
commit 4f1c7b782a
18 changed files with 192 additions and 31 deletions

View File

@@ -3,4 +3,6 @@
@inject NavigationManager nav
@inject AppState state
<PageTitle Title="Logging in..." />
<p>@Message</p>

View File

@@ -2,6 +2,8 @@
@inject HttpClient http
@inject AppState state
<PageTitle Title="Dashboard" />
<h3>Welcome, @state.User!.Name!</h3>
@if (RetrievingData)
@@ -17,17 +19,19 @@ else
Your employment profile was last updated <FullDateTime TheDate=@Profile.LastUpdatedOn />. Your profile currently
lists @Profile.Skills.Length skill@(Profile.Skills.Length != 1 ? "s" : "").
</p>
<p><a href="/profile/view/@state.User.Id">View Your Employment Profile</a></p>
}
else
{
<p>You do not have an employment profile established; click &ldquo;Profile&rdquo;* in the menu to get started!</p>
}
<hr>
<p>
There @(ProfileCount == 1 ? "is" : "are") @(ProfileCount == 0 ? "no" : ProfileCount) employment
profile@(ProfileCount != 1 ? "s" : "") from citizens of Gitmo Nation.
@if (ProfileCount > 0)
{
<text>Take a look around and see if you can help them find work!</text>
<text>Take a look around and see if you can help them find work!</text> <em>(coming soon)</em>
}
</p>
</ErrorList>

View File

@@ -1,22 +1,16 @@
@page "/citizen/profile"
@inject HttpClient http
@inject AppState state
@inject NavigationManager nav
@inject IToastService toast
<PageTitle Title="Edit Profile" />
<h3>Employment Profile</h3>
@if (AllLoaded)
{
@if (ErrorMessages.Count > 0)
{
<p><strong>Error</strong></p>
@foreach (var msg in ErrorMessages)
{
<p>@msg</p>
}
}
else
{
<ErrorList Errors=@ErrorMessages>
<EditForm Model=@ProfileForm OnValidSubmit=@SaveProfile>
<DataAnnotationsValidator />
<div class="form-row">
@@ -111,7 +105,13 @@
</div>
</div>
</EditForm>
}
@if (!IsNew)
{
<p>
<br><a href="/profile/view/@state.User!.Id"><span class="oi oi-file"></span> View Your User Profile</a>
</p>
}
</ErrorList>
}
else
{

View File

@@ -33,6 +33,11 @@ namespace JobsJobsJobs.Client.Pages.Citizen
/// </summary>
private IEnumerable<Continent> Continents { get; set; } = Enumerable.Empty<Continent>();
/// <summary>
/// Whether this is a new profile or not
/// </summary>
private bool IsNew { get; set; } = false;
/// <summary>
/// Error messages from API access
/// </summary>
@@ -57,9 +62,15 @@ namespace JobsJobsJobs.Client.Pages.Citizen
if (profileTask.Result.IsOk)
{
ProfileForm = (profileTask.Result.Ok == null)
? new ProfileForm()
: ProfileForm.FromProfile(profileTask.Result.Ok);
if (profileTask.Result.Ok == null)
{
ProfileForm = new ProfileForm();
IsNew = true;
}
else
{
ProfileForm = ProfileForm.FromProfile(profileTask.Result.Ok);
}
if (ProfileForm.Skills.Count == 0) AddNewSkill();
}
else
@@ -98,6 +109,7 @@ namespace JobsJobsJobs.Client.Pages.Citizen
if (res.IsSuccessStatusCode)
{
toast.ShowSuccess("Profile Saved Successfully");
nav.NavigateTo($"/profile/view/{state.User!.Id}");
}
else
{