Skip to content

Commit

Permalink
feat: disabling response limit toggle for MRF (#7180)
Browse files Browse the repository at this point in the history
* feat: disabling response limit toggle for mrf

* fix: correcting const mrf acronym
  • Loading branch information
kathleenkhy authored Mar 22, 2024
1 parent bfe40a5 commit a760d50
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import {
} from 'react'
import { FormControl, Skeleton } from '@chakra-ui/react'

import { FormResponseMode } from '~shared/types'

import FormErrorMessage from '~components/FormControl/FormErrorMessage'
import FormLabel from '~components/FormControl/FormLabel'
import InlineMessage from '~components/InlineMessage'
import NumberInput from '~components/NumberInput'
import Toggle from '~components/Toggle'

Expand Down Expand Up @@ -106,6 +109,8 @@ export const FormLimitToggle = (): JSX.Element => {
const { data: settings, isLoading: isLoadingSettings } =
useAdminFormSettings()

const isMrf = settings?.responseMode === FormResponseMode.Multirespondent

const { data: responseCount, isLoading: isLoadingCount } =
useFormResponsesCount()

Expand Down Expand Up @@ -149,11 +154,17 @@ export const FormLimitToggle = (): JSX.Element => {
return (
<Skeleton isLoaded={!isLoadingSettings && !!settings} mt="2rem">
<Toggle
isDisabled={isMrf}
isLoading={mutateFormLimit.isLoading}
isChecked={isLimit}
label="Set a response limit"
onChange={() => handleToggleLimit()}
/>
{isMrf ? (
<InlineMessage variant="warning" mt="0.5rem">
Response limits cannot be applied for multi-respondent forms.
</InlineMessage>
) : null}
{settings && settings?.submissionLimit !== null && (
<Skeleton isLoaded={!isLoadingCount}>
<FormLimitBlock
Expand Down

0 comments on commit a760d50

Please sign in to comment.