Compare commits
No commits in common. "89a72c9fbcc9cf1fea665675980c95201adb7971" and "76af0becf93ff6c4e77b7dfbdb30920f5d079cdd" have entirely different histories.
89a72c9fbc
...
76af0becf9
@ -30,10 +30,9 @@ uuid = "1.8.0"
|
|||||||
leptos-use = "0.10.6"
|
leptos-use = "0.10.6"
|
||||||
strsim = "0.11.1"
|
strsim = "0.11.1"
|
||||||
web-sys = { version = "0.3.69", features = ["Document", "Window", "Element", "ScrollIntoViewOptions", "ScrollLogicalPosition", "ScrollBehavior" ] }
|
web-sys = { version = "0.3.69", features = ["Document", "Window", "Element", "ScrollIntoViewOptions", "ScrollLogicalPosition", "ScrollBehavior" ] }
|
||||||
leptos_toaster = { version = "0.1.7", optional = true, features = [ "builtin_toast" ] }
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate", "leptos_toaster/hydrate"]
|
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
|
||||||
ssr = [
|
ssr = [
|
||||||
"dep:surrealdb",
|
"dep:surrealdb",
|
||||||
"dep:axum",
|
"dep:axum",
|
||||||
@ -46,7 +45,6 @@ ssr = [
|
|||||||
"leptos_meta/ssr",
|
"leptos_meta/ssr",
|
||||||
"leptos_router/ssr",
|
"leptos_router/ssr",
|
||||||
"dep:tracing",
|
"dep:tracing",
|
||||||
"leptos_toaster/ssr"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Defines a size-optimized profile for the WASM bundle in release mode
|
# Defines a size-optimized profile for the WASM bundle in release mode
|
||||||
|
@ -7,7 +7,6 @@ use leptos_router::*;
|
|||||||
use crate::components;
|
use crate::components;
|
||||||
use crate::pages;
|
use crate::pages;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
use leptos_toaster::{Toaster, ToasterPosition};
|
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn App() -> impl IntoView {
|
pub fn App() -> impl IntoView {
|
||||||
@ -39,20 +38,16 @@ pub fn App() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
.into_view()
|
.into_view()
|
||||||
}>
|
}>
|
||||||
<Toaster
|
<components::header::Header />
|
||||||
position=ToasterPosition::BottomCenter
|
<components::participant::Modal />
|
||||||
>
|
<main>
|
||||||
<components::header::Header />
|
<Routes>
|
||||||
<components::participant::Modal />
|
<Route path="/" view=pages::index::HomePage />
|
||||||
<main>
|
<Route path="/add-participant" view=pages::add_participant::AddParticipant />
|
||||||
<Routes>
|
<Route path="/add-time" view=pages::add_time::AddTime />
|
||||||
<Route path="/" view=pages::index::HomePage />
|
<Route path="/groups" view=pages::groups::Groups />
|
||||||
<Route path="/add-participant" view=pages::add_participant::AddParticipant />
|
</Routes>
|
||||||
<Route path="/add-time" view=pages::add_time::AddTime />
|
</main>
|
||||||
<Route path="/groups" view=pages::groups::Groups />
|
|
||||||
</Routes>
|
|
||||||
</main>
|
|
||||||
</Toaster>
|
|
||||||
</Router>
|
</Router>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::util::surrealdb::{client::Time, schemas};
|
use crate::util::surrealdb::{client::Time, schemas};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_toaster::{Toast, ToastId, ToastVariant, Toasts};
|
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(feature = "ssr")] {
|
if #[cfg(feature = "ssr")] {
|
||||||
@ -54,7 +53,6 @@ async fn modify_participant(
|
|||||||
pub fn Modal() -> impl IntoView {
|
pub fn Modal() -> impl IntoView {
|
||||||
let participant_id = use_context::<RwSignal<Option<String>>>().unwrap();
|
let participant_id = use_context::<RwSignal<Option<String>>>().unwrap();
|
||||||
let participants = use_context::<schemas::ParticipantsContext>().unwrap();
|
let participants = use_context::<schemas::ParticipantsContext>().unwrap();
|
||||||
let toasts_context = expect_context::<Toasts>();
|
|
||||||
|
|
||||||
let time_lifesaver = create_rw_signal(Time {
|
let time_lifesaver = create_rw_signal(Time {
|
||||||
minutes: 0,
|
minutes: 0,
|
||||||
@ -133,20 +131,6 @@ pub fn Modal() -> impl IntoView {
|
|||||||
|
|
||||||
modify_participant_action.dispatch((p, participant().unwrap().get().id));
|
modify_participant_action.dispatch((p, participant().unwrap().get().id));
|
||||||
|
|
||||||
let toast_id = ToastId::new();
|
|
||||||
|
|
||||||
toasts_context.toast(
|
|
||||||
view! {
|
|
||||||
<Toast
|
|
||||||
toast_id
|
|
||||||
variant=ToastVariant::Success
|
|
||||||
title=view! { "Successfully modified participant" }.into_view()
|
|
||||||
/>
|
|
||||||
},
|
|
||||||
Some(toast_id),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
participant_id.set(None);
|
participant_id.set(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_toaster::{Toast, ToastId, ToastVariant, Toasts};
|
use leptos_router::ActionForm;
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(feature = "ssr")] {
|
if #[cfg(feature = "ssr")] {
|
||||||
@ -49,60 +49,15 @@ async fn add_participant(name: String, group: String) -> Result<(), ServerFnErro
|
|||||||
/// Renders the home page of your application.
|
/// Renders the home page of your application.
|
||||||
#[component]
|
#[component]
|
||||||
pub fn AddParticipant() -> impl IntoView {
|
pub fn AddParticipant() -> impl IntoView {
|
||||||
let toasts_context = expect_context::<Toasts>();
|
let form_submit = create_server_action::<AddParticipant>();
|
||||||
|
|
||||||
let name = create_rw_signal("".to_string());
|
|
||||||
let group = create_rw_signal("A1".to_string());
|
|
||||||
|
|
||||||
let name_input_ref: NodeRef<html::Input> = create_node_ref();
|
|
||||||
|
|
||||||
let form_submit_action = create_action(|input: &(String, String)| {
|
|
||||||
let input = input.to_owned();
|
|
||||||
|
|
||||||
async move { add_participant(input.0, input.1).await }
|
|
||||||
});
|
|
||||||
|
|
||||||
let form_submit = move |ev: ev::SubmitEvent| {
|
|
||||||
ev.prevent_default();
|
|
||||||
|
|
||||||
form_submit_action.dispatch((name.get(), group.get()));
|
|
||||||
|
|
||||||
let toast_id = ToastId::new();
|
|
||||||
|
|
||||||
toasts_context.toast(
|
|
||||||
view! {
|
|
||||||
<Toast
|
|
||||||
toast_id
|
|
||||||
variant=ToastVariant::Success
|
|
||||||
title=view! { "Successfully added participant" }.into_view()
|
|
||||||
/>
|
|
||||||
},
|
|
||||||
Some(toast_id),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
name.set("".to_string());
|
|
||||||
let _ = name_input_ref.get().unwrap().focus();
|
|
||||||
};
|
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<h2>"Deelnemer toevoegen"</h2>
|
<h2>"Deelnemer toevoegen"</h2>
|
||||||
<form on:submit=form_submit>
|
<ActionForm action=form_submit>
|
||||||
<label>Naam</label>
|
<label>Naam</label>
|
||||||
<input
|
<input type="text" name="name" autocomplete="off" />
|
||||||
type="text"
|
|
||||||
autocomplete="off"
|
|
||||||
node_ref=name_input_ref
|
|
||||||
on:input=move |ev| {
|
|
||||||
name.set(event_target_value(&ev));
|
|
||||||
}
|
|
||||||
prop:value=name
|
|
||||||
/>
|
|
||||||
<label>Groep</label>
|
<label>Groep</label>
|
||||||
<select on:change=move |ev| {
|
<select name="group" autocomplete="off">
|
||||||
let new_value = event_target_value(&ev);
|
|
||||||
group.set(new_value);
|
|
||||||
} autocomplete="off">
|
|
||||||
<option value="A1">A1</option>
|
<option value="A1">A1</option>
|
||||||
<option value="A2">A2</option>
|
<option value="A2">A2</option>
|
||||||
<option value="A3">A3</option>
|
<option value="A3">A3</option>
|
||||||
@ -139,6 +94,6 @@ pub fn AddParticipant() -> impl IntoView {
|
|||||||
<option value="Z6">Z6</option>
|
<option value="Z6">Z6</option>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="Deelnemer toevoegen" />
|
<input type="submit" value="Deelnemer toevoegen" />
|
||||||
</form>
|
</ActionForm>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::util::surrealdb::{client::sort_participants, client::Time, schemas};
|
use crate::util::surrealdb::{client::sort_participants, client::Time, schemas};
|
||||||
use leptos::{ev::keydown, *};
|
use leptos::{ev::keydown, *};
|
||||||
use leptos_toaster::{Toast, ToastId, ToastVariant, Toasts};
|
|
||||||
use leptos_use::*;
|
use leptos_use::*;
|
||||||
use web_sys::ScrollIntoViewOptions;
|
use web_sys::ScrollIntoViewOptions;
|
||||||
|
|
||||||
@ -57,7 +56,6 @@ async fn add_time(
|
|||||||
#[component]
|
#[component]
|
||||||
pub fn AddTime() -> impl IntoView {
|
pub fn AddTime() -> impl IntoView {
|
||||||
let participants = use_context::<schemas::ParticipantsContext>().unwrap();
|
let participants = use_context::<schemas::ParticipantsContext>().unwrap();
|
||||||
let toasts_context = expect_context::<Toasts>();
|
|
||||||
|
|
||||||
let container_ref: NodeRef<html::Ul> = create_node_ref();
|
let container_ref: NodeRef<html::Ul> = create_node_ref();
|
||||||
let name_input_ref: NodeRef<html::Input> = create_node_ref();
|
let name_input_ref: NodeRef<html::Input> = create_node_ref();
|
||||||
@ -89,20 +87,6 @@ pub fn AddTime() -> impl IntoView {
|
|||||||
time.get().as_milliseconds(),
|
time.get().as_milliseconds(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let toast_id = ToastId::new();
|
|
||||||
|
|
||||||
toasts_context.toast(
|
|
||||||
view! {
|
|
||||||
<Toast
|
|
||||||
toast_id
|
|
||||||
variant=ToastVariant::Success
|
|
||||||
title=view! { "Successfully added time" }.into_view()
|
|
||||||
/>
|
|
||||||
},
|
|
||||||
Some(toast_id),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
name.set("".to_string());
|
name.set("".to_string());
|
||||||
time.set(Time {
|
time.set(Time {
|
||||||
minutes: 0,
|
minutes: 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user