From 5b55a20afaccd1a4f0a5bf5e399ebed458054016 Mon Sep 17 00:00:00 2001 From: Franklin Date: Fri, 14 Apr 2023 10:38:11 -0400 Subject: [PATCH] Added real data to agent section in details page, finished floating whatsapp widget --- Readme.md | 3 ++- css/components/floating_widget.css | 1 + src/components/floating_widget.rs | 13 +++++++++---- src/pages/details.rs | 19 +++++++++++++++---- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/Readme.md b/Readme.md index c767205..644aad9 100644 --- a/Readme.md +++ b/Readme.md @@ -23,4 +23,5 @@ - [x] Make the navbar logo bigger - [x] Finish agents screen - [ ] Finish Contact us screen -- [ ] Link agent info with details screen, remove hardcoded pic and details \ No newline at end of file +- [ ] Link agent info with details screen, remove hardcoded pic and details +- [ ] Whatsapp button should direct to agent's phone number wa.me link \ No newline at end of file diff --git a/css/components/floating_widget.css b/css/components/floating_widget.css index 0fc6a3e..c77cc58 100644 --- a/css/components/floating_widget.css +++ b/css/components/floating_widget.css @@ -10,6 +10,7 @@ background-color: #25D366; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); font-size: 45px; + text-decoration: none; } .floating-widget-container:hover { diff --git a/src/components/floating_widget.rs b/src/components/floating_widget.rs index 42de77d..8332eaf 100644 --- a/src/components/floating_widget.rs +++ b/src/components/floating_widget.rs @@ -1,18 +1,23 @@ +use uuid::Uuid; use yew::prelude::*; //TODO: Finish, add whatsapp link or email link? #[function_component(FloatingWidget)] -pub fn floating_widget(_props: &FloatingWidgetProps) -> Html { +pub fn floating_widget(props: &FloatingWidgetProps) -> Html { + let message = format!("Buenas, me interesa conocer mas sobre esta propiedad: %0A https://proyectosenconstruccion.com/details/{}", props.project_id); + let number = format!("1{}", props.phone_number); + let wa_me_url = format!("https://wa.me/{number}/?text={message}"); html! { -
+
-
+ } } #[derive(Properties, PartialEq)] pub struct FloatingWidgetProps { - + pub project_id: Uuid, + pub phone_number: String, } \ No newline at end of file diff --git a/src/pages/details.rs b/src/pages/details.rs index 2cafd3e..60b8a88 100644 --- a/src/pages/details.rs +++ b/src/pages/details.rs @@ -54,7 +54,7 @@ pub fn details_page(props: &DetailsPageProps) -> Html { html!{ <> - +
{ if *finished_loading { @@ -67,11 +67,13 @@ pub fn details_page(props: &DetailsPageProps) -> Html { // Agent
// Profile pic - {"agent_pfp"}/ + {"agent_pfp"}/
-
{"Vendido por Luis Jose"}
-
{"(809)-123-4567"}
+
{listing.agent.full_name}
+
{ + format_phone_number(&listing.agent.credential) + }
@@ -221,6 +223,15 @@ pub struct DetailsPageProps { pub project_id: Uuid } +pub fn format_phone_number<'a>(phone_number: &'a String) -> String { + if phone_number.len() <= 11 && phone_number.len() >= 10 { + let (first_part, after_first) = phone_number.split_at(3); + let (second_part, last_part) = after_first.split_at(3); + format!("({})-{}-{}", first_part, second_part, last_part) + } else { + phone_number.clone() + } +} pub fn create_unit_selection_menu(units: &Vec<&Unit>, selected_unit_handle: UseStateHandle) -> Html {