mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 09:35:36 +01:00
Updated team provider.
This commit is contained in:
parent
10f1b906ec
commit
d307eb4317
1 changed files with 4 additions and 4 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue