<?php

namespace Database\Factories\Contact;

use App\Enum\Contact\MessageChannel;
use App\Models\Contact\ContactTemplate;
use App\Models\Solicitor\Solicitor;
use Illuminate\Database\Eloquent\Factories\Factory;

class ContactTemplateFactory extends Factory
{
    protected $model = ContactTemplate::class;

    public function definition(): array
    {
        return [
            'solicitor_id' => Solicitor::query()->value('id') ?? 1,
            'name' => $this->faker->sentence(3),
            'slug' => $this->faker->unique()->uuid(),
            'key' => $this->faker->unique()->slug(2, false),
            'channel' => MessageChannel::EMAIL,
            'is_active' => true,
            'allow_manual_send' => true,
            'allow_automatic_send' => false,
            'subject' => $this->faker->sentence(6),
            'body_text_template' => "Hi {{ client.first_name|there }},\n\n" . $this->faker->paragraph(),
            'body_html_template' => '<p>Hi {{ client.first_name|there }},</p><p>' . $this->faker->paragraph() . '</p>',
            'applies_to_type' => null,
            'config' => ['include_signature' => true],
        ];
    }

    public function sms(): static
    {
        return $this->state(fn () => [
            'channel' => MessageChannel::SMS,
            'subject' => null,
            'body_html_template' => null,
            'body_text_template' => "Hi {{ client.first_name|there }}, this is a short SMS from {{ solicitor.name }}.",
        ]);
    }
}
