import { SoActStatus as CwSoActStatus } from "../../generated/prisma/client";
import { Translation } from "./types";

type ApiActivityStatusRecord = {
    id: number;
    name: string;
    description: string | null;
    closedFlag: boolean;
    inactiveFlag: boolean;
    defaultFlag: boolean;
    spawnFollowupFlag: boolean;
    createdById: string | null;
    updatedById: string | null;
    createdAt: Date;
    updatedAt: Date;
};

export const activityStatusTranslation: Translation<
    CwSoActStatus,
    ApiActivityStatusRecord
> = {
    values: [
        { from: "soActStatusRecId", to: "id" },
        {
            from: "description",
            to: "name",
            process: (value) => (value ? value : "Unknown Status"),
        },
        { from: "description", to: "description" },
        {
            from: "closedFlag",
            to: "closedFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "inactiveFlag",
            to: "inactiveFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "defaultFlag",
            to: "defaultFlag",
            process: (value) => Boolean(value),
        },
        {
            from: "spawnFollowupFlag",
            to: "spawnFollowupFlag",
            process: (value) => Boolean(value),
        },
        { from: "enteredBy", to: "createdById" },
        { from: "updatedBy", to: "updatedById" },
        { from: "dateEnteredUtc", to: "createdAt" },
        { from: "lastUpdateUtc", to: "updatedAt" },
    ],
};
