Remove mildly annoying groups fetch (#2733)

* remove mildly annoying groups fetch

* ensure in client component
This commit is contained in:
pablodanswer 2024-10-08 20:13:19 -07:00 committed by GitHub
parent f83e6806b6
commit 10f221cd37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,4 @@
"use client";
import {
ConnectorIndexingStatus,
DocumentBoostStatus,
@ -6,14 +7,14 @@ import {
} from "@/lib/types";
import useSWR, { mutate, useSWRConfig } from "swr";
import { errorHandlingFetcher } from "./fetcher";
import { useEffect, useState } from "react";
import { useContext, useEffect, useState } from "react";
import { DateRangePickerValue } from "@tremor/react";
import { SourceMetadata } from "./search/interfaces";
import { destructureValue } from "./llm/utils";
import { ChatSession } from "@/app/chat/interfaces";
import { UsersResponse } from "./users/interfaces";
import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled";
import { Credential } from "./connectors/credentials";
import { SettingsContext } from "@/components/settings/SettingsProvider";
const CREDENTIAL_URL = "/api/manage/admin/credential";
@ -220,8 +221,14 @@ export const useUserGroups = (): {
error: string;
refreshUserGroups: () => void;
} => {
const swrResponse = useSWR<UserGroup[]>(USER_GROUP_URL, errorHandlingFetcher);
const isPaidEnterpriseFeaturesEnabled = usePaidEnterpriseFeaturesEnabled();
const combinedSettings = useContext(SettingsContext);
const isPaidEnterpriseFeaturesEnabled =
combinedSettings && combinedSettings.enterpriseSettings !== null;
const swrResponse = useSWR<UserGroup[]>(
isPaidEnterpriseFeaturesEnabled ? USER_GROUP_URL : null,
errorHandlingFetcher
);
if (!isPaidEnterpriseFeaturesEnabled) {
return {