Skip to content

Commit

Permalink
refactor: fetch households on mount in households page
Browse files Browse the repository at this point in the history
  • Loading branch information
dila1001 committed Feb 12, 2024
1 parent ee9dd7e commit 4469f88
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 0 additions & 3 deletions frontend/src/pages/EditPlant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ const EditPlant = () => {
response = await addPlant(householdId!, data, user);
navigate(`/${householdId}/plants/${response?.id}?created=true`);
}

const households = await getHouseholdsForUser(user.id);
setHouseholds(households);
}
};

Expand Down
4 changes: 4 additions & 0 deletions frontend/src/pages/Households/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const HouseholdsPage = () => {
joinHouseholdModal.showModal();
}
}
if (user) {
const households = await getHouseholdsForUser(user.id);
setHouseholds(households);
}
};

fetchData();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Plant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const PlantPage = () => {

{/* Check for error state */}
{error && (
<div className='flex flex-col items-center justify-center h-[calc(100vh-220px)] gap-6'>
<div className='flex flex-col items-center justify-center h-[calc(100vh-64px)] gap-6'>
<FaHeartBroken className='text-warning text-[120px]' />
<h1 className='card-title text-neutral mb-12 text-center'>
An error occured while fetching plant
Expand Down

0 comments on commit 4469f88

Please sign in to comment.