2023-07-06 20:01:23 +03:00
|
|
|
import { useAxios } from "@/lib/hooks";
|
|
|
|
|
2023-07-07 13:56:08 +03:00
|
|
|
import {
|
2023-07-12 16:45:45 +03:00
|
|
|
addBrainSubscriptions,
|
2023-07-07 13:56:08 +03:00
|
|
|
createBrain,
|
|
|
|
deleteBrain,
|
|
|
|
getBrain,
|
|
|
|
getBrainDocuments,
|
|
|
|
getBrains,
|
2023-07-17 16:45:18 +03:00
|
|
|
getBrainUsers,
|
2023-07-07 13:56:08 +03:00
|
|
|
getDefaultBrain,
|
2023-07-25 13:08:08 +03:00
|
|
|
setAsDefaultBrain,
|
2023-07-12 16:45:45 +03:00
|
|
|
Subscription,
|
2023-07-26 00:12:46 +03:00
|
|
|
updateBrain,
|
2023-07-18 15:30:19 +03:00
|
|
|
updateBrainAccess,
|
2023-07-07 13:56:08 +03:00
|
|
|
} from "./brain";
|
2023-07-26 00:12:46 +03:00
|
|
|
import {
|
|
|
|
CreateBrainInput,
|
|
|
|
SubscriptionUpdatableProperties,
|
|
|
|
UpdateBrainInput,
|
|
|
|
} from "./types";
|
2023-07-06 20:01:23 +03:00
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
|
export const useBrainApi = () => {
|
|
|
|
const { axiosInstance } = useAxios();
|
|
|
|
|
|
|
|
return {
|
|
|
|
getBrainDocuments: async (brainId: string) =>
|
|
|
|
getBrainDocuments(brainId, axiosInstance),
|
2023-07-25 13:08:08 +03:00
|
|
|
createBrain: async (brain: CreateBrainInput) =>
|
|
|
|
createBrain(brain, axiosInstance),
|
2023-07-07 13:56:08 +03:00
|
|
|
deleteBrain: async (id: string) => deleteBrain(id, axiosInstance),
|
|
|
|
getDefaultBrain: async () => getDefaultBrain(axiosInstance),
|
|
|
|
getBrains: async () => getBrains(axiosInstance),
|
|
|
|
getBrain: async (id: string) => getBrain(id, axiosInstance),
|
2023-07-12 16:45:45 +03:00
|
|
|
addBrainSubscriptions: async (
|
|
|
|
brainId: string,
|
2023-07-17 16:45:18 +03:00
|
|
|
subscriptions: Subscription[]
|
2023-07-12 16:45:45 +03:00
|
|
|
) => addBrainSubscriptions(brainId, subscriptions, axiosInstance),
|
2023-07-17 16:45:18 +03:00
|
|
|
getBrainUsers: async (brainId: string) =>
|
|
|
|
getBrainUsers(brainId, axiosInstance),
|
2023-07-18 15:30:19 +03:00
|
|
|
updateBrainAccess: async (
|
|
|
|
brainId: string,
|
|
|
|
userEmail: string,
|
|
|
|
subscription: SubscriptionUpdatableProperties
|
|
|
|
) => updateBrainAccess(brainId, userEmail, subscription, axiosInstance),
|
2023-07-25 13:08:08 +03:00
|
|
|
setAsDefaultBrain: async (brainId: string) =>
|
|
|
|
setAsDefaultBrain(brainId, axiosInstance),
|
2023-07-26 00:12:46 +03:00
|
|
|
updateBrain: async (brainId: string, brain: UpdateBrainInput) =>
|
|
|
|
updateBrain(brainId, brain, axiosInstance),
|
2023-07-06 20:01:23 +03:00
|
|
|
};
|
|
|
|
};
|