Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin9foong committed Sep 18, 2024
1 parent 1e9ca05 commit 008689a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface BadgeProps extends ChakraBadgeProps {
* The theme of the tag to display
*/
variant?: BadgeVariants
bgColor?: string
colorScheme?: string
}

export const Badge = (props: BadgeProps): JSX.Element => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export const FieldLogicBadge = ({
}
}, [defaults.variant, fieldMeta])

const badgeBgColor = useMemo(() => {
const badgeColorScheme = useMemo(() => {
if (fieldMeta) return undefined
if (defaults.variant === 'error') {
return 'danger.100'
return 'danger'
}
return undefined
}, [defaults.variant, fieldMeta])
Expand All @@ -68,7 +68,7 @@ export const FieldLogicBadge = ({
}, [defaults.variant, fieldMeta])

return (
<LogicBadge display="inline-flex" bgColor={badgeBgColor}>
<LogicBadge display="inline-flex" colorScheme={badgeColorScheme}>
<Stack direction="row" spacing="0.25rem" maxW="100%" align="center">
<Tooltip placement="top" label={tooltipLabel}>
<Box display="inline-flex" alignItems="center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const EditStepBlock = ({
defaultValues,
})
const { user, isLoading: isUserLoading } = useUser()
isLoading = isLoading || isUserLoading
const _isLoading = isLoading || isUserLoading

const wrapperRef = useRef<HTMLDivElement | null>(null)

Expand Down Expand Up @@ -138,10 +138,10 @@ export const EditStepBlock = ({
user={user}
stepNumber={stepNumber}
formMethods={formMethods}
isLoading={isLoading}
isLoading={_isLoading}
/>
<Divider />
<QuestionsBlock formMethods={formMethods} isLoading={isLoading} />
<QuestionsBlock formMethods={formMethods} isLoading={_isLoading} />
{/*TODO: (MRF-email-notif) Remove isTest and betaFlag check when approvals is out of beta */}
{isTest || user?.betaFlags?.mrfEmailNotifications ? (
!isFirstStep ? (
Expand All @@ -153,7 +153,7 @@ export const EditStepBlock = ({
) : null}
<Divider />
<SaveActionGroup
isLoading={isLoading}
isLoading={_isLoading}
handleSubmit={handleSubmit}
handleDelete={isFirstStep ? undefined : handleOpenDeleteModal}
handleCancel={setToInactive}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const StaticRespondentOption = ({
allowDeselect={false}
value={WorkflowType.Static}
{...register('workflow_type', WORKFLOW_TYPE_VALIDATION)}
px="8px"
px="0.5rem"
__css={{
_focusWithin: {
boxShadow: 'none',
Expand Down Expand Up @@ -138,7 +138,7 @@ const DynamicRespondentOption = ({
allowDeselect={false}
value={WorkflowType.Dynamic}
{...register('workflow_type', WORKFLOW_TYPE_VALIDATION)}
px="8px"
px="0.5rem"
__css={{
_focusWithin: {
boxShadow: 'none',
Expand Down Expand Up @@ -289,32 +289,29 @@ export const RespondentBlock = ({
)}
</>
) : (
<>
<FormControl
isReadOnly={isLoading}
id="workflow_type"
isRequired
isInvalid={!!errors.workflow_type}
>
<FormLabel style={textStyles.h4}>Select a respondent</FormLabel>
<Stack spacing="0.25rem">
<Radio.RadioGroup value={selectedWorkflowType}>
<DynamicRespondentOption
selectedWorkflowType={selectedWorkflowType}
emailFieldItems={emailFieldItems}
formMethods={formMethods}
isLoading={isLoading}
/>
<StaticRespondentOption
selectedWorkflowType={selectedWorkflowType}
formMethods={formMethods}
isLoading={isLoading}
/>
</Radio.RadioGroup>
</Stack>
<FormErrorMessage>{errors.workflow_type?.message}</FormErrorMessage>
</FormControl>
</>
<FormControl
isReadOnly={isLoading}
isRequired
isInvalid={!!errors.workflow_type}
>
<FormLabel style={textStyles.h4}>Select a respondent</FormLabel>
<Stack spacing="0.25rem">
<Radio.RadioGroup value={selectedWorkflowType}>
<DynamicRespondentOption
selectedWorkflowType={selectedWorkflowType}
emailFieldItems={emailFieldItems}
formMethods={formMethods}
isLoading={isLoading}
/>
<StaticRespondentOption
selectedWorkflowType={selectedWorkflowType}
formMethods={formMethods}
isLoading={isLoading}
/>
</Radio.RadioGroup>
</Stack>
<FormErrorMessage>{errors.workflow_type?.message}</FormErrorMessage>
</FormControl>
)}
</EditStepBlockContainer>
)
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/core/core.errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export enum ErrorCodes {
SUBMISSION_MALICIOUS_FILE_DETECTED = 100220,
SUBMISSION_INVALID_WORKFLOW_TYPE = 100221,
SUBMISSION_ATTACHMENT_UPLOAD = 100222,
SUBMISSION_EXPECTED_RESPONSE_NOT_FOUND = 100223,
SUBMISSION_EXPECTED_RESPONSE_NOT_FOUND = 100224,
// Email Submission Errors (email mode deprecated soon)
EMAIL_SUBMISSION_HASH = 100250,
EMAIL_SUBMISSION_HASH = 100223,
// [100300 - 100399] Receiver Errors (/modules/submission/receiver)
RECEIVER_INITIALISE_MULTIPART_RECEIVER = 100301,
RECEIVER_MULTIPART_CONTENT_LIMIT = 100302,
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/form/admin-form/admin-form.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export const createForm = (
if (!isApprovalFieldInEditFields) {
return errAsync(
new MalformedParametersError(
"For all steps, the selected approval field must also be included in same step's edit fields",
'Approval fields must be included in edit fields.',
),
)
}
Expand Down

0 comments on commit 008689a

Please sign in to comment.