diff --git a/src/components/AddFacilitator.tsx b/src/components/AddFacilitator.tsx index cb89ba75..bbc7b45f 100644 --- a/src/components/AddFacilitator.tsx +++ b/src/components/AddFacilitator.tsx @@ -67,6 +67,8 @@ const AddFacilitatorModal: React.FC = ({ handleDistrictChangeWrapper, handleBlockChangeWrapper, handleCenterChangeWrapper, + BlockFieldId, DistrctFieldId, StateFieldId + } = useLocationState(open, onClose); useEffect(() => { @@ -190,16 +192,16 @@ const AddFacilitatorModal: React.FC = ({ if (!isEditModal) { apiBody.customFields.push({ - fieldId: "549d3575-bf01-48a9-9fff-59220fede174", + fieldId: BlockFieldId, value: [selectedBlockCode], }); apiBody.customFields.push({ - fieldId: "b61edfc6-3787-4079-86d3-37262bf23a9e", - value: [selectedStateCode], + fieldId: StateFieldId, + value: [selectedStateCode] }); apiBody.customFields.push({ - fieldId: "f2d731dd-2298-40d3-80bb-9ae6c5b38fb8", - value: [selectedDistrictCode], + fieldId: DistrctFieldId, + value: [selectedDistrictCode] }); } try { diff --git a/src/components/AddLeanerModal.tsx b/src/components/AddLeanerModal.tsx index 666dbaa8..511e4a4e 100644 --- a/src/components/AddLeanerModal.tsx +++ b/src/components/AddLeanerModal.tsx @@ -74,7 +74,8 @@ const AddLearnerModal: React.FC = ({ handleDistrictChangeWrapper, handleBlockChangeWrapper, handleCenterChangeWrapper, - selectedCenterCode, + selectedCenterCode, BlockFieldId, DistrctFieldId, StateFieldId + } = useLocationState(open, onClose); useEffect(() => { @@ -178,15 +179,15 @@ const AddLearnerModal: React.FC = ({ }); if (!isEditModal) { apiBody.customFields.push({ - fieldId: "a717bb68-5c8a-45cb-b6dd-376caa605736", + fieldId: BlockFieldId, value: [selectedBlockCode], }); apiBody.customFields.push({ - fieldId: "61b5909a-0b45-4282-8721-e614fd36d7bd", + fieldId: StateFieldId, value: [selectedStateCode], }); apiBody.customFields.push({ - fieldId: "aecb84c9-fe4c-4960-817f-3d228c0c7300", + fieldId: DistrctFieldId, value: [selectedDistrictCode], }); } diff --git a/src/components/AddTeamLeaderModal.tsx b/src/components/AddTeamLeaderModal.tsx index c4f0d222..53457e90 100644 --- a/src/components/AddTeamLeaderModal.tsx +++ b/src/components/AddTeamLeaderModal.tsx @@ -83,7 +83,8 @@ const AddTeamLeaderModal: React.FC = ({ handleCenterChangeWrapper, selectedCenterCode, selectedBlockFieldId, - dynamicFormForBlock + dynamicFormForBlock, + BlockFieldId, DistrctFieldId, StateFieldId } = useLocationState(open, onClose); @@ -185,15 +186,15 @@ const AddTeamLeaderModal: React.FC = ({ }); if (!isEditModal) { apiBody.customFields.push({ - fieldId: "394ee6c9-3c4b-4065-ab82-19dc6ab52e67", + fieldId: BlockFieldId, value: [selectedBlockCode], }); apiBody.customFields.push({ - fieldId: "8d56e5e6-d504-4c51-a848-eb1b0a8d2ed6", + fieldId: StateFieldId, value: [selectedStateCode], }); apiBody.customFields.push({ - fieldId: "ea1461c1-2dd3-469d-b58d-52c6acdce30b", + fieldId: DistrctFieldId, value: [selectedDistrictCode], }); } @@ -320,11 +321,11 @@ const AddTeamLeaderModal: React.FC = ({ marginTop: "10px", }} > - {!dynamicForm && ( + {/* {!dynamicForm && ( {t("LEARNERS.FIRST_SELECT_REQUIRED_FIELDS")}{" "} - )} + )} */} = ({ }; - + function transformErrors(errors: any) { console.log("errors", errors); console.log("schema", schema); @@ -78,6 +78,25 @@ const DynamicForm: React.FC = ({ error.message = t("FORM_ERROR_MESSAGES.THIS_IS_REQUIRED_FIELD"); break; } + case "maximum": + { + const property = error.property.substring(1); + + if (schema.properties?.[property]?.validation?.includes("numeric")) { + error.message = t("FORM_ERROR_MESSAGES.MAX_LENGTH_DIGITS_ERROR", { + maxLength: schema.properties?.[property]?.maxLength, + }); + } + } + case "minimum": + { + const property = error.property.substring(1); + if (schema.properties?.[property]?.validation?.includes("numeric")) { + error.message = t("FORM_ERROR_MESSAGES.MIN_LENGTH_DIGITS_ERROR", { + minLength: schema.properties?.[property]?.minLength, + }); + } + } case "pattern": { // if (schema.properties?.[property]?.validation?.includes("numeric")) { // error.message = t("FORM_ERROR_MESSAGES.ENTER_ONLY_DIGITS"); @@ -96,6 +115,7 @@ const DynamicForm: React.FC = ({ // } const pattern = error?.params?.pattern; + console.log(pattern) const property = error.property.substring(1); switch (pattern) { @@ -109,8 +129,15 @@ const DynamicForm: React.FC = ({ if (schema.properties?.[property]?.validation?.includes("mobile")) { error.message = t( "FORM_ERROR_MESSAGES.ENTER_VALID_MOBILE_NUMBER" - ); - } else { + ); + + } + else if (schema.properties?.[property]?.validation?.includes(".age")) { + error.message = t( + "age must be valid" + ); + } + else { error.message = t( "FORM_ERROR_MESSAGES.CHARACTERS_AND_SPECIAL_CHARACTERS_NOT_ALLOWED" ); @@ -153,6 +180,7 @@ const DynamicForm: React.FC = ({ } } } + } return error; diff --git a/src/components/HeaderComponent.tsx b/src/components/HeaderComponent.tsx index bfd1a4e1..4068441e 100644 --- a/src/components/HeaderComponent.tsx +++ b/src/components/HeaderComponent.tsx @@ -91,7 +91,7 @@ const HeaderComponent = ({ }; console.log(object); const response = await getStateBlockDistrictList(object); - const result = response?.result; + const result = response?.result?.values; setDistricts(result); } catch (error) { console.log(error); @@ -113,7 +113,7 @@ const HeaderComponent = ({ fieldName: "blocks", }; const response = await getStateBlockDistrictList(object); - const result = response?.result; + const result = response?.result?.values; setBlocks(result); } catch (error) { console.log(error); @@ -137,7 +137,7 @@ const HeaderComponent = ({ fieldName: "states", }; const response = await getStateBlockDistrictList(object); - const result = response?.result; + const result = response?.result?.values; setStates(result); console.log(typeof states); } catch (error) { @@ -188,35 +188,30 @@ const HeaderComponent = ({ - {showFilter && ( - <> - - {t("COMMON.FILTER_BY_STATUS")} - - - - - - )} - + + {t("COMMON.FILTER_BY_STATUS")} + + + + {showSort && (