Add WIP for listing page (#16)

This commit is contained in:
2021-06-19 22:49:50 -04:00
parent cbd92e6491
commit 73d6d0df94
5 changed files with 144 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
@page "/listings/mine"
@inject HttpClient http
@inject NavigationManager nav
@inject AppState state
<PageTitle Title="My Job Listings" />
<h3>My Job Listings</h3>
<ErrorList Errors=@ErrorMessages>
@if (Loading)
{
<p>Loading job listings&hellip;</p>
}
else
{
@if (Listings.Any())
{
<p>TODO: list them</p>
}
else
{
<p><em>No job listings found</em></p>
}
}
</ErrorList>

View File

@@ -0,0 +1,41 @@
using JobsJobsJobs.Shared;
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
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()
{
var listings = await ServerApi.RetrieveMany<Listing>(http, "listing/mine");
if (listings.IsOk)
{
Listings = listings.Ok;
}
else
{
ErrorMessages.Add(listings.Error);
}
}
}
}