All files / src/features/wallet/components withdraw-method-selector.tsx

100% Statements 4/4
100% Branches 9/9
100% Functions 3/3
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59                              3x         9x               2x                           3x                                
import { cn } from '@/lib/utils';
import { WITHDRAWAL_METHODS, WALLET_DIALOG_LABELS } from '@/constants/wallet';
 
interface WithdrawMethodSelectorProps {
  method: typeof WITHDRAWAL_METHODS.BANK | typeof WITHDRAWAL_METHODS.CRYPTO;
  onChange: (
    method: typeof WITHDRAWAL_METHODS.BANK | typeof WITHDRAWAL_METHODS.CRYPTO
  ) => void;
  disabled?: boolean;
}
 
/**
 * WithdrawMethodSelector - Allows users to choose withdrawal method
 * Supports bank transfer and crypto wallet options
 */
export const WithdrawMethodSelector = ({
  method,
  onChange,
  disabled = false,
}: WithdrawMethodSelectorProps) => {
  return (
    <div className="space-y-2">
      <label className="text-sm font-medium text-gray-700">
        {WALLET_DIALOG_LABELS.WITHDRAWAL_METHOD}
      </label>
      <div className="flex space-x-4">
        <button
          type="button"
          onClick={() => onChange(WITHDRAWAL_METHODS.BANK)}
          disabled={disabled}
          className={cn(
            'flex-1 p-3 border rounded-lg text-sm transition-colors',
            method === WITHDRAWAL_METHODS.BANK
              ? 'border-blue-500 bg-blue-50 text-blue-700'
              : 'border-gray-300 hover:border-gray-400',
            disabled && 'opacity-50 cursor-not-allowed'
          )}
        >
          {WALLET_DIALOG_LABELS.BANK_TRANSFER}
        </button>
        <button
          type="button"
          onClick={() => onChange(WITHDRAWAL_METHODS.CRYPTO)}
          disabled={disabled}
          className={cn(
            'flex-1 p-3 border rounded-lg text-sm transition-colors',
            method === WITHDRAWAL_METHODS.CRYPTO
              ? 'border-blue-500 bg-blue-50 text-blue-700'
              : 'border-gray-300 hover:border-gray-400',
            disabled && 'opacity-50 cursor-not-allowed'
          )}
        >
          {WALLET_DIALOG_LABELS.CRYPTO_WALLET}
        </button>
      </div>
    </div>
  );
};