quivr/frontend/lib/api/subscription/useSubscriptionApi.ts
Mamadou DICKO 1643b54b7b
feat: allow user to unsubscribe from a brain (#1254)
* feat: update translations

* feat: add <DeleteOrUnsubscribeConfirmationModal />

* test(DeleteOrUnsubscribeConfirmationModal): update tests

* feat: redirect to /brains-management on invalid brain id

* refactor: move delete_brain_user to delete_brain_users

* feat: add /POST '/brains/{brain_id}/subscribe'

* feat: handle public brain unsubscription
2023-09-25 14:22:59 +02:00

30 lines
869 B
TypeScript

import { UUID } from "crypto";
import { useAxios } from "@/lib/hooks";
import {
acceptInvitation,
declineInvitation,
getInvitation,
subscribeToBrain,
unsubscribeFromBrain,
} from "./subscription";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useSubscriptionApi = () => {
const { axiosInstance } = useAxios();
return {
acceptInvitation: async (brainId: UUID) =>
acceptInvitation(brainId, axiosInstance),
declineInvitation: async (brainId: UUID) =>
declineInvitation(brainId, axiosInstance),
getInvitation: async (brainId: UUID) =>
getInvitation(brainId, axiosInstance),
subscribeToBrain: async (brainId: UUID) =>
subscribeToBrain(brainId, axiosInstance),
unsubscribeFromBrain: async (brainId: UUID) =>
unsubscribeFromBrain(brainId, axiosInstance),
};
};