✨(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:
committed by
aleb_the_flash
parent
84c820bc60
commit
34fde10854
21
src/frontend/src/features/rooms/api/removeParticipant.ts
Normal file
21
src/frontend/src/features/rooms/api/removeParticipant.ts
Normal 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 }
|
||||
}
|
||||
Reference in New Issue
Block a user