Contact us page done
This commit is contained in:
parent
89fe0495cb
commit
b12b7bb34d
@ -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
|
@ -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! {
|
||||||
|
@ -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
0
src/pages/thanks.rs
Normal file
Loading…
Reference in New Issue
Block a user