Fix: useCallback dependency array in availability page

Compute dates inside fetchAvailability callback to avoid
dependency on external variable that changes on every render.
This commit is contained in:
counterweight 2025-12-21 17:32:55 +01:00
parent 77e7f98e1e
commit eefdfd714f
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 7 additions and 3 deletions

3
.gitignore vendored
View file

@ -24,3 +24,6 @@ Thumbs.db
current_pr.md
next_pr.md
# Notes
notes/

View file

@ -73,11 +73,12 @@ export default function AdminAvailabilityPage() {
const dates = getDateRange();
const fetchAvailability = useCallback(async () => {
if (!dates.length) return;
const dateRange = getDateRange();
if (!dateRange.length) return;
try {
const fromDate = formatDate(dates[0]);
const toDate = formatDate(dates[dates.length - 1]);
const fromDate = formatDate(dateRange[0]);
const toDate = formatDate(dateRange[dateRange.length - 1]);
const data = await api.get<AvailabilityResponse>(
`/api/admin/availability?from=${fromDate}&to=${toDate}`
);