feature/IO-3182-Phone-Number-Consent - Checkpoint

This commit is contained in:
Dave Richer
2025-05-20 18:19:39 -04:00
parent 83860152a9
commit 7bd5190bf2
17 changed files with 772 additions and 320 deletions

View File

@@ -1,5 +1,5 @@
import { LoadingOutlined, SendOutlined } from "@ant-design/icons";
import { Input, Spin } from "antd";
import { Input, Spin, Alert } from "antd";
import React, { useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
@@ -31,12 +31,15 @@ function ChatSendMessageComponent({ conversation, bodyshop, sendMessage, isSendi
const [selectedMedia, setSelectedMedia] = useState([]);
const { t } = useTranslation();
const enforceConsent = bodyshop?.enforce_sms_consent ?? false;
const normalizedPhone = phone(conversation.phone_num, "CA").phoneNumber.replace(/^\+1/, "");
const { data: consentData } = useQuery(GET_PHONE_NUMBER_CONSENT, {
variables: { bodyshopid: bodyshop.id, phone_number: normalizedPhone },
fetchPolicy: "cache-and-network"
fetchPolicy: "cache-and-network",
skip: !enforceConsent
});
const isConsented = consentData?.phone_number_consent?.[0]?.consent_status ?? false;
const isConsented = enforceConsent ? (consentData?.phone_number_consent?.[0]?.consent_status ?? false) : true;
useEffect(() => {
inputArea.current.focus();
@@ -69,8 +72,8 @@ function ChatSendMessageComponent({ conversation, bodyshop, sendMessage, isSendi
return (
<div className="imex-flex-row" style={{ width: "100%" }}>
{!isConsented && (
<AlertComponent message={t("messaging.errors.no_consent")} type="warning" style={{ marginBottom: 8 }} />
{enforceConsent && !isConsented && (
<Alert message={t("messaging.errors.no_consent")} type="warning" style={{ marginBottom: 8 }} />
)}
<ChatPresetsComponent className="imex-flex-row__margin" />
<ChatMediaSelector