import { DataType, UserInterface } from "@sankhyalabs/core";
import { SnkMessageBuilder } from "../../../../lib/message/SnkMessageBuilder";
let messageBuilderInstance;
const getMessage = (key) => {
  if (!messageBuilderInstance) {
    messageBuilderInstance = new SnkMessageBuilder();
  }
  return messageBuilderInstance.getMessage(key);
};
export const attachCrudConfig = {
  grid: {
    columns: [
      { name: "CODATA", orderIndex: 0, width: 0 },
      { name: "DESCRICAO", orderIndex: 1, width: 0 },
      { name: "ARQUIVO", orderIndex: 2, width: 0 },
      { name: "DTALTER", orderIndex: 3, width: 0 },
      { name: "USUARIO", orderIndex: 4, width: 0 },
    ],
  },
  form: {
    emptyConfig: false,
    fields: [
      {
        name: "DESCRICAO",
        label: getMessage("snkAttach.attachMetadata.lblDescription"),
        visible: true,
        readOnly: false,
        required: true,
      },
      {
        name: "CAMINHO_ARQUIVO",
        label: getMessage("snkAttach.attachMetadata.lblFile"),
        visible: true,
        readOnly: false,
        required: true,
      },
    ],
  },
};
export const attachFetcherMetadataBuilder = {
  name: "Attach",
  label: "Attach List",
  fields: [
    { name: "CODATA", label: getMessage("snkAttach.attachMetadata.lblCode"), dataType: DataType.TEXT },
    { name: "DESCRICAO", label: getMessage("snkAttach.attachMetadata.lblDescription"), dataType: DataType.TEXT, readOnly: false },
    { name: "ARQUIVO", label: getMessage("snkAttach.attachMetadata.lblFileOrLink"), dataType: DataType.TEXT },
    { name: "USUARIO", label: getMessage("snkAttach.attachMetadata.lblUser"), dataType: DataType.TEXT },
    { name: "DTALTER", label: getMessage("snkAttach.attachMetadata.lblDate"), dataType: DataType.TEXT },
    {
      name: "CAMINHO_ARQUIVO",
      label: getMessage("snkAttach.attachMetadata.lblFileUpload"),
      dataType: DataType.OBJECT,
      userInterface: UserInterface.FILE,
      readOnly: false,
      required: true,
      visible: true,
      properties: {
        subTitle: getMessage("snkAttach.attachMetadata.lblSubTitle"),
        MAX_FILES: 1,
        STORAGESTRATEGY: "SESSION",
        INTERNAL_FILENAME: "Attach.upload",
      }
    },
  ],
};
