<?php

namespace Database\Factories;

use App\Domain\Organization\Models\Company;
use App\Domain\Recruitment\Enums\ComplianceStatus;
use App\Domain\Recruitment\Enums\EmployerStatus;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

class EmployerFactory extends Factory
{
    public function definition(): array
    {
        return [
            'employer_code' => 'EMR-TST-'.Str::padLeft((string) $this->faker->unique()->numberBetween(1, 99999), 5, '0'),
            'company_id' => Company::factory(),
            'company_name' => $this->faker->unique()->company(),
            'country' => $this->faker->randomElement(['SA', 'AE', 'QA', 'MY', 'KW']),
            'city' => $this->faker->city(),
            'email' => $this->faker->unique()->companyEmail(),
            'status' => EmployerStatus::Prospect->value,
            'compliance_status' => ComplianceStatus::Pending->value,
        ];
    }

    public function cleared(): static
    {
        return $this->state(fn () => ['compliance_status' => ComplianceStatus::Cleared->value]);
    }

    /** An employer ready to receive job demands. */
    public function active(): static
    {
        return $this->state(fn () => [
            'status' => EmployerStatus::Active->value,
            'compliance_status' => ComplianceStatus::Cleared->value,
            'agreement_expiry_date' => now()->addYear()->toDateString(),
        ]);
    }
}
