From e56424c9b36470dec326d2f561ed6a2dc6e82d07 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Fri, 6 May 2022 09:30:29 -0700 Subject: [PATCH] IO-1858 Email Groupings --- bodyshop_translations.babel | 42 +++++++++++++++ .../email-overlay/email-overlay.component.jsx | 12 ++++- .../shop-info/shop-info.general.component.jsx | 54 +++++++++++++++++++ client/src/graphql/bodyshop.queries.js | 2 + client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + hasura/metadata/tables.yaml | 2 + .../down.sql | 4 ++ .../up.sql | 2 + 10 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/down.sql create mode 100644 hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/up.sql diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index a7de63bcb..d03467a82 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -8927,6 +8927,48 @@ + + md_to_emails + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + md_to_emails_emails + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + messagingpresets false diff --git a/client/src/components/email-overlay/email-overlay.component.jsx b/client/src/components/email-overlay/email-overlay.component.jsx index baf52d376..0c7fefc78 100644 --- a/client/src/components/email-overlay/email-overlay.component.jsx +++ b/client/src/components/email-overlay/email-overlay.component.jsx @@ -42,7 +42,12 @@ export function EmailOverlayComponent({ const { t } = useTranslation(); const handleClick = ({ item, key, keyPath }) => { const email = item.props.value; - form.setFieldsValue({ to: _.uniq([...form.getFieldValue("to"), email]) }); + form.setFieldsValue({ + to: _.uniq([ + ...form.getFieldValue("to"), + ...(typeof email === "string" ? [email] : email), + ]), + }); }; const menu = ( @@ -55,6 +60,11 @@ export function EmailOverlayComponent({ {`${e.first_name} ${e.last_name}`} ))} + {bodyshop.md_to_emails.map((e, idx) => ( + + {e.label} + + ))} ); diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index 0eeb78d4a..92e99791b 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -1393,6 +1393,60 @@ export default function ShopInfoGeneral({ form }) { }} + + + {(fields, { add, remove, move }) => { + return ( + + {fields.map((field, index) => ( + + + + + + + + + + + { + remove(field.name); + }} + /> + + + + + ))} + + { + add(); + }} + style={{ width: "100%" }} + > + {t("general.actions.add")} + + + + ); + }} + + ); } diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index 26f3f72a0..045fe4278 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -106,6 +106,7 @@ export const QUERY_BODYSHOP = gql` last_name_first md_parts_order_comment bill_allow_post_to_closed + md_to_emails employees { user_email id @@ -209,6 +210,7 @@ export const UPDATE_SHOP = gql` last_name_first md_parts_order_comment bill_allow_post_to_closed + md_to_emails employees { id first_name diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index c57cb7cdb..713aeef22 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -544,6 +544,8 @@ "jobstatuses": "Job Statuses", "laborrates": "Labor Rates", "licensing": "Licensing", + "md_to_emails": "Preset To Emails", + "md_to_emails_emails": "Emails", "messagingpresets": "Messaging Presets", "notemplatesavailable": "No templates available to add.", "notespresets": "Notes Presets", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index ac51a720e..e02845ee7 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -544,6 +544,8 @@ "jobstatuses": "", "laborrates": "", "licensing": "", + "md_to_emails": "", + "md_to_emails_emails": "", "messagingpresets": "", "notemplatesavailable": "", "notespresets": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 945381bdd..8193fce89 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -544,6 +544,8 @@ "jobstatuses": "", "laborrates": "", "licensing": "", + "md_to_emails": "", + "md_to_emails_emails": "", "messagingpresets": "", "notemplatesavailable": "", "notespresets": "", diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 767c52081..709a33ec0 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -858,6 +858,7 @@ - md_referral_sources - md_responsibility_centers - md_ro_statuses + - md_to_emails - messagingservicesid - pbs_configuration - pbs_serialnumber @@ -944,6 +945,7 @@ - md_referral_sources - md_responsibility_centers - md_ro_statuses + - md_to_emails - pbs_configuration - phone - prodtargethrs diff --git a/hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/down.sql b/hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/down.sql new file mode 100644 index 000000000..1d189d5ae --- /dev/null +++ b/hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."bodyshops" add column "md_to_emails" jsonb +-- null default jsonb_build_array(); diff --git a/hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/up.sql b/hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/up.sql new file mode 100644 index 000000000..013e6a5f3 --- /dev/null +++ b/hasura/migrations/1651792938097_alter_table_public_bodyshops_add_column_md_to_emails/up.sql @@ -0,0 +1,2 @@ +alter table "public"."bodyshops" add column "md_to_emails" jsonb + null default jsonb_build_array();