Refactored useQuery functions.

This commit is contained in:
Mike Cao 2023-12-01 20:27:59 -08:00
parent be550cc440
commit b578162cb6
33 changed files with 179 additions and 151 deletions

View file

@ -17,15 +17,15 @@ export function TeamSettings({ teamId }) {
const [tab, setTab] = useState('details');
const { get, useQuery } = useApi();
const { showToast } = useToasts();
const { data, isLoading } = useQuery(
['team', teamId],
() => {
const { data, isLoading } = useQuery({
queryKey: ['team', teamId],
queryFn: () => {
if (teamId) {
return get(`/teams/${teamId}`);
}
},
{ cacheTime: 0 },
);
cacheTime: 0,
});
const canEdit = data?.teamUser?.find(
({ userId, role }) => role === ROLES.teamOwner && userId === user.id,
);