WIP on profile page

This commit is contained in:
Daniel J. Summers 2020-12-18 22:46:34 -05:00
parent 786f79a52c
commit 47e32fd475
4 changed files with 154 additions and 1 deletions

View File

@ -25,7 +25,7 @@ else
@code { @code {
bool retrievingProfile = true; bool retrievingProfile = true;
Profile? profile = null; JobsJobsJobs.Shared.Profile? profile = null;
string? errorMessage = null; string? errorMessage = null;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()

View File

@ -0,0 +1,81 @@
@page "/citizen/profile"
@using JobsJobsJobs.Client.ViewModels
@inject HttpClient http
@inject AppState state
<h3>Employment Profile</h3>
@if (errorMessage != "")
{
<p>@errorMessage</p>
}
else if (profileForm != null)
{
<EditForm Model="@profileForm" OnValidSubmit="@SaveProfile">
<DataAnnotationsValidator />
<ValidationSummary />
<label>
<InputCheckbox @bind-Value="@profileForm.IsSeekingEmployment" />
I am currently seeking employment
</label>
<label>
<InputCheckbox @bind-Value="@profileForm.IsPublic" />
Allow my profile to be searched publicly (outside NA Social)
</label><br>
<label>
Continent
<InputSelect @bind-Value="@profileForm.ContinentId" />
</label>
<label>
Region
<InputText @bind-Value="@profileForm.Region" />
</label><br>
<label>
<InputCheckbox @bind-Value="@profileForm.RemoteWork" />
I am looking for remote work
</label>
<label>
<InputCheckbox @bind-Value="@profileForm.FullTime" />
I am looking for full-time work
</label><br>
<label>
Professional Biography
<InputTextArea @bind-Value="@profileForm.Biography" />
</label><br>
<label>
Experience
<InputTextArea @bind-Value="@profileForm.Experience" />
</label>
<p>
<button type="submit">Save</button>
</p>
</EditForm>
}
@code {
public JobsJobsJobs.Shared.Profile? profile = null;
public ProfileForm? profileForm = null;
public string errorMessage = "";
protected override async Task OnInitializedAsync()
{
var result = await ServerApi.RetrieveProfile(http, state);
if (result.IsOk)
{
profile = result.Ok;
profileForm = (profile == null) ? new ProfileForm() : ProfileForm.FromProfile(profile);
}
else
{
errorMessage = result.Error;
}
}
public void SaveProfile()
{
// TODO: save profile
}
}

View File

@ -0,0 +1,70 @@
using JobsJobsJobs.Shared;
using System.ComponentModel.DataAnnotations;
namespace JobsJobsJobs.Client.ViewModels
{
/// <summary>
/// The data required to update a profile
/// </summary>
public class ProfileForm
{
/// <summary>
/// Whether the citizen to whom this profile belongs is actively seeking employment
/// </summary>
public bool IsSeekingEmployment { get; set; }
/// <summary>
/// Whether this profile should appear in the public search
/// </summary>
public bool IsPublic { get; set; }
/// <summary>
/// The ID of the continent on which the citizen is located
/// </summary>
[Required]
[StringLength(12, MinimumLength = 1)]
[Display(Name = "Continent")]
public string ContinentId { get; set; } = "";
/// <summary>
/// The area within that continent where the citizen is located
/// </summary>
[Required]
[StringLength(255)]
public string Region { get; set; } = "";
/// <summary>
/// If the citizen is available for remote work
/// </summary>
public bool RemoteWork { get; set; }
/// <summary>
/// If the citizen is seeking full-time employment
/// </summary>
public bool FullTime { get; set; }
/// <summary>
/// The user's professional biography
/// </summary>
[Required]
public string Biography { get; set; } = "";
/// <summary>
/// The user's past experience
/// </summary>
public string Experience { get; set; } = "";
public static ProfileForm FromProfile(Profile profile) =>
new ProfileForm
{
IsSeekingEmployment = profile.SeekingEmployment,
IsPublic = profile.IsPublic,
ContinentId = profile.ContinentId.ToString(),
Region = profile.Region,
RemoteWork = profile.RemoteWork,
FullTime = profile.FullTime,
Biography = profile.Biography.Text,
Experience = profile.Experience?.Text ?? ""
};
}
}

View File

@ -20,5 +20,7 @@ namespace JobsJobsJobs.Shared
/// <returns>The continent ID</returns> /// <returns>The continent ID</returns>
/// <exception cref="System.FormatException">If the string is not a valid continent ID</exception> /// <exception cref="System.FormatException">If the string is not a valid continent ID</exception>
public static ContinentId Parse(string id) => new ContinentId(ShortId.Parse(id)); public static ContinentId Parse(string id) => new ContinentId(ShortId.Parse(id));
public override string ToString() => Id.ToString();
} }
} }