@@ -6,20 +6,36 @@
|
||||
<PageTitle Title="My Job Listings" />
|
||||
<h3>My Job Listings</h3>
|
||||
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
@if (Loading)
|
||||
<Loading OnLoad=@OnLoad Message=@(new MarkupString("Loading job listings…"))>
|
||||
<p>
|
||||
<a class="btn" href="/listing/new/edit">Add a New Job Listing</a>
|
||||
</p>
|
||||
@if (Listings.Any())
|
||||
{
|
||||
<p>Loading job listings…</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Action</th>
|
||||
<th>Title</th>
|
||||
<th>Created</th>
|
||||
<th>Updated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var listing in Listings)
|
||||
{
|
||||
<tr>
|
||||
<td><a href="/listing/@listing.Id/edit">Edit</a></td>
|
||||
<td>@listing.Title</td>
|
||||
<td><FullDateTime TheDate=@listing.CreatedOn /></td>
|
||||
<td><FullDateTime TheDate=@listing.UpdatedOn /></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (Listings.Any())
|
||||
{
|
||||
<p>TODO: list them</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p><em>No job listings found</em></p>
|
||||
}
|
||||
<p><em>No job listings found</em></p>
|
||||
}
|
||||
</ErrorList>
|
||||
</Loading>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using JobsJobsJobs.Shared;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -9,22 +8,16 @@ namespace JobsJobsJobs.Client.Pages.Listings
|
||||
{
|
||||
public partial class Mine : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the page is loading data
|
||||
/// </summary>
|
||||
private bool Loading { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Error messages encountered while searching for profiles
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The job listings entered by the current user
|
||||
/// </summary>
|
||||
private IEnumerable<Listing> Listings { get; set; } = Enumerable.Empty<Listing>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
/// <summary>
|
||||
/// Load the user's job listings
|
||||
/// </summary>
|
||||
/// <param name="errors">Error collection for possible problems</param>
|
||||
private async Task OnLoad(ICollection<string> errors)
|
||||
{
|
||||
var listings = await ServerApi.RetrieveMany<Listing>(http, "listing/mine");
|
||||
|
||||
@@ -34,7 +27,7 @@ namespace JobsJobsJobs.Client.Pages.Listings
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(listings.Error);
|
||||
errors.Add(listings.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user