-
Notifications
You must be signed in to change notification settings - Fork 77
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
TCF modal display data #3879
TCF modal display data #3879
Changes from 11 commits
503c138
734217d
e2333c8
b6e2e0a
b46b2f8
b7f327d
e570b3b
7e5e323
eb39c18
203fe4f
f9a7154
09e17ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ const Toggle = ({ | |
onChange={() => { | ||
onChange(id); | ||
}} | ||
defaultChecked={checked} | ||
checked={checked} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is kind of a weird thing, but it turns out |
||
role="switch" | ||
aria-labelledby={labelId} | ||
disabled={disabled} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { h } from "preact"; | ||
|
||
import { PrivacyExperience } from "../../lib/consent-types"; | ||
import { ConsentButtons } from "../ConsentButtons"; | ||
import type { EnabledIds } from "./TcfOverlay"; | ||
import { | ||
TCFPurposeRecord, | ||
TCFFeatureRecord, | ||
TCFVendorRecord, | ||
} from "../../lib/tcf/types"; | ||
|
||
interface TcfConsentButtonProps { | ||
experience: PrivacyExperience; | ||
onManagePreferencesClick?: () => void; | ||
onSave: (keys: EnabledIds) => void; | ||
enabledKeys: EnabledIds; | ||
isInModal?: boolean; | ||
} | ||
|
||
const getAllIds = ( | ||
modelList: | ||
| TCFPurposeRecord[] | ||
| TCFFeatureRecord[] | ||
| TCFVendorRecord[] | ||
| undefined | ||
) => { | ||
if (!modelList) { | ||
return []; | ||
} | ||
return modelList.map((m) => `${m.id}`); | ||
}; | ||
|
||
export const TcfConsentButtons = ({ | ||
experience, | ||
onManagePreferencesClick, | ||
onSave, | ||
enabledKeys, | ||
isInModal, | ||
}: TcfConsentButtonProps) => { | ||
if (!experience.experience_config) { | ||
return null; | ||
} | ||
|
||
const handleAcceptAll = () => { | ||
const allIds: EnabledIds = { | ||
purposes: getAllIds(experience.tcf_purposes), | ||
specialPurposes: getAllIds(experience.tcf_special_purposes), | ||
features: getAllIds(experience.tcf_features), | ||
specialFeatures: getAllIds(experience.tcf_special_features), | ||
vendors: getAllIds(experience.tcf_vendors), | ||
}; | ||
onSave(allIds); | ||
}; | ||
const handleRejectAll = () => { | ||
const emptyIds: EnabledIds = { | ||
purposes: [], | ||
specialPurposes: [], | ||
features: [], | ||
specialFeatures: [], | ||
vendors: [], | ||
}; | ||
onSave(emptyIds); | ||
}; | ||
|
||
const handleSave = () => { | ||
onSave(enabledKeys); | ||
}; | ||
|
||
return ( | ||
<ConsentButtons | ||
experienceConfig={experience.experience_config} | ||
onManagePreferencesClick={onManagePreferencesClick} | ||
onSave={handleSave} | ||
onAcceptAll={handleAcceptAll} | ||
onRejectAll={handleRejectAll} | ||
isInModal={isInModal} | ||
/> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved this to its own file