Skip to content

Commit ac582dd

Browse files
committed
feat: add feature flag for admin email pdf
1 parent f8bc7ad commit ac582dd

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

shared/constants/feature-flags.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ export const featureFlags = {
2828
singpassMrf: 'singpass-mrf' as const,
2929
enableSaveDraftButtonFloating: 'enable-save-draft-button-floating' as const,
3030
enableSaveDraftButtonHeader: 'enable-save-draft-button-header' as const,
31+
adminEmailPdf: 'admin-email-pdf' as const,
32+
}
33+
34+
export enum AdminEmailPdfFeatureValue {
35+
OFF = 'OFF',
36+
SIGNATURES_ONLY = 'SIGNATURES_ONLY',
37+
ON = 'ON',
3138
}

src/app/modules/submission/submission.utils.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GrowthBook } from '@growthbook/growthbook'
12
import { encode as encodeBase64 } from '@stablelib/base64'
23
import crypto from 'crypto'
34
import StatusCodes from 'http-status-codes'
@@ -14,7 +15,11 @@ import {
1415
import mongoose from 'mongoose'
1516
import { err, ok, Result } from 'neverthrow'
1617

17-
import { MULTIRESPONDENT_FORM_SUBMISSION_VERSION } from '../../../../shared/constants'
18+
import {
19+
AdminEmailPdfFeatureValue,
20+
featureFlags,
21+
MULTIRESPONDENT_FORM_SUBMISSION_VERSION,
22+
} from '../../../../shared/constants'
1823
import { FIELDS_TO_REJECT } from '../../../../shared/constants/field/basic'
1924
import { MYINFO_ATTRIBUTE_MAP } from '../../../../shared/constants/field/myinfo'
2025
import {
@@ -941,3 +946,26 @@ export const buildMrfMetadata = ({
941946
hasNextStepRecipientEmails,
942947
}
943948
}
949+
950+
export const isAdminEmailPdfEnabled = ({
951+
growthbook,
952+
formFields,
953+
}: {
954+
growthbook?: GrowthBook
955+
formFields: FormFieldSchema[]
956+
}) => {
957+
if (!growthbook) {
958+
return false
959+
}
960+
const adminEmailPdfFeatureValue = growthbook.getFeatureValue(
961+
featureFlags.adminEmailPdf,
962+
AdminEmailPdfFeatureValue.OFF,
963+
)
964+
if (adminEmailPdfFeatureValue === AdminEmailPdfFeatureValue.ON) {
965+
return true
966+
}
967+
if (adminEmailPdfFeatureValue === AdminEmailPdfFeatureValue.SIGNATURES_ONLY) {
968+
return formFields.some((field) => field.fieldType === BasicField.Signature)
969+
}
970+
return false
971+
}

0 commit comments

Comments
 (0)