Skip to content

Commit

Permalink
Fix labels for CompleteOptionsInverted (#153)
Browse files Browse the repository at this point in the history
* Fix CompleteOptionsInverted

* Fix labels for CompleteOptionsInverted

* pretty

* rm console
  • Loading branch information
anotherminh authored Dec 18, 2023
1 parent 9b2cf7f commit c48ca30
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/transcend-io/consent-manager-ui.git"
},
"homepage": "https://github.com/transcend-io/consent-manager-ui",
"version": "4.11.0",
"version": "4.11.1",
"license": "MIT",
"main": "build/ui",
"files": [
Expand Down
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
16 changes: 15 additions & 1 deletion src/components/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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 +13,16 @@ 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 comment on commit c48ca30

@vercel
Copy link

@vercel vercel bot commented on c48ca30 Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.