+++ title = "Home page: show friendly empty state when no quotes in database" priority = 7 status = "done" ticket_type = "bug" dependencies = [] +++ ## Bug When the database is empty, `GET /api/quotes/random` returns a 404 response. The home page (`src/bin/ui/pages/home.rs`) currently treats all errors (including 404) the same way — it sets the `error` state and displays it via ``, which results in something like a raw JSON error message being shown to the user. ## Expected behaviour When the API returns a 404 on `/api/quotes/random`, the home page should display a friendly empty-state message instead of a generic error: > "Nothing here yet. Submit a quote!" The message should include a link to `/submit`. ## How to fix In `src/bin/ui/pages/home.rs`, in the `use_effect_with` block, inspect the `Err` value. The API client returns `ApiError::Server { status, .. }` for HTTP error codes. When `status == 404`, set a dedicated "empty" state (or detect it from the error) and render the friendly message instead of ``. Relevant code: `src/bin/ui/pages/home.rs` — the `use_effect_with` error branch and the HTML render block. ## File - `src/bin/ui/pages/home.rs` ## Validation ```sh # From quotesdb/ root cargo fmt && cargo check && cargo clippy && cargo test ``` Also manually test with an empty database: ```sh rm -f quotesdb.sqlite cargo run & # navigate to http://localhost:3000 — should show the friendly message, not a raw error ``` ## Commit scope `fix(quotesdb): home page empty state`