Skip to content

Commit

Permalink
Fix CompleteOptionsInverted
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherminh committed Dec 18, 2023
1 parent 9b2cf7f commit 2274bbd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/components/CompleteOptionsInverted.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import { Button } from './Button';
import { GPCIndicator } from './GPCIndicator';
import { Toggle } from './Toggle';
import { CONSENT_OPTIONS } from '../constants';
import { DEFAULT_PURPOSE_TO_MESSAGE_KEY, ORDER_OF_PURPOSES } from './constants';
import {
DEFAULT_PURPOSE_TO_INVERTED_MESSAGE_KEY,
ORDER_OF_PURPOSES,
} from './constants';

/**
* The model view where checking each checkbox represents an opt otu
Expand All @@ -31,7 +34,7 @@ export function CompleteOptionsInverted({
const initialConsentSelections = getConsentSelections(airgap);
const purposeToMessageKey = useGetPurposeMessageKeys({
consentSelection: initialConsentSelections,
defaultPurposeToMessageKey: DEFAULT_PURPOSE_TO_MESSAGE_KEY,
defaultPurposeToMessageKey: DEFAULT_PURPOSE_TO_INVERTED_MESSAGE_KEY,
});

// Set state on the currently selected toggles
Expand Down
10 changes: 9 additions & 1 deletion src/components/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DefinedMessage } from '@transcend-io/internationalization';
import { completeOptionsMessages } from '../messages';
import { completeOptionsMessages, completeOptionsInvertedMessages } from '../messages';

// Mapping of purposes to the message translation key
export const DEFAULT_PURPOSE_TO_MESSAGE_KEY: Record<string, DefinedMessage> = {
Expand All @@ -10,5 +10,13 @@ export const DEFAULT_PURPOSE_TO_MESSAGE_KEY: Record<string, DefinedMessage> = {
SaleOfInfo: completeOptionsMessages.saleOfInfoLabel,
};

export const DEFAULT_PURPOSE_TO_INVERTED_MESSAGE_KEY: Record<string, DefinedMessage> = {
Essential: completeOptionsMessages.essentialLabel,
Functional: completeOptionsInvertedMessages.functionalLabel,
Analytics: completeOptionsInvertedMessages.analyticsLabel,
Advertising: completeOptionsInvertedMessages.advertisingLabel,
SaleOfInfo: completeOptionsInvertedMessages.saleOfInfoLabel,
};

// Encode the default purpose ordering
export const ORDER_OF_PURPOSES = Object.keys(DEFAULT_PURPOSE_TO_MESSAGE_KEY);
1 change: 1 addition & 0 deletions src/hooks/useGetPurposeMessageKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const useGetPurposeMessageKeys = ({
}, defaultPurposeToMessageKey as Record<string, DefinedMessage>),
[consentSelection, defaultPurposeToMessageKey],
);
console.log({ purposeToMessageKey })

return purposeToMessageKey;
};

0 comments on commit 2274bbd

Please sign in to comment.