import { MemberType as CwMemberType } from "../../generated/prisma/client";
import { Translation } from "./types";

type ApiCwMemberTypeRecord = {
    id: number;
    description: string | null;
    inactiveFlag: boolean;
    createdById: string | null;
    updatedById: string | null;
    createdAt: Date;
    updatedAt: Date;
};

export const cwMemberTypeTranslation: Translation<
    CwMemberType,
    ApiCwMemberTypeRecord
> = {
    values: [
        { from: "memberTypeRecId", to: "id" },
        { from: "description", to: "description" },
        {
            from: "inactiveFlag",
            to: "inactiveFlag",
            process: (value) => Boolean(value),
        },
        { from: "enteredBy", to: "createdById" },
        { from: "updatedBy", to: "updatedById" },
        {
            from: "dateEnteredUtc",
            to: "createdAt",
            process: (value) => (value as Date | null) ?? new Date(0),
        },
        {
            from: "lastUpdateUtc",
            to: "updatedAt",
            process: (value) => (value as Date | null) ?? new Date(0),
        },
    ],
};
