<?php

namespace App\Services;

use App\Models\Company;
use App\Models\PipelineStage;

class CompanySetupService
{
    /**
     * @return list<array{name: string, sort_order: int, color: string}>
     */
    public static function defaultStages(): array
    {
        return [
            ['name' => 'New', 'sort_order' => 0, 'color' => '#6366f1'],
            ['name' => 'Contacted', 'sort_order' => 1, 'color' => '#0ea5e9'],
            ['name' => 'Interested', 'sort_order' => 2, 'color' => '#22c55e'],
            ['name' => 'Converted', 'sort_order' => 3, 'color' => '#a855f7'],
            ['name' => 'Lost', 'sort_order' => 4, 'color' => '#ef4444'],
        ];
    }

    public function seedDefaultPipeline(Company $company): void
    {
        foreach (self::defaultStages() as $row) {
            PipelineStage::withoutGlobalScope('company')->create([
                'company_id' => $company->id,
                'name' => $row['name'],
                'sort_order' => $row['sort_order'],
                'color' => $row['color'],
            ]);
        }
    }
}
