mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-17 05:57:48 +00:00
bfb02b2242
Add the frontend client that calls the update participant role endpoint. Straightforward API call, no special handling.
32 lines
882 B
TypeScript
32 lines
882 B
TypeScript
import { fetchApi } from '@/api/fetchApi'
|
|
import { useRoomData } from '@/features/rooms/livekit/hooks/useRoomData'
|
|
import { AssignableParticipantRole } from '@/features/rooms/api/ApiRoom'
|
|
|
|
export const useParticipantRole = () => {
|
|
const data = useRoomData()
|
|
|
|
const updateParticipantRole = async (
|
|
identity: string,
|
|
role: AssignableParticipantRole
|
|
) => {
|
|
if (!data?.id) {
|
|
throw new Error('Room id is not available')
|
|
}
|
|
|
|
try {
|
|
return fetchApi(`rooms/${data.id}/update-participant-role/`, {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
participant_identity: identity,
|
|
role: role,
|
|
}),
|
|
})
|
|
} catch (error) {
|
|
console.error(
|
|
`Failed to update participant's role ${identity}: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
)
|
|
}
|
|
}
|
|
return { updateParticipantRole }
|
|
}
|