From 34fde1085461797128ff706711f7b6e2b91691eb Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Tue, 26 Aug 2025 22:57:47 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(frontend)=20add=20client-side=20API?= =?UTF-8?q?=20call=20for=20participant=20removal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement frontend functionality to call backend endpoints for removing participants from rooms through proper server-mediated requests. --- .../features/rooms/api/removeParticipant.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/frontend/src/features/rooms/api/removeParticipant.ts diff --git a/src/frontend/src/features/rooms/api/removeParticipant.ts b/src/frontend/src/features/rooms/api/removeParticipant.ts new file mode 100644 index 00000000..aba45dad --- /dev/null +++ b/src/frontend/src/features/rooms/api/removeParticipant.ts @@ -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 } +}