first error feedback (sorta)
This commit is contained in:
parent
10e573a905
commit
62afc49675
3 changed files with 35 additions and 9 deletions
|
@ -27,6 +27,10 @@
|
|||
--clr-txt-on-dark: #fff;
|
||||
--clr-txt-on-light: #000;
|
||||
|
||||
--clr-error-primary-0: #c71216;
|
||||
--clr-error-primary-40: #ec8b77;
|
||||
--clr-error-surface: #2b1108;
|
||||
|
||||
font-size: 1.2em;
|
||||
color: var(--clr-txt-on-dark);
|
||||
background-color: var(--clr-surface-tonal-a0);
|
||||
|
@ -109,6 +113,14 @@ section {
|
|||
margin-top: 2em;
|
||||
}
|
||||
|
||||
p.form-error {
|
||||
background-color: var(--clr-error-surface);
|
||||
border: 2pt solid var(--clr-error-primary-0);
|
||||
color: var(--clr-error-primary-40);
|
||||
border-radius: 4pt;
|
||||
padding: .5em 1em;
|
||||
}
|
||||
|
||||
.split {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -34,9 +34,16 @@ pub fn id_db_to_public(id: i64) -> String {
|
|||
format!("{:0>3}-{:0>3}", first, second)
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Template {
|
||||
Template::render("index", context! {})
|
||||
#[get("/?<miss>&<ident>&<microchip_id>")]
|
||||
fn index(miss: Option<bool>, ident: Option<&str>, microchip_id: Option<&str>) -> Template {
|
||||
Template::render(
|
||||
"index",
|
||||
context! {
|
||||
miss,
|
||||
ident,
|
||||
microchip_id,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/register")]
|
||||
|
@ -195,12 +202,14 @@ async fn show_profile(
|
|||
let internal_id = ident.and_then(|v| id_public_to_db(v)).unwrap_or(0);
|
||||
let microchip_id = microchip_id.unwrap_or("");
|
||||
|
||||
println!("id: {}\nmicrochip id: {}", internal_id, microchip_id);
|
||||
|
||||
let profile = doll::get(db, internal_id, microchip_id)
|
||||
.await
|
||||
.expect("fuck")
|
||||
.ok_or(Redirect::to(uri!("/")))?;
|
||||
.ok_or(Redirect::to(uri!(index(
|
||||
Some(true),
|
||||
ident,
|
||||
Some(microchip_id)
|
||||
))))?;
|
||||
let has_notable_traits = profile.has_notable_traits();
|
||||
let has_chassis_info = profile.chassis_id.is_some()
|
||||
&& profile.chassis_type.is_some()
|
||||
|
|
|
@ -3,13 +3,18 @@
|
|||
{% block main %}
|
||||
<form action="/profile" id="stray-form">
|
||||
<h2>Found a stray?</h2>
|
||||
|
||||
{% if miss %}
|
||||
<p class="form-error">Nothing found with this ID</p>
|
||||
{% endif %}
|
||||
|
||||
<label for="ident">Enter the 6-digit ID you found</label>
|
||||
<input type="text" inputmode="numeric" pattern="\d{6}" id="ident" name="ident" size="6" placeholder="000000"
|
||||
autofocus />
|
||||
autofocus {% if ident %}value="{{ident}}" {% endif %} />
|
||||
|
||||
<label for="ident">Alternatively, enter the microchip ID (hexadecimal form), if available</label>
|
||||
<input type="text" pattern="(0x)?[a-fA-F0-9]+" id="microchip_id" name="microchip_id"
|
||||
placeholder="A hexadecimal ID" />
|
||||
<input type="text" pattern="(0x)?[a-fA-F0-9]+" id="microchip_id" name="microchip_id" placeholder="A hexadecimal ID"
|
||||
{% if microchip_id %}value="{{microchip_id}}" {% endif %} />
|
||||
|
||||
<button type="submit">Search the database</button>
|
||||
</form>
|
||||
|
|
Loading…
Add table
Reference in a new issue