Skip to content

Commit

Permalink
fix: avoid using auth provider name in components
Browse files Browse the repository at this point in the history
  • Loading branch information
mirovladimitrovski committed Jul 13, 2023
1 parent 411d0dd commit 1a8a70c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/services/cleeng.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const getPublisherConsents: GetPublisherConsents = async (config) => {
const consents = ((response?.responseData?.consents || []) as CleengConsent[]).map(
(cleengConsent): Consent => ({
type: REGISTER_FIELD_VARIANT.CHECKBOX,
provider: 'cleeng',
isCustomRegisterField: false,
defaultValue: cleengConsent.enabledByDefault,
name: cleengConsent.name,
label: cleengConsent.label,
Expand Down
4 changes: 2 additions & 2 deletions src/services/inplayer.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const getPublisherConsents: GetPublisherConsents = async (config) => {
.map(
(field): Consent => ({
type: field.type as ConsentFieldVariants,
provider: 'jwp',
isCustomRegisterField: true,
defaultValue: field.type === REGISTER_FIELD_VARIANT.CHECKBOX ? field.default_value === 'true' : field.default_value,
name: field.name,
label: field.label,
Expand Down Expand Up @@ -479,7 +479,7 @@ function getTermsConsent(): Consent {

return {
type: REGISTER_FIELD_VARIANT.CHECKBOX,
provider: 'jwp',
isCustomRegisterField: true,
required: true,
name: 'terms',
label: i18next.t('account:registration.terms_consent', { termsUrl }),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const formatConsentValues = (publisherConsents: Consent[] | null = [], customerC
const consent = customerConsents?.find((customerConsent) => customerConsent.name === publisherConsent.name);

if (consent) {
const value = publisherConsent.provider === 'cleeng' ? consent.state === 'accepted' : consent.value ?? '';
const value = publisherConsent.isCustomRegisterField ? consent.value ?? '' : consent.state === 'accepted';
values[publisherConsent.name] = value;
}
});
Expand Down
4 changes: 1 addition & 3 deletions types/account.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,11 @@ export type UpdateCustomerArgs = {
fullName?: string;
};

export type ConsentProvider = 'cleeng' | 'jwp';

export type ConsentFieldVariants = 'input' | 'select' | 'country' | 'us_state' | 'radio' | 'checkbox' | 'datepicker';

export interface Consent {
type: ConsentFieldVariantss;
provider: ConsentProvider;
isCustomRegisterField: boolean;
defaultValue: string | boolean;
name: string;
label: string;
Expand Down

0 comments on commit 1a8a70c

Please sign in to comment.