import { Head, usePage } from '@inertiajs/react';
import LegalDocument from '@/components/landing/legal-document';
import type { LegalSection } from '@/components/landing/legal-document';
import PublicPageHeader from '@/components/landing/public-page-header';

function privacySections(organisationName: string): LegalSection[] {
    return [
        {
            heading: 'Who we are',
            paragraphs: [
                `${organisationName} is a transparent savings and loan cooperative society registered in Nigeria. We are the data controller for the personal data described in this policy.`,
                'This policy explains what personal data we collect, why we collect it, how we protect it and the rights you have under the Nigeria Data Protection Act 2023.',
            ],
        },
        {
            heading: 'Data we collect',
            items: [
                'Identity details: your full name, date of birth, photograph and government-issued ID.',
                'Verification details: your Bank Verification Number (BVN) for know-your-customer (KYC) checks.',
                'Contact details: email address, phone number and residential address.',
                'Financial details: savings plans, contributions, financing applications, repayments and bank account details used for transfers.',
                'Technical details: device, browser and log information collected when you use our website or dashboard.',
            ],
        },
        {
            heading: 'How we use your data',
            items: [
                'To open and manage your membership and accounts.',
                'To verify your identity and meet anti-money-laundering obligations.',
                'To assess financing applications and administer repayments.',
                'To send service messages, statements and important notices.',
                'To keep our platform secure and prevent fraud.',
            ],
        },
        {
            heading: 'Legal basis for processing',
            paragraphs: [
                'We process your data to perform our agreement with you, to comply with legal and regulatory obligations, and where necessary for our legitimate interests in running a safe cooperative. Where we rely on consent, for example for optional marketing, you can withdraw it at any time.',
            ],
        },
        {
            heading: 'Sharing your data',
            paragraphs: [
                'We do not sell your personal data. We share it only where necessary with identity verification providers, payment processors and banks, our auditors and professional advisers, and regulators or law enforcement when the law requires it. Every service provider is bound by confidentiality and data protection terms.',
            ],
        },
        {
            heading: 'How long we keep data',
            paragraphs: [
                'We keep your data for as long as you are a member and afterwards for as long as the law requires to meet record-keeping and regulatory requirements, after which it is securely deleted or anonymised.',
            ],
        },
        {
            heading: 'Your rights',
            items: [
                'Access the personal data we hold about you.',
                'Ask us to correct inaccurate or incomplete data.',
                'Ask us to delete data we no longer have a reason to keep.',
                'Object to or restrict certain processing.',
                'Receive your data in a portable format.',
                'Lodge a complaint with the Nigeria Data Protection Commission.',
            ],
        },
        {
            heading: 'Security',
            paragraphs: [
                'We protect your data with encryption in transit, access controls, PIN-protected accounts and regular reviews of our systems. No system is completely secure, so please keep your PIN private and contact us immediately if you suspect unauthorised access.',
            ],
        },
        {
            heading: 'Changes to this policy',
            paragraphs: [
                'We may update this policy from time to time. We will notify you of material changes by email or through your dashboard before they take effect.',
            ],
        },
    ];
}

export default function PrivacyPolicy() {
    const { name } = usePage().props;

    return (
        <>
            <Head title="Privacy Policy" />

            <PublicPageHeader
                kicker="Legal"
                title="Privacy Policy"
                intro={`How ${name} collects, uses and protects your personal data.`}
            />

            <LegalDocument sections={privacySections(name)} />
        </>
    );
}
