From 84f41b2c1182fcf78bc9e5b3ecb10f37b318ff76 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Thu, 10 Apr 2025 12:27:54 -0400 Subject: [PATCH] feature/IO-3045-Product-Fruits-Tours-Modifications - Add in roles prop on Product fruits, tie the usage of it to a new db bodyshop var tours_enabled. --- client/src/App/App.jsx | 7 +++---- client/src/App/ProductFruitsWrapper.jsx | 18 ++++++++++++++---- client/src/graphql/bodyshop.queries.js | 2 ++ hasura/metadata/tables.yaml | 2 ++ .../down.sql | 4 ++++ .../up.sql | 2 ++ 6 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/down.sql create mode 100644 hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/up.sql diff --git a/client/src/App/App.jsx b/client/src/App/App.jsx index 1b26476ff..3cda7fe8e 100644 --- a/client/src/App/App.jsx +++ b/client/src/App/App.jsx @@ -142,11 +142,10 @@ export function App({ bodyshop, checkUserSession, currentUser, online, setOnline > + { + const featureProps = bodyshop?.features + ? Object.entries(bodyshop.features).reduce((acc, [key, value]) => { + acc[key] = value === true || (typeof value === "string" && dayjs(value).isAfter(dayjs())); + return acc; + }, {}) + : {}; -const ProductFruitsWrapper = React.memo(({ currentUser, workspaceCode }) => { return ( workspaceCode && currentUser?.authorized === true && @@ -14,7 +22,8 @@ const ProductFruitsWrapper = React.memo(({ currentUser, workspaceCode }) => { language="en" user={{ email: currentUser.email, - username: currentUser.email + username: currentUser.email, + props: featureProps }} /> ) @@ -28,5 +37,6 @@ ProductFruitsWrapper.propTypes = { authorized: PropTypes.bool, email: PropTypes.string }), - workspaceCode: PropTypes.string + workspaceCode: PropTypes.string, + bodyshop: PropTypes.object }; diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index 32a93980f..59651017d 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -57,6 +57,7 @@ export const QUERY_BODYSHOP = gql` logo_img_path md_ro_statuses md_order_statuses + tours_enabled md_functionality_toggles shopname state @@ -186,6 +187,7 @@ export const UPDATE_SHOP = gql` phone federal_tax_id id + tours_enabled insurance_vendor_id logo_img_path md_ro_statuses diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 4d1f5192e..e783e3935 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -965,6 +965,7 @@ - insurance_vendor_id - intakechecklist - intellipay_config + - intellipay_merchant_id - jc_hourly_rates - jobsizelimit - last_name_first @@ -1023,6 +1024,7 @@ - template_header - textid - timezone + - tours_enabled - tt_allow_post_to_invoiced - tt_enforce_hours_for_tech_console - updated_at diff --git a/hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/down.sql b/hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/down.sql new file mode 100644 index 000000000..9cc955aae --- /dev/null +++ b/hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/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 "tours_enabled" boolean +-- not null default 'true'; diff --git a/hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/up.sql b/hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/up.sql new file mode 100644 index 000000000..edf9c83e2 --- /dev/null +++ b/hasura/migrations/1744302073757_alter_table_public_bodyshops_add_column_tours_enabled/up.sql @@ -0,0 +1,2 @@ +alter table "public"."bodyshops" add column "tours_enabled" boolean + not null default 'true';