import { TeStatus as CwTeStatus } from "../../generated/prisma/client";
import { Translation } from "./types";

type ApiTimeEntryStatusRecord = {
    id: number;
    statusId: number;
    description: string | null;
    action: string | null;
    createdAt: Date;
    updatedAt: Date;
};

export const timeEntryStatusTranslation: Translation<
    CwTeStatus,
    ApiTimeEntryStatusRecord
> = {
    values: [
        { from: "teStatusRecId", to: "id" },
        { from: "teStatusId", to: "statusId" },
        { from: "description", to: "description" },
        { from: "action", to: "action" },
        {
            from: "lastUpdatedUtc",
            to: "createdAt",
            process: (value) => (value as Date | null) ?? new Date(0),
        },
        {
            from: "lastUpdatedUtc",
            to: "updatedAt",
            process: (value) => (value as Date | null) ?? new Date(0),
        },
    ],
};
