feat: improve chat composer with file attachments and media previews

This commit is contained in:
2026-06-13 10:28:39 +02:00 Unverified
parent fcb2bc2f09
commit c42a68c1ed
4 changed files with 113 additions and 73 deletions
+5 -5
View File
@@ -42,13 +42,13 @@ const selectedMediaIndex = ref(0)
const isGalleryOpen = ref(false)
// Invia messaggio
const handleSendMessage = async () => {
if (!newMessage.value.trim()) return
const handleSendMessage = async (msgText: string, files: File[]) => {
if (!msgText.trim() && files.length === 0) return
isSubmittingMessage.value = true
try {
await addMessage(reportId, { body: newMessage.value })
newMessage.value = ''
// Gestione mock di file, nella realtà si usa FormData o simle
await addMessage(reportId, { body: msgText })
await refreshMessages()
} catch (error) {
console.error('Error sending message:', error)
@@ -221,7 +221,7 @@ const formatDate = (dateString: string): string => {
Chat ({{ messages.length }})
</h6>
<MessageList :messages="messages" />
<MessageComposer @send="(msg) => { newMessage = msg; handleSendMessage() }" />
<MessageComposer @send="handleSendMessage" />
</div>
</div>
</div>