Refine machine details layout and improve download feedback

This commit is contained in:
Esdras Renan 2025-10-19 00:52:42 -03:00
parent 5f7efa13e6
commit 1251468b77
6 changed files with 96 additions and 10 deletions

View file

@ -328,14 +328,14 @@ export function PortalTicketDetail({ ticketId }: PortalTicketDetailProps) {
) : null}
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-5">
<label htmlFor="comment" className="text-sm font-medium text-neutral-800">
<label htmlFor="comment" className="block text-sm font-medium text-neutral-800">
Enviar uma mensagem para a equipe
</label>
<RichTextEditor
value={comment}
onChange={(html) => setComment(html)}
placeholder="Descreva o que aconteceu, envie atualizações ou compartilhe novas informações."
className="rounded-2xl border border-slate-200 shadow-sm focus-within:border-neutral-900 focus-within:ring-neutral-900/20"
className="mt-3 rounded-2xl border border-slate-200 shadow-sm focus-within:border-neutral-900 focus-within:ring-neutral-900/20"
disabled={machineInactive}
/>
</div>
@ -610,6 +610,8 @@ function PortalCommentAttachmentCard({
const handleDownload = useCallback(async () => {
const target = await ensureUrl()
if (!target) return
const toastId = `portal-attachment-download-${attachment.id}`
toast.loading("Baixando anexo...", { id: toastId })
try {
const response = await fetch(target, { credentials: "include" })
if (!response.ok) {
@ -627,9 +629,11 @@ function PortalCommentAttachmentCard({
window.setTimeout(() => {
window.URL.revokeObjectURL(blobUrl)
}, 1000)
toast.success("Download concluído!", { id: toastId })
} catch (error) {
console.error("Falha ao iniciar download do anexo", error)
window.open(target, "_blank", "noopener,noreferrer")
toast.error("Não foi possível baixar o anexo automaticamente.", { id: toastId })
}
}, [attachment.name, ensureUrl])