import { BaseEntity } from "./base";
import { ProjectDto, ProjectCreateDto, ProjectUpdateDto } from "./dto";
import { UserId, ProjectId } from "./value-ids";

export type Project = Omit<ProjectDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
    id: ProjectId;
} & BaseEntity;

export const mapProjectDtoToProject = (dto: ProjectDto): Project => ({
    ...dto,
    id: dto.id as ProjectId,
    createdAt: new Date(dto.createdAt),
    updatedAt: new Date(dto.updatedAt),
    lastEditorID: dto.lastEditorID as UserId,
});

export type ProjectCreate = ProjectCreateDto;

export const mapProjectCreateDtoToProjectCreate = (dto: ProjectCreateDto): ProjectCreate => ({
    ...dto,
});

export type ProjectUpdate = ProjectUpdateDto;

export const mapProjectUpdateDtoToProjectUpdate = (dto: ProjectUpdateDto): ProjectUpdate => ({
    ...dto,
});
