<?php

declare(strict_types=1);

namespace App\Administration\Application\Query\GetAssignmentsForTeacher;

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

final readonly class TeacherAssignmentDto
{
    public function __construct(
        public string $id,
        public string $teacherId,
        public string $classId,
        public string $subjectId,
        public string $academicYearId,
        public string $status,
        public DateTimeImmutable $startDate,
        public ?DateTimeImmutable $endDate,
        public DateTimeImmutable $createdAt,
    ) {
    }

    public static function fromDomain(TeacherAssignment $assignment): self
    {
        return new self(
            id: (string) $assignment->id,
            teacherId: (string) $assignment->teacherId,
            classId: (string) $assignment->classId,
            subjectId: (string) $assignment->subjectId,
            academicYearId: (string) $assignment->academicYearId,
            status: $assignment->status->value,
            startDate: $assignment->startDate,
            endDate: $assignment->endDate,
            createdAt: $assignment->createdAt,
        );
    }
}
