<?php

namespace Database\Seeders;

use App\Models\Claim\Status;
use Illuminate\Database\Seeder;

class PensionStatusSeeder extends Seeder
{
    /**
     * Statuses keyed by their type discriminator.
     * Type format: 'pension-{claim_type}' matching PensionCase::claim_type enum (bank/fscs/fos).
     */
    private array $statuses = [

        'pension-fscs' => [
            'Entered details into CRM',
            'ATC received',
            'Issued TOB',
            'Incomplete TOB',
            'Received signed TOB',
            'Received signed TOB. SAR out',
            'Received signed TOB. Under investigation',
            'Received signed TOB - claim subject unclear',
            'New case, on hold',
            'Pre app, aw. related case',
            'Aw. related case progress',
            'SAR received',
            'SAR received – Bank',
            'SAR in. Evidence missing',
            'SAR in. Under review',
            'Allocated to investigator',
            'Allocated to claims writer',
            'Application out for signature',
            'FSCS Application submitted',
            'FSCS claim in progress',
            'FSCS consulting another team',
            'FSCS declined – already claimed',
            'FSCS declined – no valid claim',
            'FSCS declined – under appeal',
            'FSCS evidence required',
            'FSCS firm investigation underway',
            'FSCS inactive – awaiting other settlement',
            'FSCS inactive – consulting another team',
            'FSCS inactive – info request',
            'FSCS inactive – with legal team',
            'FSCS in calculation',
            'FSCS under review',
            'Award issued by FSCS',
            'All CASS completed – final',
            'All CASS completed – interim',
            'Complete, invoice settled',
            'CPFC invoice issued',
            'Quality controlled',
            'TOB to be QC\'d',
            'Client paid by FSCS',
            'Disinstructed – no payment',
            'Disinstructed – after payment',
            'Case on hold, client instruction',
            'Client not proceeding',
            'Declined/closed',
            'No valid claim',
            'Closed – no evidence',
            'Bank – closed',
            'Preparing appeal',
            'Rejected appeal – legal referral',
            'Pending new approach',
            'All GCEN completed',
            'FOS Rejected',
            'Paid prior to invoice',
        ],

        'pension-fos' => [
            'Entered details into CRM',
            'ATC received',
            'Issued TOB',
            'Incomplete TOB',
            'Received signed TOB',
            'Received signed TOB. Under investigation',
            'Received signed TOB. SAR out',
            'New case, on hold',
            'SAR received',
            'SAR received – bank',
            'SAR in. Under review',
            'SAR in. Evidence missing',
            'Allocated to investigator',
            'Allocated to claims writer',
            'FOS letter with client',
            'FOS initial complaint sent',
            'FOS non standard case',
            'FOS app written sent to client',
            'FOS submitted awaiting case ref',
            'FOS open case ref received, awaiting investigator',
            'FOS under review with investigator',
            'Firm to respond to rep view',
            'Pending final Ombudsman decision',
            'Firm to respond to Ombudsman decision',
            'Pre-FOS offer accepted',
            'FOS pre-award confirmation',
            'FOS CPFC calculation',
            'FOS rejection being challenged',
            'FOS rejected',
            'FOS won but NO losses',
            'FOS compensation awarded',
            'Invoice issued',
            'Invoice settled – final',
            'FOS dormant',
            'Disinstructed – no payment',
            'Disinstructed – after payment',
            'Case on hold, client instruction',
            'Client not proceeding',
            'Declined/closed',
            'Solicitor referred',
            'No valid claim',
            'Bank – closed',
            'Preparing appeal',
        ],

        'pension-bank' => [
            'Received signed TOB',
            'Received signed TOB. SAR out',
            'SAR received',
            'SAR received. Evidence missing',
            'FOS letter with client',
            'FOS initial complaint sent',
            'FOS app written sent to client',
            'FOS submitted awaiting case ref',
            'FOS open case ref received, awaiting investigator',
            'FOS under review with investigator',
            'Firm to respond to rep view',
            'Pending final Ombudsman decision',
            'Firm to respond to Omb. view',
            'Pre-FOS offer made',
            'Pre-FOS offer accepted',
            'FOS pre award confirmation',
            'FOS rejected',
            'FOS compensation awarded',
            'Invoice issued',
            'Invoice settled – final',
            'Declined/closed',
            'Case on hold / client instruction',
            'Bank – closed',
        ],

    ];

    public function run(): void
    {
        foreach ($this->statuses as $type => $names) {
            // Remove any existing statuses for this type so the seeder is safely re-runnable
            Status::where('type', $type)->delete();

            foreach ($names as $index => $name) {
                Status::create([
                    'display_name' => $name,
                    'description'  => '',
                    'colour'       => '#6c757d',
                    'sort_order'   => $index,
                    'type'         => $type,
                ]);
            }
        }
    }
}
