Skip to content

Commit

Permalink
Merge pull request #7470 from opengovsg/feat/encrypt-mode-pdf-response
Browse files Browse the repository at this point in the history
feat: add pdf attachments for encrypt forms
  • Loading branch information
g-tejas authored Jul 4, 2024
2 parents 713d6a1 + cd10a32 commit 81495c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,9 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {

const { data: form } = useCreateTabForm()
const isPdfResponseEnabled = useMemo(
() => form?.responseMode !== FormResponseMode.Encrypt,
() => form?.responseMode !== FormResponseMode.Multirespondent,
[form],
)
const pdfResponseToggleDescription = useMemo(() => {
if (!isPdfResponseEnabled) {
return 'For security reasons, PDF responses are not included in email confirmations for Storage mode forms'
}
}, [isPdfResponseEnabled])

// email confirmation is not supported on MRF
const isToggleEmailConfirmationDisabled = useMemo(
Expand Down Expand Up @@ -239,7 +234,6 @@ export const EditEmail = ({ field }: EditEmailProps): JSX.Element => {
<Toggle
{...register('autoReplyOptions.includeFormSummary')}
label="Include PDF response"
description={pdfResponseToggleDescription}
isDisabled={!isPdfResponseEnabled}
/>
</FormControl>
Expand Down
5 changes: 2 additions & 3 deletions src/app/models/field/__tests__/emailField.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('models.fields.emailField', () => {
beforeEach(async () => await dbHandler.clearDatabase())
afterAll(async () => await dbHandler.closeDatabase())

it('should set includeFormSummary to false on ResponseMode.Encrypt forms', async () => {
it('should set includeFormSummary to given value on ResponseMode.Encrypt forms', async () => {
// Arrange
const mockEmailField = {
autoReplyOptions: {
Expand All @@ -66,8 +66,7 @@ describe('models.fields.emailField', () => {
const expected = merge(EMAIL_FIELD_DEFAULTS, mockEmailField, {
_id: expect.anything(),
autoReplyOptions: {
// Regardless, should be false since ResponseMode is Encrypt.
includeFormSummary: false,
includeFormSummary: true,
},
})
expect(actual.field.toObject()).toEqual(expected)
Expand Down
4 changes: 2 additions & 2 deletions src/app/models/field/emailField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const createEmailFieldSchema = (): Schema<IEmailFieldSchema> => {
type: Boolean,
default: false,
set: function (this: IEmailFieldSchema, v: boolean) {
// Set to false if encrypt mode regardless of initial value.
return this.parent().responseMode === FormResponseMode.Encrypt
// Set to false if mrf mode regardless of initial value.
return this.parent().responseMode === FormResponseMode.Multirespondent
? false
: v
},
Expand Down

0 comments on commit 81495c1

Please sign in to comment.