export const mountSelectRangeValues = () => {
  const ranges: any[] = [];
  for (let i = 0; i < 24; i++) {
    ranges.push({
      key: Math.random()
        .toString(36)
        .substring(7),
      value: i < 10 ? `0${i}:00` : `${i}:00`,
      text: i < 10 ? `0${i}:00` : `${i}:00`
    });
    ranges.push({
      key: Math.random()
        .toString(36)
        .substring(7),
      value: i < 10 ? `0${i}:30` : `${i}:30`,
      text: i < 10 ? `0${i}:30` : `${i}:30`
    });
  }
  return ranges;
};

export const addRanges = () => {
  return {
    row: {
      grouped: true,
      groupName: "range",
      fields: [
        {
          label: "Início",
          name: "start",
          type: "select",
          value: "",
          placeholder: "",
          width: 6,
          data: mountSelectRangeValues(),
          defaultValue: "00:00",
          required: true,
          validationErrors: {
            isDefaultRequiredValue: "O horário inicial é obrigatório"
          }
        },
        {
          label: "Fim",
          name: "end",
          type: "select",
          value: "",
          placeholder: "",
          width: 6,
          data: mountSelectRangeValues(),
          defaultValue: "00:00",
          required: true,
          validationErrors: {
            isDefaultRequiredValue: "O horário final é obrigatório"
          }
        }
      ]
    }
  };
};

export const formTemplate = () => {
  return [
    {
      row: {
        fields: [
          {
            label: "Operação",
            name: "operationType",
            type: "select",
            value: "",
            defaultValue: 1,
            placeholder: "",
            maxLength: 100,
            required: true,
            validationErrors: {
              isDefaultRequiredValue: "A operação é obrigatória"
            },
            width: 6,
            data: [
              {
                key: 1,
                value: 1,
                text: "RODO"
              },
              {
                key: 2,
                value: 2,
                text: "COURIER"
              }
            ]
          },
          {
            label: "Nome",
            name: "description",
            type: "text",
            value: "",
            defaultValue: "Turno 1",
            placeholder: "",
            maxLength: 100,
            required: true,
            validations: { minLength: 3 },
            validationErrors: {
              isDefaultRequiredValue: "O nome é obrigatório",
              minLength: "Deve possuir no minimo 3 caracteres"
            },
            width: 10
          }
        ]
      }
    },
    {
      row: {
        fields: [
          {
            label: "Frequência",
            name: "frequency",
            type: "multiSelectArea",
            value: "",
            defaultValue: "",
            placeholder: "",
            maxLength: 100,
            required: true,
            validationErrors: {
              isDefaultRequiredValue: "A frequência é obrigatória"
            },
            width: 16,
            defaultData: [],
            data: [
              {
                id: 1,
                label: "Segunda"
              },
              {
                id: 2,
                label: "Terça"
              },
              {
                id: 3,
                label: "Quarta"
              },
              {
                id: 4,
                label: "Quinta"
              },
              {
                id: 5,
                label: "Sexta"
              },
              {
                id: 6,
                label: "Sábado"
              },
              {
                id: 7,
                label: "Domingo"
              }
            ],
            multiple: true
          }
        ]
      }
    },
    {
      row: {
        fields: [
          {
            label: "Horário de carregamento",
            as: "h3",
            icon: "time",
            type: "header",
            color: "blue"
          }
        ]
      }
    },
    {
      row: {
        fields: [
          {
            label: "Salvar",
            name: "action",
            type: "submit",
            value: "",
            placeholder: "",
            color: "green",
            icon: "save",
            floated: "right",
            validations: {},
            validationErrors: {},
            width: 16
          }
        ]
      }
    }
  ];
};
