({
timePeriodMinutes,
setTimePeriodMinutes,
options = DEFAULT_OPTIONS,
}: TimePeriodSelectProps)
| 21 | } |
| 22 | |
| 23 | const TimePeriodSelect = ({ |
| 24 | timePeriodMinutes, |
| 25 | setTimePeriodMinutes, |
| 26 | options = DEFAULT_OPTIONS, |
| 27 | }: TimePeriodSelectProps) => { |
| 28 | const navigate = useNavigate(); |
| 29 | const location = useLocation(); |
| 30 | const setTimePeriod = (timePeriod: string) => { |
| 31 | const searchParams = new URLSearchParams(location.search); |
| 32 | searchParams.set("timePeriod", timePeriod); |
| 33 | navigate( |
| 34 | location.pathname + "?" + searchParams.toString() + location.hash, |
| 35 | { |
| 36 | replace: true, |
| 37 | }, |
| 38 | ); |
| 39 | setTimePeriodMinutes(parseInt(timePeriod)); |
| 40 | }; |
| 41 | |
| 42 | return ( |
| 43 | <SimpleSelect |
| 44 | value={timePeriodMinutes} |
| 45 | onChange={(e) => setTimePeriod(e.target.value)} |
| 46 | > |
| 47 | {Object.entries(options).map(([value, text]) => ( |
| 48 | <option key={value} value={value}> |
| 49 | {text} |
| 50 | </option> |
| 51 | ))} |
| 52 | </SimpleSelect> |
| 53 | ); |
| 54 | }; |
| 55 | |
| 56 | export default TimePeriodSelect; |
nothing calls this directly
no test coverage detected