<?php

declare(strict_types=1);

namespace App\Administration\Application\Query\GetStudentsImageRights;

use App\Administration\Domain\Model\User\User;
use DateTimeImmutable;

final readonly class StudentImageRightsDto
{
    public function __construct(
        public string $id,
        public string $firstName,
        public string $lastName,
        public string $email,
        public string $imageRightsStatus,
        public string $imageRightsStatusLabel,
        public ?DateTimeImmutable $imageRightsUpdatedAt,
        public ?string $className,
    ) {
    }

    public static function fromDomain(User $user, ?string $className = null): self
    {
        return new self(
            id: (string) $user->id,
            firstName: $user->firstName,
            lastName: $user->lastName,
            email: (string) $user->email,
            imageRightsStatus: $user->imageRightsStatus->value,
            imageRightsStatusLabel: $user->imageRightsStatus->label(),
            imageRightsUpdatedAt: $user->imageRightsUpdatedAt,
            className: $className,
        );
    }
}
