diff --git a/frontend/src/app/allocation/page.tsx b/frontend/src/app/allocation/page.tsx index 59fb23b..e944f97 100644 --- a/frontend/src/app/allocation/page.tsx +++ b/frontend/src/app/allocation/page.tsx @@ -17,8 +17,8 @@ export default function AllocationPage() { fetchData(); }, [year]); - const fetchData = async () => { - setLoading(true); + const fetchData = async (background = false) => { + if (!background) setLoading(true); try { const [fieldsRes, cropsRes, plansRes] = await Promise.all([ api.get('/fields/'), @@ -31,7 +31,7 @@ export default function AllocationPage() { } catch (error) { console.error('Failed to fetch data:', error); } finally { - setLoading(false); + if (!background) setLoading(false); } }; @@ -64,7 +64,7 @@ export default function AllocationPage() { notes: '', }); } - await fetchData(); + await fetchData(true); } catch (error) { console.error('Failed to save crop:', error); } finally { @@ -87,7 +87,7 @@ export default function AllocationPage() { variety, notes: existingPlan.notes, }); - await fetchData(); + await fetchData(true); } catch (error) { console.error('Failed to save variety:', error); } finally { @@ -108,7 +108,7 @@ export default function AllocationPage() { await api.patch(`/plans/${existingPlan.id}/`, { notes, }); - await fetchData(); + await fetchData(true); } catch (error) { console.error('Failed to save notes:', error); } finally {