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

✨ add feature flag to disable contract d1 power modification #85

Merged
merged 2 commits into from
Dec 18, 2023
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ PUBLIC_URL=/static/webforms
REACT_APP_API_BASE_URL=
REACT_APP_PLAUSIBLE_TRACK_DOMAIN=
REACT_APP_PLAUSIBLE_APIHOST_URL=
REACT_APP_SHOW_D1_POWER_MODIFICATION_CHOOSER=false
59 changes: 33 additions & 26 deletions src/containers/CaseDetail/AcceptD1.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import SendIcon from '@material-ui/icons/Send'

import Uploader from '../../components/Uploader'

const showD1PowerModificationChooser =
process.env.REACT_APP_SHOW_D1_POWER_MODIFICATION_CHOOSER === 'true'

const useStyles = makeStyles((theme) => ({
root: {
flexGrow: 1,
Expand Down Expand Up @@ -58,18 +61,19 @@ function AcceptD1({
const [sending, setSending] = useState(false)

const AcceptD1Schema = Yup.object().shape({
m1: Yup.bool()
.required(t('UNACCEPTED_PRIVACY_POLICY'))
.oneOf([true, false], t('UNACCEPTED_PRIVACY_POLICY')),
})
m1: Yup.bool()
.required(t('UNACCEPTED_PRIVACY_POLICY'))
.oneOf([true, false], t('UNACCEPTED_PRIVACY_POLICY'))
}
)

return (
<Paper className={classes.paperContainer} elevation={0}>
<Formik
initialValues={{
...{
d1Attachments: [],
m1: ''
m1: showD1PowerModificationChooser ? '' : false
},
...params
}}
Expand Down Expand Up @@ -120,7 +124,7 @@ function AcceptD1({
maxFiles={5}
fieldError={
errors?.d1Attachments &&
(touched?.d1Attachments || values?.m1 !== "") &&
(touched?.d1Attachments || values?.m1 !== '') &&
errors?.d1Attachments
}
callbackFn={(d1Attachments) =>
Expand All @@ -131,25 +135,28 @@ function AcceptD1({
</Box>
</Box>

<Box mx={1} mt={1} mb={2} className={classes.chooserLabelBox}>
<Chooser
question={t('APROFITAR_LA_MODIFICACIO')}
onChange={(option) => setFieldValue('m1', option.option)}
value={values.m1}
options={[
{
value: true,
label: t('SI'),
description: t('AVIS_APROFITAR_M1')
},
{
value: false,
label: t('NO'),
description: t('AVIS_NO_APROFITAR_M1')
}
]}
/>
</Box>
{showD1PowerModificationChooser && (
<Box mx={1} mt={1} mb={2} className={classes.chooserLabelBox}>
<Chooser
question={t('APROFITAR_LA_MODIFICACIO')}
onChange={(option) => setFieldValue('m1', option.option)}
value={values.m1}
options={[
{
value: true,
label: t('SI'),
description: t('AVIS_APROFITAR_M1')
},
{
value: false,
label: t('NO'),
description: t('AVIS_NO_APROFITAR_M1')
}
]}
/>
</Box>
)}

<div className={classes.actionsContainer}>
{
<Button
Expand All @@ -167,7 +174,7 @@ function AcceptD1({
className={classes.button}
color="primary"
variant="contained"
disabled={!isValid || sending}
disabled={(showD1PowerModificationChooser && !isValid) || sending}
endIcon={
(sending && <CircularProgress size={24} />) ||
(values?.m1 === false && <SendIcon />) || (
Expand Down
Loading