Spaces:
Running
Running
axeronis commited on
Commit ·
8ad0c07
1
Parent(s): 5bb4c25
feat: implement premium glass ConfirmModal and upgrade all platform dialogs
Browse files
frontend/components/ChatWindow.tsx
CHANGED
|
@@ -16,6 +16,7 @@ import { ChatHeader } from './ChatWindow/ChatHeader'
|
|
| 16 |
import { MessageBubble } from './ChatWindow/MessageBubble'
|
| 17 |
import { MessageInput } from './ChatWindow/MessageInput'
|
| 18 |
import { TypingIndicator } from './ChatWindow/TypingIndicator'
|
|
|
|
| 19 |
|
| 20 |
// ============================================================================
|
| 21 |
// Types
|
|
@@ -89,6 +90,7 @@ export function ChatWindow({
|
|
| 89 |
const [isTogglingAI, setIsTogglingAI] = useState(false)
|
| 90 |
const [isBookingModalOpen, setIsBookingModalOpen] = useState(false)
|
| 91 |
const [isTraining, setIsTraining] = useState(false)
|
|
|
|
| 92 |
const toast = useToast()
|
| 93 |
|
| 94 |
const messagesEndRef = useRef<HTMLDivElement>(null)
|
|
@@ -292,7 +294,10 @@ export function ChatWindow({
|
|
| 292 |
return
|
| 293 |
}
|
| 294 |
|
| 295 |
-
|
|
|
|
|
|
|
|
|
|
| 296 |
|
| 297 |
setIsTraining(true)
|
| 298 |
try {
|
|
@@ -325,6 +330,7 @@ export function ChatWindow({
|
|
| 325 |
toast.error(error.message || 'Ошибка сохранения')
|
| 326 |
} finally {
|
| 327 |
setIsTraining(false)
|
|
|
|
| 328 |
}
|
| 329 |
}
|
| 330 |
|
|
@@ -485,6 +491,17 @@ export function ChatWindow({
|
|
| 485 |
/>
|
| 486 |
)}
|
| 487 |
</AnimatePresence>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
</div>
|
| 489 |
)
|
| 490 |
}
|
|
|
|
| 16 |
import { MessageBubble } from './ChatWindow/MessageBubble'
|
| 17 |
import { MessageInput } from './ChatWindow/MessageInput'
|
| 18 |
import { TypingIndicator } from './ChatWindow/TypingIndicator'
|
| 19 |
+
import { ConfirmModal } from '@/components/ui/ConfirmModal'
|
| 20 |
|
| 21 |
// ============================================================================
|
| 22 |
// Types
|
|
|
|
| 90 |
const [isTogglingAI, setIsTogglingAI] = useState(false)
|
| 91 |
const [isBookingModalOpen, setIsBookingModalOpen] = useState(false)
|
| 92 |
const [isTraining, setIsTraining] = useState(false)
|
| 93 |
+
const [isTrainConfirmOpen, setIsTrainConfirmOpen] = useState(false)
|
| 94 |
const toast = useToast()
|
| 95 |
|
| 96 |
const messagesEndRef = useRef<HTMLDivElement>(null)
|
|
|
|
| 294 |
return
|
| 295 |
}
|
| 296 |
|
| 297 |
+
setIsTrainConfirmOpen(true)
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
const handleConfirmTrain = async () => {
|
| 301 |
|
| 302 |
setIsTraining(true)
|
| 303 |
try {
|
|
|
|
| 330 |
toast.error(error.message || 'Ошибка сохранения')
|
| 331 |
} finally {
|
| 332 |
setIsTraining(false)
|
| 333 |
+
setIsTrainConfirmOpen(false)
|
| 334 |
}
|
| 335 |
}
|
| 336 |
|
|
|
|
| 491 |
/>
|
| 492 |
)}
|
| 493 |
</AnimatePresence>
|
| 494 |
+
|
| 495 |
+
{/* Train AI Confirmation Modal */}
|
| 496 |
+
<ConfirmModal
|
| 497 |
+
isOpen={isTrainConfirmOpen}
|
| 498 |
+
onClose={() => setIsTrainConfirmOpen(false)}
|
| 499 |
+
onConfirm={handleConfirmTrain}
|
| 500 |
+
title="Обучение AI"
|
| 501 |
+
message="Сохранить этот диалог как пример для обучения AI? Это поможет AI лучше понимать ваших клиентов."
|
| 502 |
+
confirmText="Обучить AI"
|
| 503 |
+
isLoading={isTraining}
|
| 504 |
+
/>
|
| 505 |
</div>
|
| 506 |
)
|
| 507 |
}
|
frontend/components/DemoChat.tsx
CHANGED
|
@@ -325,8 +325,13 @@ export function DemoChat({ isOpen, onClose }: DemoChatProps) {
|
|
| 325 |
animate={{ x: 0 }}
|
| 326 |
exit={{ x: '100%' }}
|
| 327 |
transition={{ type: 'spring', damping: 25, stiffness: 300 }}
|
| 328 |
-
className="fixed right-0 top-0 h-screen w-full max-w-md bg-[#
|
| 329 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
{/* Header */}
|
| 331 |
<div className="flex items-center justify-between p-4 border-b border-white/10">
|
| 332 |
<div className="flex items-center gap-3">
|
|
|
|
| 325 |
animate={{ x: 0 }}
|
| 326 |
exit={{ x: '100%' }}
|
| 327 |
transition={{ type: 'spring', damping: 25, stiffness: 300 }}
|
| 328 |
+
className="fixed right-0 top-0 h-screen w-full max-w-md bg-[#0D0E18]/80 backdrop-blur-3xl border-l border-white/10 z-50 flex flex-col shadow-[-20px_0_50px_rgba(0,0,0,0.5)]"
|
| 329 |
>
|
| 330 |
+
{/* Aurora Background Atmosphere */}
|
| 331 |
+
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 opacity-40">
|
| 332 |
+
<div className="absolute top-[-10%] right-[-10%] w-[80%] h-[40%] bg-indigo-500/10 blur-[100px] rounded-full rotate-12" />
|
| 333 |
+
<div className="absolute bottom-[10%] left-[-10%] w-[80%] h-[40%] bg-purple-500/10 blur-[100px] rounded-full -rotate-12" />
|
| 334 |
+
</div>
|
| 335 |
{/* Header */}
|
| 336 |
<div className="flex items-center justify-between p-4 border-b border-white/10">
|
| 337 |
<div className="flex items-center gap-3">
|
frontend/components/LeadsList.tsx
CHANGED
|
@@ -4,7 +4,8 @@ import { useState, useEffect } from 'react'
|
|
| 4 |
import { createPortal } from 'react-dom'
|
| 5 |
import { Lead } from '@/lib/api'
|
| 6 |
import { cn } from '@/lib/utils'
|
| 7 |
-
import { Search, Flame, Inbox, CheckCircle2, MessageCircle, Mail, Linkedin, Trash2, X, Brain, RotateCcw } from 'lucide-react'
|
|
|
|
| 8 |
import { useTranslation } from '@/lib/i18n'
|
| 9 |
|
| 10 |
interface LeadsListProps {
|
|
@@ -105,68 +106,97 @@ export function LeadsList({
|
|
| 105 |
|
| 106 |
return (
|
| 107 |
<>
|
| 108 |
-
{/* Delete/Reset Confirmation Modal
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
<div className="
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
>
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
</div>
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
<div className="p-2 bg-indigo-500/20 rounded-lg">
|
| 133 |
-
<RotateCcw className="w-5 h-5 text-indigo-400" />
|
| 134 |
-
</div>
|
| 135 |
-
<div>
|
| 136 |
-
<div className="text-sm font-bold text-white mb-1">{t('chats.resetChat')}</div>
|
| 137 |
-
<p className="text-xs text-slate-400">
|
| 138 |
-
{t('chats.resetChatDesc')}
|
| 139 |
-
</p>
|
| 140 |
</div>
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
className="w-full flex items-start gap-3 p-4 bg-red-500/10 rounded-xl border border-red-500/20 hover:border-red-500/40 transition-colors text-left"
|
| 148 |
-
>
|
| 149 |
-
<div className="p-2 bg-red-500/20 rounded-lg">
|
| 150 |
-
<Trash2 className="w-5 h-5 text-red-400" />
|
| 151 |
</div>
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
<
|
| 155 |
-
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
</div>
|
| 158 |
-
</button>
|
| 159 |
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
|
|
|
| 166 |
</div>
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
)}
|
| 170 |
|
| 171 |
<div className="flex flex-col h-full bg-[#0D0E18] border-r border-white/10">
|
| 172 |
{/* Header & Search - Fixed at top via flex parent */}
|
|
|
|
| 4 |
import { createPortal } from 'react-dom'
|
| 5 |
import { Lead } from '@/lib/api'
|
| 6 |
import { cn } from '@/lib/utils'
|
| 7 |
+
import { Search, Flame, Inbox, CheckCircle2, MessageCircle, Mail, Linkedin, Trash2, X, Brain, RotateCcw, AlertCircle } from 'lucide-react'
|
| 8 |
+
import { motion, AnimatePresence } from 'framer-motion'
|
| 9 |
import { useTranslation } from '@/lib/i18n'
|
| 10 |
|
| 11 |
interface LeadsListProps {
|
|
|
|
| 106 |
|
| 107 |
return (
|
| 108 |
<>
|
| 109 |
+
{/* Delete/Reset Confirmation Modal */}
|
| 110 |
+
<AnimatePresence>
|
| 111 |
+
{mounted && deleteModal && (
|
| 112 |
+
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4">
|
| 113 |
+
{/* Backdrop */}
|
| 114 |
+
<motion.div
|
| 115 |
+
initial={{ opacity: 0 }}
|
| 116 |
+
animate={{ opacity: 1 }}
|
| 117 |
+
exit={{ opacity: 0 }}
|
| 118 |
+
onClick={() => { setDeleteModal(null); setClearCacheOnDelete(false) }}
|
| 119 |
+
className="absolute inset-0 bg-black/80 backdrop-blur-md"
|
| 120 |
+
/>
|
|
|
|
| 121 |
|
| 122 |
+
{/* Modal Card */}
|
| 123 |
+
<motion.div
|
| 124 |
+
initial={{ opacity: 0, scale: 0.9, y: 20 }}
|
| 125 |
+
animate={{ opacity: 1, scale: 1, y: 0 }}
|
| 126 |
+
exit={{ opacity: 0, scale: 0.9, y: 20 }}
|
| 127 |
+
className="relative bg-[#0D0E18]/90 backdrop-blur-3xl border border-white/10 rounded-[32px] p-8 max-w-sm w-full shadow-[0_0_50px_rgba(0,0,0,0.5)] overflow-hidden"
|
| 128 |
+
>
|
| 129 |
+
{/* Aurora Atmosphere */}
|
| 130 |
+
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 opacity-30">
|
| 131 |
+
<div className="absolute -top-24 -right-24 w-48 h-48 bg-red-500/20 blur-[60px] rounded-full" />
|
| 132 |
+
<div className="absolute -bottom-24 -left-24 w-48 h-48 bg-indigo-500/20 blur-[60px] rounded-full" />
|
| 133 |
+
</div>
|
| 134 |
|
| 135 |
+
<div className="flex items-center justify-between mb-6">
|
| 136 |
+
<div className="flex items-center gap-3">
|
| 137 |
+
<div className="w-10 h-10 rounded-xl bg-red-500/10 border border-red-500/20 flex items-center justify-center">
|
| 138 |
+
<AlertCircle className="w-6 h-6 text-red-400" />
|
| 139 |
+
</div>
|
| 140 |
+
<h3 className="text-xl font-bold text-white">Управление чатом</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
</div>
|
| 142 |
+
<button
|
| 143 |
+
onClick={() => { setDeleteModal(null); setClearCacheOnDelete(false) }}
|
| 144 |
+
className="p-2 hover:bg-white/10 rounded-full text-slate-400 hover:text-white transition-all"
|
| 145 |
+
>
|
| 146 |
+
<X className="w-5 h-5" />
|
| 147 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
</div>
|
| 149 |
+
|
| 150 |
+
<p className="text-slate-400 text-sm mb-8">
|
| 151 |
+
{t('chats.selectActionFor')} <span className="font-semibold text-white">"{deleteModal.leadName}"</span>
|
| 152 |
+
</p>
|
| 153 |
+
|
| 154 |
+
<div className="space-y-4">
|
| 155 |
+
{/* Reset Option */}
|
| 156 |
+
{onResetLead && (
|
| 157 |
+
<button
|
| 158 |
+
onClick={handleResetLead}
|
| 159 |
+
className="w-full flex items-center gap-4 p-4 bg-white/5 rounded-2xl border border-white/5 hover:border-indigo-500/30 hover:bg-indigo-500/5 transition-all text-left group"
|
| 160 |
+
>
|
| 161 |
+
<div className="w-12 h-12 flex-shrink-0 bg-indigo-500/10 rounded-xl flex items-center justify-center group-hover:scale-110 transition-transform">
|
| 162 |
+
<RotateCcw className="w-6 h-6 text-indigo-400" />
|
| 163 |
+
</div>
|
| 164 |
+
<div>
|
| 165 |
+
<div className="text-sm font-bold text-white mb-0.5">{t('chats.resetChat')}</div>
|
| 166 |
+
<p className="text-[11px] text-slate-500 line-clamp-1">
|
| 167 |
+
{t('chats.resetChatDesc')}
|
| 168 |
+
</p>
|
| 169 |
+
</div>
|
| 170 |
+
</button>
|
| 171 |
+
)}
|
| 172 |
+
|
| 173 |
+
{/* Delete Option */}
|
| 174 |
+
<button
|
| 175 |
+
onClick={handleConfirmDelete}
|
| 176 |
+
className="w-full flex items-center gap-4 p-4 bg-white/5 rounded-2xl border border-white/5 hover:border-red-500/30 hover:bg-red-500/5 transition-all text-left group"
|
| 177 |
+
>
|
| 178 |
+
<div className="w-12 h-12 flex-shrink-0 bg-red-500/10 rounded-xl flex items-center justify-center group-hover:scale-110 transition-transform">
|
| 179 |
+
<Trash2 className="w-6 h-6 text-red-400" />
|
| 180 |
+
</div>
|
| 181 |
+
<div>
|
| 182 |
+
<div className="text-sm font-bold text-white mb-0.5">{t('chats.deleteCompletely')}</div>
|
| 183 |
+
<p className="text-[11px] text-slate-500 line-clamp-1">
|
| 184 |
+
{t('chats.deleteChatDesc')}
|
| 185 |
+
</p>
|
| 186 |
+
</div>
|
| 187 |
+
</button>
|
| 188 |
</div>
|
|
|
|
| 189 |
|
| 190 |
+
<button
|
| 191 |
+
onClick={() => { setDeleteModal(null); setClearCacheOnDelete(false) }}
|
| 192 |
+
className="w-full mt-6 py-4 text-sm font-bold text-slate-500 hover:text-white transition-colors"
|
| 193 |
+
>
|
| 194 |
+
{t('common.cancel')}
|
| 195 |
+
</button>
|
| 196 |
+
</motion.div>
|
| 197 |
</div>
|
| 198 |
+
)}
|
| 199 |
+
</AnimatePresence>
|
|
|
|
| 200 |
|
| 201 |
<div className="flex flex-col h-full bg-[#0D0E18] border-r border-white/10">
|
| 202 |
{/* Header & Search - Fixed at top via flex parent */}
|
frontend/components/bookings/BookingModal.tsx
CHANGED
|
@@ -98,18 +98,26 @@ export function BookingModal({ isOpen, onClose, leadId, leadName }: BookingModal
|
|
| 98 |
return (
|
| 99 |
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm">
|
| 100 |
<motion.div
|
| 101 |
-
initial={{ opacity: 0, scale: 0.95 }}
|
| 102 |
-
animate={{ opacity: 1, scale: 1 }}
|
| 103 |
-
exit={{ opacity: 0, scale: 0.95 }}
|
| 104 |
-
className="bg-[#
|
| 105 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
{/* Header */}
|
| 107 |
-
<div className="px-
|
| 108 |
-
<
|
| 109 |
-
<
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
| 113 |
<X className="w-5 h-5" />
|
| 114 |
</button>
|
| 115 |
</div>
|
|
@@ -176,22 +184,22 @@ export function BookingModal({ isOpen, onClose, leadId, leadName }: BookingModal
|
|
| 176 |
|
| 177 |
{/* Notes */}
|
| 178 |
<div>
|
| 179 |
-
<label className="block text-xs font-bold text-slate-
|
| 180 |
<textarea
|
| 181 |
value={bookingNote}
|
| 182 |
onChange={(e) => setBookingNote(e.target.value)}
|
| 183 |
placeholder="О чем пойдет речь?"
|
| 184 |
-
className="w-full p-
|
| 185 |
/>
|
| 186 |
</div>
|
| 187 |
</div>
|
| 188 |
|
| 189 |
{/* Footer */}
|
| 190 |
-
<div className="p-
|
| 191 |
<button
|
| 192 |
onClick={handleBook}
|
| 193 |
disabled={!selectedDate || !selectedTime || isSubmitting}
|
| 194 |
-
className="w-full py-
|
| 195 |
>
|
| 196 |
{isSubmitting ? (
|
| 197 |
<Loader2 className="w-5 h-5 animate-spin" />
|
|
|
|
| 98 |
return (
|
| 99 |
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm">
|
| 100 |
<motion.div
|
| 101 |
+
initial={{ opacity: 0, scale: 0.95, y: 20 }}
|
| 102 |
+
animate={{ opacity: 1, scale: 1, y: 0 }}
|
| 103 |
+
exit={{ opacity: 0, scale: 0.95, y: 20 }}
|
| 104 |
+
className="relative bg-[#0D0E18]/90 backdrop-blur-3xl border border-white/10 rounded-[32px] w-full max-w-md overflow-hidden shadow-[0_0_50px_rgba(0,0,0,0.5)] flex flex-col max-h-[90vh]"
|
| 105 |
>
|
| 106 |
+
{/* Aurora Background Atmosphere */}
|
| 107 |
+
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 opacity-30">
|
| 108 |
+
<div className="absolute top-[-10%] right-[-10%] w-[60%] h-[60%] bg-indigo-500/20 blur-[80px] rounded-full" />
|
| 109 |
+
<div className="absolute bottom-[-10%] left-[-10%] w-[60%] h-[60%] bg-purple-500/20 blur-[80px] rounded-full" />
|
| 110 |
+
</div>
|
| 111 |
{/* Header */}
|
| 112 |
+
<div className="px-8 py-6 border-b border-white/5 flex items-center justify-between">
|
| 113 |
+
<div>
|
| 114 |
+
<h3 className="font-bold text-xl text-white flex items-center gap-2">
|
| 115 |
+
<CalendarIcon className="w-5 h-5 text-indigo-400" />
|
| 116 |
+
Записать клиента
|
| 117 |
+
</h3>
|
| 118 |
+
<p className="text-xs text-slate-400 mt-1">Выберите время для встречи</p>
|
| 119 |
+
</div>
|
| 120 |
+
<button onClick={onClose} className="p-2 hover:bg-white/10 rounded-full transition-all text-slate-400 hover:text-white border border-transparent hover:border-white/10">
|
| 121 |
<X className="w-5 h-5" />
|
| 122 |
</button>
|
| 123 |
</div>
|
|
|
|
| 184 |
|
| 185 |
{/* Notes */}
|
| 186 |
<div>
|
| 187 |
+
<label className="block text-xs font-bold text-slate-500 uppercase tracking-widest mb-2 ml-1">Комментарий</label>
|
| 188 |
<textarea
|
| 189 |
value={bookingNote}
|
| 190 |
onChange={(e) => setBookingNote(e.target.value)}
|
| 191 |
placeholder="О чем пойдет речь?"
|
| 192 |
+
className="w-full p-4 bg-white/5 border border-white/10 rounded-2xl text-sm focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 outline-none resize-none h-24 text-slate-200 placeholder:text-slate-600 transition-all"
|
| 193 |
/>
|
| 194 |
</div>
|
| 195 |
</div>
|
| 196 |
|
| 197 |
{/* Footer */}
|
| 198 |
+
<div className="p-8 border-t border-white/5 bg-white/[0.02]">
|
| 199 |
<button
|
| 200 |
onClick={handleBook}
|
| 201 |
disabled={!selectedDate || !selectedTime || isSubmitting}
|
| 202 |
+
className="w-full py-4 bg-indigo-600 hover:bg-indigo-500 text-white font-bold rounded-2xl shadow-lg shadow-indigo-900/40 transition-all flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed hover:scale-[1.02] active:scale-[0.98]"
|
| 203 |
>
|
| 204 |
{isSubmitting ? (
|
| 205 |
<Loader2 className="w-5 h-5 animate-spin" />
|
frontend/components/ui/ConfirmModal.tsx
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use client'
|
| 2 |
+
|
| 3 |
+
import { motion, AnimatePresence } from 'framer-motion'
|
| 4 |
+
import { AlertCircle, X, Check, Loader2 } from 'lucide-react'
|
| 5 |
+
import { cn } from '@/lib/utils'
|
| 6 |
+
|
| 7 |
+
interface ConfirmModalProps {
|
| 8 |
+
isOpen: boolean
|
| 9 |
+
onClose: () => void
|
| 10 |
+
onConfirm: () => void
|
| 11 |
+
title?: string
|
| 12 |
+
message: string
|
| 13 |
+
confirmText?: string
|
| 14 |
+
cancelText?: string
|
| 15 |
+
isLoading?: boolean
|
| 16 |
+
variant?: 'danger' | 'primary' | 'success'
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export function ConfirmModal({
|
| 20 |
+
isOpen,
|
| 21 |
+
onClose,
|
| 22 |
+
onConfirm,
|
| 23 |
+
title = 'Подтвердите действие',
|
| 24 |
+
message,
|
| 25 |
+
confirmText = 'Подтвердить',
|
| 26 |
+
cancelText = 'Отмена',
|
| 27 |
+
isLoading = false,
|
| 28 |
+
variant = 'primary'
|
| 29 |
+
}: ConfirmModalProps) {
|
| 30 |
+
return (
|
| 31 |
+
<AnimatePresence>
|
| 32 |
+
{isOpen && (
|
| 33 |
+
<div className="fixed inset-0 z-[999] flex items-center justify-center p-4">
|
| 34 |
+
{/* Backdrop */}
|
| 35 |
+
<motion.div
|
| 36 |
+
initial={{ opacity: 0 }}
|
| 37 |
+
animate={{ opacity: 1 }}
|
| 38 |
+
exit={{ opacity: 0 }}
|
| 39 |
+
onClick={!isLoading ? onClose : undefined}
|
| 40 |
+
className="absolute inset-0 bg-black/80 backdrop-blur-md"
|
| 41 |
+
/>
|
| 42 |
+
|
| 43 |
+
{/* Modal Card */}
|
| 44 |
+
<motion.div
|
| 45 |
+
initial={{ opacity: 0, scale: 0.9, y: 20 }}
|
| 46 |
+
animate={{ opacity: 1, scale: 1, y: 0 }}
|
| 47 |
+
exit={{ opacity: 0, scale: 0.9, y: 20 }}
|
| 48 |
+
transition={{ type: 'spring', damping: 25, stiffness: 300 }}
|
| 49 |
+
className="relative w-full max-w-sm bg-[#0D0E18]/90 backdrop-blur-2xl border border-white/10 rounded-[32px] overflow-hidden shadow-[0_0_50px_rgba(0,0,0,0.5)]"
|
| 50 |
+
>
|
| 51 |
+
{/* Aurora blobs inside modal */}
|
| 52 |
+
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 opacity-30">
|
| 53 |
+
<div className="absolute -top-24 -right-24 w-48 h-48 bg-indigo-500/20 blur-[60px] rounded-full" />
|
| 54 |
+
<div className="absolute -bottom-24 -left-24 w-48 h-48 bg-purple-500/20 blur-[60px] rounded-full" />
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
{/* Content */}
|
| 58 |
+
<div className="p-8">
|
| 59 |
+
<div className="flex justify-center mb-6">
|
| 60 |
+
<div className={cn(
|
| 61 |
+
"w-16 h-16 rounded-2xl flex items-center justify-center border",
|
| 62 |
+
variant === 'primary' ? "bg-indigo-500/10 border-indigo-500/30 text-indigo-400" :
|
| 63 |
+
variant === 'danger' ? "bg-red-500/10 border-red-500/30 text-red-400" :
|
| 64 |
+
"bg-emerald-500/10 border-emerald-500/30 text-emerald-400"
|
| 65 |
+
)}>
|
| 66 |
+
<AlertCircle className="w-8 h-8" />
|
| 67 |
+
</div>
|
| 68 |
+
</div>
|
| 69 |
+
|
| 70 |
+
<h3 className="text-xl font-bold text-white text-center mb-3">
|
| 71 |
+
{title}
|
| 72 |
+
</h3>
|
| 73 |
+
<p className="text-slate-400 text-center text-sm leading-relaxed">
|
| 74 |
+
{message}
|
| 75 |
+
</p>
|
| 76 |
+
</div>
|
| 77 |
+
|
| 78 |
+
{/* Actions */}
|
| 79 |
+
<div className="px-8 pb-8 flex flex-col gap-3">
|
| 80 |
+
<button
|
| 81 |
+
onClick={onConfirm}
|
| 82 |
+
disabled={isLoading}
|
| 83 |
+
className={cn(
|
| 84 |
+
"w-full py-4 rounded-2xl font-bold transition-all flex items-center justify-center gap-2 shadow-lg",
|
| 85 |
+
variant === 'primary' ? "bg-indigo-600 hover:bg-indigo-500 text-white shadow-indigo-900/20" :
|
| 86 |
+
variant === 'danger' ? "bg-red-600 hover:bg-red-500 text-white shadow-red-900/20" :
|
| 87 |
+
"bg-emerald-600 hover:bg-emerald-500 text-white shadow-emerald-900/20"
|
| 88 |
+
)}
|
| 89 |
+
>
|
| 90 |
+
{isLoading ? (
|
| 91 |
+
<Loader2 className="w-5 h-5 animate-spin" />
|
| 92 |
+
) : (
|
| 93 |
+
<Check className="w-5 h-5" />
|
| 94 |
+
)}
|
| 95 |
+
{confirmText}
|
| 96 |
+
</button>
|
| 97 |
+
<button
|
| 98 |
+
onClick={onClose}
|
| 99 |
+
disabled={isLoading}
|
| 100 |
+
className="w-full py-4 rounded-2xl font-bold text-slate-400 hover:text-white hover:bg-white/5 border border-transparent hover:border-white/10 transition-all text-sm"
|
| 101 |
+
>
|
| 102 |
+
{cancelText}
|
| 103 |
+
</button>
|
| 104 |
+
</div>
|
| 105 |
+
</motion.div>
|
| 106 |
+
</div>
|
| 107 |
+
)}
|
| 108 |
+
</AnimatePresence>
|
| 109 |
+
)
|
| 110 |
+
}
|