import { Head, Link, router, useForm } from '@inertiajs/react'; import { ArrowLeft, FileDown, FileUp, KeyRound, Lock, Send, Unlock, User, } from 'lucide-react'; import type { FormEvent, ReactNode } from 'react'; import { useRef } from 'react'; import { SupportAttachmentErrors } from '@/components/support-attachment-errors'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { useTranslation } from '@/lib/translations'; import { cn } from '@/lib/utils'; import { dashboard as adminDashboard } from '@/routes/admin'; import { index as adminSupportIndex, update as updateConversation, } from '@/routes/admin/support'; import { store as storeAdminMessage } from '@/routes/admin/support/messages'; import { show as showChannel } from '@/routes/channels'; import { show as showAttachment } from '@/routes/support/attachments'; import type { SupportAttachment, SupportConversation, SupportMessage, } from '@/types'; type Props = { conversation: SupportConversation; }; export default function AdminSupportShow({ conversation }: Props) { const fileInputRef = useRef(null); const { t } = useTranslation(); const form = useForm({ body: '', attachments: [] as File[], }); const isClosed = conversation.status === 'closed'; function submit(event: FormEvent) { event.preventDefault(); form.post(storeAdminMessage.url(conversation.id), { forceFormData: true, preserveScroll: true, onSuccess: () => { form.reset(); if (fileInputRef.current) { fileInputRef.current.value = ''; } }, }); } function setStatus(status: 'open' | 'closed') { router.patch( updateConversation(conversation.id), { status }, { preserveScroll: true }, ); } function setAttachments(files: FileList | null) { form.setData('attachments', Array.from(files ?? []).slice(0, 3)); } return ( <>
{conversation.category_label}

{conversation.subject}

{conversation.messages.map((message) => ( ))}
{isClosed ? (
{t('Reopen the conversation to reply.')}
) : (