Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix precommit #194

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/hooks/useGetInvertedPurposeMessageKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ export const useGetInvertedPurposeMessageKeys = ({
// the purpose type is unique for the bundle
[...Object.keys(consentSelection ?? {}), 'Essential'].reduce(
(allMessages, purposeType) => {
if (allMessages[purposeType]) {
return allMessages;
}
const purposeMessageLabel = `${PURPOSE_MESSAGE_PREFIX}.${purposeType}.title`;
return {
...allMessages,
[purposeType]: {
id: purposeMessageLabel,
defaultMessage: defaultPurposeToMessageKey[purposeType]?.defaultMessage
|| purposeType,
description: `Translatable name for purpose '${purposeType}'`,
} as DefinedMessage,
};
if (allMessages[purposeType]) {
return allMessages;
}
const purposeMessageLabel = `${PURPOSE_MESSAGE_PREFIX}.${purposeType}.title`;
return {
...allMessages,
[purposeType]: {
id: purposeMessageLabel,
defaultMessage:
defaultPurposeToMessageKey[purposeType]?.defaultMessage ||
purposeType,
description: `Translatable name for purpose '${purposeType}'`,
} as DefinedMessage,
};
},
defaultPurposeToMessageKey as Record<string, DefinedMessage>,
),
Expand Down
13 changes: 7 additions & 6 deletions src/hooks/useGetPurposeDescriptionKeys.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type {
TrackingPurposesTypes,
} from '@transcend-io/airgap.js-types';
import type { TrackingPurposesTypes } from '@transcend-io/airgap.js-types';

import { ConsentSelection } from '../types';

Expand All @@ -25,7 +23,8 @@ export const useGetPurposeDescriptionKeys = ({
const purposeToDescriptionKey: Record<string, DefinedMessage> = useMemo(
() =>
// hard-coding Essential since it's not provided by consentSelection
[...Object.keys(consentSelection ?? {}), 'Essential'].reduce((allMessages, purposeType) => {
[...Object.keys(consentSelection ?? {}), 'Essential'].reduce(
(allMessages, purposeType) => {
// making sure default message for Essential is not overwritten
// by missing Essential message from airgap
if (airgapPurposes[purposeType]?.description) {
Expand All @@ -39,8 +38,10 @@ export const useGetPurposeDescriptionKeys = ({
} as DefinedMessage,
};
}
return {...allMessages};
}, defaultPurposeToDescriptionKey as Record<string, DefinedMessage>),
return { ...allMessages };
},
defaultPurposeToDescriptionKey as Record<string, DefinedMessage>,
),
[consentSelection, defaultPurposeToDescriptionKey],
);

Expand Down
6 changes: 2 additions & 4 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,7 @@ export const purposeMessages = defineMessages('purpose.trackingType', {
},
'Functional.title': {
defaultMessage: 'Functional',
description:
'Text for functional purposes in CompleteOptions view state.',
description: 'Text for functional purposes in CompleteOptions view state.',
},
'Functional.description': {
defaultMessage: 'Personalization, autofilled forms, etc.',
Expand All @@ -487,8 +486,7 @@ export const purposeMessages = defineMessages('purpose.trackingType', {
},
'Advertising.title': {
defaultMessage: 'Advertising',
description:
'Text for advertising purposes in CompleteOptions view state.',
description: 'Text for advertising purposes in CompleteOptions view state.',
},
'Advertising.description': {
defaultMessage: 'Helps us and others serve ads relevant to you.',
Expand Down
Loading