Loading...
// Author: Shiv // Date: April 2026 "use client"; import dynamic from "next/dynamic"; import { useState, useEffect, useRef, useCallback } from "react"; import { useRouter, useSearchParams } from "next/navigation"; import { useAuth } from "@/context/AuthContext"; import { createStompClient } from "@/lib/chatSocket"; const API_BASE = ""; //Checks if a filename looks like an image based on its extension function isImageFilename(name) { return /\.(jpe?g|png|gif|webp|bmp|svg)$/i.test(name || ""); } //Shows an image inline or a download link for other file types function AttachmentPreview({ url, name, token }) { const [blobUrl, setBlobUrl] = useState(null); const isImage = isImageFilename(name); useEffect(() => { if (!url || !token) return; let objectUrl; fetch(url, { headers: { Authorization: `Bearer ${token}` } }) .then((r) => (r.ok ? r.blob() : null)) .then((blob) => { if (blob) { objectUrl = URL.createObjectURL(blob); setBlobUrl(objectUrl); } }) .catch(() => {}); return () => { if (objectUrl) URL.revokeObjectURL(objectUrl); }; }, [url, token]); if (isImage) { return (
Loading...
Chat with our support team in real time
Loading...
} {!convsLoading && conversations.length === 0 && (No conversations yet.
)}Start a new conversation to chat with our support team.
{error &&Your conversation has started. A support agent will join soon.