quivr/frontend/lib/api/brain/useBrainApi.ts
Mamadou DICKO 8172704b61
feat: add public brain page (#1230)
* feat: add brain library button

* feat(Field): add inputClassName key

* feat: add GET brains/public route

* feat: add brains library layout

* feat: add brain subscriber count
2023-09-21 09:35:53 +02:00

55 lines
1.7 KiB
TypeScript

import { useAxios } from "@/lib/hooks";
import {
addBrainSubscriptions,
createBrain,
deleteBrain,
getBrain,
getBrainDocuments,
getBrains,
getBrainUsers,
getDefaultBrain,
getPublicBrains,
setAsDefaultBrain,
Subscription,
updateBrain,
updateBrainAccess,
} from "./brain";
import {
CreateBrainInput,
SubscriptionUpdatableProperties,
UpdateBrainInput,
} from "./types";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useBrainApi = () => {
const { axiosInstance } = useAxios();
return {
getBrainDocuments: async (brainId: string) =>
getBrainDocuments(brainId, axiosInstance),
createBrain: async (brain: CreateBrainInput) =>
createBrain(brain, axiosInstance),
deleteBrain: async (id: string) => deleteBrain(id, axiosInstance),
getDefaultBrain: async () => getDefaultBrain(axiosInstance),
getBrains: async () => getBrains(axiosInstance),
getBrain: async (id: string) => getBrain(id, axiosInstance),
addBrainSubscriptions: async (
brainId: string,
subscriptions: Subscription[]
) => addBrainSubscriptions(brainId, subscriptions, axiosInstance),
getBrainUsers: async (brainId: string) =>
getBrainUsers(brainId, axiosInstance),
updateBrainAccess: async (
brainId: string,
userEmail: string,
subscription: SubscriptionUpdatableProperties
) => updateBrainAccess(brainId, userEmail, subscription, axiosInstance),
setAsDefaultBrain: async (brainId: string) =>
setAsDefaultBrain(brainId, axiosInstance),
updateBrain: async (brainId: string, brain: UpdateBrainInput) =>
updateBrain(brainId, brain, axiosInstance),
getPublicBrains: async () => getPublicBrains(axiosInstance),
};
};