import { BranchesOutlined, PauseCircleOutlined } from "@ant-design/icons";
import { Checkbox, Space, Tooltip } from "antd";
import i18n from "i18next";
import { Link } from "react-router-dom";
import { setModalContext } from "../../redux/modals/modals.actions";
import { store } from "../../redux/store";
import CurrencyFormatter from "../../utils/CurrencyFormatter";
import { TimeFormatter } from "../../utils/DateFormatter";
import PhoneNumberFormatter from "../../utils/PhoneFormatter";
import { onlyUnique } from "../../utils/arrayHelper";
import InstanceRenderManager from "../../utils/instanceRenderMgr";
import { alphaSort, dateSort, statusSort } from "../../utils/sorters";
import JobAltTransportChange from "../job-at-change/job-at-change.component";
import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component";
import OwnerNameDisplay, { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
import ProductionSubletsManageComponent from "../production-sublets-manage/production-sublets-manage.component";
import ProductionListColumnAlert from "./production-list-columns.alert.component";
import ProductionListColumnBodyPriority from "./production-list-columns.bodypriority.component";
import ProductionListColumnComment from "./production-list-columns.comment.component";
import ProductionListDate from "./production-list-columns.date.component";
import ProductionListColumnDetailPriority from "./production-list-columns.detailpriority.component";
import ProductionListEmployeeAssignment from "./production-list-columns.empassignment.component";
import ProductionListLastContacted from "./production-list-columns.lastcontacted.component";
import ProductionListColumnPaintPriority from "./production-list-columns.paintpriority.component";
import ProductionListColumnPartsReceived from "./production-list-columns.partsreceived.component";
import ProductionListColumnNote from "./production-list-columns.productionnote.component";
import ProductionListColumnCategory from "./production-list-columns.status.category";
import ProductionListColumnStatus from "./production-list-columns.status.component";
import ProductionListColumnTouchTime from "./prodution-list-columns.touchtime.component";
import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx";
import ChatOpenButton from "../chat-open-button/chat-open-button.component.jsx";

const getEmployeeName = (employeeId, employees) => {
  const employee = employees.find((e) => e.id === employeeId);
  return employee ? `${employee.first_name} ${employee.last_name}` : "";
};

const productionListColumnsData = ({ technician, state, activeStatuses, data, bodyshop, refetch, treatments }) => {
  const { Enhanced_Payroll } = treatments;

  return [
    {
      title: i18n.t("jobs.actions.viewdetail"),
      dataIndex: "viewdetail",
      key: "viewdetail",
      ellipsis: true,
      render: (text, record) => (
        <Space>
          <Link to={{ search: `?selected=${record.id}` }}>{i18n.t("general.labels.view")}</Link>
          <ShareToTeamsButton
            noIcon={true}
            linkText={"Share"}
            noIconStyle={{ color: "#1890ff" }}
            urlOverride={`${window.location.origin}/manage/jobs/${record.id}`}
          />
        </Space>
      )
    },
    ...(Enhanced_Payroll.treatment === "on"
      ? [
          {
            title: i18n.t("timetickets.actions.claimtasks"),
            dataIndex: "claimtasks",
            key: "claimtasks",
            ellipsis: true,
            render: (text, record) => (
              <div
                style={{ cursor: "pointer" }}
                onClick={() => {
                  store.dispatch(
                    setModalContext({
                      context: {
                        actions: {},
                        context: { jobid: record.id }
                      },
                      modal: "timeTicketTask"
                    })
                  );
                }}
              >
                {i18n.t("timetickets.actions.claimtasks")}
              </div>
            )
          }
        ]
      : []),
    {
      title: i18n.t("jobs.fields.ro_number"),
      dataIndex: "ro_number",
      key: "ro_number",
      ellipsis: true,
      sorter: (a, b) => alphaSort(a.ro_number, b.ro_number),
      sortOrder: state.sortedInfo.columnKey === "ro_number" && state.sortedInfo.order,
      render: (text, record) =>
        technician ? (
          <Link to={`/tech/joblookup?selected=${record.id}`}>
            {record.ro_number}
            {record.suspended && <PauseCircleOutlined style={{ color: "orangered" }} />}
          </Link>
        ) : (
          <Link to={`/manage/jobs/${record.id}`}>
            <Space>
              {record.ro_number}
              {record.suspended && <PauseCircleOutlined style={{ color: "orangered" }} />}
              {record.iouparent && (
                <Tooltip title={i18n.t("jobs.labels.iou")}>
                  <BranchesOutlined style={{ color: "orangered" }} />
                </Tooltip>
              )}
            </Space>
          </Link>
        )
    },
    {
      title: i18n.t("jobs.fields.owner"),
      dataIndex: "ownr",
      key: "ownr",
      ellipsis: true,
      render: (text, record) =>
        technician ? (
          <OwnerNameDisplay ownerObject={record} />
        ) : (
          <Link to={`/manage/owners/${record.ownerid}`}>
            <OwnerNameDisplay ownerObject={record} />
          </Link>
        ),
      sorter: (a, b) => alphaSort(OwnerNameDisplayFunction(a), OwnerNameDisplayFunction(b)),
      sortOrder: state.sortedInfo.columnKey === "ownr" && state.sortedInfo.order
    },
    {
      title: i18n.t("jobs.fields.vehicle"),
      dataIndex: "vehicle",
      key: "vehicle",
      ellipsis: true,
      sorter: (a, b) =>
        alphaSort(
          `${a.v_model_yr || ""} ${a.v_make_desc || ""} ${a.v_model_desc || ""}`,
          `${b.v_model_yr || ""} ${b.v_make_desc || ""} ${b.v_model_desc || ""}`
        ),
      sortOrder: state.sortedInfo.columnKey === "vehicle" && state.sortedInfo.order,
      render: (text, record) =>
        technician ? (
          <>{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${record.v_model_desc || ""} ${
            record.v_color || ""
          } ${record.plate_no || ""}`}</>
        ) : (
          <Link to={`/manage/vehicles/${record.vehicleid}`}>{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
            record.v_model_desc || ""
          } ${record.v_color || ""} ${record.plate_no || ""}`}</Link>
        )
    },
    {
      title: i18n.t("jobs.fields.actual_in"),
      dataIndex: "actual_in",
      key: "actual_in",
      ellipsis: true,
      sorter: (a, b) => dateSort(a.actual_in, b.actual_in),
      sortOrder: state.sortedInfo.columnKey === "actual_in" && state.sortedInfo.order,
      render: (text, record) => <ProductionListDate record={record} field="actual_in" time />
    },
    {
      title: i18n.t("jobs.fields.actual_in") + " (HH:MM)",
      dataIndex: "actual_in_time",
      key: "actual_in_time",
      ellipsis: true,
      render: (text, record) => <TimeFormatter>{record.actual_in}</TimeFormatter>
    },
    {
      title: i18n.t("jobs.fields.scheduled_completion"),
      dataIndex: "scheduled_completion",
      key: "scheduled_completion",
      ellipsis: true,
      sorter: (a, b) => dateSort(a.scheduled_completion, b.scheduled_completion),
      sortOrder: state.sortedInfo.columnKey === "scheduled_completion" && state.sortedInfo.order,
      render: (text, record) => <ProductionListDate record={record} field="scheduled_completion" pastIndicator time />
    },
    {
      title: i18n.t("jobs.fields.scheduled_completion") + " (HH:MM)",
      dataIndex: "scheduled_completion_time",
      key: "scheduled_completion_time",
      ellipsis: true,

      render: (text, record) => <TimeFormatter>{record.scheduled_completion}</TimeFormatter>
    },
    {
      title: i18n.t("jobs.fields.actual_completion"),
      dataIndex: "actual_completion",
      key: "actual_completion",
      ellipsis: true,
      sorter: (a, b) => dateSort(a.actual_completion, b.actual_completion),
      sortOrder: state.sortedInfo.columnKey === "actual_completion" && state.sortedInfo.order,
      render: (text, record) => <ProductionListDate record={record} field="actual_completion" time />
    },
    {
      title: i18n.t("jobs.fields.actual_completion") + " (HH:MM)",
      dataIndex: "actual_completion_time",
      key: "actual_completion_time",
      ellipsis: true,
      render: (text, record) => <TimeFormatter>{record.actual_completion}</TimeFormatter>
    },
    {
      title: i18n.t("jobs.fields.date_last_contacted"),
      dataIndex: "date_last_contacted",
      key: "date_last_contacted",
      ellipsis: true,
      sorter: (a, b) => dateSort(a.date_last_contacted, b.date_last_contacted),
      sortOrder: state.sortedInfo.columnKey === "date_last_contacted" && state.sortedInfo.order,
      render: (text, record) => <ProductionListLastContacted record={record} />
    },
    {
      title: i18n.t("jobs.fields.date_next_contact"),
      dataIndex: "date_next_contact",
      key: "date_next_contact",
      ellipsis: true,
      sorter: (a, b) => dateSort(a.date_next_contact, b.date_next_contact),
      sortOrder: state.sortedInfo.columnKey === "date_next_contact" && state.sortedInfo.order,
      render: (text, record) => <ProductionListDate record={record} field="date_next_contact" pastIndicator time />
    },
    {
      title: i18n.t("jobs.fields.scheduled_delivery"),
      dataIndex: "scheduled_delivery",
      key: "scheduled_delivery",
      ellipsis: true,
      sorter: (a, b) => dateSort(a.scheduled_delivery, b.scheduled_delivery),
      sortOrder: state.sortedInfo.columnKey === "scheduled_delivery" && state.sortedInfo.order,
      render: (text, record) => <ProductionListDate record={record} field="scheduled_delivery" pastIndicator time />
    },
    {
      title: i18n.t("jobs.fields.scheduled_delivery") + " (HH:MM)",
      dataIndex: "scheduled_delivery_time",
      key: "scheduled_delivery_time",
      ellipsis: true,

      render: (text, record) => <TimeFormatter>{record.scheduled_delivery}</TimeFormatter>
    },
    {
      title: i18n.t("jobs.fields.ins_co_nm"),
      dataIndex: "ins_co_nm",
      key: "ins_co_nm",
      ellipsis: true,
      sorter: (a, b) => alphaSort(a.ins_co_nm, b.ins_co_nm),
      sortOrder: state.sortedInfo.columnKey === "ins_co_nm" && state.sortedInfo.order
    },
    {
      title: i18n.t("jobs.fields.clm_no"),
      dataIndex: "clm_no",
      key: "clm_no",
      ellipsis: true,
      sorter: (a, b) => alphaSort(a.clm_no, b.clm_no),
      sortOrder: state.sortedInfo.columnKey === "clm_no" && state.sortedInfo.order
    },
    {
      title: i18n.t("jobs.fields.clm_total"),
      dataIndex: "clm_total",
      key: "clm_total",
      ellipsis: true,
      sorter: (a, b) => a.clm_total - b.clm_total,
      sortOrder: state.sortedInfo.columnKey === "clm_total" && state.sortedInfo.order,
      render: (text, record) => <CurrencyFormatter>{record.clm_total}</CurrencyFormatter>
    },
    {
      title: i18n.t("jobs.fields.owner_owing"),
      dataIndex: "owner_owing",
      key: "owner_owing",
      ellipsis: true,
      sorter: (a, b) => a.owner_owing - b.owner_owing,
      sortOrder: state.sortedInfo.columnKey === "owner_owing" && state.sortedInfo.order,
      render: (text, record) => <CurrencyFormatter>{record.owner_owing}</CurrencyFormatter>
    },
    {
      title: i18n.t("jobs.fields.ownr_ph1"),
      dataIndex: "ownr_ph1",
      key: "ownr_ph1",
      ellipsis: true,
      render: (text, record) =>
        technician ? (
          <PhoneNumberFormatter type={record.ownr_ph1_ty}>{record.ownr_ph1}</PhoneNumberFormatter>
        ) : (
          <ChatOpenButton type={record.ownr_ph1_ty} phone={record.ownr_ph1} jobid={record.id} />
        )
    },
    {
      title: i18n.t("jobs.fields.ownr_ph2"),
      dataIndex: "ownr_ph2",
      key: "ownr_ph2",
      ellipsis: true,
      render: (text, record) =>
        technician ? (
          <PhoneNumberFormatter type={record.ownr_ph2_ty}>{record.ownr_ph2}</PhoneNumberFormatter>
        ) : (
          <ChatOpenButton type={record.ownr_ph2_ty} phone={record.ownr_ph2} jobid={record.id} />
        )
    },
    {
      title: i18n.t("jobs.fields.specialcoveragepolicy"),
      dataIndex: "special_coverage_policy",
      key: "special_coverage_policy",
      ellipsis: true,
      sorter: (a, b) => Number(a.special_coverage_policy) - Number(b.special_coverage_policy),
      sortOrder: state.sortedInfo.columnKey === "special_coverage_policy" && state.sortedInfo.order,
      filters: [
        { text: "True", value: true },
        { text: "False", value: false }
      ],
      onFilter: (value, record) => value === record.special_coverage_policy,
      render: (text, record) => <Checkbox checked={record.special_coverage_policy} />
    },

    {
      title: i18n.t("jobs.fields.alt_transport"),
      dataIndex: "alt_transport",
      key: "alt_transport",
      ellipsis: true,
      sorter: (a, b) => alphaSort(a.alt_transport, b.alt_transport),
      sortOrder: state.sortedInfo.columnKey === "alt_transport" && state.sortedInfo.order,
      filters:
        (bodyshop &&
          bodyshop.appt_alt_transport.map((s) => {
            return {
              text: s,
              value: [s]
            };
          })) ||
        [],
      onFilter: (value, record) => value.includes(record.alt_transport),
      render: (text, record) => (
        <div>
          {record.alt_transport}
          <JobAltTransportChange job={record} />
        </div>
      )
    },
    {
      title: i18n.t("jobs.fields.status"),
      dataIndex: "status",
      key: "status",
      ellipsis: true,
      sorter: (a, b) => statusSort(a.status, b.status, activeStatuses),
      sortOrder: state.sortedInfo.columnKey === "status" && state.sortedInfo.order,
      filters:
        activeStatuses
          ?.map((s) => {
            return {
              text: s || i18n.t("dashboard.errors.status"),
              value: [s]
            };
          })
          .sort((a, b) => statusSort(a.text, b.text, activeStatuses)) || [],
      onFilter: (value, record) => value.includes(record.status),
      render: (text, record) => <ProductionListColumnStatus record={record} />
    },
    {
      title: i18n.t("jobs.fields.category"),
      dataIndex: "category",
      key: "category",
      ellipsis: true,

      filters:
        (bodyshop &&
          bodyshop.md_categories.map((s) => {
            return {
              text: s,
              value: [s]
            };
          })) ||
        [],
      onFilter: (value, record) => value.includes(record.category),
      sorter: (a, b) => alphaSort(a.category, b.category),
      sortOrder: state.sortedInfo.columnKey === "category" && state.sortedInfo.order,
      render: (text, record) => <ProductionListColumnCategory record={record} />
    },
    {
      title: i18n.t("production.labels.bodyhours"),
      dataIndex: "labhrs",
      key: "labhrs",
      sorter: (a, b) => a.labhrs.aggregate.sum.mod_lb_hrs - b.labhrs.aggregate.sum.mod_lb_hrs,
      sortOrder: state.sortedInfo.columnKey === "labhrs" && state.sortedInfo.order,
      render: (text, record) => record.labhrs.aggregate.sum.mod_lb_hrs
    },
    {
      title: i18n.t("production.labels.refinishhours"),
      dataIndex: "larhrs",
      key: "larhrs",
      sorter: (a, b) => a.larhrs.aggregate.sum.mod_lb_hrs - b.larhrs.aggregate.sum.mod_lb_hrs,
      sortOrder: state.sortedInfo.columnKey === "larhrs" && state.sortedInfo.order,
      render: (text, record) => record.larhrs.aggregate.sum.mod_lb_hrs
    },
    {
      title: i18n.t("production.labels.totalhours"),
      dataIndex: "totalhours",
      key: "totalhours",
      sorter: (a, b) =>
        a.labhrs.aggregate.sum.mod_lb_hrs +
        a.larhrs.aggregate.sum.mod_lb_hrs -
        (b.labhrs.aggregate.sum.mod_lb_hrs + b.larhrs.aggregate.sum.mod_lb_hrs),
      sortOrder: state.sortedInfo.columnKey === "totalhours" && state.sortedInfo.order,
      render: (text, record) =>
        (record.labhrs.aggregate.sum.mod_lb_hrs + record.larhrs.aggregate.sum.mod_lb_hrs).toFixed(1)
    },
    {
      title: i18n.t("production.labels.alert"),
      dataIndex: "alert",
      key: "alert",
      sorter: (a, b) => Number(a.production_vars?.alert || false) - Number(b.production_vars?.alert || false),
      sortOrder: state.sortedInfo.columnKey === "alert" && state.sortedInfo.order,
      filters: [
        { text: "True", value: true },
        { text: "False", value: false }
      ],
      onFilter: (value, record) => value === (record.production_vars?.alert || false),
      render: (text, record) => (
        <ProductionListColumnAlert id={record.id} productionVars={record?.production_vars} refetch={refetch} />
      )
    },
    {
      title: i18n.t("production.labels.note"),
      dataIndex: "note",
      key: "note",
      ellipsis: true,
      render: (text, record) => <ProductionListColumnNote record={record} />
    },
    {
      title: i18n.t("production.labels.comment"),
      dataIndex: "comment",
      key: "comment",
      ellipsis: true,
      render: (text, record) => <ProductionListColumnComment record={record} />
    },
    {
      title: i18n.t("production.labels.touchtime"),
      dataIndex: "tt",
      key: "tt",
      render: (text, record) => {
        return <ProductionListColumnTouchTime job={record} />;
      }
    },
    {
      title: i18n.t("production.labels.bodypriority"),
      dataIndex: "bodypriority",
      key: "bodypriority",

      sorter: (a, b) =>
        ((a.production_vars && a.production_vars.bodypriority) || 11) -
        ((b.production_vars && b.production_vars.bodypriority) || 11),
      sortOrder: state.sortedInfo.columnKey === "bodypriority" && state.sortedInfo.order,
      render: (text, record) => <ProductionListColumnBodyPriority record={record} />
    },
    {
      title: i18n.t("production.labels.paintpriority"),
      dataIndex: "paintpriority",
      key: "paintpriority",

      sorter: (a, b) =>
        ((a.production_vars && a.production_vars.paintpriority) || 11) -
        ((b.production_vars && b.production_vars.paintpriority) || 11),
      sortOrder: state.sortedInfo.columnKey === "paintpriority" && state.sortedInfo.order,
      render: (text, record) => <ProductionListColumnPaintPriority record={record} />
    },
    {
      title: i18n.t("production.labels.detailpriority"),
      dataIndex: "detailpriority",
      key: "detailpriority",

      sorter: (a, b) =>
        ((a.production_vars && a.production_vars.detailpriority) || 11) -
        ((b.production_vars && b.production_vars.detailpriority) || 11),
      sortOrder: state.sortedInfo.columnKey === "detailpriority" && state.sortedInfo.order,
      render: (text, record) => <ProductionListColumnDetailPriority record={record} />
    },
    {
      title: i18n.t("production.labels.sublets"),
      dataIndex: "sublets",
      key: "sublets",
      render: (text, record) => <ProductionSubletsManageComponent subletJobLines={record.subletLines} />
    },
    {
      title: i18n.t("jobs.fields.employee_body"),
      dataIndex: "employee_body",
      key: "employee_body",
      sortOrder: state.sortedInfo.columnKey === "employee_body" && state.sortedInfo.order,
      sorter: (a, b) =>
        alphaSort(
          getEmployeeName(a.employee_body, bodyshop.employees),
          getEmployeeName(b.employee_body, bodyshop.employees)
        ),
      render: (text, record) => (
        <ProductionListEmployeeAssignment refetch={refetch} record={record} type="employee_body" />
      )
    },
    {
      title: i18n.t("jobs.fields.employee_prep"),
      dataIndex: "employee_prep",
      key: "employee_prep",
      sortOrder: state.sortedInfo.columnKey === "employee_prep" && state.sortedInfo.order,
      sorter: (a, b) =>
        alphaSort(
          getEmployeeName(a.employee_prep, bodyshop.employees),
          getEmployeeName(b.employee_prep, bodyshop.employees)
        ),
      render: (text, record) => (
        <ProductionListEmployeeAssignment record={record} refetch={refetch} type="employee_prep" />
      )
    },
    {
      title: i18n.t(
        InstanceRenderManager({
          imex: "jobs.fields.employee_csr",
          rome: "jobs.fields.employee_csr_writer"
        })
      ),
      dataIndex: "employee_csr",
      key: "employee_csr",
      sortOrder: state.sortedInfo.columnKey === "employee_csr" && state.sortedInfo.order,
      sorter: (a, b) =>
        alphaSort(
          getEmployeeName(a.employee_csr, bodyshop.employees),
          getEmployeeName(b.employee_csr, bodyshop.employees)
        ),
      render: (text, record) => (
        <ProductionListEmployeeAssignment refetch={refetch} record={record} type="employee_csr" />
      )
    },
    {
      title: i18n.t("jobs.fields.employee_refinish"),
      dataIndex: "employee_refinish",
      key: "employee_refinish",
      sortOrder: state.sortedInfo.columnKey === "employee_refinish" && state.sortedInfo.order,
      sorter: (a, b) =>
        alphaSort(
          getEmployeeName(a.employee_refinish, bodyshop.employees),
          getEmployeeName(b.employee_refinish, bodyshop.employees)
        ),
      render: (text, record) => (
        <ProductionListEmployeeAssignment record={record} refetch={refetch} type="employee_refinish" />
      )
    },
    {
      title: i18n.t("jobs.labels.parts_received"),
      dataIndex: "parts_received",
      key: "parts_received",
      render: (text, record) => <ProductionListColumnPartsReceived record={record} />
    },
    {
      title: i18n.t("jobs.fields.partsstatus"),
      dataIndex: "partsstatus",
      key: "partsstatus",
      render: (text, record) => <JobPartsQueueCount parts={record.joblines_status} record={record} />
    },
    {
      title: i18n.t("jobs.labels.estimator"),
      dataIndex: "estimator",
      key: "estimator",
      sorter: (a, b) =>
        alphaSort(
          `${a.est_ct_fn || ""} ${a.est_ct_ln || ""}`.trim(),
          `${b.est_ct_fn || ""} ${b.est_ct_ln || ""}`.trim()
        ),
      sortOrder: state.sortedInfo.columnKey === "estimator" && state.sortedInfo.order,
      filters:
        (data &&
          data
            .map((j) => `${j.est_ct_fn || ""} ${j.est_ct_ln || ""}`.trim())
            .filter(onlyUnique)
            .map((s) => {
              return {
                text: s || "N/A",
                value: [s]
              };
            })) ||
        [],
      onFilter: (value, record) => value.includes(`${record.est_ct_fn || ""} ${record.est_ct_ln || ""}`.trim()),
      render: (text, record) => `${record.est_ct_fn || ""} ${record.est_ct_ln || ""}`.trim()
    },

    //Added as a place holder for St Claude. Not implemented as it requires another join for a field used by only 1 client.
    // {
    //   title: i18n.t("vehicles.fields.v_paint_codes", { number: "" }),
    //   dataIndex: "v_paint_codes",
    //   key: "v_paint_codes",
    //   render: (text, record) =>
    //     record.vehicle?.v_paint_codes ? (
    //       <span style={{ whiteSpace: "pre" }}>
    //         {Object.keys(record.vehicle.v_paint_codes)
    //           .filter(
    //             (key) =>
    //               record.vehicle.v_paint_codes[key] !== "" &&
    //               record.vehicle.v_paint_codes[key] !== null &&
    //               record.vehicle.v_paint_codes[key] !== undefined
    //           )
    //           .map((key, idx) => (
    //             <Tag key={idx}>{record.vehicle.v_paint_codes[key]}</Tag>
    //           ))}
    //       </span>
    //     ) : null,
    // },
    {
      title: i18n.t("jobs.fields.date_repairstarted"),
      dataIndex: "date_repairstarted",
      key: "date_repairstarted",
      ellipsis: true,
      sorter: (a, b) => dateSort(a.date_repairstarted, b.date_repairstarted),
      sortOrder: state.sortedInfo.columnKey === "date_repairstarted" && state.sortedInfo.order,
      render: (text, record) => <ProductionListDate record={record} field="date_repairstarted" time />
    },
    {
      title: i18n.t("jobs.fields.date_repairstarted") + " (HH:MM)",
      dataIndex: "date_repairstarted_time",
      key: "date_repairstarted_time",
      ellipsis: true,

      render: (text, record) => <TimeFormatter>{record.date_repairstarted}</TimeFormatter>
    },
    ...(bodyshop && bodyshop.rr_dealerid
      ? [
          {
            title: i18n.t("jobs.fields.dms.id"),
            dataIndex: "dms_id",
            key: "dms_id",
            ellipsis: true,
            sorter: (a, b) => alphaSort(a.dms_id, b.dms_id),
            sortOrder: state.sortedInfo.columnKey === "dms_id" && state.sortedInfo.order
          }
        ]
      : []),
  ];
};
export default productionListColumnsData;
