-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(onboarding): save TOS acceptance on CONTINUE button
- Loading branch information
1 parent
2d78982
commit b414fea
Showing
10 changed files
with
125 additions
and
62 deletions.
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
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,14 @@ | ||
import React from 'react'; | ||
import { ExternalLink } from 'components/atoms'; | ||
import TOSText from './TOSText'; | ||
|
||
const TOSAlreadyAccepted = () => ( | ||
<TOSText> | ||
Vous avez accepté les{' '} | ||
<ExternalLink href="https://www.bulles.fr/cgu"> | ||
conditions générales d'utilisation (CGU) | ||
</ExternalLink> | ||
</TOSText> | ||
); | ||
|
||
export default TOSAlreadyAccepted; |
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,42 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { ExternalLink } from 'components/atoms'; | ||
|
||
const TOSForm = styled.form` | ||
display: flex; | ||
align-items: center; | ||
font-size: 20px; | ||
[type='checkbox'] { | ||
align-self: baseline; | ||
} | ||
label { | ||
margin-left: 12px; | ||
} | ||
`; | ||
|
||
interface Props { | ||
onChange: (checked: boolean) => void; | ||
checked: boolean; | ||
} | ||
|
||
const TOSCheckbox = ({ onChange, checked }: Props) => ( | ||
<TOSForm> | ||
<input | ||
type="checkbox" | ||
id="tos" | ||
onChange={event => onChange(event.target.checked)} | ||
checked={checked} | ||
/> | ||
<label htmlFor="tos"> | ||
J'ai lu et j'accepte les nouvelles{' '} | ||
<ExternalLink href="https://www.bulles.fr/cgu"> | ||
conditions générales d'utilisation (CGU) | ||
</ExternalLink> | ||
. | ||
</label> | ||
</TOSForm> | ||
); | ||
|
||
export default TOSCheckbox; |
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,7 @@ | ||
import styled from 'styled-components'; | ||
|
||
const TOSText = styled.p` | ||
font-size: 18px; | ||
`; | ||
|
||
export default TOSText; |
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
22 changes: 22 additions & 0 deletions
22
src/app/options/store/reducers/tosAccepted.reducer.spec.ts
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,22 @@ | ||
/* eslint-disable no-unused-expressions, @typescript-eslint/ban-ts-ignore */ | ||
import { expect } from 'chai'; | ||
import { tosAccepted, transmitTosStatus } from 'app/actions'; | ||
import tosAcceptedReducer from './tosAccepted.reducer'; | ||
|
||
describe('options > reducers > tosAccepted', function() { | ||
// @ts-ignore | ||
const initialState = tosAcceptedReducer(undefined, { type: 'UNKNOWN' }); | ||
|
||
it('is false initially', () => { | ||
expect(initialState).to.be.false; | ||
}); | ||
it('saves true on TOS_ACCEPTED', () => { | ||
expect(tosAcceptedReducer(initialState, tosAccepted({}))).to.be.true; | ||
}); | ||
it('saves given value on TRANSMIT_TOS_STATUS', () => { | ||
expect(tosAcceptedReducer(initialState, transmitTosStatus(false))).to.be | ||
.false; | ||
expect(tosAcceptedReducer(initialState, transmitTosStatus(true))).to.be | ||
.true; | ||
}); | ||
}); |
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,13 +1,17 @@ | ||
import { AppAction } from 'app/actions'; | ||
import { AppAction, TRANSMIT_TOS_STATUS } from 'app/actions'; | ||
|
||
export type TosAcceptedState = boolean; | ||
|
||
export default ( | ||
state: TosAcceptedState = false, | ||
action: AppAction | ||
): TosAcceptedState => { | ||
if (action.type === 'TOS_ACCEPTED') { | ||
return true; | ||
switch (action.type) { | ||
case 'TOS_ACCEPTED': | ||
return true; | ||
case TRANSMIT_TOS_STATUS: | ||
return action.payload; | ||
default: | ||
return state; | ||
} | ||
return state; | ||
}; |