feat(payment): fix zibal refund api, add maskable fields, receipt modal, standardized buttons and order refund options
Deploy Canina / deploy (push) Successful in 41s

This commit is contained in:
parsa aghaei committed 2026-08-22 17:01:13 +03:30
1 parent f9e40564cf
commit d62787cd99
22 files changed
+10934 -9318

No files matched your search

@@ -0,0 +1,96 @@
import React, { useState } from 'react';
import { Eye, EyeOff, Copy, Check } from 'lucide-react';
import { toast } from 'react-hot-toast';
interface MaskableFieldProps {
value?: string | number | null;
maskedValue?: string;
isMaskedByDefault?: boolean;
label?: string;
copyable?: boolean;
className?: string;
valueClassName?: string;
dir?: 'ltr' | 'rtl';
}
export default function MaskableField({
value,
maskedValue,
isMaskedByDefault = true,
label,
copyable = true,
className = '',
valueClassName = '',
dir = 'ltr',
}: MaskableFieldProps) {
const [isRevealed, setIsRevealed] = useState(!isMaskedByDefault);
const [copied, setCopied] = useState(false);
const rawVal = value !== undefined && value !== null ? String(value) : '';
// Create mask if not provided
const generateMask = (str: string) => {
if (!str) return '-';
if (str.length <= 4) return '****';
if (str.length === 16) {
// 16-digit Card: 6037-99**-****-1234
return `${str.slice(0, 4)}-${str.slice(4, 6)}**-****-${str.slice(12)}`;
}
const visibleStart = Math.min(4, Math.floor(str.length / 3));
const visibleEnd = Math.min(4, Math.floor(str.length / 3));
return `${str.slice(0, visibleStart)}${'*'.repeat(Math.max(4, str.length - visibleStart - visibleEnd))}${str.slice(-visibleEnd)}`;
};
const displayMasked = maskedValue || generateMask(rawVal);
const currentText = isRevealed ? (rawVal || '-') : displayMasked;
const handleCopy = (e: React.MouseEvent) => {
e.stopPropagation();
if (!rawVal) return;
navigator.clipboard.writeText(rawVal);
setCopied(true);
toast.success(`${label || 'مقدار'} در کلیپ‌بورد کپی شد`);
setTimeout(() => setCopied(false), 2000);
};
return (
<div className={`inline-flex items-center gap-1.5 ${className}`}>
<span
dir={dir}
className={`font-mono text-xs select-all ${valueClassName}`}
title={isRevealed ? 'مقدار واقعی' : 'مقدار پنهان‌شده'}
>
{currentText}
</span>
{rawVal && (
<div className="inline-flex items-center gap-1">
{/* Toggle Eye Button */}
<button
type="button"
onClick={(e) => {
e.stopPropagation();
setIsRevealed(!isRevealed);
}}
className="p-1 text-gray-400 hover:text-indigo-600 hover:bg-indigo-50 rounded-md transition-colors cursor-pointer"
title={isRevealed ? 'پنهان‌سازی' : 'نمایش مقدار اصلی'}
>
{isRevealed ? <EyeOff className="w-3.5 h-3.5" /> : <Eye className="w-3.5 h-3.5" />}
</button>
{/* Copy to Clipboard Button */}
{copyable && (
<button
type="button"
onClick={handleCopy}
className="p-1 text-gray-400 hover:text-emerald-600 hover:bg-emerald-50 rounded-md transition-colors cursor-pointer"
title="کپی در کلیپ‌بورد"
>
{copied ? <Check className="w-3.5 h-3.5 text-emerald-600" /> : <Copy className="w-3.5 h-3.5" />}
</button>
)}
</div>
)}
</div>
);
}