From b7f9fffd61a2ed54d589432e79a819930cea92a2 Mon Sep 17 00:00:00 2001 From: Mendy Berger <12537668+MendyBerger@users.noreply.github.com> Date: Sun, 15 Sep 2024 13:43:20 -0400 Subject: [PATCH] Re-enable location (undo ed09ca85c) --- .../src/member_details/edit_about/dom.rs | 64 +++++++++---------- .../user/src/register/pages/step_2/actions.rs | 5 +- .../user/src/register/pages/step_2/dom.rs | 22 +++---- .../crates/entry/user/src/school_start/dom.rs | 34 +++++----- .../apps/crates/entry/user/src/strings.rs | 4 +- shared/rust/src/config.rs | 4 +- 6 files changed, 65 insertions(+), 68 deletions(-) diff --git a/frontend/apps/crates/entry/community/src/member_details/edit_about/dom.rs b/frontend/apps/crates/entry/community/src/member_details/edit_about/dom.rs index c14bd21299..1020dbc30d 100644 --- a/frontend/apps/crates/entry/community/src/member_details/edit_about/dom.rs +++ b/frontend/apps/crates/entry/community/src/member_details/edit_about/dom.rs @@ -8,11 +8,12 @@ use utils::{ component::Component, events, languages::{Language, JIG_LANGUAGES}, + unwrap::UnwrapJiExt, }; use web_sys::{HtmlInputElement, ShadowRoot}; pub const STR_HEADING: &str = "Edit your details"; -// pub const STR_LOCATION: &str = "Where I live"; +pub const STR_LOCATION: &str = "Where I live"; pub const STR_ORGANIZATION: &str = "Where I work"; pub const STR_PERSONA: &str = "What I do"; pub const STR_LANGUAGE: &str = "Language"; @@ -52,37 +53,36 @@ impl Component for Rc { .prop("slot", "body") .class("field-grid") .children(&mut [ - // TODO: Temporary disabled location to prevent usage of Places API - // html!("fa-icon", { - // .prop("icon", "fa-solid fa-location-dot") - // }), - // html!("input-wrapper", { - // .prop("slot", "location") - // .prop("label", STR_LOCATION) - // .child(html!("input-location", { - // .prop_signal("locationAsString", state.location.signal_cloned().map(|location| { - // location.unwrap_or_default() - // .as_str() - // .unwrap_or_default() - // .to_owned() - // })) - // .event(clone!(state => move |evt: events::GoogleLocation| { - // let raw = serde_json::to_value(evt.raw_json()).unwrap_ji(); - // state.location.set(Some(raw)); - // })) - // })) - // .child(html!("img-ui", { - // .prop("slot", "icon") - // .prop("path", "core/inputs/pencil-blue-darker.svg") - // })) - // }), - // html!("community-private-public-switch", { - // .prop("type", "checkbox") - // .prop_signal("isPublic", state.location_public.signal()) - // .event(clone!(state => move |evt: events::CustomToggle| { - // state.location_public.set_neq(evt.value()); - // })) - // }), + html!("fa-icon", { + .prop("icon", "fa-solid fa-location-dot") + }), + html!("input-wrapper", { + .prop("slot", "location") + .prop("label", STR_LOCATION) + .child(html!("input-location", { + .prop_signal("locationAsString", state.location.signal_cloned().map(|location| { + location.unwrap_or_default() + .as_str() + .unwrap_or_default() + .to_owned() + })) + .event(clone!(state => move |evt: events::GoogleLocation| { + let raw = serde_json::to_value(evt.raw_json()).unwrap_ji(); + state.location.set(Some(raw)); + })) + })) + .child(html!("img-ui", { + .prop("slot", "icon") + .prop("path", "core/inputs/pencil-blue-darker.svg") + })) + }), + html!("community-private-public-switch", { + .prop("type", "checkbox") + .prop_signal("isPublic", state.location_public.signal()) + .event(clone!(state => move |evt: events::CustomToggle| { + state.location_public.set_neq(evt.value()); + })) + }), html!("fa-icon", { .prop("icon", "fa-solid fa-briefcase") }), diff --git a/frontend/apps/crates/entry/user/src/register/pages/step_2/actions.rs b/frontend/apps/crates/entry/user/src/register/pages/step_2/actions.rs index a012353cf0..2aeef46144 100644 --- a/frontend/apps/crates/entry/user/src/register/pages/step_2/actions.rs +++ b/frontend/apps/crates/entry/user/src/register/pages/step_2/actions.rs @@ -21,10 +21,7 @@ pub fn submit(state: Rc) { }; state.location_error.set_neq(location_error); - // TODO: Temporary disabled location_error check to prevent usage of Places API - if !terms_error && !language_error && !persona_error - /* && !location_error */ - { + if !terms_error && !language_error && !persona_error && !location_error { next_step(state); } } diff --git a/frontend/apps/crates/entry/user/src/register/pages/step_2/dom.rs b/frontend/apps/crates/entry/user/src/register/pages/step_2/dom.rs index 2325a9ab02..856ba261c9 100644 --- a/frontend/apps/crates/entry/user/src/register/pages/step_2/dom.rs +++ b/frontend/apps/crates/entry/user/src/register/pages/step_2/dom.rs @@ -28,17 +28,17 @@ impl Step2Page { html!("page-register-step2", { .children(&mut [ - // html!("input-wrapper", { - // .prop("slot", "location") - // .prop("label", STR_LOCATION_LABEL) - // .prop_signal("error", state.location_error.signal()) - // .child(html!("input-location", { - // .prop("placeholder", STR_LOCATION_PLACEHOLDER) - // .event(clone!(state => move |evt:events::GoogleLocation| { - // *state.location_json.borrow_mut() = evt.raw_json(); - // })) - // })) - // }), + html!("input-wrapper", { + .prop("slot", "location") + .prop("label", STR_LOCATION_LABEL) + .prop_signal("error", state.location_error.signal()) + .child(html!("input-location", { + .prop("placeholder", STR_LOCATION_PLACEHOLDER) + .event(clone!(state => move |evt:events::GoogleLocation| { + *state.location_json.borrow_mut() = evt.raw_json(); + })) + })) + }), SimpleSelect::render_mixin( SimpleSelect::new( Some(STR_LANGUAGE_LABEL), diff --git a/frontend/apps/crates/entry/user/src/school_start/dom.rs b/frontend/apps/crates/entry/user/src/school_start/dom.rs index d8349ede01..2f3c8fc596 100644 --- a/frontend/apps/crates/entry/user/src/school_start/dom.rs +++ b/frontend/apps/crates/entry/user/src/school_start/dom.rs @@ -1,9 +1,10 @@ use super::state::SchoolStart; use const_format::formatcp; use dominator::{clone, html, with_node, DomBuilder}; +use futures_signals::signal::SignalExt; use shared::domain::billing::SCHOOL_TRIAL_PERIOD; use std::rc::Rc; -use utils::{component::Component, events}; +use utils::{component::Component, events, unwrap::UnwrapJiExt}; use web_sys::{HtmlInputElement, ShadowRoot}; impl Component for Rc { @@ -33,7 +34,6 @@ impl Component for Rc { .child(html!("div", { .class("inputs") .child(html!("input-wrapper", { - .style("grid-column", "span 2") // TODO Remove when enabling Places API again .prop("label", "School/Organization*") .child(html!("input" => HtmlInputElement, { .with_node!(elem => { @@ -45,21 +45,21 @@ impl Component for Rc { }) })) })) - // .child(html!("input-wrapper", { - // .prop("label", "Location") - // .child(html!("input-location", { - // .prop_signal("locationAsString", state.location.signal_cloned().map(|location| { - // location.unwrap_or_default() - // .as_str() - // .unwrap_or_default() - // .to_owned() - // })) - // .event(clone!(state => move |evt: events::GoogleLocation| { - // let raw = serde_json::to_value(evt.raw_json()).unwrap_ji(); - // state.location.set(Some(raw)); - // })) - // })) - // })) + .child(html!("input-wrapper", { + .prop("label", "Location") + .child(html!("input-location", { + .prop_signal("locationAsString", state.location.signal_cloned().map(|location| { + location.unwrap_or_default() + .as_str() + .unwrap_or_default() + .to_owned() + })) + .event(clone!(state => move |evt: events::GoogleLocation| { + let raw = serde_json::to_value(evt.raw_json()).unwrap_ji(); + state.location.set(Some(raw)); + })) + })) + })) })) .child(html!("button-rect", { .text("Continue") diff --git a/frontend/apps/crates/entry/user/src/strings.rs b/frontend/apps/crates/entry/user/src/strings.rs index 228691627e..58b958c991 100644 --- a/frontend/apps/crates/entry/user/src/strings.rs +++ b/frontend/apps/crates/entry/user/src/strings.rs @@ -23,8 +23,8 @@ pub mod register { } pub mod step_2 { - // pub const STR_LOCATION_LABEL: &str = "Location *"; - // pub const STR_LOCATION_PLACEHOLDER: &str = "City, State"; + pub const STR_LOCATION_LABEL: &str = "Location *"; + pub const STR_LOCATION_PLACEHOLDER: &str = "City, State"; pub const STR_PERSONA_LABEL: &str = "I am signing up as a... *"; pub const STR_ORGANIZATION_LABEL: &str = "School/Organization"; pub const STR_TERMS_LABEL_ONE: &str = "I have read and accept the "; diff --git a/shared/rust/src/config.rs b/shared/rust/src/config.rs index 49955aad18..804b8a115c 100644 --- a/shared/rust/src/config.rs +++ b/shared/rust/src/config.rs @@ -213,8 +213,8 @@ impl RemoteTarget { match self { // these are _apparently_ public? Self::Local - | Self::Sandbox => "https://maps.googleapis.com/maps/api/js?key=AIzaSyCtU4taX_GG36bXfZr98HSwZTBNYo9HS1I&libraries=places", - Self::Release => "https://maps.googleapis.com/maps/api/js?key=AIzaSyCU1HygSZgK4L3qPdRmrV-dTnS1GBBiqyE&libraries=places" + | Self::Sandbox => "https://maps.googleapis.com/maps/api/js?key=AIzaSyA_2bOsRAkYy6M5W-FgC66sSMs6xasYsRs&libraries=places", + Self::Release => "https://maps.googleapis.com/maps/api/js?key=AIzaSyACFIbFhygrinifRdlsg8Ig_ztm5LphlkY&libraries=places" } }