import { BaseEntity } from "./base";
import { CustomerDto, CustomerCreateDto, CustomerUpdateDto } from "./dto";
import { UserId, CustomerId } from "./value-ids";

export type Customer = Omit<CustomerDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
    id: CustomerId;
} & BaseEntity;

export const mapCustomerDtoToCustomer = (dto: CustomerDto): Customer => ({
    ...dto,
    id: dto.id as CustomerId,
    createdAt: new Date(dto.createdAt),
    updatedAt: new Date(dto.updatedAt),
    lastEditorID: dto.lastEditorID as UserId,
});

export type CustomerCreate = CustomerCreateDto;

export const mapCustomerCreateDtoToCustomerCreate = (dto: CustomerCreateDto): CustomerCreate => ({
    ...dto,
});

export type CustomerUpdate = CustomerUpdateDto;

export const mapCustomerUpdateDtoToCustomerUpdate = (dto: CustomerUpdateDto): CustomerUpdate => ({
    ...dto,
});
