Contact us page done

This commit is contained in:
Franklin 2023-04-14 18:22:34 -04:00
parent 89fe0495cb
commit b12b7bb34d
4 changed files with 20 additions and 10 deletions

View File

@ -32,4 +32,4 @@ New todo's
- [ ] Admin panel with page loads & contact us clicks - [ ] Admin panel with page loads & contact us clicks
- [ ] Put JL on top of the Agents section - [ ] Put JL on top of the Agents section
- [ ] If someone enters the page from an agent, make anything that appears on the website reference them. - [ ] If someone enters the page from an agent, make anything that appears on the website reference them.
- [ ] Contact us Functionality - [x] Contact us Functionality

View File

@ -1,12 +1,15 @@
use jl_types::dto::payloads::contact::ContactPayload; use jl_types::dto::payloads::contact::ContactPayload;
use yew::prelude::*; use yew::prelude::*;
use yew_router::prelude::use_navigator;
use crate::{components::{nav_bar::NavigationBar, footer::PageFooter}, utils::input::{get_value_from_input_event, get_value_from_textarea_event}, api::backend::create_new_contact_request}; use crate::{components::{nav_bar::NavigationBar, footer::PageFooter}, utils::input::{get_value_from_input_event, get_value_from_textarea_event}, api::backend::create_new_contact_request, routes::main_router::Route};
#[function_component(ContactPage)] #[function_component(ContactPage)]
pub fn contact_page() -> Html { pub fn contact_page() -> Html {
let navigator = use_navigator().unwrap();
let first_name = use_state(|| String::new()); let first_name = use_state(|| String::new());
let last_name = use_state(|| String::new()); let last_name = use_state(|| String::new());
let credential = use_state(|| String::new()); let credential = use_state(|| String::new());
@ -49,12 +52,18 @@ pub fn contact_page() -> Html {
credential: (*credential).clone(), credential: (*credential).clone(),
message: (*messsage).clone() message: (*messsage).clone()
}; };
let navigator = navigator.clone();
if contact.first_name.len() > 1 && contact.last_name.len() > 1 && contact.credential.len() > 3 && contact.message.len() > 5 {
wasm_bindgen_futures::spawn_local(async move { wasm_bindgen_futures::spawn_local(async move {
match create_new_contact_request(contact).await { match create_new_contact_request(contact).await {
Ok(_) => {}, Ok(_) => {
// TODO: Take to homepage? Say thanks?
navigator.push(&Route::LandingPage);
},
Err(error) => log::error!("Error in sending a contact request to the backend: {error}") Err(error) => log::error!("Error in sending a contact request to the backend: {error}")
}; };
}); });
}
}) })
}; };
html! { html! {

View File

@ -5,3 +5,4 @@ pub mod not_found;
pub mod contact; pub mod contact;
pub mod admin; pub mod admin;
pub mod agents; pub mod agents;
pub mod thanks;

0
src/pages/thanks.rs Normal file
View File