Skip to content

Commit

Permalink
chore: remove mrf flag checks
Browse files Browse the repository at this point in the history
  • Loading branch information
KenLSM committed Apr 3, 2024
1 parent 02f7429 commit 6ca677c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import FormLabel from '~components/FormControl/FormLabel'
import InlineMessage from '~components/InlineMessage'
import Input from '~components/Input'

import { useUser } from '~features/user/queries'

import { WorkspaceRowsProvider } from '../../WorkspaceFormRow/WorkspaceRowsContext'
import { useCreateFormWizard } from '../CreateFormWizardContext'

Expand Down Expand Up @@ -50,18 +48,15 @@ export const CreateFormDetailsScreen = (): JSX.Element => {
const titleInputValue = watch('title')
const responseModeValue = watch('responseMode')

const { user } = useUser()
const showMrf = Boolean(user?.betaFlags?.mrf)

return (
<>
<ModalHeader color="secondary.700">
<Container maxW={showMrf ? '69.5rem' : '42.5rem'} p={0}>
<Container maxW="69.5rem" p={0}>
{modalHeader}
</Container>
</ModalHeader>
<ModalBody whiteSpace="pre-wrap">
<Container maxW={showMrf ? '69.5rem' : '42.5rem'} p={0}>
<Container maxW="69.5rem" p={0}>
<FormControl isRequired isInvalid={!!errors.title} mb="2.25rem">
<FormLabel useMarkdownForDescription>Form name</FormLabel>
<Skeleton isLoaded={!isFetching}>
Expand All @@ -87,11 +82,7 @@ export const CreateFormDetailsScreen = (): JSX.Element => {
control={control}
render={({ field }) => (
<WorkspaceRowsProvider>
<FormResponseOptions
{...field}
showMrf={showMrf}
isSingpass={isSingpass}
/>
<FormResponseOptions {...field} isSingpass={isSingpass} />
</WorkspaceRowsProvider>
)}
rules={{ required: 'Please select a form response mode' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Tile from '~components/Tile'
export interface FormResponseOptionsProps {
onChange: (option: FormResponseMode) => void
value: FormResponseMode
showMrf: boolean
isSingpass: boolean
}

Expand All @@ -31,17 +30,13 @@ const OptionDescription = ({ listItems = [] }: { listItems: string[] }) => {
export const FormResponseOptions = forwardRef<
FormResponseOptionsProps,
'button'
>(({ value, onChange, showMrf, isSingpass }, ref) => {
>(({ value, onChange, isSingpass }, ref) => {
return (
<Stack spacing="1rem" w="100%" direction={{ base: 'column', md: 'row' }}>
<Tile
variant="complex"
icon={BiLockAlt}
badge={
<Badge colorScheme={showMrf ? 'neutral' : 'success'}>
Recommended
</Badge>
}
badge={<Badge colorScheme={'neutral'}>Recommended</Badge>}
isActive={value === FormResponseMode.Encrypt}
onClick={() => onChange(FormResponseMode.Encrypt)}
isFullWidth
Expand Down Expand Up @@ -76,31 +71,29 @@ export const FormResponseOptions = forwardRef<
]}
/>
</Tile>
{showMrf && (
<Tile
ref={ref}
variant="complex"
icon={MultiParty}
badge={<Badge colorScheme="success">New</Badge>}
isActive={value === FormResponseMode.Multirespondent}
onClick={() => onChange(FormResponseMode.Multirespondent)}
isFullWidth
flex={1}
isDisabled={isSingpass}
>
<Tile.Title>Multi-respondent form</Tile.Title>
<Tile.Subtitle>
Create a workflow to collect responses from multiple respondents in
the same form submission
</Tile.Subtitle>
<OptionDescription
listItems={[
'Route form to respondents according to a sequence',
'Assign fields and specify respondents to route form to for filling',
]}
/>
</Tile>
)}
<Tile
ref={ref}
variant="complex"
icon={MultiParty}
badge={<Badge colorScheme="success">New</Badge>}
isActive={value === FormResponseMode.Multirespondent}
onClick={() => onChange(FormResponseMode.Multirespondent)}
isFullWidth
flex={1}
isDisabled={isSingpass}
>
<Tile.Title>Multi-respondent form</Tile.Title>
<Tile.Subtitle>
Create a workflow to collect responses from multiple respondents in
the same form submission
</Tile.Subtitle>
<OptionDescription
listItems={[
'Route form to respondents according to a sequence',
'Assign fields and specify respondents to route form to for filling',
]}
/>
</Tile>
</Stack>
)
})
1 change: 0 additions & 1 deletion shared/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const UserBase = z.object({
.object({
payment: z.boolean().optional(),
children: z.boolean().optional(),
mrf: z.boolean().optional(),
})
.optional(),
flags: z
Expand Down
1 change: 0 additions & 1 deletion src/app/models/user.server.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const compileUserModel = (db: Mongoose) => {
betaFlags: {
payment: Boolean,
children: Boolean,
mrf: Boolean,
},
flags: {
lastSeenFeatureUpdateVersion: Number,
Expand Down
8 changes: 1 addition & 7 deletions src/app/modules/form/admin-form/admin-form.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { celebrate, Joi as BaseJoi, Segments } from 'celebrate'
import { AuthedSessionData } from 'express-session'
import { StatusCodes } from 'http-status-codes'
import JSONStream from 'JSONStream'
import { okAsync, ResultAsync } from 'neverthrow'
import { ResultAsync } from 'neverthrow'

import {
MAX_UPLOAD_FILE_SIZE,
Expand Down Expand Up @@ -103,7 +103,6 @@ import { PermissionLevel } from './admin-form.types'
import {
mapGoGovErrors,
mapRouteError,
verifyUserBetaflag,
verifyValidUnicodeString,
} from './admin-form.utils'

Expand Down Expand Up @@ -1182,11 +1181,6 @@ export const createForm: ControllerHandler<
return (
// Step 1: Retrieve currently logged in user.
UserService.findUserById(sessionUserId)
.andThen((user) =>
formParams.responseMode === FormResponseMode.Multirespondent
? verifyUserBetaflag(user, 'mrf')
: okAsync(user),
)
// Step 2: Create form with given params and set admin to logged in user.
.andThen((user) =>
AdminFormService.createForm(
Expand Down

0 comments on commit 6ca677c

Please sign in to comment.