/* eslint-disable no-nested-ternary */
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
import { FormInput } from '@blocklet/payment-react';

export default function StripeMethodForm({ checkDisabled }: { checkDisabled: (key: string) => boolean }) {
  const { t } = useLocaleContext();

  return (
    <>
      <FormInput
        name="name"
        type="text"
        rules={{ required: true }}
        label={t('admin.paymentMethod.name.label')}
        placeholder={t('admin.paymentMethod.name.tip')}
        disabled={checkDisabled('name')}
        inputProps={{ maxLength: 32 }}
      />
      <FormInput
        name="description"
        type="text"
        rules={{ required: true }}
        label={t('admin.paymentMethod.description.label')}
        placeholder={t('admin.paymentMethod.description.tip')}
        inputProps={{ maxLength: 255 }}
      />
      <FormInput
        name="settings.stripe.dashboard"
        type="text"
        rules={{ required: true }}
        label={t('admin.paymentMethod.stripe.dashboard.label')}
        placeholder={t('admin.paymentMethod.stripe.dashboard.tip')}
        disabled={checkDisabled('settings.stripe.dashboard')}
      />
      <FormInput
        name="settings.stripe.publishable_key"
        type="text"
        rules={{ required: true }}
        label={t('admin.paymentMethod.stripe.publishable_key.label')}
        placeholder={t('admin.paymentMethod.stripe.publishable_key.tip')}
        disabled={checkDisabled('settings.stripe.publishable_key')}
      />
      <FormInput
        name="settings.stripe.secret_key"
        type="password"
        rules={{ required: true }}
        label={t('admin.paymentMethod.stripe.secret_key.label')}
        placeholder={t('admin.paymentMethod.stripe.secret_key.tip')}
        disabled={checkDisabled('settings.stripe.secret_key')}
      />
    </>
  );
}
