17 lines
458 B
TypeScript
17 lines
458 B
TypeScript
import { fetcher } from 'services/utils'
|
|
import useSWR from 'swr'
|
|
import { env } from 'utils'
|
|
|
|
export const useUsage = (workspaceId?: string) => {
|
|
const { data, error } = useSWR<
|
|
{ totalChatsUsed: number; totalStorageUsed: number },
|
|
Error
|
|
>(workspaceId ? `/api/workspaces/${workspaceId}/usage` : null, fetcher, {
|
|
dedupingInterval: env('E2E_TEST') === 'enabled' ? 0 : undefined,
|
|
})
|
|
return {
|
|
data,
|
|
isLoading: !error && !data,
|
|
}
|
|
}
|