import { BaseEntity } from "./base";
import { UserDto, UserCreateDto, UserUpdateDto } from "./dto";
import { UserId } from "./value-ids";

export type User = Omit<UserDto, "id" | "createdAt" | "updatedAt" | "lastEditorID"> & {
    id: UserId;
} & BaseEntity;

export const mapUserDtoToUser = (dto: UserDto): User => ({
    ...dto,
    id: dto.id as UserId,
    createdAt: new Date(dto.createdAt),
    updatedAt: new Date(dto.updatedAt),
    lastEditorID: dto.lastEditorID as UserId,
});

export type UserCreate = Omit<UserCreateDto, never>;

export const mapUserCreateDtoToUserCreate = (dto: UserCreateDto): UserCreate => ({
    ...dto,
});

export type UserUpdate = Omit<UserUpdateDto, never>;

export const mapUserUpdateDtoToUserUpdate = (dto: UserUpdateDto): UserUpdate => ({
    ...dto,
});
