Files
meet/src/frontend/src/features/participants/api/enterRoom.ts
T
lebaudantoine d1dde71bea 🚚(frontend) move participant list code into a feature folder
Reorganize all participant list related code elements into a
dedicated feature folder, so related components, hooks and helpers
are grouped together and easier to locate.
2026-07-24 18:31:47 +02:00

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,
})
}