Add WIP for listing page (#16)
This commit is contained in:
25
src/JobsJobsJobs/Client/Pages/Listings/Mine.razor
Normal file
25
src/JobsJobsJobs/Client/Pages/Listings/Mine.razor
Normal 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…</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (Listings.Any())
|
||||
{
|
||||
<p>TODO: list them</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p><em>No job listings found</em></p>
|
||||
}
|
||||
}
|
||||
</ErrorList>
|
||||
41
src/JobsJobsJobs/Client/Pages/Listings/Mine.razor.cs
Normal file
41
src/JobsJobsJobs/Client/Pages/Listings/Mine.razor.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user