export const generalSettingForm = {
  column: 2,
  format: [
    {
      key: 'page_title',
      name: 'Page title',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Page title',
        }
      },
    },
    {
      key: 'email',
      name: 'E-mail',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'E-mail',
        }
      },
    },
    {
      key: 'phone',
      name: 'Phone number',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Phone number',
        }
      },
    },
    {
      key: 'meta_title',
      name: 'Meta title',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Meta title',
        }
      },
    },
    {
      key: 'address',
      name: 'Address',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Address',
        }
      },
    },
    {
      key: 'license',
      name: 'License',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'License',
        }
      },
    },
    {
      key: 'meta_description',
      name: 'Meta Description',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Meta Description',
        }
      },
    },
    {
      key: 'facebook',
      name: 'Facebook',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Facebook',
        }
      },
    },
    {
      key: 'twitter',
      name: 'Twitter',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Twitter',
        }
      },
    },
    {
      key: 'linkedin',
      name: 'Linkedin',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          placeholder: 'Linkedin',
        }
      },
    },
  ],
}

export const packageForm = {
  column: 1,
  format: [
    {
      key: 'title',
      name: 'Title',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          maxLength: 127,
          placeholder: 'New package',
          required: true,
        }
      },
    },
    {
      key: 'description',
      name: 'Description',
      type: 'TextInput',
      optional: () => {
        return {
          mt: 'md',
          maxLength: 127,
          placeholder: 'New package',
        }
      },
    },
    {
      key: 'point',
      name: 'Point',
      type: 'NumberInput',
      optional: () => {
        return {
          mt: 'md',
          decimalScale: 0,
          min: 1,
          maxLength: 10,
          required: true,
          placeholder: '1000',
        }
      },
      customOnChange: (e: any, form: any, item: any) => {
        form.setFieldValue(
          item.key,
          parseInt(e.toString()) > 1000000000 ? 1000000000 : e,
        )
      },
    },
    {
      key: 'price',
      name: 'Price',
      type: 'NumberInput',
      optional: () => {
        return {
          mt: 'md',
          decimalScale: 2,
          min: 1,
          prefix: '$',
          maxLength: 9,
          required: true,
          placeholder: '1000',
        }
      },
      customOnChange: (e: any, form: any, item: any) => {
        form.setFieldValue(
          item.key,
          parseFloat(e.toString()) > 1000000 ? '1000000.00' : e,
        )
      },
    },
    {
      key: 'status',
      name: 'Status',
      type: 'Checkbox',
      optional: () => {
        return {
          mt: 'lg',
          id: 'status_checkbox',
        }
      },
    },
  ],
}

export const discountForm = {
  column: 1,
  format: [
    {
      key: 'discount_type',
      name: 'Type',
      type: 'Select',
      optional: () => {
        return {
          defaultValue: '1',
          required: true,
        }
      },
      data: [
        { value: '1', label: 'Price' },
        { value: '2', label: 'Percent' },
      ],
    },
    {
      key: 'value',
      name: 'Value',
      type: 'NumberInput',
      optional: (form: any) => {
        return {
          decimalScale: form.values.discount_type === '1' ? 2 : 0,
          suffix: form.values.discount_type === '2' ? '%' : '',
          prefix: form.values.discount_type === '1' ? '$' : '',
          min: 1,
          maxLength: form.values.discount_type === '1' ? 9 : 3,
          mt: 'md',
          required: true,
        }
      },
      customOnChange: (e: any, form: any, item: any) => {
        if (form.values.discount_type === '1') {
          form.setFieldValue(
            item.key,
            parseFloat(e) > 1000000 ? '1000000.00' : e,
          )
        } else {
          form.setFieldValue(item.key, parseInt(e) > 100 ? 99 : e)
        }
      },
    },
    {
      key: 'active_date',
      name: 'Active date',
      type: 'DateTimePicker',
      optional: () => {
        return {
          mt: 'md',
          required: true,
        }
      },
    },
    {
      key: 'expiry',
      name: 'Expiry date',
      type: 'DateTimePicker',
      optional: () => {
        return {
          mt: 'md',
        }
      },
    },
    {
      key: 'status',
      name: 'Status',
      type: 'Checkbox',
      optional: () => {
        return {
          mt: 'md',
        }
      },
    },
  ],
}

export const orderForm = {
  column: 1,
  format: [
    {
      key: 'payment_id',
      name: 'Payment ID',
      type: 'TextInput',
      optional: () => {
        return {
          disabled: true,
          mb: 'md',
        }
      },
    },
    {
        key: 'discount',
        name: 'Discount code',
        type: 'TextInput',
        optional: () => {
          return {
            disabled: true,
            mb: 'md',
          }
        },
      },
      {
        key: 'total_price',
        name: 'Price',
        type: 'TextInput',
        optional: () => {
          return {
            disabled: true,
            mb: 'md',
          }
        },
      },
      {
        key: 'point',
        name: 'Point',
        type: 'TextInput',
        optional: () => {
          return {
            disabled: true,
            mb: 'md',
          }
        },
      },
      {
        key: 'created_at',
        name: 'Created at',
        type: 'TextInput',
        optional: () => {
          return {
            disabled: true,
            mb: 'md',
          }
        },
      },
  ],
}
