Notes features are ready

This commit is contained in:
2023-04-20 22:00:58 +02:00
parent ede368b963
commit 0b69e0b13a
4 changed files with 146 additions and 9 deletions

View File

@ -0,0 +1,39 @@
@page "/notes"
@inject HttpClient Http
@inject NavigationManager NavigationManager
<h3>Notes</h3>
@foreach (var note in NoteList)
{
<SfCard>
<CardHeader Title="@note.DateCreated.ToString()" />
<CardContent Content="@note.Text" />
<CardFooter>
<CardFooterContent>
@if(note.Contact is not null)
{
<SfButton Content=@($"Show {note.Contact.NickName}")
IsPrimary="true"
OnClick="(() => NavigateToContact(note.Contact.Id))" ></SfButton>
}
</CardFooterContent>
</CardFooter>
</SfCard>
}
@code {
public List<Note> NoteList { get; set; } = new List<Note>();
protected override async Task OnInitializedAsync()
{
var result = await Http.GetFromJsonAsync<List<Note>>("api/notes");
if (result is not null)
NoteList = result;
}
void NavigateToContact(int contactId)
{
NavigationManager.NavigateTo($"contacts/edit/{contactId}");
}
}