mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
fix: resolve import errors and add missing api hooks
- Create constants.ts for RECORD_A_MEETING_URL - Add api-types.ts for backward compatible type exports - Update all imports from deleted api folder to new locations - Add missing React Query hooks for rooms and zulip operations - Create useApi compatibility layer for unmigrated components
This commit is contained in:
@@ -108,3 +108,88 @@ export function useTranscriptGet(transcriptId: string | null) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
// Rooms mutations
|
||||
export function useRoomCreate() {
|
||||
const { setError } = useError();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return $api.useMutation("post", "/v1/rooms", {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
|
||||
});
|
||||
},
|
||||
onError: (error) => {
|
||||
setError(error as Error, "There was an error creating the room");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useRoomUpdate() {
|
||||
const { setError } = useError();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return $api.useMutation("patch", "/v1/rooms/{room_id}", {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
|
||||
});
|
||||
},
|
||||
onError: (error) => {
|
||||
setError(error as Error, "There was an error updating the room");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useRoomDelete() {
|
||||
const { setError } = useError();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return $api.useMutation("delete", "/v1/rooms/{room_id}", {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: $api.queryOptions("get", "/v1/rooms").queryKey,
|
||||
});
|
||||
},
|
||||
onError: (error) => {
|
||||
setError(error as Error, "There was an error deleting the room");
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Zulip hooks
|
||||
export function useZulipStreams() {
|
||||
const { setError } = useError();
|
||||
|
||||
return $api.useQuery(
|
||||
"get",
|
||||
"/v1/zulip/get-streams",
|
||||
{},
|
||||
{
|
||||
onError: (error) => {
|
||||
setError(error as Error, "There was an error fetching Zulip streams");
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function useZulipTopics(streamId: number | null) {
|
||||
const { setError } = useError();
|
||||
|
||||
return $api.useQuery(
|
||||
"get",
|
||||
"/v1/zulip/get-topics",
|
||||
{
|
||||
params: {
|
||||
query: { stream_id: streamId || 0 },
|
||||
},
|
||||
},
|
||||
{
|
||||
enabled: !!streamId,
|
||||
onError: (error) => {
|
||||
setError(error as Error, "There was an error fetching Zulip topics");
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user