Skip to content

Commit

Permalink
fix inverted
Browse files Browse the repository at this point in the history
  • Loading branch information
kate-kazantseva committed Oct 25, 2024
1 parent 29f1e8e commit 943ba5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/CompleteOptionsInverted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useGetPurposeMessageKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, DefinedMessage>;
/** Whether messages are for CompleteOptionsInverted */
inverted?: boolean;
}): Record<string, DefinedMessage> => {
const purposeToMessageKey: Record<string, DefinedMessage> = 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,
Expand All @@ -28,6 +32,8 @@ export const useGetPurposeMessageKeys = ({
description: `Translatable name for purpose '${purposeType}'`,
} as DefinedMessage,
};
}
return {...allMessages};
}, defaultPurposeToMessageKey as Record<string, DefinedMessage>),
[consentSelection, defaultPurposeToMessageKey],
);
Expand Down

0 comments on commit 943ba5c

Please sign in to comment.