mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-07 01:13:21 +00:00
bf6f7430e7
Mark JS imports as type-only when applicable so they are stripped at build time and ignored during chunk splitting, ensuring we take full advantage of Rollup's code-splitting optimizations.
38 lines
918 B
TypeScript
38 lines
918 B
TypeScript
import { ApiError } from '@/api/ApiError'
|
|
import { fetchApi } from '@/api/fetchApi'
|
|
import { useMutation, type UseMutationOptions } from '@tanstack/react-query'
|
|
|
|
export interface EnterRoomParams {
|
|
roomId: string
|
|
allowEntry: boolean
|
|
participantId: string
|
|
}
|
|
|
|
export interface EnterRoomResponse {
|
|
message?: string
|
|
}
|
|
|
|
export const enterRoom = async ({
|
|
roomId,
|
|
allowEntry,
|
|
participantId,
|
|
}: EnterRoomParams): Promise<EnterRoomResponse> => {
|
|
return await fetchApi<EnterRoomResponse>(`/rooms/${roomId}/enter/`, {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
participant_id: participantId,
|
|
allow_entry: allowEntry,
|
|
}),
|
|
})
|
|
}
|
|
|
|
export function useEnterRoom(
|
|
options?: UseMutationOptions<EnterRoomResponse, ApiError, EnterRoomParams>
|
|
) {
|
|
return useMutation<EnterRoomResponse, ApiError, EnterRoomParams>({
|
|
mutationFn: enterRoom,
|
|
onSuccess: options?.onSuccess,
|
|
...options,
|
|
})
|
|
}
|