Enforce assignee-required commenting for staff; UI disables commenting until responsible is set; poll machine session for live deactivation; desktop deactivation screen update
This commit is contained in:
parent
2a8fb4330c
commit
b468c6c9e7
2 changed files with 21 additions and 2 deletions
|
|
@ -36,6 +36,10 @@ export function TicketComments({ ticket }: TicketCommentsProps) {
|
|||
const { convexUserId, isStaff, role } = useAuth()
|
||||
const normalizedRole = role ?? null
|
||||
const canSeeInternalComments = normalizedRole === "admin" || normalizedRole === "agent"
|
||||
const hasAssignee = Boolean(ticket.assignee)
|
||||
const isRequester = convexUserId ? ticket.requester.id === convexUserId : false
|
||||
const canStaffComment = hasAssignee
|
||||
const canComment = isRequester || (isStaff && canStaffComment)
|
||||
const addComment = useMutation(api.tickets.addComment)
|
||||
const removeAttachment = useMutation(api.tickets.removeCommentAttachment)
|
||||
const updateComment = useMutation(api.tickets.updateComment)
|
||||
|
|
@ -360,12 +364,18 @@ 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.
|
||||
</div>
|
||||
)}
|
||||
<form onSubmit={handleSubmit} className="mt-4 space-y-3">
|
||||
<RichTextEditor value={body} onChange={setBody} placeholder="Escreva um comentário..." />
|
||||
<RichTextEditor value={body} onChange={setBody} placeholder="Escreva um comentário..." className="rounded-2xl border border-slate-200" disabled={!canComment} />
|
||||
<Dropzone
|
||||
onUploaded={(files) => setAttachmentsToSend((prev) => [...prev, ...files])}
|
||||
currentFileCount={attachmentsToSend.length}
|
||||
currentTotalBytes={attachmentsToSendTotalBytes}
|
||||
disabled={!canComment}
|
||||
/>
|
||||
{attachmentsToSend.length > 0 ? (
|
||||
<div className="grid max-w-xl grid-cols-[repeat(auto-fill,minmax(96px,1fr))] gap-3">
|
||||
|
|
@ -477,7 +487,7 @@ export function TicketComments({ ticket }: TicketCommentsProps) {
|
|||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
<Button type="submit" size="sm" className={submitButtonClass}>
|
||||
<Button type="submit" size="sm" className={submitButtonClass} disabled={!canComment}>
|
||||
Enviar
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue