Skip to content

Commit

Permalink
Example repro for leptos-rs#3425
Browse files Browse the repository at this point in the history
  • Loading branch information
spencewenski committed Dec 31, 2024
1 parent 7a5b27a commit 51c0226
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Binary file modified examples/todo_app_sqlite_csr/Todos.db
Binary file not shown.
18 changes: 17 additions & 1 deletion examples/todo_app_sqlite_csr/src/todo.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::error_template::ErrorTemplate;
use leptos::either::Either;
use leptos::prelude::*;
use leptos_router::components::{Route, Router, Routes};
use leptos_router::path;
use serde::{Deserialize, Serialize};
use server_fn::ServerFnError;

Expand Down Expand Up @@ -77,6 +79,8 @@ pub async fn delete_todo(id: u16) -> Result<(), ServerFnError> {
use self::ssr::*;
let mut conn = db().await?;

leptos_axum::redirect("/foo");

Ok(sqlx::query("DELETE FROM todos WHERE id = $1")
.bind(id)
.execute(&mut conn)
Expand All @@ -91,11 +95,23 @@ pub fn TodoApp() -> impl IntoView {
<h1>"My Tasks"</h1>
</header>
<main>
<Todos/>
<Router>
<Routes fallback=|| "Not found">
<Route path=path!("/") view=Todos />
<Route path=path!("/foo") view=Foo />
</Routes>
</Router>
</main>
}
}

#[component]
fn Foo() -> impl IntoView {
view! {
<p>"Foo"</p>
}
}

#[component]
pub fn Todos() -> impl IntoView {
let add_todo = ServerMultiAction::<AddTodo>::new();
Expand Down

0 comments on commit 51c0226

Please sign in to comment.