import { BaseEntity } from "./base";
import { CompanyDto, CompanyCreateDto, CompanyUpdateDto } from "./dto";
import { UserId, CompanyId } from "./value-ids";

export type Company = Omit<CompanyDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
    id: CompanyId;
} & BaseEntity;

export const mapCompanyDtoToCompany = (dto: CompanyDto): Company => ({
    ...dto,
    id: dto.id as CompanyId,
    createdAt: new Date(dto.createdAt),
    updatedAt: new Date(dto.updatedAt),
    lastEditorID: dto.lastEditorID as UserId,
});

export type CompanyCreate = CompanyCreateDto;

export const mapCompanyCreateDtoToCompanyCreate = (dto: CompanyCreateDto): CompanyCreate => ({
    ...dto,
});

export type CompanyUpdate = CompanyUpdateDto;

export const mapCompanyUpdateDtoToCompanyUpdate = (dto: CompanyUpdateDto): CompanyUpdate => ({
    ...dto,
});
