(frontend) add client-side API call for participant removal

Implement frontend functionality to call backend endpoints for removing
participants from rooms through proper server-mediated requests.
This commit is contained in:
lebaudantoine
2025-08-26 22:57:47 +02:00
committed by aleb_the_flash
parent 84c820bc60
commit 34fde10854

View File

@@ -0,0 +1,21 @@
import { Participant } from 'livekit-client'
import { useRoomData } from '../livekit/hooks/useRoomData'
import { fetchApi } from '@/api/fetchApi'
export const useRemoveParticipant = () => {
const data = useRoomData()
const removeParticipant = async (participant: Participant) => {
if (!data?.id) {
throw new Error('Room id is not available')
}
return fetchApi(`rooms/${data.id}/remove-participant/`, {
method: 'POST',
body: JSON.stringify({
participant_identity: participant.identity,
}),
})
}
return { removeParticipant }
}