2.4 KiB
+++ title = "quotesdb/ui: /submit page locked-state banner" priority = 5 status = "done" ticket_type = "feature" dependencies = ["161f32"] +++
/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():
// 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)
<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:
cargo check --target wasm32-unknown-unknown --bin ui
Validation
cargo fmt && cargo check --target wasm32-unknown-unknown --bin ui
Commit
feat(quotesdb): show locked banner on /submit when submissions are closed