diff --git a/web/convex/files.ts b/web/convex/files.ts
index 55dd9ce..9e7ee74 100644
--- a/web/convex/files.ts
+++ b/web/convex/files.ts
@@ -1,4 +1,4 @@
-import { action, query } from "./_generated/server";
+import { action } from "./_generated/server";
import { v } from "convex/values";
export const generateUploadUrl = action({
@@ -8,7 +8,7 @@ export const generateUploadUrl = action({
},
});
-export const getUrl = query({
+export const getUrl = action({
args: { storageId: v.id("_storage") },
handler: async (ctx, { storageId }) => {
const url = await ctx.storage.getUrl(storageId);
diff --git a/web/src/components/tickets/ticket-comments.rich.tsx b/web/src/components/tickets/ticket-comments.rich.tsx
index af3029a..2ee6ed3 100644
--- a/web/src/components/tickets/ticket-comments.rich.tsx
+++ b/web/src/components/tickets/ticket-comments.rich.tsx
@@ -1,11 +1,11 @@
"use client"
-import { useMemo, useState } from "react"
+import { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { formatDistanceToNow } from "date-fns"
import { ptBR } from "date-fns/locale"
import { IconLock, IconMessage } from "@tabler/icons-react"
import { FileIcon, Trash2, X } from "lucide-react"
-import { useMutation } from "convex/react"
+import { useAction, useMutation } from "convex/react"
// @ts-expect-error Convex runtime API lacks TypeScript declarations
import { api } from "@/convex/_generated/api"
import { useAuth } from "@/lib/auth-client"
@@ -179,58 +179,16 @@ export function TicketComments({ ticket }: TicketCommentsProps) {
) : null}
{comment.attachments?.length ? (
- {comment.attachments.map((attachment) => {
- const name = attachment?.name ?? ""
- const url = attachment?.url
- const type = attachment?.type ?? ""
- const isImage =
- (!!type && type.startsWith("image/")) ||
- /\.(png|jpe?g|gif|webp|svg)$/i.test(name) ||
- /\.(png|jpe?g|gif|webp|svg)$/i.test(url ?? "")
- const openRemovalModal = (event: React.MouseEvent) => {
- event.preventDefault()
- event.stopPropagation()
- setAttachmentToRemove({ commentId: comment.id, attachmentId: attachment.id, name })
- }
- return (
-
- {isImage && url ? (
-
- ) : (
-
-
- {url ? Baixar : Pendente}
-
- )}
-
-
- {name}
-
-
- )
- })}
+ {comment.attachments.map((attachment) => (
+
setPreview(url)}
+ onRequestRemoval={() =>
+ setAttachmentToRemove({ commentId: comment.id, attachmentId: attachment.id, name: attachment.name })
+ }
+ />
+ ))}
) : null}
@@ -341,6 +299,9 @@ export function TicketComments({ ticket }: TicketCommentsProps) {