diff --git a/Cargo.lock b/Cargo.lock index a3d0e1a..33d3c14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + [[package]] name = "android_system_properties" version = "0.1.5" @@ -78,11 +87,34 @@ dependencies = [ "js-sys", "num-integer", "num-traits", + "serde", "time", "wasm-bindgen", "winapi", ] +[[package]] +name = "chrono-tz" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9cc2b23599e6d7479755f3594285efb3f74a1bdca7a7374948bc831e23a552" +dependencies = [ + "chrono", + "chrono-tz-build", + "phf", +] + +[[package]] +name = "chrono-tz-build" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9998fb9f7e9b2111641485bf8beb32f92945f97f92a3d061f744cfef335f751" +dependencies = [ + "parse-zoneinfo", + "phf", + "phf_codegen", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -200,6 +232,15 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "format_num" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14ac05eb8d2eb4ed1eeff847911deae077b0b53332465de9d6a26b0ea9961bc8" +dependencies = [ + "regex", +] + [[package]] name = "futures" version = "0.3.28" @@ -776,12 +817,59 @@ version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +[[package]] +name = "parse-zoneinfo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41" +dependencies = [ + "regex", +] + [[package]] name = "percent-encoding" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +[[package]] +name = "phf" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928c6535de93548188ef63bb7c4036bd415cd8f36ad25af44b9789b2ee72a48c" +dependencies = [ + "phf_shared", +] + +[[package]] +name = "phf_codegen" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56ac890c5e3ca598bbdeaa99964edb5b0258a583a9eb6ef4e89fc85d9224770" +dependencies = [ + "phf_generator", + "phf_shared", +] + +[[package]] +name = "phf_generator" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1181c94580fa345f50f19d738aaa39c0ed30a600d95cb2d3e23f94266f14fbf" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_shared" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1fb5f6f826b772a8d4c0394209441e7d37cbbb967ae9c7e0e8134365c9ee676" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.0.12" @@ -938,6 +1026,7 @@ dependencies = [ "err", "js-sys", "log", + "realtor-lp-types", "reqwest", "serde", "serde_json", @@ -952,6 +1041,37 @@ dependencies = [ "yew-router", ] +[[package]] +name = "realtor-lp-types" +version = "0.1.0" +dependencies = [ + "bincode", + "chrono", + "chrono-tz", + "format_num", + "rand", + "serde", + "serde_json", + "uuid", +] + +[[package]] +name = "regex" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" + [[package]] name = "reqwest" version = "0.11.17" @@ -1116,6 +1236,12 @@ dependencies = [ "serde", ] +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + [[package]] name = "slab" version = "0.4.8" diff --git a/Cargo.toml b/Cargo.toml index 6b0967d..fffbbaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ thousands = "0.2.0" chrono = "0.4.23" # Core -#realtor-lp-types = { path = "../realtor-lp-types", features = ["wasm"] } +realtor-lp-types = { path = "../realtor-lp-types", features = ["wasm"] } [profile.release] diff --git a/assets/images/agent-banner.png b/assets/images/agent-banner.png new file mode 100644 index 0000000..4825344 Binary files /dev/null and b/assets/images/agent-banner.png differ diff --git a/assets/images/agent-pfp.png b/assets/images/agent-pfp.png new file mode 100644 index 0000000..5247cf3 Binary files /dev/null and b/assets/images/agent-pfp.png differ diff --git a/assets/images/melido-pfp.jpeg b/assets/images/melido-pfp.jpeg new file mode 100644 index 0000000..3e7f324 Binary files /dev/null and b/assets/images/melido-pfp.jpeg differ diff --git a/css/components/page/hero.css b/css/components/page/hero.css index 2d452fc..215956e 100644 --- a/css/components/page/hero.css +++ b/css/components/page/hero.css @@ -18,7 +18,7 @@ } .hero-banner-image { width: 100%; - height: 150px; + height: 180px; object-fit: cover; background-color: rebeccapurple; @@ -33,13 +33,15 @@ border-radius: 100%; border: 3px solid white; + background-color: white; - background-color: blue; - - margin-top: -65px; + margin-top: -80px; } .hero-profile-picture { - object-fit: cover; + object-fit: fill; + width: 100%; + height: 100%; + border-radius: 100%; } .hero-name { font-size: 20px; diff --git a/css/components/page/results.css b/css/components/page/results.css new file mode 100644 index 0000000..39eb28c --- /dev/null +++ b/css/components/page/results.css @@ -0,0 +1,5 @@ +.results-container { + display: grid; + gap: 20px; + +} \ No newline at end of file diff --git a/index.html b/index.html index bbac21f..f41abda 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,7 @@ + diff --git a/src/api/backend/mod.rs b/src/api/backend/mod.rs new file mode 100644 index 0000000..5f2a369 --- /dev/null +++ b/src/api/backend/mod.rs @@ -0,0 +1,30 @@ + +use realtor_lp_types::domain::realtor::Realtor; +use reqwest::Method; +use uuid::Uuid; + +use super::base::{perform_request_without_client}; + +const BASE_URL: &str = "http://0.0.0.0:8085/api/"; + +/* +pub fn get_auth_header() -> (String, String) { + let token = admin_panel::get_admin_token_from_storage(); + match token { + Some(token) => (String::from("auth_token"), token), + None => (String::from("noauth"), String::new()), + } +}*/ + +pub async fn get_realtor_profile(realtor_id: Uuid) -> Result { + perform_request_without_client::( + BASE_URL.into(), + Method::GET, + format!("public/realtor/{}", realtor_id), + None, + 200, + Vec::new(), + None, + ) + .await +} \ No newline at end of file diff --git a/src/api/base.rs b/src/api/base.rs new file mode 100644 index 0000000..7b2472a --- /dev/null +++ b/src/api/base.rs @@ -0,0 +1,119 @@ +use err::{Error, MessageResource}; +use reqwest::Client; +use serde::{de::DeserializeOwned, Serialize}; + +/// This function is mainly for when you don't have a client in your application and just want to get it over with. +/// This shouldn't be used as it takes more resource consumption than the above method. +pub async fn perform_request_without_client( + base_url: String, + method: reqwest::Method, + path: String, + body: Option, + expected_status_code: u16, + headers: Vec<(String, String)>, + params: Option>, +) -> Result { + let client = Client::new(); + let mut req_incomplete = + client.request(method, format!("{url}{path}", url = base_url, path = path)); + + for header in headers { + req_incomplete = req_incomplete.header(&header.0, &header.1); + } + + if let Some(parameters) = params { + req_incomplete = req_incomplete.query(¶meters) + } + + let req_complete = match body { + Some(b) => req_incomplete.json(&b), + None => req_incomplete.header("content-length", 0), + }; + println!("{:?}", req_complete); + match req_complete.send().await { + // Error handling here + Ok(res) => { + // Request sent correctly + match res.status().as_u16() == expected_status_code { + true => { + match res.json::().await { + Ok(resp_dto) => Ok(resp_dto), // Return correctly deserialized obj + Err(err) => Err(Error::Serde(MessageResource::from(err))), + } + } + false => { + //If status code is any other than expected + Err(Error::UnexpectedStatusCode( + expected_status_code, + res.status().as_u16(), + match res.json::>().await { + Ok(messages) => messages, + Err(e) => vec![MessageResource::from(e)], + }, + )) + } + } + } + Err(e) => { + // Request couldn't be sent + Err(Error::Network(MessageResource::from(e))) + } + } +} + +#[allow(unused)] +pub async fn perform_multipart_request_without_client( + base_url: String, + method: reqwest::Method, + path: String, + body: Vec, + expected_status_code: u16, + headers: Vec<(String, String)>, + params: Option>, +) -> Result { + let client = Client::new(); + let mut req_incomplete = + client.request(method, format!("{url}{path}", url = base_url, path = path)); + + for header in headers { + req_incomplete = req_incomplete.header(&header.0, &header.1); + } + + if let Some(parameters) = params { + req_incomplete = req_incomplete.query(¶meters) + } + + let part = reqwest::multipart::Part::bytes(body).file_name("image"); + let form = reqwest::multipart::Form::new(); + let form = form.part("image", part); + + match req_incomplete.multipart(form).send().await { + // Error handling here + Ok(res) => { + // Request sent correctly + match res.status().as_u16() == expected_status_code { + true => { + match res.json::().await { + Ok(resp_dto) => Ok(resp_dto), // Return correctly deserialized obj + Err(err) => Err(Error::Serde(MessageResource::from(err))), + } + } + false => { + //If status code is any other than expected + Err(Error::UnexpectedStatusCode( + expected_status_code, + res.status().as_u16(), + match res.json::>().await { + Ok(messages) => messages, + Err(e) => vec![MessageResource::from(e)], + }, + )) + } + } + } + Err(e) => { + // Request couldn't be sent + Err(Error::Network(MessageResource::from(e))) + } + } +} diff --git a/src/api/mod.rs b/src/api/mod.rs index 8b13789..dd5c4b2 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1 +1,2 @@ - +pub mod backend; +pub mod base; \ No newline at end of file diff --git a/src/components/page/agency.rs b/src/components/page/agency.rs index 2cb4c5d..196b9bf 100644 --- a/src/components/page/agency.rs +++ b/src/components/page/agency.rs @@ -5,10 +5,10 @@ pub fn agency_section() -> Html { html! {
- {"Meet Our"} + {"Conoce mas"}
- {"Partner"} + {"Sobre Nosotros"}
{"agency-logo"}/
diff --git a/src/components/page/hero.rs b/src/components/page/hero.rs index e97afe4..9721dab 100644 --- a/src/components/page/hero.rs +++ b/src/components/page/hero.rs @@ -1,27 +1,38 @@ +use realtor_lp_types::domain::realtor::Realtor; use yew::prelude::*; +#[derive(PartialEq, Properties)] +pub struct HeroSectionProps { + pub realtor: Realtor +} + #[function_component(HeroSection)] -pub fn hero_section() -> Html { +pub fn hero_section(props: &HeroSectionProps) -> Html { + html! {
- realtor-banner-image + url, + None => "images/agent-banner.png".to_string() + }} alt="realtor-banner-image"/>
- realtor-pfp + realtor-pfp
- {"Brooklyn Simmons"} + {props.realtor.name.clone()}
- {"Agent"} + {"Director Regional Remax Metropolitana RD"}
- {"About me"} + {"Sobre mí"}
- {"Lorem ipsum dolor sit amet consectetur. Mauris sapien arcu ac quis eget sed nullam. Facilisi odio leo non lectus tincidunt orci dictum sed. Id vulputate maecenas scelerisque pellentesque rhoncus at ullamcorper."} + {props.realtor.bio.clone()}
diff --git a/src/components/page/results.rs b/src/components/page/results.rs index ae21dfe..9794dce 100644 --- a/src/components/page/results.rs +++ b/src/components/page/results.rs @@ -2,5 +2,10 @@ use yew::prelude::*; #[function_component(ResultsSection)] pub fn results_section() -> Html { - html! {} + + html! { +
+ +
+ } } diff --git a/src/pages/main_page.rs b/src/pages/main_page.rs index e77d021..ed96d35 100644 --- a/src/pages/main_page.rs +++ b/src/pages/main_page.rs @@ -1,18 +1,48 @@ +use std::str::FromStr; + +use uuid::Uuid; use yew::prelude::*; -use crate::components::{ +use crate::{components::{ footer::Footer, page::{ agency::AgencySection, contact::ContactSection, hero::HeroSection, results::ResultsSection, search::SearchSection, }, -}; +}, api::backend}; #[function_component(MainPage)] pub fn main_page() -> Html { + let realtor_id = Uuid::from_str("544eac57-a80d-457e-9ee8-7ec14b2bebd0").unwrap(); + let realtor_handle = use_state(|| None); + use_state(|| { + let realtor_handle = realtor_handle.clone(); + wasm_bindgen_futures::spawn_local(async move { + realtor_handle.set(match backend::get_realtor_profile(realtor_id).await { + Ok(realtor) => Some(realtor), + Err(error) => { + log::error!("Error getting realtor_handle: {error}"); + None + }, + }); + }); + }); + + html! {
- + { + if let Some(realtor) = (*realtor_handle).clone() { + html! { + + } + } else { + html! { + + } + } + } +