import { Form, Head, Link, router } from '@inertiajs/react';
import {
    AlertTriangle,
    CalendarClock,
    Camera,
    CheckCircle2,
    Clock,
    History,
    LifeBuoy,
    MessageSquare,
    Pencil,
    Phone,
    Timer,
    Trash2,
    Users,
} from 'lucide-react';
import { useState } from 'react';
import TicketAttachmentController from '@/actions/App/Http/Controllers/TicketAttachmentController';
import TicketStatusController from '@/actions/App/Http/Controllers/TicketStatusController';
import { AttachmentPicker } from '@/components/crm/attachment-picker';
import { FormActions } from '@/components/crm/form-field';
import { FormField, NativeSelect } from '@/components/crm/native-select';
import { RichText } from '@/components/crm/rich-text';
import {
    Callout,
    EmptyState,
    KeyValueGrid,
    PageHeader,
    SectionCard,
} from '@/components/crm/page-header';
import { StatStrip } from '@/components/crm/kpi-tile';
import {
    PriorityBadge,
    RuleFlag,
    StatusPill,
} from '@/components/crm/status-badge';
import { TicketActivity } from '@/components/crm/ticket-activity';
import { TicketAttachmentGallery } from '@/components/crm/ticket-attachment-gallery';
import { TicketOutcome } from '@/components/crm/ticket-outcome';
import { TicketStatusOptions } from '@/components/crm/ticket-status-options';
import { toneClasses } from '@/components/crm/tone';
import { Button } from '@/components/ui/button';
import { formatDateTime, formatDuration, formatRelative } from '@/lib/format';
import { cn } from '@/lib/utils';
import { show as customerShow } from '@/routes/customers';
import { show as jobShow } from '@/routes/jobs';
import {
    destroy as ticketDestroy,
    edit as ticketEdit,
    index as ticketsIndex,
    show as ticketShow,
} from '@/routes/tickets';
import type { TicketShowProps } from '@/types';

const textareaClassName =
    'border-input dark:bg-input/30 flex min-h-[84px] w-full rounded-md border bg-transparent px-3 py-2 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50';

export default function TicketShow({
    ticket,
    activity,
    resolutionCodes,
    related,
    history,
    options,
    discussion,
    can,
}: TicketShowProps) {
    // A ticket that has been open past its threshold is the thing the support
    // desk is judged on, so it outranks its own status colour.
    const isProblem = ticket.is_overdue && ticket.status.is_open;

    const handleDelete = () => {
        if (
            window.confirm(
                `Delete ticket ${ticket.display_number}? The customer and job records are not touched.`,
            )
        ) {
            router.delete(ticketDestroy({ ticket: ticket.id }).url, {
                preserveScroll: true,
            });
        }
    };

    return (
        <>
            <Head title={`Ticket ${ticket.display_number}`} />

            <div className="flex flex-col gap-5">
                <PageHeader
                    eyebrow={
                        <>
                            <span className="font-mono crm-num">
                                {ticket.display_number}
                            </span>
                            <StatusPill tone={ticket.source.color}>
                                {ticket.source.label}
                            </StatusPill>
                            {ticket.ticket_import_id ? (
                                <span className="hidden font-mono text-muted-foreground/70 crm-num sm:inline">
                                    {ticket.ticket_import_id}
                                </span>
                            ) : null}
                            <span
                                aria-hidden
                                className="text-muted-foreground/40"
                            >
                                ·
                            </span>
                            <span>
                                Reported {formatRelative(ticket.reported_at)}
                            </span>
                        </>
                    }
                    title={ticket.issue}
                    /**
                    description={
                        // Words only: the header is one line, so the markup comes
                        // off rather than showing as tags.
                        ticket.body_text ||
                        `Logged from the ${ticket.source.label} system.`
                    }*/
                    actions={
                        <>
                            {ticket.category ? (
                                <StatusPill tone={ticket.category.color}>
                                    {ticket.category.label}
                                </StatusPill>
                            ) : null}
                            <StatusPill tone={ticket.status.color}>
                                {ticket.status.label}
                            </StatusPill>
                            <PriorityBadge priority={ticket.priority} />
                            {can.update ? (
                                <Button variant="outline" size="sm" asChild>
                                    <Link
                                        href={ticketEdit({ ticket: ticket.id })}
                                    >
                                        <Pencil />
                                        Edit
                                    </Link>
                                </Button>
                            ) : null}
                            {can.delete ? (
                                <Button
                                    variant="outline"
                                    size="sm"
                                    onClick={handleDelete}
                                    data-test="delete-ticket-button"
                                >
                                    <Trash2 />
                                    Delete
                                </Button>
                            ) : null}
                        </>
                    }
                />

                <StatStrip
                    items={[
                        {
                            label: 'Reported',
                            value: formatRelative(ticket.reported_at),
                            tone: 'slate',
                            icon: CalendarClock,
                        },
                        {
                            label: 'Age',
                            value: formatDuration(ticket.days_open),
                            tone: isProblem ? 'danger' : 'slate',
                            icon: Clock,
                        },
                        {
                            label: 'In this status',
                            value: formatDuration(ticket.days_in_status),
                            tone: ticket.status.color,
                            icon: Timer,
                        },
                        {
                            label: 'Priority',
                            value: ticket.priority.label,
                            tone: ticket.priority.color,
                            icon: AlertTriangle,
                        },
                    ]}
                />

                {isProblem ? (
                    <Callout
                        tone="danger"
                        icon={AlertTriangle}
                        title={`Open for ${formatDuration(ticket.days_open)}`}
                    >
                        This ticket has gone past the threshold for its
                        priority. It is waiting on{' '}
                        {ticket.status.waiting_on.toLowerCase()}.
                    </Callout>
                ) : null}

                <div className="grid items-start gap-4 xl:grid-cols-[1.15fr_1fr]">
                    <div className="flex flex-col gap-4">
                        <SectionCard
                            id="issue"
                            title="The issue"
                            description="Exactly what the customer reported, kept as it arrived."
                            icon={MessageSquare}
                            tone={isProblem ? 'danger' : 'info'}
                        >
                            {/* Sanitized on the way in and again on the way out,
                                so the description can be formatted without the
                                page ever trusting the markup it renders. */}
                            {ticket.body_html ? (
                                <RichText html={ticket.body_html} />
                            ) : (
                                <p className="text-sm text-muted-foreground">
                                    {ticket.issue}
                                </p>
                            )}
                        </SectionCard>

                        <TicketOutcome ticket={ticket} />

                        <StatusPanel
                            ticket={ticket}
                            options={options}
                            resolutionCodes={resolutionCodes}
                            canUpdate={can.update}
                        />

                        <TicketActivity
                            ticket={ticket}
                            activity={activity}
                            discussion={discussion}
                            canComment={can.comment}
                            canDiscuss={can.discuss}
                        />

                        <Attachments ticket={ticket} canUpdate={can.update} />
                    </div>

                    <div className="flex flex-col gap-4">
                        <SectionCard
                            title="Who and what"
                            description="The customer, the job it is about, the installer who answers for it and the staff member holding it."
                            icon={Users}
                            tone="slate"
                        >
                            <KeyValueGrid
                                columns={1}
                                items={[
                                    {
                                        label: 'Category',
                                        value: ticket.category ? (
                                            <>
                                                <span className="font-medium">
                                                    {ticket.category.label}
                                                </span>
                                                <span className="mt-0.5 block text-xs text-muted-foreground">
                                                    {ticket.category.description}
                                                </span>
                                            </>
                                        ) : (
                                            <span className="text-muted-foreground">
                                                Not categorised yet
                                            </span>
                                        ),
                                    },
                                    {
                                        label: 'Customer',
                                        value: ticket.client ? (
                                            <>
                                                <Link
                                                    href={customerShow({
                                                        customer:
                                                            ticket.client.id,
                                                    })}
                                                    className="font-medium underline-offset-4 hover:underline"
                                                >
                                                    {ticket.client.name}
                                                </Link>
                                                <span className="mt-0.5 block text-xs text-muted-foreground">
                                                    {
                                                        ticket.client
                                                            .customer_number
                                                    }
                                                    {ticket.client.phone
                                                        ? ` · ${ticket.client.phone}`
                                                        : ''}
                                                    {ticket.client.email
                                                        ? ` · ${ticket.client.email}`
                                                        : ''}
                                                </span>
                                            </>
                                        ) : (
                                            <span className="text-muted-foreground">
                                                Not matched to a customer yet
                                            </span>
                                        ),
                                    },
                                    {
                                        label: 'Address',
                                        value: ticket.address ? (
                                            <>
                                                {ticket.address.line}
                                                <span className="mt-0.5 block text-xs text-muted-foreground">
                                                    {ticket.address.is_site
                                                        ? 'Installation site'
                                                        : 'Billing address — no job site is linked'}
                                                </span>
                                            </>
                                        ) : (
                                            <span className="text-muted-foreground">
                                                No address recorded
                                            </span>
                                        ),
                                    },
                                    {
                                        label: 'Job',
                                        value: ticket.job ? (
                                            <>
                                                <Link
                                                    href={jobShow({
                                                        job: ticket.job.id,
                                                    })}
                                                    className="font-mono text-xs font-medium crm-num underline-offset-4 hover:underline"
                                                >
                                                    {ticket.job.job_number}
                                                </Link>
                                                {ticket.job.title ? (
                                                    <span className="ml-2 text-xs text-muted-foreground">
                                                        {ticket.job.title}
                                                    </span>
                                                ) : null}
                                                <span className="mt-1 block">
                                                    <StatusPill
                                                        tone={
                                                            ticket.job
                                                                .status_color
                                                        }
                                                    >
                                                        {
                                                            ticket.job
                                                                .status_label
                                                        }
                                                    </StatusPill>
                                                </span>
                                            </>
                                        ) : (
                                            <span className="text-muted-foreground">
                                                No job linked
                                            </span>
                                        ),
                                    },
                                    {
                                        label: 'Installer',
                                        value: ticket.installer ? (
                                            <>
                                                <span className="font-medium">
                                                    {ticket.installer.name}
                                                </span>
                                                {ticket.job ? null : (
                                                    <span className="mt-0.5 block text-xs text-muted-foreground">
                                                        Assigned by hand — no
                                                        job is linked to this
                                                        ticket.
                                                    </span>
                                                )}
                                            </>
                                        ) : (
                                            <span className="text-muted-foreground">
                                                Unassigned
                                            </span>
                                        ),
                                    },
                                    {
                                        label: 'Assigned to',
                                        value:
                                            ticket.assignees.length > 0 ? (
                                                <>
                                                    {/* However many people
                                                        are holding it, all
                                                        of them are named. */}
                                                    <span className="flex flex-wrap gap-x-2 gap-y-1">
                                                        {ticket.assignees.map(
                                                            (member) => (
                                                                <span
                                                                    key={
                                                                        member.id
                                                                    }
                                                                    className="font-medium"
                                                                >
                                                                    {
                                                                        member.name
                                                                    }
                                                                </span>
                                                            ),
                                                        )}
                                                    </span>
                                                    <span className="mt-0.5 block text-xs text-muted-foreground">
                                                        {ticket.assignees
                                                            .length === 1
                                                            ? 'Holding this ticket in the office. The installer answers for the work itself.'
                                                            : `${ticket.assignees.length} people are holding this ticket. The installer answers for the work itself.`}
                                                    </span>
                                                </>
                                            ) : (
                                                <span className="text-muted-foreground">
                                                    Nobody in the office yet
                                                </span>
                                            ),
                                    },
                                    {
                                        label: 'Picked up',
                                        value: ticket.dates.acknowledged_at ? (
                                            formatDateTime(
                                                ticket.dates.acknowledged_at,
                                            )
                                        ) : (
                                            <span className="text-muted-foreground">
                                                Not yet picked up
                                            </span>
                                        ),
                                    },
                                ]}
                            />
                        </SectionCard>

                        <SectionCard
                            title="Contact as reported"
                            description="The details the message arrived with, kept exactly as sent."
                            icon={Phone}
                            tone="slate"
                        >
                            <KeyValueGrid
                                columns={1}
                                items={[
                                    {
                                        label: 'Name',
                                        value: ticket.contact.name,
                                    },
                                    {
                                        label: 'Phone',
                                        value: ticket.contact.phone ? (
                                            <a
                                                href={`tel:${ticket.contact.phone}`}
                                                className="crm-num underline-offset-4 hover:underline"
                                            >
                                                {ticket.contact.phone}
                                            </a>
                                        ) : null,
                                    },
                                    {
                                        label: 'Email',
                                        value: ticket.contact.email ? (
                                            <a
                                                href={`mailto:${ticket.contact.email}`}
                                                className="underline-offset-4 hover:underline"
                                            >
                                                {ticket.contact.email}
                                            </a>
                                        ) : null,
                                    },
                                    {
                                        label: 'SMS message id',
                                        value: ticket.ticket_import_id ? (
                                            <span className="font-mono text-xs crm-num">
                                                {ticket.ticket_import_id}
                                            </span>
                                        ) : (
                                            <span className="text-xs text-muted-foreground">
                                                Logged by staff, not imported
                                            </span>
                                        ),
                                    },
                                ]}
                            />

                            {ticket.creator ? (
                                <p className="mt-4 text-xs text-muted-foreground">
                                    Logged by {ticket.creator.name}
                                </p>
                            ) : null}
                        </SectionCard>

                        <SectionCard
                            title="Timeline"
                            description="Reported, picked up, resolved, closed."
                            icon={History}
                            tone="slate"
                        >
                            {history.length === 0 ? (
                                <EmptyState
                                    icon={History}
                                    title="Nothing recorded yet"
                                    description="Events appear here as the ticket is worked."
                                />
                            ) : (
                                <ol className="relative space-y-4">
                                    <span
                                        aria-hidden
                                        className="absolute top-2 bottom-2 left-[5px] w-px bg-hairline"
                                    />
                                    {history.map((entry) => (
                                        <li
                                            key={`${entry.label}-${entry.at}`}
                                            className="relative flex gap-3"
                                        >
                                            <span
                                                aria-hidden
                                                className={cn(
                                                    'z-10 mt-1.5 size-2.5 shrink-0 rounded-full ring-4 ring-card',
                                                    toneClasses(entry.tone).dot,
                                                )}
                                            />
                                            <div className="min-w-0">
                                                <p className="text-sm font-medium">
                                                    {entry.label}
                                                </p>
                                                <p className="text-xs text-muted-foreground">
                                                    {formatDateTime(entry.at)}
                                                </p>
                                                {entry.detail ? (
                                                    <RichText
                                                        html={entry.detail}
                                                        className="mt-1 text-xs leading-relaxed text-muted-foreground"
                                                    />
                                                ) : null}
                                            </div>
                                        </li>
                                    ))}
                                </ol>
                            )}
                        </SectionCard>
                    </div>
                </div>

                <SectionCard
                    title="Other tickets on this job, customer or installer"
                    description="If the same fault has been reported twice, it shows up here before anyone calls the customer back."
                    icon={LifeBuoy}
                    tone="violet"
                    flush
                >
                    {related.length === 0 ? (
                        <div className="px-5 pb-4">
                            <EmptyState
                                icon={CheckCircle2}
                                title="Nothing else reported here"
                                description="This is the only ticket linked to this job, customer and installer."
                            />
                        </div>
                    ) : (
                        <ul className="divide-y divide-hairline">
                            {related.map((other) => (
                                <li key={other.id}>
                                    <Link
                                        href={ticketShow({
                                            ticket: other.id,
                                        })}
                                        className="flex flex-col gap-2 px-5 py-3 transition-colors hover:bg-accent/40 sm:flex-row sm:items-center sm:gap-4"
                                    >
                                        <div className="flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1">
                                            <RuleFlag tone="info">
                                                {other.match}
                                            </RuleFlag>
                                            <span className="font-mono text-xs font-medium crm-num">
                                                {other.display_number}
                                            </span>
                                            <span className="truncate text-sm">
                                                {other.issue}
                                            </span>
                                        </div>

                                        <div className="flex shrink-0 items-center gap-3">
                                            <StatusPill
                                                tone={other.status.color}
                                            >
                                                {other.status.label}
                                            </StatusPill>
                                            <span className="w-16 text-right text-xs text-muted-foreground crm-num">
                                                {formatDuration(
                                                    other.days_open,
                                                )}
                                            </span>
                                        </div>
                                    </Link>
                                </li>
                            ))}
                        </ul>
                    )}
                </SectionCard>
            </div>
        </>
    );
}

/**
 * The files on the ticket itself: a screenshot of the inverter's display, a
 * photo of the roof, the manufacturer's claim form.
 *
 * They are part of the ticket rather than the conversation because they are the
 * evidence, not something somebody said. Uploading is offered to anyone who can
 * work the ticket, and the files are served through the ticket policy.
 */
function Attachments({
    ticket,
    canUpdate,
}: {
    ticket: TicketShowProps['ticket'];
    canUpdate: boolean;
}) {
    return (
        <SectionCard
            id="attachments"
            title="Photos and screenshots"
            description={
                ticket.attachments.length === 0
                    ? 'Photograph the fault, or screenshot the app or the display.'
                    : `${ticket.attachments.length} file${ticket.attachments.length === 1 ? '' : 's'} on this ticket, kept privately.`
            }
            icon={Camera}
            tone="solar"
        >
            {ticket.attachments.length === 0 ? (
                <EmptyState
                    icon={Camera}
                    title="Nothing attached yet"
                    description="A screenshot of a fault code is often the fastest thing to work from, and a photo of the roof settles an argument later."
                />
            ) : (
                <TicketAttachmentGallery
                    attachments={ticket.attachments}
                    canDelete={canUpdate}
                />
            )}

            {canUpdate ? (
                <Form
                    action={TicketAttachmentController.store.url({
                        ticket: ticket.id,
                    })}
                    method="post"
                    options={{ preserveScroll: true }}
                    className="mt-5 flex flex-col gap-4 border-t border-hairline pt-5"
                >
                    {({ processing, errors }) => (
                        <>
                            <FormField
                                label="Add to this ticket"
                                htmlFor="ticket-attachments"
                                error={
                                    errors.attachments ??
                                    errors['attachments.0']
                                }
                                hint="Up to six files at a time"
                            >
                                <AttachmentPicker
                                    id="ticket-attachments"
                                    name="attachments[]"
                                />
                            </FormField>

                            <FormActions note="Stored privately; only people who can see this ticket can open them.">
                                <Button
                                    type="submit"
                                    disabled={processing}
                                    data-test="attach-files-button"
                                >
                                    {processing ? 'Uploading…' : 'Attach files'}
                                </Button>
                            </FormActions>
                        </>
                    )}
                </Form>
            ) : null}
        </SectionCard>
    );
}

/**
 * Moving the ticket on.
 *
 * Two things are written here and they are deliberately apart. The note says
 * why it moved and what happens next, and it lands in the activity feed where
 * the next person will read it. The outcome only appears when the move finishes
 * the ticket, because that is the part the business keeps afterwards: what was
 * done, what kind of fix it was, and who signed it off.
 */
function StatusPanel({
    ticket,
    options,
    resolutionCodes,
    canUpdate,
}: {
    ticket: TicketShowProps['ticket'];
    options: TicketShowProps['options'];
    resolutionCodes: TicketShowProps['resolutionCodes'];
    canUpdate: boolean;
}) {
    const [status, setStatus] = useState<string>(ticket.status.value);
    const [code, setCode] = useState<string>(
        ticket.resolution_code?.value ?? '',
    );

    const finishing = status === 'resolved' || status === 'closed';
    const chosenCode = resolutionCodes.find((option) => option.value === code);
    const needsResolution = finishing && !ticket.resolution;
    const needsCode = finishing && !ticket.resolution_code;

    return (
        <SectionCard
            id="status"
            title="Ticket status"
            description="Every change stamps who picked the ticket up and, when it is finished, the outcome that closed it."
            icon={LifeBuoy}
            tone={ticket.status.color}
        >
            {ticket.status.needs_installer ? (
                <Callout
                    tone="warning"
                    icon={AlertTriangle}
                    title={
                        ticket.installer
                            ? `${ticket.installer.name} has to come back to us`
                            : 'An installer has to be assigned'
                    }
                    className="mb-4"
                >
                    This ticket is parked on the install crew. Whoever did the
                    job is the person who can confirm or rectify it.
                </Callout>
            ) : null}

            {ticket.status.is_warranty ? (
                <Callout
                    tone={
                        ticket.status.is_waiting_on_third_party
                            ? 'info'
                            : 'success'
                    }
                    icon={
                        ticket.status.is_waiting_on_third_party
                            ? Clock
                            : CheckCircle2
                    }
                    title={ticket.status.label}
                    className="mb-4"
                >
                    {ticket.status.description} Record the claim or reference
                    number and the manufacturer's answer as an internal note,
                    so the decision is traceable later.
                </Callout>
            ) : null}

            <p className="mb-4 text-xs leading-relaxed text-muted-foreground">
                Currently waiting on{' '}
                <span className="font-medium text-foreground">
                    {ticket.status.waiting_on}
                </span>
                . {ticket.status.description}
            </p>

            {canUpdate ? (
                <Form
                    {...TicketStatusController.store.form({
                        ticket: ticket.id,
                    })}
                    options={{ preserveScroll: true }}
                    className="flex flex-col gap-5"
                >
                    {({ processing, errors }) => (
                        <>
                            <FormField
                                label="Move to"
                                htmlFor="ticket-status"
                                hint={`In ${ticket.status.label} for ${formatDuration(ticket.days_in_status)}`}
                            >
                                <NativeSelect
                                    id="ticket-status"
                                    name="status"
                                    value={status}
                                    onChange={(event) =>
                                        setStatus(event.target.value)
                                    }
                                >
                                    <TicketStatusOptions
                                        statuses={options.ticketStatuses}
                                    />
                                </NativeSelect>
                            </FormField>

                            <FormField
                                label="Note for the activity feed"
                                htmlFor="ticket-note"
                                error={errors.note}
                                hint="Optional — why it moved, and what happens next. Recorded in the conversation, not as the outcome."
                            >
                                <textarea
                                    id="ticket-note"
                                    name="note"
                                    rows={2}
                                    placeholder="e.g. Crew booked for Thursday; customer asked for a call afterwards."
                                    className={textareaClassName}
                                    data-test="ticket-note"
                                />
                            </FormField>

                            {finishing ? (
                                <div className="flex flex-col gap-4 rounded-lg border border-success/30 bg-success-soft/30 p-3">
                                    <p className="text-xs font-medium text-success">
                                        The outcome — kept on the record after
                                        this ticket is finished
                                    </p>

                                    <FormField
                                        label="What was done"
                                        htmlFor="ticket-resolution"
                                        error={errors.resolution}
                                        hint="The words the customer and the next person will read. Required to finish a ticket."
                                    >
                                        <textarea
                                            id="ticket-resolution"
                                            name="resolution"
                                            rows={3}
                                            defaultValue={
                                                ticket.resolution ?? ''
                                            }
                                            placeholder="What was done, who attended, what the customer was told."
                                            className={textareaClassName}
                                            data-test="ticket-resolution"
                                        />
                                    </FormField>

                                    <FormField
                                        label="Kind of outcome"
                                        htmlFor="ticket-resolution-code"
                                        error={errors.resolution_code}
                                        hint={
                                            chosenCode?.description ??
                                            'How it closed, for the figures afterwards: a repair, a warranty claim, our own crew back on site.'
                                        }
                                    >
                                        <NativeSelect
                                            id="ticket-resolution-code"
                                            name="resolution_code"
                                            value={code}
                                            onChange={(event) =>
                                                setCode(event.target.value)
                                            }
                                            data-test="ticket-resolution-code"
                                        >
                                            <option value="">
                                                Choose an outcome…
                                            </option>
                                            {resolutionCodes.map((option) => (
                                                <option
                                                    key={option.value}
                                                    value={option.value}
                                                >
                                                    {option.label}
                                                </option>
                                            ))}
                                        </NativeSelect>
                                    </FormField>

                                    {needsResolution || needsCode ? (
                                        <Callout
                                            tone="warning"
                                            icon={AlertTriangle}
                                        >
                                            A finished ticket keeps the answer,{' '}
                                            so both the words and the kind of
                                            outcome are needed before it can be
                                            resolved or closed.
                                        </Callout>
                                    ) : null}
                                </div>
                            ) : null}

                            <FormActions note="The customer and the job are not changed by this.">
                                <Button
                                    type="submit"
                                    disabled={processing}
                                    data-test="move-ticket-button"
                                >
                                    {processing ? 'Saving…' : 'Update status'}
                                </Button>
                            </FormActions>
                        </>
                    )}
                </Form>
            ) : (
                <p className="text-sm text-muted-foreground">
                    You can see this ticket but not change it. Ask an
                    administrator for the tickets.update permission.
                </p>
            )}
        </SectionCard>
    );
}

TicketShow.layout = {
    breadcrumbs: [
        { title: 'Tickets', href: ticketsIndex() },
        { title: 'Ticket detail', href: '#' },
    ],
};
