import { Head, usePage } from '@inertiajs/react';
import ComplaintForm from '@/components/landing/complaint-form';
import type { ComplaintCategoryOption } from '@/components/landing/complaint-form';
import PublicPageHeader from '@/components/landing/public-page-header';
import Reveal from '@/components/landing/reveal';

const complaintSteps = [
    {
        title: 'Tell us what happened',
        description:
            'Use the form on this page. Include what went wrong, when it happened and what you would like us to do.',
    },
    {
        title: 'We acknowledge it',
        description:
            'You get a reference number straight away, and we confirm who is handling your complaint within 2 business days.',
    },
    {
        title: 'We investigate and respond',
        description:
            'We aim to resolve most complaints within 14 business days. If we need longer, we will explain why and tell you when to expect a final response.',
    },
    {
        title: 'Escalate if you’re not satisfied',
        description:
            'If you are unhappy with our final response, you can ask for a review by our board of directors, and then refer the matter to the relevant cooperative authority.',
    },
] as const;

export default function Complaints({
    categories,
}: {
    categories: ComplaintCategoryOption[];
}) {
    const { name } = usePage().props;

    return (
        <>
            <Head title="Complaints" />

            <PublicPageHeader
                kicker="Complaints"
                title="How to make a complaint."
                intro={`We want every member to be treated fairly. If something has gone wrong, tell us — ${name} takes every complaint seriously and handles it free of charge.`}
            />

            <section className="px-5 py-14 sm:px-6 lg:px-10 lg:py-20">
                <div className="mx-auto grid w-full max-w-6xl items-start gap-10 lg:grid-cols-[1fr_360px] lg:gap-14">
                    <Reveal>
                        <ComplaintForm categories={categories} />
                    </Reveal>

                    <Reveal delay={120} className="lg:sticky lg:top-28">
                        <h2 className="mb-6 font-display text-xl font-semibold text-ink">
                            What happens next
                        </h2>
                        <ol className="flex flex-col gap-6">
                            {complaintSteps.map((step, index) => (
                                <li key={step.title} className="flex gap-4">
                                    <span
                                        aria-hidden="true"
                                        className="flex size-8 shrink-0 items-center justify-center rounded-full bg-brand-faint font-display text-sm font-semibold text-brand"
                                    >
                                        {index + 1}
                                    </span>
                                    <div>
                                        <h3 className="mb-1 font-display text-base font-semibold text-ink">
                                            {step.title}
                                        </h3>
                                        <p className="text-sm leading-[1.7] text-ink-500">
                                            {step.description}
                                        </p>
                                    </div>
                                </li>
                            ))}
                        </ol>

                        <div className="mt-8 rounded-landing-lg border border-surface-200 bg-surface-50 p-5">
                            <h2 className="mb-1.5 font-display text-base font-semibold text-ink">
                                Our promise
                            </h2>
                            <p className="text-sm leading-[1.7] text-ink-500">
                                Making a complaint will never affect your
                                membership, savings or financing.
                            </p>
                        </div>
                    </Reveal>
                </div>
            </section>
        </>
    );
}
