Added footer to public page. Leptos upgraded to 0.6.13
This commit is contained in:
+14
@@ -62,6 +62,19 @@ impl DialogHelper {
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn app_footer() -> impl IntoView {
|
||||
let loc = use_location();
|
||||
|
||||
view! {
|
||||
<footer class="content-footer footer bg-footer-theme" style={move || if loc.pathname.get().starts_with("/admin") {"display: none;"} else {"display: block;"}}>
|
||||
<div class="mb-2 mb-md-0" >
|
||||
<a href="https://rezervovator.cz" target="_blank"><img src="/rezervovator_l.svg" width="110"/></a> {format!(" v {}", env!("CARGO_PKG_VERSION"))}
|
||||
</div>
|
||||
</footer>
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
// Provides context that manages stylesheets, titles, meta tags, etc.
|
||||
@@ -111,6 +124,7 @@ pub fn App() -> impl IntoView {
|
||||
}/>
|
||||
</Routes>
|
||||
</main>
|
||||
<AppFooter/>
|
||||
</Router>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
||||
}
|
||||
|
||||
if let Ok(Some(mut field)) = data.try_next().await {
|
||||
let content_disp = field.content_disposition().clone();
|
||||
let file_name = content_disp.get_filename().unwrap();
|
||||
let content_disp = field.content_disposition();
|
||||
let file_name = content_disp.unwrap().get_filename().unwrap().to_string();
|
||||
|
||||
if file_name.is_empty() {
|
||||
return Redirect::to("/admin/appearance").see_other();
|
||||
@@ -90,8 +90,8 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
||||
let c = chunk.unwrap();
|
||||
let _ = file.write_all(&c);
|
||||
}
|
||||
let _ = set_banner_name(file_name, &app_data.db_pool).await;
|
||||
let _ = modify_style(file_name).await;
|
||||
let _ = set_banner_name(&file_name, &app_data.db_pool).await;
|
||||
let _ = modify_style(&file_name).await;
|
||||
}
|
||||
|
||||
Redirect::to("/admin/appearance").see_other()
|
||||
|
||||
+24
-10
@@ -10,7 +10,12 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
||||
use std::ops::DerefMut;
|
||||
use leptos::expect_context;
|
||||
use leptos_actix::extract;
|
||||
use actix_session::Session;
|
||||
use actix_web::cookie::Cookie;
|
||||
use actix_web::cookie::SameSite;
|
||||
use leptos_actix::ResponseOptions;
|
||||
use actix_web::http::header;
|
||||
use actix_web::http::header::HeaderValue;
|
||||
use actix_web::HttpRequest;
|
||||
|
||||
pub async fn find_customer_by_email(email: &str, tx: &mut Transaction<'_, Postgres>) -> Option<Customer> {
|
||||
let customer = query_as::<_, Customer>("SELECT * FROM customer WHERE email = $1")
|
||||
@@ -54,8 +59,19 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
||||
}
|
||||
|
||||
pub async fn remember_customer(customer: Customer) -> Result<(), ServerFnError> {
|
||||
let session: Session = extract().await?;
|
||||
session.insert("customer", customer)?;
|
||||
let cookie = Cookie::build("customer", serde_json::to_string(&customer).unwrap_or("".to_string()))
|
||||
.http_only(true)
|
||||
.secure(true)
|
||||
.same_site(SameSite::Lax)
|
||||
.permanent()
|
||||
.path("/")
|
||||
.finish();
|
||||
let response = expect_context::<ResponseOptions>();
|
||||
|
||||
if let Ok(cookie) = HeaderValue::from_str(&cookie.to_string()) {
|
||||
response.insert_header(header::SET_COOKIE, cookie);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}}
|
||||
@@ -78,14 +94,12 @@ pub async fn get_customers() -> Result<ApiResponse<Vec<Customer>>, ServerFnError
|
||||
|
||||
#[server]
|
||||
pub async fn get_remembered() -> Result<Option<Customer>, ServerFnError> {
|
||||
use actix_session::*;
|
||||
use leptos_actix::extract;
|
||||
let request: HttpRequest = extract().await?;
|
||||
|
||||
let session = extract::<Session>().await;
|
||||
|
||||
if session.is_err() {
|
||||
return Ok(None);
|
||||
if let Some(cv) = request.cookie("customer").map(|c| c.value().to_string()) {
|
||||
Ok(Some(serde_json::from_str(&cv).unwrap_or(Customer::default())))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
Ok(session.unwrap().get::<Customer>("customer").unwrap_or(None))
|
||||
}
|
||||
Reference in New Issue
Block a user