Skip to content

Commit

Permalink
Completed some TODOs. (#13)
Browse files Browse the repository at this point in the history
* Updated Logitar Vue3 UI.

* Removed a todo.

* Completed Toasts and error handling.

* Removed package-lock.json

* Removed package-log.json

* Returning the saved item.

* Using saved return item and exclude selected types.

* Added a refresh button.

* Fixed toasts.

* Fixed sorts and added an action column.

* Code clean-up.
  • Loading branch information
Utar94 authored Jan 4, 2024
1 parent e1bb7c4 commit ea7b2e8
Show file tree
Hide file tree
Showing 21 changed files with 247 additions and 5,682 deletions.
6 changes: 5 additions & 1 deletion backend/src/PokeData.Contracts/Regions/RegionSortOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ namespace PokeData.Contracts.Regions;

public record RegionSortOption : SortOption
{
public new RegionSort Field => Enum.Parse<RegionSort>(base.Field);
public new RegionSort Field
{
get => Enum.Parse<RegionSort>(base.Field);
set => base.Field = value.ToString();
}

public RegionSortOption() : this(RegionSort.UpdatedOn, isDescending: true)
{
Expand Down
7 changes: 7 additions & 0 deletions backend/src/PokeData.Contracts/Roster/SavedRosterItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace PokeData.Contracts.Roster;

public record SavedRosterItem
{
public RosterItem Item { get; set; } = new();
public RosterStatistics Stats { get; set; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ namespace PokeData.Contracts.Types;

public record PokemonTypeSortOption : SortOption
{
public new PokemonTypeSort Field => Enum.Parse<PokemonTypeSort>(base.Field);
public new PokemonTypeSort Field
{
get => Enum.Parse<PokemonTypeSort>(base.Field);
set => base.Field = value.ToString();
}

public PokemonTypeSortOption() : this(PokemonTypeSort.UpdatedOn, isDescending: true)
{
Expand Down
11 changes: 9 additions & 2 deletions backend/src/PokeData/Controllers/PokemonRosterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ public async Task<ActionResult<PokemonRoster>> GetAsync(CancellationToken cancel
}

[HttpPut("{speciesId}")]
public async Task<ActionResult> SaveAsync(ushort speciesId, [FromBody] SaveRosterItemPayload payload, CancellationToken cancellationToken)
public async Task<ActionResult<SavedRosterItem>> SaveAsync(ushort speciesId, [FromBody] SaveRosterItemPayload payload, CancellationToken cancellationToken)
{
await _rosterService.SaveItemAsync(speciesId, payload, cancellationToken);
return NoContent();

PokemonRoster roster = await _rosterService.GetAsync(cancellationToken);
SavedRosterItem result = new()
{
Item = roster.Items.Single(item => item.SpeciesId == speciesId),
Stats = roster.Stats
};
return Ok(result);
}
}
2 changes: 1 addition & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_APP_API_BASE_URL="http://localhost:43551/"
__VITE_APP_API_BASE_URL="https://localhost:32778/"
__VITE_APP_API_BASE_URL="https://localhost:32768/"
8 changes: 7 additions & 1 deletion frontend/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
/// <reference types="vite/client" />
// VITE_APP_API_BASE_URL // TODO(fpion): implement
interface ImportMetaEnv {
readonly VITE_APP_API_BASE_URL: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
Loading

0 comments on commit ea7b2e8

Please sign in to comment.