useEffect(() => {
const newAccounts = Object.values(accountGroups).map((ownershipType) =>
ownershipType.map((group) => ({
...group,
accounts: group.accounts.map((account) => {
const isChecked = !!selectedFavoriteFilter.value;
return { ...account, expanded: [{ selected: isChecked && account.isFavorite }] };
}),
})),
);
const filteredFavoriteAccountGroups = {
single: newAccounts[0],
shared: newAccounts[1],
tutor: newAccounts[2],
proxy: newAccounts[3],
};
setAccountGroups(filteredFavoriteAccountGroups);
}, [selectedFavoriteFilter]);
useEffect(() => {
const newAccounts = Object.values(accountGroups).map((ownershipType) =>
ownershipType.map((group) => ({
...group,
accounts: group.accounts.map((account) => {
const isChecked = !!selectedFavoriteFilter.value;
return { ...account, expanded: [{ selected: isChecked && account.isFavorite }] };
}),
})),
);
const filteredFavoriteAccountGroups = {
single: newAccounts[0],
shared: newAccounts[1],
tutor: newAccounts[2],
proxy: newAccounts[3],
};
setAccountGroups(filteredFavoriteAccountGroups);
}, [selectedFavoriteFilter]);