diff --git a/collection/app/(app)/PageActions.tsx b/collection/app/(app)/PageActions.tsx index 1fc0648..a714c5b 100644 --- a/collection/app/(app)/PageActions.tsx +++ b/collection/app/(app)/PageActions.tsx @@ -27,7 +27,11 @@ export const PageActions = ({ {...formHook.getInputProps("academicYears")} /> - + void }) { +function CheckboxesForProducts({ + close, + academicYears, + currentlySelectedAcademicYears, +}: { + close: () => void; + academicYears: string[]; + currentlySelectedAcademicYears: string[]; +}) { const [value, setValue] = useState([]); const [status, setStatus] = useState({ status: "pending", }); + const [academicYearsToSync, setAcademicYearsToSync] = useState(currentlySelectedAcademicYears); + const { data: products, isLoading } = useSWR("/api/products/syncable", fetcher); const [isPending, startTransition] = useTransition(); @@ -29,6 +50,7 @@ function CheckboxesForProducts({ close }: { close: () => void }) { startTransition(async () => { const res = await loadSalesFromEActivites( value.map((id) => parseInt(id, 10)).filter(isFinite), + academicYearsToSync, ); if (res.status === "error") { setStatus(res); @@ -39,7 +61,7 @@ function CheckboxesForProducts({ close }: { close: () => void }) { close(); } }); - }, [close, value]); + }, [close, value, academicYearsToSync]); const cards = products?.map((product, i) => ( @@ -88,6 +110,13 @@ function CheckboxesForProducts({ close }: { close: () => void }) { ) } + setAcademicYearsToSync(e)} + data={academicYears} + /> void }) { export const SyncEActivities = ({ setActionsError, + academicYears, + currentlySelectedAcademicYears, }: { setActionsError: (error: string | null) => void; + academicYears: string[]; + currentlySelectedAcademicYears: string[]; }) => { const [opened, { open, close }] = useDisclosure(false); return ( <> - +