Skip to content

Commit 17352ec

Browse files
feat: respondent copy v3 (phase2) (#8869)
* enabled email confirmation & pdf response toggle * enabled email confirmation & pdf response toggle fix * betaFlag form status toggle & hiding of email confirmation infobox * added extractRespondentCopyEmails function in mrf utils * implement extractRespondentCopyEmails in submitMultirespondentForm to pass to post actions * created MrfRespondentCopyTemplate * update sendMrfRespondentCopyEmail in mail.service to use MrfRespondentCopyEmail template * create extractRespondentCopyEmails function to obtain autoReplyMailData from mrf submission * update postSubmissionCreateActions to obtain AutoReplyMailData from submission to sendMrfRespondentCopyEmails * update postSubmissionUpdateActions to obtain AutoReplyMailData from submission to sendMrfRespondentCopyEmails * updated extractRespondentCopyEmails to account for active fields in current workflow step * updated sendMrfRespondentCopyEmails to handle multiple autoReplyMailDatas * removed respondent copy email extraction in controller * updated rc flow to account for agencyName * remove default setting of includeFormSummary=false for MRF in email field model * updated rc functions to handle agency names * update editEmail include responses toggle to be updatable in MRF mode * replaced hasRepsondentCopy in snapshotted form def with admin for agencyName * initial fix for mrf service.spec.ts tests * remove toggle and respondent copy multi-input on formpage * removed unused variables after removing respondent copy v2 FE components * fixed tests * removed respondent copy toggle from mrf email settings page * update question title in workflow question block for email fields with autoReply enabled * attempt to use pdf lambda to generate PDF for mrf rc * fixed lint issues * testing extractRepsondenCopyEmails take 2 * fixed custom sender in mail, added formUrl and submission timestamp * replace hypens with divider in mrf respondent copy email * refactored mrf utils to clean up pdf responses for respondent copy * fixed lint * fixed utilsingle field question answer function * bug fix to handle undefined for activeFields * update placeholder text to grey for editMail & stepName default text * updated some variable names and added comments to improve codebase readability * remove respondent copy from mrf workflow completion email * fixed mrf util tests by moveing questionAnswerPair return out of case switch block in questiontitleanswerString function * removed changes from vscode settings * updated disabling of email confirmation toggle only based on beta flag * fixed lint for e2e test file * update email confirmation toggle to be disabled only when mrf mode and no beta flag * Update src/app/modules/submission/multirespondent-submission/multirespondent-submission.service.ts Co-authored-by: Eliot Lim <[email protected]> * Update src/app/modules/submission/multirespondent-submission/multirespondent-submission.service.ts Co-authored-by: Eliot Lim <[email protected]> --------- Co-authored-by: Eliot Lim <[email protected]>
1 parent 44041c7 commit 17352ec

File tree

20 files changed

+700
-495
lines changed

20 files changed

+700
-495
lines changed

__tests__/e2e/helpers/createForm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
getMyInfoAttribute,
5050
getTitleWithQuestionNumber,
5151
} from '../utils'
52+
5253
import { closeModals } from './closeModals';
5354

5455
type CreateFormReturn = {

frontend/src/features/admin-form/create/builder-and-design/BuilderAndDesignDrawer/EditFieldDrawer/edit-fieldtype/EditEmail/EditEmail.tsx

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import Input from '~components/Input'
1616
import Textarea from '~components/Textarea'
1717
import Toggle from '~components/Toggle'
1818

19+
import { useUser } from '~features/user/queries'
20+
1921
import { CreatePageDrawerContentContainer } from '../../../../../common'
2022
import { useCreateTabForm } from '../../../../useCreateTabForm'
2123
import { SPLIT_TEXTAREA_TRANSFORM } from '../common/constants'
@@ -87,6 +89,8 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
8789
const watchedHasAllowedEmailDomains = watch('hasAllowedEmailDomains')
8890
const watchedHasAutoReply = watch('autoReplyOptions.hasAutoReply')
8991

92+
const { user } = useUser()
93+
9094
const requiredValidationRule = useMemo(
9195
() =>
9296
createBaseValidationRules<EditEmailInputs, 'title'>({
@@ -139,23 +143,21 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
139143
const isEncryptMode = form?.responseMode === FormResponseMode.Encrypt
140144
const isPaymentDisabledForm =
141145
isEncryptMode &&
142-
form.payments_channel.channel === PaymentChannel.Unconnected
146+
form.payments_channel.channel !== PaymentChannel.Unconnected
143147

144-
const isPdfResponseEnabled =
145-
form?.responseMode === FormResponseMode.Email || isPaymentDisabledForm
146-
147-
const pdfResponseToggleDescription = isPdfResponseEnabled
148+
// For payment forms inclusion of PDF responses are disallowed
149+
const pdfResponseToggleDescription = isPaymentDisabledForm
148150
? t(
149-
'features.adminForm.sidebar.fields.email.emailConfirmation.includeResponseDescription',
151+
'features.adminForm.sidebar.fields.email.emailConfirmation.includePdfResponseWarning',
150152
)
151153
: t(
152-
'features.adminForm.sidebar.fields.email.emailConfirmation.includePdfResponseWarning',
154+
'features.adminForm.sidebar.fields.email.emailConfirmation.includeResponseDescription',
153155
)
154156

155-
// email confirmation is not supported on MRF
157+
// TODO: FRM-2172 Remove when respondent copy is out of beta
156158
const isToggleEmailConfirmationDisabled =
157159
form?.responseMode === FormResponseMode.Multirespondent &&
158-
!field.autoReplyOptions.hasAutoReply
160+
!user?.betaFlags?.respondentCopy
159161

160162
return (
161163
<CreatePageDrawerContentContainer>
@@ -211,7 +213,7 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
211213
'features.adminForm.sidebar.fields.email.emailConfirmation.includeResponse',
212214
)}
213215
description={pdfResponseToggleDescription}
214-
isDisabled={!isPdfResponseEnabled}
216+
isDisabled={isPaymentDisabledForm}
215217
/>
216218
</FormControl>
217219
<FormControl isRequired isReadOnly={isLoading} mt="1.5rem">
@@ -222,7 +224,6 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
222224
'features.adminForm.sidebar.fields.email.emailConfirmation.subject.placeholder',
223225
{ formTitle: form?.title },
224226
)}
225-
_placeholder={{ color: 'secondary.700' }}
226227
{...register('autoReplyOptions.autoReplySubject')}
227228
/>
228229
</FormControl>
@@ -234,7 +235,6 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
234235
</FormLabel>
235236
<Input
236237
placeholder={form?.admin.agency.fullName}
237-
_placeholder={{ color: 'secondary.700' }}
238238
{...register('autoReplyOptions.autoReplySender')}
239239
/>
240240
</FormControl>
@@ -249,12 +249,6 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
249249
'features.adminForm.sidebar.fields.email.emailConfirmation.content.placeholder',
250250
{ agencyName: form?.admin.agency.fullName },
251251
)}
252-
sx={{
253-
'::placeholder': {
254-
color: 'secondary.700',
255-
opacity: 1,
256-
},
257-
}}
258252
{...register('autoReplyOptions.autoReplyMessage')}
259253
/>
260254
</FormControl>

frontend/src/features/admin-form/create/logic/components/LogicContent/utils/getLogicFieldLabel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export const getLogicFieldLabel = (field: FormFieldWithQuestionNo) => {
1313
case BasicField.Image:
1414
title = field.name
1515
break
16+
case BasicField.Email:
17+
// Inform admins if email confirmation will be sent
18+
if (field.autoReplyOptions.hasAutoReply) {
19+
title = title + ' (confirmation will be sent)'
20+
}
21+
break
1622
default:
1723
break
1824
}

frontend/src/features/admin-form/create/workflow/components/WorkflowContent/EditStepBlock/StepNameBlock.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export const StepNameBlock = ({
8181
<Input
8282
{...field}
8383
placeholder={displayStepName}
84-
_placeholder={{ color: 'secondary.700' }}
8584
_focus={{
8685
_placeholder: { color: 'transparent' },
8786
}}

frontend/src/features/admin-form/settings/components/FormEmailSection.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ export const FormEmailSection = ({
103103
settings,
104104
isHighContrast = true,
105105
}: EmailFormSectionProps): JSX.Element => {
106-
//TODO: (Respondent Copy): Remove isTest and user when respondent copy is out of beta
107-
const { user } = useUser()
108-
const isTest = import.meta.env.STORYBOOK_NODE_ENV === 'test'
109-
110106
const { t } = useTranslation()
111107
const initialEmailSet = useMemo(
112108
() => new Set(settings.emails),
@@ -169,13 +165,6 @@ export const FormEmailSection = ({
169165
</FormLabel.Description>
170166
) : null}
171167
</FormControl>
172-
{isTest || user?.betaFlags?.respondentCopy ? (
173-
<FormControl isDisabled={isDisabled}>
174-
<Box mt={'1.5rem'}>
175-
<RespondentCopyToggle />
176-
</Box>
177-
</FormControl>
178-
) : null}
179168
</FormProvider>
180169
</>
181170
)

frontend/src/features/admin-form/settings/components/FormStatusToggle.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Flex, Skeleton, Stack, Text, useDisclosure } from '@chakra-ui/react'
55
import { BasicField } from '~shared/types'
66
import {
77
EmailFormDto,
8-
FormAuthType,
98
FormResponseMode,
109
FormStatus,
1110
} from '~shared/types/form/form'
@@ -14,6 +13,7 @@ import InlineMessage from '~components/InlineMessage'
1413
import { Switch } from '~components/Toggle/Switch'
1514

1615
import { useAdminForm } from '~features/admin-form/common/queries'
16+
import { useUser } from '~features/user/queries'
1717

1818
import { useMutateFormSettings } from '../mutations'
1919
import { useAdminFormSettings } from '../queries'
@@ -30,7 +30,7 @@ export const FormStatusToggle = (): JSX.Element => {
3030
} = useAdminForm()
3131
const { data: formSettings, isLoading: isLoadingFormSettings } =
3232
useAdminFormSettings()
33-
33+
const { user } = useUser()
3434
const { status, responseMode, authType, esrvcId } = formSettings ?? {}
3535

3636
const secretKeyActivationModalProps = useDisclosure()
@@ -54,7 +54,8 @@ export const FormStatusToggle = (): JSX.Element => {
5454
form_fields?.some(
5555
(ff) =>
5656
ff.fieldType === BasicField.Email && ff.autoReplyOptions.hasAutoReply,
57-
)
57+
) &&
58+
!user?.betaFlags?.respondentCopy
5859
) {
5960
return t('features.adminForm.settings.general.status.noEmailsInMRF')
6061
}

frontend/src/features/admin-form/settings/components/MrfFormEmailSection.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,6 @@ const MrfEmailNotificationsForm = ({
285285
</FormErrorMessage>
286286
)}
287287
</FormControl>
288-
{isTest || user?.betaFlags?.respondentCopy ? (
289-
<FormControl isDisabled={isDisabled}>
290-
<Box mt={'1.5rem'}>
291-
<RespondentCopyToggle />
292-
</Box>
293-
</FormControl>
294-
) : null}
295288
</Box>
296289
</form>
297290
)

frontend/src/features/public-form/components/FormFields/FormFields.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { PaymentPreview } from '../../../../templates/Field/PaymentPreview/Payme
2424
import { PublicFormPaymentResumeModal } from '../FormPaymentPage/FormPaymentResumeModal'
2525

2626
import { PublicFormSubmitButton } from './PublicFormSubmitButton'
27-
import { PublicRespondentEmailField } from './PublicRespondentEmailField'
2827
import { VisibleFormFields } from './VisibleFormFields'
2928

3029
export interface FormFieldsProps {
@@ -119,12 +118,6 @@ export const FormFields = ({
119118
/>
120119
</Box>
121120
)}
122-
{/* TODO: (respondent copy): Remove when respondent copy is out of beta */}
123-
{form?.hasRespondentCopy && isRespondentCopyEnabled ? (
124-
<Box mt="2.5rem" px={{ base: '1rem', md: 0 }}>
125-
<PublicRespondentEmailField />
126-
</Box>
127-
) : null}
128121
<PublicFormPaymentResumeModal />
129122
<PublicFormSubmitButton
130123
onSubmit={onSubmit ? handleSubmit(onSubmit) : undefined}

src/app/models/field/__tests__/emailField.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ describe('models.fields.emailField', () => {
102102
expect(actual.field.toObject()).toEqual(expected)
103103
})
104104

105-
it('should set includeFormSummary to false on ResponseMode.Multirespondent forms', async () => {
105+
it('should set includeFormSummary to given on ResponseMode.Multirespondent forms', async () => {
106106
// Arrange
107107
const mockEmailField = {
108108
autoReplyOptions: {
@@ -125,7 +125,7 @@ describe('models.fields.emailField', () => {
125125
_id: expect.anything(),
126126
autoReplyOptions: {
127127
// Should be always set to false for MRF forms
128-
includeFormSummary: false,
128+
includeFormSummary: true,
129129
},
130130
})
131131
expect(actual.field.toObject()).toEqual(expected)

src/app/models/field/emailField.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Schema } from 'mongoose'
22

3-
import { FormResponseMode } from '../../../../shared/types'
43
import { validateEmailDomains } from '../../../../shared/utils/email-domain-validation'
54
import { IEmailFieldSchema } from '../../../types'
65

@@ -30,12 +29,6 @@ const createEmailFieldSchema = (): Schema<IEmailFieldSchema> => {
3029
includeFormSummary: {
3130
type: Boolean,
3231
default: false,
33-
set: function (this: IEmailFieldSchema, v: boolean) {
34-
// Set to false if mrf mode regardless of initial value.
35-
return this.parent().responseMode === FormResponseMode.Multirespondent
36-
? false
37-
: v
38-
},
3932
},
4033
},
4134

0 commit comments

Comments
 (0)