Unverified Commit 4a1c5f17 authored by Zhou (Link)  Fang's avatar Zhou (Link) Fang Committed by GitHub
Browse files

Fixed can't skip a wg issue (#297)

* Fixed can't skip a wg issue

* Added a missing property back for updating formvalues
parent 2a8d4fe0
...@@ -80,6 +80,7 @@ export default function Application() { ...@@ -80,6 +80,7 @@ export default function Application() {
purchasingAndVAT, purchasingAndVAT,
membershipLevel, membershipLevel,
'membershipLevel-label': membershipLevelLabel, 'membershipLevel-label': membershipLevelLabel,
workingGroups: formikWorkingGroups.values.workingGroups,
signingAuthorityRepresentative: signingAuthorityRepresentative, signingAuthorityRepresentative: signingAuthorityRepresentative,
}; };
setUpdatedFormValues(theNewValue); setUpdatedFormValues(theNewValue);
...@@ -159,7 +160,7 @@ export default function Application() { ...@@ -159,7 +160,7 @@ export default function Application() {
setUpdatedFormValues({ ...updatedFormValues, workingGroups }); setUpdatedFormValues({ ...updatedFormValues, workingGroups });
console.log('updated working groups: ', values); console.log('updated working groups: ', values);
if (values.isJoiningWG) { if (!values.skipJoiningWG) {
// If the user is joining at least 1 wg, then make related API call // If the user is joining at least 1 wg, then make related API call
const setFieldValueObj = { const setFieldValueObj = {
fieldName: 'workingGroups', fieldName: 'workingGroups',
......
...@@ -67,7 +67,7 @@ const WorkingGroupsWrapper = ({ formik, formikOrgValue, fullWorkingGroupList, wo ...@@ -67,7 +67,7 @@ const WorkingGroupsWrapper = ({ formik, formikOrgValue, fullWorkingGroupList, wo
const handleClearData = () => { const handleClearData = () => {
// if user check it, we need to delete all wgs in formik and db // if user check it, we need to delete all wgs in formik and db
formik.values.workingGroups.map((item) => { formik.values.workingGroups.map((item) => {
deleteData(currentFormId, END_POINT.working_groups, item.id, console.log, `Deleted ${item.workingGroup.label}`); deleteData(currentFormId, END_POINT.working_groups, item.id, console.log, `Deleted ${item?.workingGroup?.label}`);
return null; return null;
}); });
formik.setFieldValue('skipJoiningWG', true); formik.setFieldValue('skipJoiningWG', true);
......
...@@ -89,22 +89,25 @@ export const validationSchema = [ ...@@ -89,22 +89,25 @@ export const validationSchema = [
// Third step - working groups // Third step - working groups
yup.object().shape({ yup.object().shape({
workingGroups: yup.array().of( workingGroups: yup.array().when('skipJoiningWG', {
yup.object().shape({ is: false,
workingGroup: yup then: yup.array().of(
.object() yup.object().shape({
.nullable() workingGroup: yup
.required('Please enter/select a valid working group') .object()
.test('workingGroup', 'Please enter/select a valid working group', function (selectedWG) { .nullable()
const allWorkingGroups = this.options.parent?.allWorkingGroups; .required('Please enter/select a valid working group')
const typedWG = this.options.parent?.['workingGroup-label']; .test('workingGroup', 'Please enter/select a valid working group', function (selectedWG) {
const isValid = allWorkingGroups?.includes(typedWG) && selectedWG?.label ? true : false; const allWorkingGroups = this.options.parent?.allWorkingGroups;
return typedWG ? isValid : true; const typedWG = this.options.parent?.['workingGroup-label'];
}), const isValid = allWorkingGroups?.includes(typedWG) && selectedWG?.label ? true : false;
participationLevel: REQUIRED_MAX_YUP, return typedWG ? isValid : true;
workingGroupRepresentative: CONTACT_YUP, }),
}) participationLevel: REQUIRED_MAX_YUP,
), workingGroupRepresentative: CONTACT_YUP,
})
),
}),
}), }),
// Forth, signing Authority // Forth, signing Authority
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment