Skip to content

Commit

Permalink
feat: minor ux improvements and corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
SchutteJan committed Jun 15, 2024
1 parent 8ac5eda commit b7b53f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ MVP:
- [x] API routes for querying visited bars
- [x] Frontend page for adding and viewing visits
- [x] Stats page for users to see how many bars they've visited
- [ ] Show errors in the UI using toast notifications
- [ ] Allow users to search for a bar (frontend only for now?)
- [ ] CSRF on all POST requests

Issues:
- The api never returns a 404, it will always fall back to the 200.html page
- Example: `curl http://localhost:8080/session/doesnotexist`
- Solution: nest api routes under `/api` and don't use catch_all route for these routes

Improvements:
- Use `Forms` for data input instead of `Json<T>` in order to use the `FromForm` macros and validations
- Add "updated_at", "created_at" fields to all tables
- Factor out database queries from the routes into a separate modules
- Use https://crates.io/crates/rocket_okapi to generate OpenAPI spec
- See if switching to https://github.com/launchbadge/sqlx is nice because managing diesel orm types is a pain
- Show errors in the UI using toast notifications

Reading:
- Learn from this example repo: https://github.com/TaeyoonKwon/rust-rocket-sample
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/BarItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<small>x:{bar.coordinates.x}, y: {bar.coordinates.y} </small>
</p>
{#if bar.visited_at && isLoggedIn}
<p>Visited on: {localDate(bar.visited_at)}</p>
<p>First visited on: {localDate(bar.visited_at)}</p>
{:else if isLoggedIn}
<p>
<button on:click={() => handleVisitBar(bar.id)} class="outline">Mark Visited</button>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/routes/me/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@

<section>
<h2>Me</h2>
<p>This is you.</p>

{#if userData}
<p>This is you.</p>
<p>Logged in with role '{userData.role}'</p>
{:else}
<p>Uhuh not sure who you are, are you even logged in?</p>
<p>This could've been you.</p>
<p>Uhuh not sure who you are, are you even <a href="/login">logged in</a>?</p>
{/if}

{#if visitStats}
<p>Visits:</p>
<ul>
<li>Distinct bar visits: {visitStats.distinct_bar_visits}</li>
</ul>
{:else}
{:else if userData}
<p>Fetching visit stats...</p>
<progress />
{/if}
Expand Down

0 comments on commit b7b53f7

Please sign in to comment.