import { usePage } from '@inertiajs/react';
import { Quote } from 'lucide-react';
import Reveal from '@/components/landing/reveal';
import SectionHeading from '@/components/landing/section-heading';
import { useInitials } from '@/hooks/use-initials';
import { cn } from '@/lib/utils';

type Testimonial = {
    name: string;
    location: string;
    occupation: string;
    product: string;
    quote: (organisationName: string) => string;
    avatarClassName: string;
};

/**
 * DRAFT testimonials. Before launch, confirm each member has approved their
 * name, details and quote for publication.
 */
const testimonials: Testimonial[] = [
    {
        name: 'Aishah Ibrahim',
        location: 'Kaduna',
        occupation: 'Teacher',
        product: 'School fees savings',
        quote: (organisationName) =>
            `I opened a Back-to-School plan with ${organisationName} and auto-debit did the rest. My children’s fees were ready before resumption — without a kobo of interest.`,
        avatarClassName: 'bg-brand',
    },
    {
        name: 'Ahmad Isah',
        location: 'Abuja',
        occupation: 'Business owner',
        product: 'Murabaha financing',
        quote: (organisationName) =>
            `Murabaha financing from ${organisationName} helped me buy a delivery van for my business. I knew the full price from day one, and the instalments fit my cash flow.`,
        avatarClassName: 'bg-highlight-dark',
    },
    {
        name: 'Umar Lawan',
        location: 'Maiduguri',
        occupation: 'Farmer',
        product: 'Agro savings',
        quote: () =>
            'With the Agro Savings plan I set money aside after every harvest and bought new equipment for the next season. Simple to use, and I know every naira is handled the halal way.',
        avatarClassName: 'bg-ink-700',
    },
];

export default function TestimonialsSection() {
    const { name } = usePage().props;
    const getInitials = useInitials();

    return (
        <section
            id="testimonials"
            aria-labelledby="testimonials-heading"
            className="bg-white px-5 py-20 sm:px-6 lg:px-10 lg:py-28"
        >
            <div className="mx-auto w-full max-w-6xl">
                <SectionHeading
                    id="testimonials-heading"
                    eyebrow="Member stories"
                    title="Real goals, reached the transparent way."
                />

                <ul className="mt-14 grid gap-6 lg:grid-cols-3">
                    {testimonials.map((testimonial, index) => (
                        <li key={testimonial.name}>
                            <Reveal delay={index * 120} className="h-full">
                                <figure className="flex h-full flex-col rounded-landing-xl border border-surface-200 bg-canvas p-7">
                                    <div className="flex items-center justify-between">
                                        <Quote
                                            className="size-7 fill-highlight/15 text-highlight"
                                            aria-hidden="true"
                                        />
                                        <span className="rounded-full bg-white px-3 py-1 text-xs font-medium text-ink-500 shadow-landing-sm">
                                            {testimonial.product}
                                        </span>
                                    </div>
                                    <blockquote className="mt-6 flex-1 text-[15.5px] leading-[1.75] text-ink-700">
                                        <p>“{testimonial.quote(name)}”</p>
                                    </blockquote>
                                    <figcaption className="mt-8 flex items-center gap-3">
                                        <span
                                            aria-hidden="true"
                                            className={cn(
                                                'flex size-11 shrink-0 items-center justify-center rounded-full text-sm font-semibold text-white',
                                                testimonial.avatarClassName,
                                            )}
                                        >
                                            {getInitials(testimonial.name)}
                                        </span>
                                        <span>
                                            <span className="block text-sm font-semibold text-ink">
                                                {testimonial.name}
                                            </span>
                                            <span className="block text-sm text-ink-400">
                                                {testimonial.occupation},{' '}
                                                {testimonial.location}
                                            </span>
                                        </span>
                                    </figcaption>
                                </figure>
                            </Reveal>
                        </li>
                    ))}
                </ul>
            </div>
        </section>
    );
}
