import { genDigitComAttr } from '@/utils';
import { $t } from '@/utils/i18n';
import useRuleMeta from '../hooks/useRuleMeta';
import type { returnType, SchemaProps } from '../type';

export const NOPLimitSchema = ({ richFormat }: SchemaProps): returnType => {
  const { symbolsShowFunc } = useRuleMeta();

  return {
    popFormTips: {
      title: `📋 ${$t('form.rules.header')}`,
      dependencies: ['param1', 'param2'],
      content: ({ param1, param2 }) => {
        return richFormat('form.rules.header.content7', {
          nopLimit: param1 || 0,
          symbols: symbolsShowFunc(param2),
        });
      },
    },
    leftForm: [
      {
        title: $t('pages.rules.ruleName'),
        dataIndex: 'name',
        width: '100%',
        formItemProps: {
          rules: [{ required: true, message: $t('form.required') }],
        },
      },
      {
        title: $t('pages.rule7.item2'),
        dataIndex: 'param1',
        valueType: 'digit',
        width: '100%',
        formItemProps: {
          rules: [{ required: true, message: $t('form.required') }],
        },
        fieldProps: {
          ...genDigitComAttr(0),
        },
      },
      {
        title: '',
        dataIndex: 'id',
        formItemProps: {
          hidden: true,
        },
      },
    ],
    transformInitialValue(values) {
      if (values.id) return values;
      return {
        ...values,
        param1: 5000,
      };
    },
    tipsComponent: $t('form.rule7.tips'),
    symbolFormShow: true,
  };
};
