Skip to content

Commit

Permalink
fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Nov 17, 2024
1 parent 954b49e commit 8fb2e6f
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ function PlanningConstraintsComponent(props: Props) {
});

const changeSelectAll =
(vals: string[]) =>
(vals: string[] | undefined) =>
(_event: ChangeEvent<HTMLInputElement>, _checked: boolean) => {
let newCheckedVals: string[];
if (vals.length !== availableDatasets.length) {
if (vals?.length !== availableDatasets.length) {
newCheckedVals = availableDatasets.map((d) => d.val);
} else {
newCheckedVals = [];
Expand All @@ -58,12 +58,13 @@ function PlanningConstraintsComponent(props: Props) {
(val: string) =>
(_event: ChangeEvent<HTMLInputElement>, _checked: boolean) => {
let newCheckedVals;
if (formik.values.dataValues.includes(val)) {
if (formik.values.dataValues?.includes(val)) {
newCheckedVals = formik.values.dataValues.filter((dv) => dv !== val);
} else {
newCheckedVals = [...formik.values.dataValues, val];
newCheckedVals = formik.values.dataValues
? [...formik.values.dataValues, val]
: [val];
}

formik.setFieldValue("dataValues", newCheckedVals);
};

Expand Down Expand Up @@ -122,7 +123,7 @@ function PlanningConstraintsComponent(props: Props) {
color="primary"
checked={
availableDatasets.length ===
formik.values.dataValues.length
formik.values.dataValues?.length
}
onChange={changeSelectAll(formik.values.dataValues)}
inputProps={{
Expand All @@ -143,7 +144,7 @@ function PlanningConstraintsComponent(props: Props) {
<TableCell sx={{ verticalAlign: "top" }}>
<Checkbox
color="primary"
checked={formik.values.dataValues.includes(
checked={formik.values.dataValues?.includes(
dataset.val,
)}
onChange={changeDataset(dataset.val)}
Expand Down

0 comments on commit 8fb2e6f

Please sign in to comment.