import { $t } from '#/locales';

import { rerenderSaveNode } from './datasetNodeRenderer';

export const SaveDatasetNode = async () => {
  return {
    title: $t('aiWorkflow.saveDataset'),
    group: 'base',
    description: $t('aiWorkflow.descriptions.saveDataset'),
    icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M5 3H19C20.1046 3 21 3.89543 21 5V19C21 20.1046 20.1046 21 19 21H5C3.89543 21 3 20.1046 3 19V5C3 3.89543 3.89543 3 5 3ZM7 5V9H17V5H7ZM7 13V19H17V13H7Z"></path></svg>',
    sortNo: 812,
    parametersAddEnable: false,
    outputDefsAddEnable: false,
    parameters: [
      {
        name: 'saveList',
        title: $t('aiWorkflow.dataToBeSaved'),
        dataType: 'Array',
        dataTypeDisabled: true,
        required: true,
        parametersAddEnable: false,
        description: $t('aiWorkflow.descriptions.dataToBeSaved'),
        deleteDisabled: true,
        nameDisabled: true,
      },
    ],
    outputDefs: [
      {
        name: 'successRows',
        title: $t('aiWorkflow.successInsertedRecords'),
        dataType: 'Number',
        dataTypeDisabled: true,
        required: true,
        parametersAddEnable: false,
        description: $t('aiWorkflow.successInsertedRecords'),
        deleteDisabled: true,
        nameDisabled: true,
      },
    ],
    render: rerenderSaveNode,
    onUpdate: rerenderSaveNode,
  };
};
