Skip to content

Commit 894779a

Browse files
authored
Update ticket-chat.html
1 parent 47cd295 commit 894779a

1 file changed

Lines changed: 67 additions & 6 deletions

File tree

ticket-chat.html

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
--danger-bg: rgba(239,68,68,.12);
2222
--danger-border: rgba(239,68,68,.28);
2323
--danger-text: #fecaca;
24-
--success-bg: rgba(34,197,94,.12);
25-
--success-text: #bbf7d0;
2624
}
2725

2826
body {
@@ -147,8 +145,10 @@
147145
}
148146

149147
.bubble {
150-
max-width: 78%;
151-
padding: 14px 16px;
148+
display: inline-block;
149+
width: fit-content;
150+
max-width: 75%;
151+
padding: 12px 14px;
152152
border-radius: 18px;
153153
line-height: 1.7;
154154
white-space: pre-wrap;
@@ -262,6 +262,31 @@
262262
border: 1px solid rgba(255,255,255,.08);
263263
}
264264

265+
.file-label {
266+
display: inline-flex;
267+
align-items: center;
268+
justify-content: center;
269+
gap: 8px;
270+
border-radius: 14px;
271+
padding: 12px 18px;
272+
font-size: 14px;
273+
font-weight: 800;
274+
cursor: pointer;
275+
background: #111827;
276+
color: #fff;
277+
border: 1px dashed rgba(255,255,255,.18);
278+
transition: .2s ease;
279+
}
280+
281+
.file-label:hover {
282+
transform: translateY(-1px);
283+
border-color: rgba(99,102,241,.55);
284+
}
285+
286+
.file-input {
287+
display: none;
288+
}
289+
265290
.notice {
266291
margin-top: 12px;
267292
font-size: 13px;
@@ -336,7 +361,8 @@
336361
align-items: stretch;
337362
}
338363

339-
.btn {
364+
.btn,
365+
.file-label {
340366
width: 100%;
341367
}
342368
}
@@ -435,10 +461,22 @@ <h3 style="margin:0 0 12px;">Reply to this ticket</h3>
435461
<textarea id="replyMessage" placeholder="Write your message here..."></textarea>
436462

437463
<div class="reply-actions">
464+
<label class="file-label" for="fileInput">
465+
Attach files / images
466+
</label>
467+
<input
468+
id="fileInput"
469+
class="file-input"
470+
type="file"
471+
multiple
472+
accept=".png,.jpg,.jpeg,.pdf,.doc,.docx"
473+
/>
474+
438475
<button id="sendBtn" class="btn primary">Send Reply</button>
439476
<button id="refreshBtn" class="btn secondary" type="button">Refresh</button>
440477
</div>
441478

479+
<div id="fileNames" class="notice"></div>
442480
<div id="replyNotice" class="notice"></div>
443481
</div>
444482
</div>
@@ -474,6 +512,8 @@ <h3 style="margin:0 0 12px;">Reply to this ticket</h3>
474512
const sendBtn = document.getElementById("sendBtn");
475513
const refreshBtn = document.getElementById("refreshBtn");
476514
const replyNotice = document.getElementById("replyNotice");
515+
const fileInput = document.getElementById("fileInput");
516+
const fileNames = document.getElementById("fileNames");
477517

478518
let currentTicket = null;
479519

@@ -607,6 +647,7 @@ <h3 style="margin:0 0 12px;">Reply to this ticket</h3>
607647
closedBox.style.display = "none";
608648
replyBox.style.display = "none";
609649
replyNotice.textContent = "";
650+
fileNames.textContent = "";
610651

611652
if (!ticketId) {
612653
loadingEl.style.display = "none";
@@ -639,6 +680,16 @@ <h3 style="margin:0 0 12px;">Reply to this ticket</h3>
639680
}
640681
}
641682

683+
fileInput.addEventListener("change", () => {
684+
const files = Array.from(fileInput.files || []);
685+
if (!files.length) {
686+
fileNames.textContent = "";
687+
return;
688+
}
689+
690+
fileNames.textContent = "Selected files: " + files.map(file => file.name).join(", ");
691+
});
692+
642693
async function sendReply() {
643694
const message = replyMessage.value.trim();
644695

@@ -662,6 +713,13 @@ <h3 style="margin:0 0 12px;">Reply to this ticket</h3>
662713
return;
663714
}
664715

716+
const files = Array.from(fileInput.files || []);
717+
const attachments = files.map(file => ({
718+
name: file.name,
719+
type: file.type || "unknown",
720+
size: file.size
721+
}));
722+
665723
sendBtn.disabled = true;
666724
replyNotice.textContent = "Sending reply...";
667725

@@ -675,7 +733,8 @@ <h3 style="margin:0 0 12px;">Reply to this ticket</h3>
675733
ticket_id: currentTicket.ticket_id,
676734
name: currentTicket.name,
677735
email: currentTicket.email,
678-
message: message
736+
message: message,
737+
attachments: attachments
679738
})
680739
});
681740

@@ -684,6 +743,8 @@ <h3 style="margin:0 0 12px;">Reply to this ticket</h3>
684743
}
685744

686745
replyMessage.value = "";
746+
fileInput.value = "";
747+
fileNames.textContent = "";
687748
replyNotice.textContent = "Reply sent successfully.";
688749
} catch (error) {
689750
replyNotice.textContent = "Something went wrong while sending your reply.";

0 commit comments

Comments
 (0)