Merged in feature/IO-3182-Phone-Number-Consent (pull request #2325)

Feature/IO-3182 Phone Number Consent
This commit is contained in:
Dave Richer
2025-05-21 19:17:52 +00:00
5 changed files with 29 additions and 12 deletions

View File

@@ -62,10 +62,7 @@ function ChatConversationListComponent({ conversationList, selectedConversation,
const renderConversation = (index, t) => {
const item = sortedConversationList[index];
const normalizedPhone = phone(item.phone_num, "CA").phoneNumber.replace(/^\+1/, "");
// Check if the phone number exists in the consentMap
const hasOptOutEntry = optOutMap.has(normalizedPhone);
// Only consider it non-consented if it exists and consent_status is false
const isOptedOut = hasOptOutEntry ? optOutMap.get(normalizedPhone) : true;
const cardContentRight = <TimeAgoFormatter>{item.updated_at}</TimeAgoFormatter>;
const cardContentLeft =
@@ -91,7 +88,7 @@ function ChatConversationListComponent({ conversationList, selectedConversation,
const cardExtra = (
<>
<Badge count={item.messages_aggregate.aggregate.count} />
{hasOptOutEntry && !isOptedOut && <Tag color="red">{t("messaging.labels.no_consent")}</Tag>}
{hasOptOutEntry && <Tag color="red">{t("messaging.labels.no_consent")}</Tag>}
</>
);

View File

@@ -39,9 +39,10 @@ function PhoneNumberConsentList({ bodyshop, currentUser }) {
sorter: (a, b) => a.phone_number.localeCompare(b.phone_number)
},
{
title: t("consent.updated_at"),
dataIndex: "consent_updated_at",
render: (text) => <TimeAgoFormatter>{text}</TimeAgoFormatter>
title: t("consent.created_at"),
dataIndex: "created_at",
render: (text) => <TimeAgoFormatter>{text}</TimeAgoFormatter>,
sorter: (a, b) => new Date(a.created_at) - new Date(b.created_at)
}
];
@@ -55,7 +56,7 @@ function PhoneNumberConsentList({ bodyshop, currentUser }) {
<Table
columns={columns}
dataSource={data?.phone_number_consent}
dataSource={data?.phone_number_opt_out}
loading={loading}
rowKey="id"
style={{ marginTop: 16 }}

View File

@@ -2,7 +2,7 @@ import { gql } from "@apollo/client";
export const GET_PHONE_NUMBER_OPT_OUT = gql`
query GET_PHONE_NUMBER_OPT_OUT($bodyshopid: uuid!, $phone_number: String!) {
phone_number_consent(where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _eq: $phone_number } }) {
phone_number_opt_out(where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _eq: $phone_number } }) {
id
bodyshopid
phone_number
@@ -14,9 +14,9 @@ export const GET_PHONE_NUMBER_OPT_OUT = gql`
export const GET_PHONE_NUMBER_OPT_OUTS = gql`
query GET_PHONE_NUMBER_OPT_OUTS($bodyshopid: uuid!, $search: String) {
phone_number_consent(
phone_number_opt_out(
where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _ilike: $search } }
order_by: [{ phone_number: asc }, { consent_updated_at: desc }]
order_by: [{ phone_number: asc }, { updated_at: desc }]
) {
id
bodyshopid

View File

@@ -3869,7 +3869,7 @@
"consent": {
"phone_number": "Phone Number",
"status": "Consent Status",
"updated_at": "Last Updated"
"created_at": "Created At"
},
"settings": {
"title": "Phone Number Opt-Out List"

View File

@@ -5868,6 +5868,25 @@
- name: bodyshop
using:
foreign_key_constraint_on: bodyshopid
select_permissions:
- role: user
permission:
columns:
- phone_number
- created_at
- updated_at
- bodyshopid
- id
filter:
bodyshop:
associations:
_and:
- user:
authid:
_eq: X-Hasura-User-Id
- active:
_eq: true
comment: ""
- table:
name: phonebook
schema: public