MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / TimePeriodSelect

Function TimePeriodSelect

console/src/components/TimePeriodSelect.tsx:23–54  ·  view source on GitHub ↗
({
  timePeriodMinutes,
  setTimePeriodMinutes,
  options = DEFAULT_OPTIONS,
}: TimePeriodSelectProps)

Source from the content-addressed store, hash-verified

21}
22
23const 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
56export default TimePeriodSelect;

Callers

nothing calls this directly

Calls 3

setTimePeriodFunction · 0.85
mapMethod · 0.45
entriesMethod · 0.45

Tested by

no test coverage detected