Allow managers to comment without assignee; keep assignee requirement for admin/agent; reflect in UI
This commit is contained in:
parent
b468c6c9e7
commit
7c025a0398
2 changed files with 7 additions and 4 deletions
|
|
@ -781,9 +781,10 @@ export const addComment = mutation({
|
|||
// Regra: a equipe (ADMIN/AGENT/MANAGER) só pode comentar se o ticket tiver responsável.
|
||||
// O solicitante (colaborador) pode comentar sempre.
|
||||
const isRequester = String(ticketDoc.requesterId) === String(author._id)
|
||||
const isStaff = normalizedRole === "ADMIN" || normalizedRole === "AGENT" || normalizedRole === "MANAGER"
|
||||
const isAdminOrAgent = normalizedRole === "ADMIN" || normalizedRole === "AGENT"
|
||||
const hasAssignee = Boolean(ticketDoc.assigneeId)
|
||||
if (!isRequester && isStaff && !hasAssignee) {
|
||||
// Gestores podem comentar mesmo sem responsável; admin/agent só com responsável
|
||||
if (!isRequester && isAdminOrAgent && !hasAssignee) {
|
||||
throw new ConvexError("Somente é possível comentar quando o chamado possui um responsável.")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,9 @@ export function TicketComments({ ticket }: TicketCommentsProps) {
|
|||
const canSeeInternalComments = normalizedRole === "admin" || normalizedRole === "agent"
|
||||
const hasAssignee = Boolean(ticket.assignee)
|
||||
const isRequester = convexUserId ? ticket.requester.id === convexUserId : false
|
||||
const canStaffComment = hasAssignee
|
||||
// Gestor pode comentar sem responsável; admin/agent só com responsável
|
||||
const isManager = normalizedRole === "manager"
|
||||
const canStaffComment = hasAssignee || isManager
|
||||
const canComment = isRequester || (isStaff && canStaffComment)
|
||||
const addComment = useMutation(api.tickets.addComment)
|
||||
const removeAttachment = useMutation(api.tickets.removeCommentAttachment)
|
||||
|
|
@ -366,7 +368,7 @@ export function TicketComments({ ticket }: TicketCommentsProps) {
|
|||
)}
|
||||
{!canComment && (
|
||||
<div className="rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-700">
|
||||
Atribua um responsável ao chamado para que a equipe possa comentar.
|
||||
Atribua um responsável ao chamado para que a equipe técnica possa comentar.
|
||||
</div>
|
||||
)}
|
||||
<form onSubmit={handleSubmit} className="mt-4 space-y-3">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue