1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-12-23 18:01:23 +00:00

Redirect to main page after edit (fixes #84)

This commit is contained in:
Felix Ableitner 2024-12-17 14:51:49 +01:00
parent 678ba64fef
commit 96233ba52a
2 changed files with 22 additions and 6 deletions

View file

@ -1,5 +1,12 @@
use crate::{
common::{newtypes::ConflictId, ApiConflict, ArticleView, EditArticleForm, Notification},
common::{
newtypes::ConflictId,
ApiConflict,
ArticleView,
EditArticleForm,
Notification,
MAIN_PAGE_NAME,
},
frontend::{
api::CLIENT,
components::{
@ -10,7 +17,7 @@ use crate::{
},
};
use leptos::{html::Textarea, prelude::*};
use leptos_router::hooks::use_params_map;
use leptos_router::{components::Redirect, hooks::use_params_map};
use leptos_use::{use_textarea_autosize, UseTextareaAutosizeReturn};
#[derive(Clone, PartialEq)]
@ -176,8 +183,11 @@ pub fn EditArticle() -> impl IntoView {
}
}
>
Edit successful!
<Redirect path={
let params = use_params_map();
let title = params.get().get("title").clone().unwrap_or(MAIN_PAGE_NAME.to_string());
format!("/article/{title}?edit_successful")
} />
</Show>
}
}

View file

@ -4,10 +4,13 @@ use crate::frontend::{
pages::article_resource,
};
use leptos::prelude::*;
use leptos_router::hooks::use_query_map;
#[component]
pub fn ReadArticle() -> impl IntoView {
let article = article_resource();
let query = use_query_map();
let edit_successful = query.get_untracked().get("edit_successful").is_some();
view! {
<ArticleNav article=article active_tab=ActiveTab::Read />
@ -26,8 +29,11 @@ pub fn ReadArticle() -> impl IntoView {
></div>
}
})
}}
}} <Show when=move || edit_successful>
<div class="toast toast-center">
<div class="alert alert-success">Edit successful</div>
</div>
</Show>
</Suspense>
}
}