+
{t("settings.title")}
+
+ {t("settings.enforce_sms_consent")}
+
+ updateEnforceConsent({
+ variables: { id: bodyshop.id, enforce_sms_consent: checked },
+ optimisticResponse: {
+ update_bodyshops_by_pk: {
+ __typename: "bodyshops",
+ id: bodyshop.id,
+ enforce_sms_consent: checked
+ }
+ }
+ })
+ }
+ />
+
+
+
+ );
+}
+
+export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoConsentComponent);
diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js
index 7faff13a2..af16899cf 100644
--- a/client/src/graphql/bodyshop.queries.js
+++ b/client/src/graphql/bodyshop.queries.js
@@ -142,6 +142,7 @@ export const QUERY_BODYSHOP = gql`
intellipay_config
md_ro_guard
notification_followers
+ enforce_sms_consent
employee_teams(order_by: { name: asc }, where: { active: { _eq: true } }) {
id
name
@@ -363,3 +364,12 @@ export const GET_ACTIVE_EMPLOYEES_IN_SHOP = gql`
}
}
`;
+
+export const UPDATE_BODYSHOP_ENFORCE_CONSENT = gql`
+ mutation UPDATE_BODYSHOP_ENFORCE_CONSENT($id: uuid!, $enforce_sms_consent: Boolean!) {
+ update_bodyshops_by_pk(pk_columns: { id: $id }, _set: { enforce_sms_consent: $enforce_sms_consent }) {
+ id
+ enforce_sms_consent
+ }
+ }
+`;
diff --git a/client/src/graphql/consent.queries.js b/client/src/graphql/consent.queries.js
new file mode 100644
index 000000000..8a3f78c8f
--- /dev/null
+++ b/client/src/graphql/consent.queries.js
@@ -0,0 +1,90 @@
+import { gql } from "@apollo/client";
+
+export const GET_PHONE_NUMBER_CONSENT = gql`
+ query GET_PHONE_NUMBER_CONSENT($bodyshopid: uuid!, $phone_number: String!) {
+ phone_number_consent(where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _eq: $phone_number } }) {
+ id
+ bodyshopid
+ phone_number
+ consent_status
+ created_at
+ updated_at
+ consent_updated_at
+ history(order_by: { changed_at: desc }, limit: 1) {
+ reason
+ }
+ }
+ }
+`;
+
+export const GET_PHONE_NUMBER_CONSENTS = gql`
+ query GET_PHONE_NUMBER_CONSENTS($bodyshopid: uuid!, $phone_numbers: [String!]) {
+ phone_number_consent(
+ where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _in: $phone_numbers } }
+ order_by: { consent_updated_at: desc }
+ ) {
+ id
+ bodyshopid
+ phone_number
+ consent_status
+ created_at
+ updated_at
+ consent_updated_at
+ history(order_by: { changed_at: desc }, limit: 1) {
+ reason
+ }
+ }
+ }
+`;
+
+export const SET_PHONE_NUMBER_CONSENT = gql`
+ mutation SET_PHONE_NUMBER_CONSENT(
+ $bodyshopid: uuid!
+ $phone_number: String!
+ $consent_status: Boolean!
+ $reason: String!
+ $changed_by: String!
+ ) {
+ insert_phone_number_consent_one(
+ object: {
+ bodyshopid: $bodyshopid
+ phone_number: $phone_number
+ consent_status: $consent_status
+ consent_updated_at: "now()"
+ }
+ on_conflict: {
+ constraint: phone_number_consent_bodyshopid_phone_number_key
+ update_columns: [consent_status, consent_updated_at]
+ }
+ ) {
+ id
+ bodyshopid
+ phone_number
+ consent_status
+ created_at
+ updated_at
+ consent_updated_at
+ }
+ }
+`;
+
+export const BULK_SET_PHONE_NUMBER_CONSENT = gql`
+ mutation BULK_SET_PHONE_NUMBER_CONSENT($objects: [phone_number_consent_insert_input!]!) {
+ insert_phone_number_consent(
+ objects: $objects
+ on_conflict: {
+ constraint: phone_number_consent_bodyshopid_phone_number_key
+ update_columns: [consent_status, consent_updated_at]
+ }
+ ) {
+ affected_rows
+ returning {
+ id
+ bodyshopid
+ phone_number
+ consent_status
+ consent_updated_at
+ }
+ }
+ }
+`;
diff --git a/client/src/pages/shop/shop.page.component.jsx b/client/src/pages/shop/shop.page.component.jsx
index b4b354b1d..b6ded16f6 100644
--- a/client/src/pages/shop/shop.page.component.jsx
+++ b/client/src/pages/shop/shop.page.component.jsx
@@ -10,10 +10,10 @@ import ShopCsiConfig from "../../components/shop-csi-config/shop-csi-config.comp
import ShopEmployeesContainer from "../../components/shop-employees/shop-employees.container";
import ShopInfoContainer from "../../components/shop-info/shop-info.container";
import ShopInfoUsersComponent from "../../components/shop-users/shop-users.component";
+import ShopInfoConsentComponent from "../../components/shop-info/shop-info.consent.component";
import { setBreadcrumbs, setSelectedHeader } from "../../redux/application/application.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import InstanceRenderManager from "../../utils/instanceRenderMgr";
-
import { HasFeatureAccess } from "../../components/feature-wrapper/feature-wrapper.component";
import ShopTeamsContainer from "../../components/shop-teams/shop-teams.container";
@@ -91,6 +91,14 @@ export function ShopPage({ bodyshop, setSelectedHeader, setBreadcrumbs }) {
children: