-
Notifications
You must be signed in to change notification settings - Fork 483
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
P20-119: Add pre-lockdown parental permission banner #58434
Merged
Merged
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
35954d5
P20-57: Add pre-lockdown parent permission modal
artem-vavilov 90cd18e
P20-57: Hide the modal behind CPA experience `cpa_all_user_lockout_wa…
artem-vavilov 5a6fd0c
P20-57: Display modal when parent permission is not requested
artem-vavilov a6d42ee
P20-57: Use `ChildAccount` namespace
artem-vavilov eda3c1f
P20-57: Rename reducer
artem-vavilov 117349e
P20-57: Add param `show_pre_lockdown_parent_permission_modal` to forc…
artem-vavilov 6558300
P20-57: Add i18n corrections
artem-vavilov 8451021
P20-57: Replace promises with async/await in reducer
artem-vavilov 854f205
P20-57: Rename component
artem-vavilov fa4e836
P20-57: Small fix
artem-vavilov d552e10
Merge remote-tracking branch 'origin' into P20-57/pre-lockdown-parren…
artem-vavilov 33fd338
P20-57: Fix currentLocale
artem-vavilov 36ce9b1
P20-57: Fix apps/src/util/locale-do-not-import.js
artem-vavilov 1b9b01c
P20-57: Sort i18n strings alphabetically
artem-vavilov dd2dea5
P20-57: Fix `Cpa.cpa_experience` desc
artem-vavilov 84d4e4a
P20-57: Improve component file structure
artem-vavilov 1d4c211
Merge remote-tracking branch 'origin' into P20-57/pre-lockdown-parren…
artem-vavilov 34a931d
P20-119: Add pre-lockdown parental permission banner
artem-vavilov 854da70
P20-119: Replace `Date()` with `new Date().toISOString()`
artem-vavilov 8567fc1
P20-119: Add colors prop to `Notification` component
artem-vavilov d27ca22
P20-119: Fix component stories
artem-vavilov 37c0077
Merge remote-tracking branch 'origin' into P20-119/parental-permissio…
artem-vavilov cb3a568
P20-119: Report events to Amplitude instead of Statsig
artem-vavilov 0e74324
P20-119: Report banner shown event
artem-vavilov eb58bb2
P20-119: Report inSection to Amplitude
artem-vavilov 76eb2be
P20-119: Render banner only when user is signed in
artem-vavilov 43bced6
P20-119: Fix Policies::ChildAccountTest
artem-vavilov 814c865
Merge remote-tracking branch 'origin' into P20-119/parental-permissio…
artem-vavilov eb83640
P20-119: Fix Unit page
artem-vavilov 61e5047
P20-119: Fix lint complaints
artem-vavilov 6c80476
Merge remote-tracking branch 'origin' into P20-119/parental-permissio…
artem-vavilov 8c6449b
P20-119: Fix typos
artem-vavilov 1a0b25c
P20-119: Fix banner data on script page
artem-vavilov 40862e5
P20-119: Fix tests for `Policies::ChildAccount.user_predates_policy?`
artem-vavilov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
apps/src/sites/studio/pages/policy_compliance/parental_permission/_banner.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import {Provider} from 'react-redux'; | ||
|
||
import {getStore} from '@cdo/apps/redux'; | ||
import getScriptData from '@cdo/apps/util/getScriptData'; | ||
import ParentalPermissionBanner from '@cdo/apps/templates/policy_compliance/ParentalPermissionBanner'; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
ReactDOM.render( | ||
<Provider store={getStore()}> | ||
<ParentalPermissionBanner lockoutDate={getScriptData('lockoutDate')} /> | ||
</Provider>, | ||
document.getElementById('parental-permission-banner-container') | ||
); | ||
}); |
46 changes: 43 additions & 3 deletions
46
apps/src/sites/studio/pages/policy_compliance/parental_permission/_modal.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,60 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import moment from 'moment'; | ||
|
||
import {tryGetLocalStorage, trySetLocalStorage} from '@cdo/apps/utils'; | ||
import getScriptData from '@cdo/apps/util/getScriptData'; | ||
import ParentalPermissionModal from '@cdo/apps/templates/policy_compliance/ParentalPermissionModal'; | ||
import analyticsReporter from '@cdo/apps/lib/util/AnalyticsReporter'; | ||
import {EVENTS, PLATFORMS} from '@cdo/apps/lib/util/AnalyticsConstants'; | ||
|
||
const SHOW_DELAY = 86400; // 1 day | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const renderModal = () => { | ||
const lockoutDate = new Date(getScriptData('lockoutDate')); | ||
const inSection = getScriptData('inSection'); | ||
|
||
const reportEvent = (eventName, payload = {}) => { | ||
payload.isSection = inSection; | ||
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. is this supposed to be |
||
analyticsReporter.sendEvent(eventName, payload, PLATFORMS.AMPLITUDE); | ||
}; | ||
|
||
const handleClose = () => { | ||
reportEvent(EVENTS.CPA_PARENT_EMAIL_MODAL_CLOSED); | ||
}; | ||
|
||
const handleSubmit = parentalPermissionRequest => { | ||
reportEvent(EVENTS.CPA_PARENT_EMAIL_MODAL_SUBMITTED, { | ||
consentStatus: parentalPermissionRequest.consent_status, | ||
}); | ||
}; | ||
|
||
return ReactDOM.render( | ||
<ParentalPermissionModal lockoutDate={lockoutDate} />, | ||
const handleResend = (prevPPR, PPR) => { | ||
reportEvent(EVENTS.CPA_PARENT_EMAIL_MODAL_RESEND, { | ||
oldConsentStatus: prevPPR.consent_status, | ||
newConsentStatus: PPR.consent_status, | ||
}); | ||
}; | ||
|
||
const handleUpdate = (prevPPR, PPR) => { | ||
reportEvent(EVENTS.CPA_PARENT_EMAIL_MODAL_UPDATED, { | ||
oldConsentStatus: prevPPR.consent_status, | ||
newConsentStatus: PPR.consent_status, | ||
}); | ||
}; | ||
|
||
ReactDOM.render( | ||
<ParentalPermissionModal | ||
lockoutDate={getScriptData('lockoutDate')} | ||
onClose={handleClose} | ||
onSubmit={handleSubmit} | ||
onResend={handleResend} | ||
onUpdate={handleUpdate} | ||
/>, | ||
document.getElementById('parental-permission-modal-container') | ||
); | ||
|
||
reportEvent(EVENTS.CPA_PARENT_EMAIL_MODAL_SHOWN); | ||
}; | ||
|
||
if (getScriptData('forceDisplay')) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
apps/src/templates/policy_compliance/ParentalPermissionBanner/index.story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {Meta, StoryFn} from '@storybook/react'; | ||
import React from 'react'; | ||
import {Provider} from 'react-redux'; | ||
import sinon from 'sinon'; | ||
|
||
import {getStore, registerReducers} from '@cdo/apps/redux'; | ||
import currentUser, { | ||
setInitialData, | ||
} from '@cdo/apps/templates/currentUserRedux'; | ||
|
||
import ParentalPermissionBanner from '.'; | ||
|
||
const store = getStore(); | ||
registerReducers({currentUser}); | ||
store.dispatch( | ||
setInitialData({ | ||
id: 1, | ||
childAccountComplianceState: 's', | ||
}) | ||
); | ||
|
||
export default { | ||
component: ParentalPermissionBanner, | ||
decorators: [ | ||
(Story: StoryFn) => ( | ||
<Provider store={store}> | ||
<Story /> | ||
</Provider> | ||
), | ||
], | ||
} as Meta; | ||
|
||
const spy = sinon.spy(); | ||
export const Default = () => { | ||
const state = { | ||
parentalPermissionRequest: null, | ||
}; | ||
|
||
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
React.useReducer.restore && React.useReducer.restore(); | ||
sinon.stub(React, 'useReducer').returns([state, spy]); | ||
|
||
return <ParentalPermissionBanner lockoutDate={new Date().toISOString()} />; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
two subtle typos in the key:
parental-permission-banner