-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/WG-242: Filters Panel react hazmapper (#225)
* task/WG-242: Filters Panel react hazmapper * updating requests and usefeatures hook to handle filters * addressing multiple network requests and state changes * added calendar comp for handling date range * lifting state up to parent comp for date storage * adding tooltip for date range * optimizing chunk size by seperating several node packages * refactoring and cleaning up code for requests and features --------- Co-authored-by: Taylor Grafft <[email protected]> Co-authored-by: Taylor Grafft <[email protected]> Co-authored-by: Taylor Grafft <[email protected]> Co-authored-by: Taylor Grafft <[email protected]>
- Loading branch information
1 parent
794e929
commit d96407b
Showing
9 changed files
with
321 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import React from 'react'; | ||
import styles from './Filters.module.css'; | ||
import DatePicker from 'react-datepicker'; | ||
import 'react-datepicker/dist/react-datepicker.css'; | ||
|
||
interface FiltersProps { | ||
selectedAssetTypes: string[]; | ||
onFiltersChange: (selectedAssetTypes: string[]) => void; | ||
startDate: Date; | ||
setStartDate: (date: Date) => void; | ||
endDate: Date; | ||
setEndDate: (date: Date) => void; | ||
} | ||
|
||
interface CustomInputProps { | ||
value?: string; | ||
onClick?: () => void; | ||
} | ||
|
||
export const assetTypeOptions = { | ||
Image: 'Image', | ||
Video: 'Video', | ||
PointCloud: 'Point Cloud', | ||
Streetview: 'Streetview', | ||
Questionnaire: 'Questionnaire', | ||
NoAssetVector: 'No Asset Vector', | ||
}; | ||
|
||
const Filters: React.FC<FiltersProps> = ({ | ||
selectedAssetTypes, | ||
onFiltersChange, | ||
startDate, | ||
setStartDate, | ||
endDate, | ||
setEndDate, | ||
}) => { | ||
const handleFilterChange = (assetType: string) => { | ||
if (selectedAssetTypes.includes(assetType)) { | ||
onFiltersChange(selectedAssetTypes.filter((type) => type !== assetType)); | ||
} else { | ||
onFiltersChange([...selectedAssetTypes, assetType]); | ||
} | ||
}; | ||
|
||
const CustomInputWithTooltip = React.forwardRef< | ||
HTMLInputElement, | ||
CustomInputProps | ||
>(({ value, onClick }, ref) => ( | ||
<div className={styles.customInputContainer}> | ||
<input | ||
className={styles.customInput} | ||
value={value} | ||
onClick={onClick} | ||
ref={ref} | ||
readOnly | ||
/> | ||
<span | ||
className={styles.tooltip} | ||
title="Choose the date(s) corresponding to when the data collection occurred in the field, not when the data was uploaded to the map project." | ||
> | ||
? | ||
</span> | ||
</div> | ||
)); | ||
|
||
CustomInputWithTooltip.displayName = 'CustomInputWithTooltip'; | ||
|
||
return ( | ||
<div className={styles.root}> | ||
<h3>Filters</h3> | ||
<h2>Date Range</h2> | ||
<h5>Start Date</h5> | ||
<DatePicker | ||
selected={startDate} | ||
onChange={(date: Date) => setStartDate(date)} | ||
selectsStart | ||
startDate={startDate} | ||
endDate={endDate} | ||
customInput={<CustomInputWithTooltip />} | ||
/> | ||
<h5>End Date</h5> | ||
<DatePicker | ||
selected={endDate} | ||
onChange={(date: Date) => setEndDate(date)} | ||
selectsEnd | ||
startDate={startDate} | ||
endDate={endDate} | ||
minDate={startDate} | ||
customInput={<CustomInputWithTooltip />} | ||
/> | ||
<h2>Asset Types</h2> | ||
{Object.entries(assetTypeOptions).map(([key, value]) => ( | ||
<div key={key}> | ||
<label className={styles.filterOption}> | ||
<input | ||
type="checkbox" | ||
checked={selectedAssetTypes.includes(key)} | ||
onChange={() => handleFilterChange(key)} | ||
/> | ||
{value} | ||
</label> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Filters; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.root { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
height: 100%; | ||
padding-left: 20px; | ||
} | ||
|
||
.customInputContainer { | ||
position: relative; | ||
display: inline-block; | ||
} | ||
|
||
.customInput { | ||
padding-right: 20px; | ||
width: 73%; | ||
} | ||
|
||
.tooltip { | ||
font-weight: bold; | ||
position: absolute; | ||
right: 15px; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
cursor: pointer; | ||
} | ||
|
||
.filterOption { | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: 8px; | ||
} | ||
|
||
.filterLabel { | ||
padding-top: 5px; | ||
} | ||
|
||
.filterOption input[type='checkbox'] { | ||
margin-right: 10px; | ||
} | ||
|
||
h2 { | ||
padding-top: 9px; | ||
} | ||
|
||
h3 { | ||
color: #0f83bd; | ||
} | ||
|
||
h5 { | ||
padding-top: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './Filter'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.