Merged in feature/IO-3182-Phone-Number-Consent (pull request #2360)
feature/IO-3182-Phone-Number-Consent - Checkpoint
This commit is contained in:
@@ -32,15 +32,17 @@ function OwnerDetailFormContainer({ owner, refetch, bodyshop }) {
|
||||
// Fetch opt-out status on mount
|
||||
useEffect(() => {
|
||||
const fetchOptOutStatus = async () => {
|
||||
if (bodyshop?.id && (owner?.ownr_ph1 || owner?.ownr_ph2)) {
|
||||
if (bodyshop?.id && bodyshop?.messagingservicesid && (owner?.ownr_ph1 || owner?.ownr_ph2)) {
|
||||
const phoneNumbers = [owner.ownr_ph1, owner.ownr_ph2].filter(Boolean);
|
||||
const optOutSet = await phoneNumberOptOutService(apolloClient, bodyshop.id, phoneNumbers);
|
||||
setOptedOutPhones(optOutSet);
|
||||
} else {
|
||||
setOptedOutPhones(new Set());
|
||||
}
|
||||
};
|
||||
|
||||
fetchOptOutStatus();
|
||||
}, [apolloClient, bodyshop?.id, owner?.ownr_ph1, owner?.ownr_ph2]);
|
||||
}, [apolloClient, bodyshop?.id, bodyshop?.messagingservicesid, owner?.ownr_ph1, owner?.ownr_ph2]);
|
||||
|
||||
// Reset form fields when owner changes
|
||||
useEffect(() => {
|
||||
@@ -136,10 +138,14 @@ function OwnerDetailFormContainer({ owner, refetch, bodyshop }) {
|
||||
loading={loading}
|
||||
form={form}
|
||||
isPhone1OptedOut={
|
||||
owner?.ownr_ph1 && optedOutPhones.has(phone(owner.ownr_ph1, "CA").phoneNumber?.replace(/^\+1/, ""))
|
||||
bodyshop?.messagingservicesid &&
|
||||
owner?.ownr_ph1 &&
|
||||
optedOutPhones.has(phone(owner.ownr_ph1, "CA").phoneNumber?.replace(/^\+1/, ""))
|
||||
}
|
||||
isPhone2OptedOut={
|
||||
owner?.ownr_ph2 && optedOutPhones.has(phone(owner.ownr_ph2, "CA").phoneNumber?.replace(/^\+1/, ""))
|
||||
bodyshop?.messagingservicesid &&
|
||||
owner?.ownr_ph2 &&
|
||||
optedOutPhones.has(phone(owner.ownr_ph2, "CA").phoneNumber?.replace(/^\+1/, ""))
|
||||
}
|
||||
/>
|
||||
</Form>
|
||||
|
||||
Reference in New Issue
Block a user