mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Updated team provider.
This commit is contained in:
parent
10f1b906ec
commit
d307eb4317
@ -5,21 +5,21 @@ import useModified from 'store/modified';
|
|||||||
|
|
||||||
export const TeamContext = createContext(null);
|
export const TeamContext = createContext(null);
|
||||||
|
|
||||||
export function TeamProvider({ teamId, children }: { teamId: string; children: ReactNode }) {
|
export function TeamProvider({ teamId, children }: { teamId?: string; children: ReactNode }) {
|
||||||
const modified = useModified(state => state?.[`team:${teamId}`]);
|
const modified = useModified(state => state?.[`team:${teamId}`]);
|
||||||
const { data: team, isLoading, isFetching, refetch } = useTeam(teamId);
|
const { data: team, isLoading, isFetching, refetch } = useTeam(teamId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (modified) {
|
if (teamId && modified) {
|
||||||
refetch();
|
refetch();
|
||||||
}
|
}
|
||||||
}, [modified]);
|
}, [teamId, modified]);
|
||||||
|
|
||||||
if (isFetching && isLoading) {
|
if (isFetching && isLoading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!team) {
|
if (teamId && !team) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user