Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
refactor: wait for teaminfo before fetching
Marc Seitz5d9a98f4ece2
diff --git a/lib/swr/use-billing.ts b/lib/swr/use-billing.tsindex 10c907b7..ba1f4568 100644--- a/lib/swr/use-billing.ts+++ b/lib/swr/use-billing.ts@@ -19,7 +19,7 @@ export function useBilling() {const teamInfo = useTeam();const { data, error } = useSWR<BillingProps>(- `/api/teams/${teamInfo?.currentTeam?.id}/billing`,+ teamInfo?.currentTeam && `/api/teams/${teamInfo.currentTeam.id}/billing`,fetcher,{dedupingInterval: 30000,diff --git a/lib/swr/use-stats.ts b/lib/swr/use-stats.tsindex c9f5ad42..fe5404e8 100644--- a/lib/swr/use-stats.ts+++ b/lib/swr/use-stats.ts@@ -26,7 +26,8 @@ export function useStats({const { data: stats, error } = useSWR<TStatsData>(id &&- `/api/teams/${teamInfo?.currentTeam?.id}/documents/${encodeURIComponent(+ teamInfo?.currentTeam &&+ `/api/teams/${teamInfo.currentTeam.id}/documents/${encodeURIComponent(id,)}/stats${excludeTeamMembers ? "?excludeTeamMembers=true" : ""}`,fetcher,