Skip to content

Commit

Permalink
feat: format handled from config itself
Browse files Browse the repository at this point in the history
  • Loading branch information
varun2948 committed Jan 8, 2024
1 parent a38dc57 commit 838eb5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/projectDetail/downloadOsmData.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ export const TITLED_ICONS = [
},
];

const fileFormats = [{ format: 'SHP' }, { format: 'GEOJSON' }, { format: 'KML' }];

/**
* Renders a list of download options for OSM data based on the project mapping types.
*
Expand Down Expand Up @@ -176,7 +174,7 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => {
<p className="fw5 ttc">{type.title}</p>
<FileFormatCard
title={type.title}
fileFormats={fileFormats}
fileFormats={type.formats}
downloadS3Data={downloadS3File}
isDownloadingState={isDownloadingState}
selectedCategoryFormat={selectedCategoryFormat}
Expand Down Expand Up @@ -214,7 +212,9 @@ export const DownloadOsmData = ({ projectMappingTypes, project }) => {
style={{ gap: '10px' }}
>
<DownloadIcon style={{ height: '28px' }} color="#D73F3F" />
<p className="ttc">{typ}</p>
<p className="ttc">
{typ} {selectedCategoryFormat.format}
</p>
</span>
))}
</div>
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/components/projectDetail/fileFormatCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ function FileFormatCard({
const loadingState =
isDownloadingState?.isDownloading &&
isDownloadingState?.title === title &&
isDownloadingState?.fileFormat === fileFormat?.format;
isDownloadingState?.fileFormat === fileFormat;

return (
<React.Fragment key={fileFormat.title}>
<React.Fragment key={fileFormat}>
<span
role="button"
tabIndex={0}
Expand All @@ -38,17 +38,16 @@ function FileFormatCard({
? { cursor: 'not-allowed', pointerEvents: 'none' }
: { cursor: 'pointer' }
}
onClick={() => setSelectedCategoryFormat({ title, format: fileFormat.format })}
onKeyUp={() => setSelectedCategoryFormat({ title, format: fileFormat.format })}
onClick={() => setSelectedCategoryFormat({ title, format: fileFormat })}
onKeyUp={() => setSelectedCategoryFormat({ title, format: fileFormat })}
className={`link ${
selectedCategoryFormat?.format === fileFormat?.format &&
selectedCategoryFormat.title === title
selectedCategoryFormat === fileFormat && selectedCategoryFormat.title === title
? 'red'
: ''
} hover-red color-inherit`}
>
<p className="underline fw5" style={{ textUnderlineOffset: '5px' }}>
{fileFormat.format}
<p className="underline fw5 ttu " style={{ textUnderlineOffset: '5px' }}>
{fileFormat}
{loadingState ? <AnimatedLoadingIcon /> : null}
</p>
</span>
Expand Down

0 comments on commit 838eb5b

Please sign in to comment.