Skip to content

Commit

Permalink
Merge pull request #4196 from unicef/fix/209087
Browse files Browse the repository at this point in the history
Prevent to press the next button without choosing category.
  • Loading branch information
patryk-dabrowski authored Sep 6, 2024
2 parents b44520d + faaf7c0 commit 2a5a6c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function Selection({
<Grid item xs={6}>
<Field
name="category"
label="Category*"
label="Category"
onChange={(e) => {
setFieldValue('issueType', null);
handleChange(e);
Expand All @@ -66,20 +66,22 @@ export function Selection({
choices={choicesData.grievanceTicketManualCategoryChoices}
component={FormikSelectField}
disabled={redirectedFromRelatedTicket}
required
/>
</Grid>
{showIssueType(values) && (
<Grid item xs={6}>
<Field
name="issueType"
label="Issue Type*"
label="Issue Type"
variant="outlined"
choices={
redirectedFromRelatedTicket
? dataChangeIssueTypes
: issueTypeDict[values.category].subCategories
}
component={FormikSelectField}
required
/>
</Grid>
)}
Expand Down
22 changes: 13 additions & 9 deletions frontend/src/components/grievances/utils/validateGrievance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ export function validateUsingSteps(
// 'sex',
// ];

if (!category) {
errors.category = 'Category is Required';
}
if (
category === GRIEVANCE_CATEGORIES.SENSITIVE_GRIEVANCE ||
category === GRIEVANCE_CATEGORIES.DATA_CHANGE ||
category === GRIEVANCE_CATEGORIES.GRIEVANCE_COMPLAINT
) {
if (!issueType) {
errors.issueType = 'Issue Type is required';
}
}

if (category === GRIEVANCE_CATEGORIES.DATA_CHANGE) {
if (issueType === GRIEVANCE_ISSUE_TYPES.ADD_INDIVIDUAL) {
if (!values.selectedHousehold && activeStep === GrievanceSteps.Lookup) {
Expand Down Expand Up @@ -415,15 +428,6 @@ export function validateUsingSteps(
}
}
}
if (
category === GRIEVANCE_CATEGORIES.SENSITIVE_GRIEVANCE ||
category === GRIEVANCE_CATEGORIES.DATA_CHANGE ||
category === GRIEVANCE_CATEGORIES.GRIEVANCE_COMPLAINT
) {
if (!issueType) {
errors.issueType = 'Issue Type is required';
}
}

if (
category === GRIEVANCE_CATEGORIES.DATA_CHANGE &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ const BoxWithBorders = styled.div`

export const validationSchemaWithSteps = (currentStep: number): unknown => {
const datum = {
category: Yup.string().required('Category is required').nullable(),
issueType: Yup.string().required('Issue Type is required').nullable(),
category: Yup.string().required('Category is required'),
issueType: Yup.string().required('Issue Type is required'),
admin: Yup.string().nullable(),
description: Yup.string().nullable(),
consent: Yup.bool().nullable(),
Expand Down

0 comments on commit 2a5a6c7

Please sign in to comment.