Skip to content

Commit

Permalink
fix(dataExtract): additionalFeature add to formValue for validation
Browse files Browse the repository at this point in the history
  • Loading branch information
NSUWAL123 committed Sep 24, 2024
1 parent b02d5c8 commit a85ce7f
Showing 1 changed file with 43 additions and 37 deletions.
80 changes: 43 additions & 37 deletions src/frontend/src/components/createnewproject/DataExtract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const DataExtract = ({
resetFile(setCustomDataExtractUpload);
generateDataExtract();
}}
className="fmtm-mt-6 fmtm-text-base"
className="fmtm-mt-4 !fmtm-mb-8 fmtm-text-base"
isLoading={isFgbFetching}
loadingText="Generating Map Features..."
disabled={dataExtractGeojson && customDataExtractUpload ? true : false}
Expand All @@ -279,42 +279,48 @@ const DataExtract = ({
/>
</>
)}
<div className="fmtm-mt-4">
<CustomCheckbox
key="uploadAdditionalFeature"
label="Upload Additional Features"
checked={formValues?.hasAdditionalFeature}
onCheckedChange={(status) => {
handleCustomChange('hasAdditionalFeature', status);
setAdditionalFeature(null);
}}
className="fmtm-text-black"
labelClickable
/>
{formValues?.hasAdditionalFeature && (
<>
<FileInputComponent
onChange={async (e) => {
if (e?.target?.files) {
const uploadedFile = e?.target?.files[0];
setAdditionalFeature(uploadedFile);
const additionalFeatureGeojson = await convertFileToFeatureCol(uploadedFile);
dispatch(CreateProjectActions.SetAdditionalFeatureGeojson(additionalFeatureGeojson));
}
}}
onResetFile={() => {
resetFile(setAdditionalFeature);
dispatch(CreateProjectActions.SetAdditionalFeatureGeojson(null));
}}
customFile={additionalFeature}
btnText="Upload Additional Features"
accept=".geojson"
fileDescription="*The supported file formats are .geojson"
errorMsg={errors.additionalFeature}
/>
</>
)}
</div>
{extractWays && (
<div className="fmtm-mt-4">
<CustomCheckbox
key="uploadAdditionalFeature"
label="Upload Additional Features"
checked={formValues?.hasAdditionalFeature}
onCheckedChange={(status) => {
handleCustomChange('hasAdditionalFeature', status);
handleCustomChange('additionalFeature', null);
dispatch(CreateProjectActions.SetAdditionalFeatureGeojson(null));
setAdditionalFeature(null);
}}
className="fmtm-text-black"
labelClickable
/>
{formValues?.hasAdditionalFeature && (
<>
<FileInputComponent
onChange={async (e) => {
if (e?.target?.files) {
const uploadedFile = e?.target?.files[0];
setAdditionalFeature(uploadedFile);
handleCustomChange('additionalFeature', uploadedFile);
const additionalFeatureGeojson = await convertFileToFeatureCol(uploadedFile);
dispatch(CreateProjectActions.SetAdditionalFeatureGeojson(additionalFeatureGeojson));
}
}}
onResetFile={() => {
resetFile(setAdditionalFeature);
dispatch(CreateProjectActions.SetAdditionalFeatureGeojson(null));
handleCustomChange('additionalFeature', null);
}}
customFile={additionalFeature}
btnText="Upload Additional Features"
accept=".geojson"
fileDescription="*The supported file formats are .geojson"
errorMsg={errors.additionalFeature}
/>
</>
)}
</div>
)}
</div>
<div className="fmtm-flex fmtm-gap-5 fmtm-mx-auto fmtm-mt-10 fmtm-my-5">
<Button
Expand Down

0 comments on commit a85ce7f

Please sign in to comment.