Allow reassigning during active sessions

This commit is contained in:
Esdras Renan 2025-11-19 09:57:04 -03:00
parent feac6c2bb7
commit c79ba4638c

View file

@ -2805,11 +2805,7 @@ export const changeAssignee = mutation({
if (viewer.role === "MANAGER") {
throw new ConvexError("Gestores não podem reatribuir chamados")
}
const normalizedStatus = normalizeStatus(ticketDoc.status)
const hasActiveSession = Boolean(ticketDoc.activeSessionId)
if (normalizedStatus === "AWAITING_ATTENDANCE" && !hasActiveSession) {
throw new ConvexError("Pause o atendimento antes de reatribuir o chamado")
}
const currentAssigneeId = ticketDoc.assigneeId ?? null
if (currentAssigneeId && currentAssigneeId !== actorId && !isAdmin) {
throw new ConvexError("Somente o responsável atual pode reatribuir este chamado")