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:
2025-08-27 23:55:59 -06:00
parent e8afe82acd
commit 68c161ee7e
33 changed files with 167 additions and 30 deletions

View File

@@ -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");
},
},
);
}

28
www/app/lib/api-types.ts Normal file
View File

@@ -0,0 +1,28 @@
// Re-export types from generated OpenAPI schema for backward compatibility
import type { components } from "../reflector-api";
// Export types with their original names
export type Room = components["schemas"]["Room"];
export type Meeting = components["schemas"]["Meeting"];
export type SourceKind = components["schemas"]["SourceKind"];
export type SearchResult = components["schemas"]["SearchResult"];
export type GetTranscript = components["schemas"]["GetTranscript"];
export type GetTranscriptTopic = components["schemas"]["GetTranscriptTopic"];
export type UpdateTranscript = components["schemas"]["UpdateTranscript"];
export type AudioWaveform = components["schemas"]["AudioWaveform"];
export type Participant = components["schemas"]["Participant"];
export type CreateTranscript = components["schemas"]["CreateTranscript"];
export type RtcOffer = components["schemas"]["RtcOffer"];
export type GetTranscriptSegmentTopic =
components["schemas"]["GetTranscriptSegmentTopic"];
export type Page_Room_ = components["schemas"]["Page_Room_"];
export type ApiError = components["schemas"]["ApiError"];
export type GetTranscriptTopicWithWordsPerSpeaker =
components["schemas"]["GetTranscriptTopicWithWordsPerSpeaker"];
export type GetTranscriptMinimal =
components["schemas"]["GetTranscriptMinimal"];
// Export any enums or constants that were in the old API
export const $SourceKind = {
values: ["SINGLE", "CALL", "WHEREBY", "UPLOAD"] as const,
} as const;

2
www/app/lib/constants.ts Normal file
View File

@@ -0,0 +1,2 @@
// Application-wide constants
export const RECORD_A_MEETING_URL = "/transcripts/new" as const;

13
www/app/lib/useApi.ts Normal file
View File

@@ -0,0 +1,13 @@
// Compatibility layer for direct API client usage
// Prefer using React Query hooks from api-hooks.ts instead
import { client } from "./apiClient";
// Returns the configured client for direct API calls
// This is a minimal compatibility layer for components that haven't been fully migrated
export default function useApi() {
return client;
}
// Export the client directly for non-hook contexts
export { client };