use crate::util::surrealdb::schemas; use leptos::*; use leptos_router::ActionForm; cfg_if::cfg_if! { if #[cfg(feature = "ssr")] { use crate::util::surrealdb::{DB}; use leptos::logging; } } #[server(AddTime)] async fn add_time(name: String, group: String) -> Result<(), ServerFnError> { let created: Vec = DB .create("participant") .content(schemas::NewParticipant { name, group }) .await?; match created.first() { Some(participant) => { logging::log!( "Created participant: {} ({})", participant.name, participant.group ); Ok(()) } None => Err(ServerFnError::ServerError(String::from( "Could not create participant", ))), } } /// Renders the home page of your application. #[component] pub fn AddTime() -> impl IntoView { let participants = use_context::>>(); let form_submit = create_server_action::(); view! {

"Tijd toevoegen"

} }