Skip to content

Commit

Permalink
Merge pull request #826 from hotosm/feat-projectinfo-bug
Browse files Browse the repository at this point in the history
Feat projectinfo bug
  • Loading branch information
robsavoye authored Sep 12, 2023
2 parents 977d638 + 3cba915 commit 59da130
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 59 deletions.
6 changes: 4 additions & 2 deletions src/frontend/fmtm_openlayer_map/src/views/DefineAreaMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const DefineAreaMap = ({
setDataExtractedGeojson(e.target.result);
};
} else {
setDataExtractedGeojson(null);
}
}, [uploadedDataExtractFile]);
useEffect(() => {
Expand All @@ -63,6 +64,7 @@ const DefineAreaMap = ({
setLineExtractedGeojson(e.target.result);
};
} else {
setLineExtractedGeojson(null);
}
}, [uploadedLineExtractFile]);
return (
Expand Down Expand Up @@ -128,7 +130,7 @@ const DefineAreaMap = ({
constrainResolution: true,
duration: 2000,
}}
// zoomToLayer
zoomToLayer
/>
)}
{lineExtractedGeojson && (
Expand All @@ -151,7 +153,7 @@ const DefineAreaMap = ({
constrainResolution: true,
duration: 2000,
}}
// zoomToLayer
zoomToLayer
/>
)}
</MapComponent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ const DataExtract: React.FC<any> = ({
submission,
DataExtractValidation,
);
useEffect(() => {
if (values.data_extract_options === 'Data Extract Ways') {
setDataExtractFile(null);
setDataExtractFileValue(null);
setLineExtractFile(null);
setLineExtractFileValue(null);
}
}, [values.data_extract_options]);

return (
<CoreModules.Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const UploadArea: React.FC<any> = ({ geojsonFile, setGeojsonFile, setInputValue,
<DefineAreaMap
uploadedGeojson={geojsonFile}
onDraw={(geojson) => {
dispatch(CreateProjectActions.SetDrawnGeojson(JSON.parse(geojson)));
dispatch(CreateProjectActions.SetDividedTaskGeojson(JSON.parse(geojson)));
}}
/>
</CoreModules.Stack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@

interface ProjectValues {
organization: string;
name: string;
username: string;
id: string;
short_description: string;
description: string;
// odk_central_url: string;
// odk_central_user: string;
// odk_central_password: string;
organization: string;
name: string;
username: string;
id: string;
short_description: string;
description: string;
// odk_central_url: string;
// odk_central_user: string;
// odk_central_password: string;
}
interface ValidationErrors {
organization?: string;
name?: string;
username?: string;
id?: string;
short_description?: string;
description?: string;
// odk_central_url?: string;
// odk_central_user?: string;
// odk_central_password?: string;
}
const regexForSymbol = /_/g;

function EditProjectValidation(values: ProjectValues) {
const errors: ValidationErrors = {};

// if (!values?.organization) {
// errors.organization = 'Organization is Required.';
// }
// if (!values?.odk_central_url) {
// errors.odk_central_url = 'ODK Central Url is Required.';
// }
// if (!values?.odk_central_user) {
// errors.odk_central_user = 'ODK Central User is Required.';
// }
// if (!values?.odk_central_password) {
// errors.odk_central_password = 'ODK Central Password is Required.';
// }
if (!values?.name) {
errors.name = 'Project Name is Required.';
}
interface ValidationErrors {
organization?: string;
name?: string;
username?: string;
id?: string;
short_description?: string;
description?: string;
// odk_central_url?: string;
// odk_central_user?: string;
// odk_central_password?: string;
if (values?.name && regexForSymbol.test(values.name)) {
errors.name = 'Project Name should not contain _.';
}
const regexForSymbol = /[-_]/g;

function EditProjectValidation(values: ProjectValues) {
const errors: ValidationErrors = {};

// if (!values?.organization) {
// errors.organization = 'Organization is Required.';
// }
// if (!values?.odk_central_url) {
// errors.odk_central_url = 'ODK Central Url is Required.';
// }
// if (!values?.odk_central_user) {
// errors.odk_central_user = 'ODK Central User is Required.';
// }
// if (!values?.odk_central_password) {
// errors.odk_central_password = 'ODK Central Password is Required.';
// }
if (!values?.name) {
errors.name = 'Project Name is Required.';
}
if (values?.name && regexForSymbol.test(values.name)) {
errors.name = 'Project Name should not contain symbols.';
}
if (!values?.short_description) {
errors.short_description = 'Short Description is Required.';
}
if (!values?.description) {
errors.description = 'Description is Required.';
}

return errors;
if (!values?.short_description) {
errors.short_description = 'Short Description is Required.';
}

export default EditProjectValidation;

if (!values?.description) {
errors.description = 'Description is Required.';
}

return errors;
}

export default EditProjectValidation;
4 changes: 2 additions & 2 deletions src/frontend/main/src/views/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const Home = () => {
</CoreModules.Stack> */}
</div>

<div className="fmtm-flex fmtm-justify-end fmtm-mr-4 fmtm-py-1 fmtm-gap-3">
{/* <div className="fmtm-flex fmtm-justify-end fmtm-mr-4 fmtm-py-1 fmtm-gap-3">
<div>1-5 of 10 </div>
<AssetModules.ArrowLeftIcon
sx={{
Expand All @@ -132,7 +132,7 @@ const Home = () => {
type="number"
className="fmtm-w-10 fmtm-rounded-md fmtm-border-[1px] fmtm-border-[#E7E2E2] fmtm-outline-none"
/>
</div>
</div> */}
</div>
);
};
Expand Down

0 comments on commit 59da130

Please sign in to comment.