You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/quotesdb/.beans/quotesdb-9jsk--quotesdbui-s...

106 lines
2.5 KiB
Markdown

---
# quotesdb-9jsk
title: 'quotesdb/ui: /submit page locked-state banner'
status: completed
type: feature
priority: normal
created_at: 2026-03-10T23:32:05Z
updated_at: 2026-03-10T23:32:12Z
blocked_by:
- quotesdb-d09v
---
## /submit page locked-state banner (UI)
Modify the existing /submit page to check the submission lock on mount. When the lock is active, hide the submission form entirely and show a closed-submissions banner in its place.
Depends on ticket 161f32 (admin API client functions). Complete that ticket first.
---
## Files to modify
- `src/bin/ui/pages/submit.rs` — add status check on mount and conditional rendering
---
## Changes to SubmitPage component
### New state fields
Add to the existing component state:
| Field | Type | Purpose |
|---|---|---|
| `submissions_locked` | `Option<bool>` | `None` while loading, `Some(true/false)` after status check |
| `status_error` | `bool` | Set if `get_status()` itself fails (show form as fallback) |
### On mount
Spawn an async task that calls `api::get_status()`:
```rust
// In use_effect_with or similar hook, fired once on mount:
let submissions_locked = submissions_locked.clone();
wasm_bindgen_futures::spawn_local(async move {
match api::get_status().await {
Ok(status) => submissions_locked.set(Some(status.submissions_locked)),
Err(_) => {
// On error, default to showing the form (fail open).
submissions_locked.set(Some(false));
}
}
});
```
### Render logic
```
if submissions_locked == None:
show a loading indicator (or nothing / skeleton)
elif submissions_locked == Some(true):
show closed banner, hide form
else:
show form as normal
```
### Closed banner markup (approximate)
```html
<div class="submissions-closed-banner">
<p>Submissions are currently closed.</p>
</div>
```
Style the banner to be visually distinct — use a muted/warning colour. Add the `.submissions-closed-banner` CSS class to `src/bin/ui/style.css`.
### Fail-open behaviour
If `api::get_status()` returns an error, treat it as unlocked (`Some(false)`) and display the form. Do not block a user from submitting due to a network error on the status check.
---
## Tests
No runtime unit tests (wasm-only). Verify the build:
```sh
cargo check --target wasm32-unknown-unknown --bin ui
```
---
## Validation
```sh
cargo fmt && cargo check --target wasm32-unknown-unknown --bin ui
```
---
## Commit
```
feat(quotesdb): show locked banner on /submit when submissions are closed
```