import React, { useState } from 'react'; import { X, Wallet, Calendar, Ban, Clock } from 'lucide-react'; export type PaymentStatusAction = 'paid' | 'postponed' | 'cancelled'; export interface PaymentStatusModalPayload { paymentDate?: string; paymentRef?: string; isCash?: boolean; postponedDate?: string; cancelReason?: string; } interface PaymentStatusModalProps { action: PaymentStatusAction; invoiceLabel?: string; /** По умолчанию отметить «Оплата наличными» */ defaultIsCash?: boolean; onConfirm: (payload: PaymentStatusModalPayload) => void; onCancel: () => void; } export const PaymentStatusModal: React.FC = ({ action, invoiceLabel, defaultIsCash = false, onConfirm, onCancel }) => { const today = new Date().toISOString().split('T')[0]; const [paymentDate, setPaymentDate] = useState(today); const [paymentRef, setPaymentRef] = useState(''); const [isCash, setIsCash] = useState(defaultIsCash); const [postponedDate, setPostponedDate] = useState(''); const [cancelReason, setCancelReason] = useState(''); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (action === 'paid') { onConfirm({ paymentDate, paymentRef: paymentRef.trim() || undefined, isCash }); } else if (action === 'postponed') { if (!postponedDate) { alert('Укажите дату переноса'); return; } onConfirm({ postponedDate }); } else { if (!cancelReason.trim()) { alert('Укажите причину отмены'); return; } onConfirm({ cancelReason: cancelReason.trim() }); } }; const title = action === 'paid' ? 'Оплата счета' : action === 'postponed' ? 'Перенос на другую дату' : 'Отмена / отказ'; return (

{title}

{invoiceLabel && (

{invoiceLabel}

)} {action === 'paid' && ( <>
setPaymentDate(e.target.value)} className="w-full pl-10 pr-3 py-2 border border-slate-200 rounded-xl text-sm" />
setPaymentRef(e.target.value)} className="w-full px-3 py-2 border border-slate-200 rounded-xl text-sm" placeholder="Номер платёжного поручения" />
)} {action === 'postponed' && (
setPostponedDate(e.target.value)} className="w-full pl-10 pr-3 py-2 border border-slate-200 rounded-xl text-sm" />
)} {action === 'cancelled' && (