import { SoActivityType as CwSoActivityType } from "../../generated/prisma/client";
import { Translation } from "./types";

type ApiActivityTypeRecord = {
    id: number;
    name: string;
    description: string;
    inactiveFlag: boolean;
    historyFlag: boolean;
    defaultFlag: boolean;
    importFlag: boolean;
    emailFlag: boolean;
    memoFlag: boolean;
    pointsValue: number | null;
    createdById: string | null;
    updatedById: string | null;
    createdAt: Date;
    updatedAt: Date;
};

export const activityTypeTranslation: Translation<
    CwSoActivityType,
    ApiActivityTypeRecord
> = {
    values: [
        { from: "soActivityTypeRecId", to: "id" },
        {
            from: "soActivityTypeId",
            to: "name",
            process: (value) => (value ? value : ""),
        },
        {
            from: "description",
            to: "description",
            process: (value) => (value ? value : ""),
        },
        {
            from: "inactiveFlag",
            to: "inactiveFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "historyFlag",
            to: "historyFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "defaultFlag",
            to: "defaultFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "importFlag",
            to: "importFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "emailFlag",
            to: "emailFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "memoFlag",
            to: "memoFlag",
            process: (value) => Boolean(value ?? false),
        },
        { from: "pointsValue", to: "pointsValue" },
        { from: "enteredBy", to: "createdById" },
        { from: "updatedBy", to: "updatedById" },
        { from: "dateEnteredUtc", to: "createdAt" },
        { from: "lastUpdateUtc", to: "updatedAt" },
    ],
};
