add real db

This commit is contained in:
Romulus21
2024-10-04 13:58:26 +02:00
parent 72b65063be
commit c931845899
10 changed files with 147 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
use leptos::*;
use leptos_meta::*;
//use leptos_meta::*;
use leptos_router::*;
use crate::models::OPTIONS;
@@ -19,31 +19,29 @@ pub async fn add_value(device: String, value: String) -> Result<(), ServerFnErro
#[component]
pub fn FormValues() -> impl IntoView {
let value_action = create_server_action::<ValueAction>();
let result = value_action.version();
let reset_value = create_rw_signal("");
//let add_value = ServerAction::<AddValue>::new();
//let value = add_value.value();
//let has_error = move || value.with(|val| matches!(val, Some(Err(_))));
let value = value_action.value();
let has_error = move || value.with(|val| matches!(val, Some(Err(_))));
view! {
<div class="my-0 mx-auto max-w-3xl text-center">
<div class="my-0 mx-auto w-72 text-center">
<h2 class="p-6 text-4xl">"Formulaire"</h2>
<ActionForm action=value_action attr:class="border">
<ActionForm action=value_action attr:class="border border-lime-500">
<div>
<label class="block">Capteur</label>
<select name="device" class="dark:bg-slate-800 px-2 py-1">
<label class="block mt-5 mb-1">Capteur</label>
<select name="device" class="w-60 dark:bg-slate-800 px-2 py-2">
{OPTIONS.into_iter()
.map(|option| view! { <option value={option.value}>{option.name}</option>})
.map(|option| view! { <option value={option.value} class="px-2 py-1">{option.name}</option>})
.collect::<Vec<_>>()}
</select>
</div>
<div>
<label class="block">Valeur</label>
<input type="text" name="value" prop:value=move || reset_value.get() class="text-center dark:bg-slate-800 dark:text-white px-2 py-1" />
<label class="block mt-3 mb-1">Valeur</label>
<input type="text" name="value" type="number"
class="text-center dark:bg-slate-800 focus:border-lime-500 dark:text-white px-2 py-2 w-60" />
</div>
<div>
<button type="submit" class="bg-slate-600 px-2 py-1 w-48 mt-3">Valider</button>
<button type="submit" class="bg-lime-500 hover:bg-lime-400 text-black px-2 py-1 w-60 my-5">Valider</button>
</div>
</ActionForm>
</div>