From 943ba5ced1f64bcfa424c5711e175452e4cb1d03 Mon Sep 17 00:00:00 2001 From: Kate Kazantseva <67483124+kate-kazantseva@users.noreply.github.com> Date: Fri, 25 Oct 2024 21:17:56 +0000 Subject: [PATCH] fix inverted --- src/components/CompleteOptionsInverted.tsx | 1 + src/hooks/useGetPurposeMessageKeys.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/components/CompleteOptionsInverted.tsx b/src/components/CompleteOptionsInverted.tsx index 6610c434..d6e263d7 100644 --- a/src/components/CompleteOptionsInverted.tsx +++ b/src/components/CompleteOptionsInverted.tsx @@ -39,6 +39,7 @@ export function CompleteOptionsInverted({ const purposeToMessageKey = useGetPurposeMessageKeys({ consentSelection: initialConsentSelections, defaultPurposeToMessageKey: DEFAULT_PURPOSE_TO_INVERTED_MESSAGE_KEY, + inverted: true, }); // Set state on the currently selected toggles diff --git a/src/hooks/useGetPurposeMessageKeys.ts b/src/hooks/useGetPurposeMessageKeys.ts index aeace54e..b62f4267 100644 --- a/src/hooks/useGetPurposeMessageKeys.ts +++ b/src/hooks/useGetPurposeMessageKeys.ts @@ -9,16 +9,20 @@ const PURPOSE_MESSAGE_PREFIX = 'purpose.trackingType'; export const useGetPurposeMessageKeys = ({ consentSelection, defaultPurposeToMessageKey, + inverted=false, }: { /** The configured airgap purpose types */ consentSelection: ConsentSelection; /** The lookup of messages for default purpose types */ defaultPurposeToMessageKey: Record; + /** Whether messages are for CompleteOptionsInverted */ + inverted?: boolean; }): Record => { const purposeToMessageKey: Record = useMemo( () => // the purpose type is unique for the bundle [...Object.keys(consentSelection ?? {}), 'Essential'].reduce((allMessages, purposeType) => { + if (!inverted) { const purposeMessageLabel = `${PURPOSE_MESSAGE_PREFIX}.${purposeType}.title`; return { ...allMessages, @@ -28,6 +32,8 @@ export const useGetPurposeMessageKeys = ({ description: `Translatable name for purpose '${purposeType}'`, } as DefinedMessage, }; + } + return {...allMessages}; }, defaultPurposeToMessageKey as Record), [consentSelection, defaultPurposeToMessageKey], );