2026-01-07 09:31:02 +00:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
import { Button } from '../../ui/button';
|
|
|
|
|
import { Input } from '../../ui/input';
|
|
|
|
|
import { X, Tag, Check, AlertCircle } from 'lucide-react';
|
|
|
|
|
|
|
|
|
|
interface PromoCodeModalProps {
|
|
|
|
|
onClose: () => void;
|
|
|
|
|
onApply: (discountPercent: number, code: string) => void;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
export const PromoCodeModal: React.FC<PromoCodeModalProps> = ({
|
|
|
|
|
onClose,
|
|
|
|
|
onApply,
|
|
|
|
|
}) => {
|
2026-01-07 09:31:02 +00:00
|
|
|
const [code, setCode] = useState('');
|
|
|
|
|
const [status, setStatus] = useState<'idle' | 'success' | 'error'>('idle');
|
2026-01-13 18:47:57 +00:00
|
|
|
|
2026-01-07 09:31:02 +00:00
|
|
|
const handleApply = () => {
|
2026-01-13 18:47:57 +00:00
|
|
|
// Mock validation
|
|
|
|
|
if (code.toUpperCase() === 'VEZA20') {
|
|
|
|
|
setStatus('success');
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
onApply(20, 'VEZA20');
|
|
|
|
|
onClose();
|
|
|
|
|
}, 1000);
|
|
|
|
|
} else {
|
|
|
|
|
setStatus('error');
|
|
|
|
|
}
|
2026-01-07 09:31:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4">
|
2026-01-13 18:47:57 +00:00
|
|
|
<div
|
|
|
|
|
className="absolute inset-0 bg-kodo-void/90 backdrop-blur-sm"
|
|
|
|
|
onClick={onClose}
|
|
|
|
|
></div>
|
2026-01-07 09:31:02 +00:00
|
|
|
<div className="relative w-full max-w-sm bg-kodo-graphite border border-kodo-steel rounded-xl shadow-2xl animate-scaleIn overflow-hidden">
|
|
|
|
|
<div className="p-4 border-b border-kodo-steel bg-kodo-ink flex justify-between items-center">
|
|
|
|
|
<h3 className="font-bold text-white flex items-center gap-2">
|
|
|
|
|
<Tag className="w-4 h-4 text-kodo-cyan" /> Add Promo Code
|
|
|
|
|
</h3>
|
2026-01-13 18:47:57 +00:00
|
|
|
<button onClick={onClose}>
|
|
|
|
|
<X className="w-5 h-5 text-gray-400 hover:text-white" />
|
|
|
|
|
</button>
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="p-6 space-y-4">
|
2026-01-13 18:47:57 +00:00
|
|
|
<Input
|
|
|
|
|
placeholder="Enter code (e.g. VEZA20)"
|
|
|
|
|
value={code}
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
setCode(e.target.value);
|
|
|
|
|
setStatus('idle');
|
|
|
|
|
}}
|
|
|
|
|
className={
|
|
|
|
|
status === 'error' ? 'border-kodo-red focus:border-kodo-red' : ''
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{status === 'error' && (
|
|
|
|
|
<div className="flex items-center gap-2 text-xs text-kodo-red animate-shake">
|
|
|
|
|
<AlertCircle className="w-3 h-3" /> Invalid promo code
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{status === 'success' && (
|
|
|
|
|
<div className="flex items-center gap-2 text-xs text-kodo-lime animate-fadeIn">
|
|
|
|
|
<Check className="w-3 h-3" /> Code applied! 20% Off
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-01-07 09:31:02 +00:00
|
|
|
|
2026-01-13 18:47:57 +00:00
|
|
|
<Button
|
|
|
|
|
variant="primary"
|
|
|
|
|
className="w-full"
|
|
|
|
|
onClick={handleApply}
|
|
|
|
|
disabled={!code}
|
|
|
|
|
>
|
|
|
|
|
Apply Discount
|
|
|
|
|
</Button>
|
2026-01-07 09:31:02 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|