Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import useCurrentTask from "../../../../../hooks/playbooks/task/useCurrentTask"; import useIsPrefetched from "../../../../../hooks/playbooks/useIsPrefetched"; import getNestedValue from "../../../../../utils/common/getNestedValue"; import { updateCardById } from "../../../../../utils/execution/updateCardById"; import Checkbox from "../../../../common/Checkbox"; import TimeseriesOffestSelection from "./TimeseriesOffestSelection"; import { CHECKBOX_KEY, DROPDOWN_KEY, TIMESERIES_OFFSET_ARR_KEY } from "./utils"; type ComparisonSelectorProps = { id: string; }; function ComparisonSelector({ id }: ComparisonSelectorProps) { const [task] = useCurrentTask(id); const isChecked = getNestedValue(task, CHECKBOX_KEY); const isPrefetched = useIsPrefetched(); const handleChange = () => { const value = !isChecked; updateCardById(CHECKBOX_KEY, value, id); Iif (!value) { updateCardById(DROPDOWN_KEY, null, id); updateCardById(TIMESERIES_OFFSET_ARR_KEY, undefined, id); } }; return ( <div> <Checkbox id="use_comparison" isChecked={isChecked ?? false} label="Also add from a previous window" onChange={handleChange} isSmall={true} disabled={!!isPrefetched} /> {isChecked && <TimeseriesOffestSelection id={id} />} </div> ); } export default ComparisonSelector; |