<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\PersonBundle\Actions\PersonCreate;

use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Civility;
use Chill\MainBundle\Entity\Gender;
use Chill\PersonBundle\Entity\Identifier\PersonIdentifier;
use Chill\PersonBundle\Entity\PersonAltName;
use libphonenumber\PhoneNumber;
use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber as MisdPhoneNumberConstraint;
use Symfony\Component\Validator\Constraints as Assert;
use Chill\PersonBundle\Validator\Constraints\Person\Birthdate;

class PersonCreateDTO
{
    #[Assert\NotBlank(message: 'The firstname cannot be empty')]
    #[Assert\Length(max: 255)]
    public string $firstName;

    #[Assert\NotBlank(message: 'The lastname cannot be empty')]
    #[Assert\Length(max: 255)]
    public string $lastName;

    #[Birthdate]
    public ?\DateTime $birthdate = null;

    #[Assert\NotNull(message: 'The gender must be set')]
    public ?Gender $gender = null;

    public ?Civility $civility = null;

    #[MisdPhoneNumberConstraint(type: [MisdPhoneNumberConstraint::FIXED_LINE, MisdPhoneNumberConstraint::VOIP, MisdPhoneNumberConstraint::PERSONAL_NUMBER])]
    public ?PhoneNumber $phonenumber = null;

    #[MisdPhoneNumberConstraint(type: [MisdPhoneNumberConstraint::MOBILE])]
    public ?PhoneNumber $mobilenumber = null;

    #[Assert\Email]
    public ?string $email = '';

    // Checkbox that indicates whether the address form was checked in creation form
    public bool $addressForm = false;

    // Selected address value (unmapped in Person entity during creation)
    public ?Address $address = null;

    public ?Center $center = null;

    /**
     * @var array<string, PersonAltName> where the key is the altname's key
     */
    public array $altNames = [];

    /**
     * @var array<string, PersonIdentifier>
     */
    #[Assert\Valid(traverse: true)]
    public array $identifiers = [];
}
