Spaces:
Running

axeronis commited on
Commit
5d26543
·
1 Parent(s): 53ff096

fix: Mobile UI - demo-chat layout, product modal scroll

Browse files
frontend/app/demo-chat/page.tsx CHANGED
@@ -1,7 +1,7 @@
1
  'use client'
2
 
3
  import { useState, useRef, useEffect } from 'react'
4
- import { motion, AnimatePresence } from 'framer-motion'
5
  import { Send, Bot, User, Loader2, Sparkles, Wand2, ArrowLeft, Trash2, CheckCircle } from 'lucide-react'
6
  import { api } from '@/lib/api'
7
  import { useToast } from '@/contexts/ToastContext'
@@ -140,26 +140,26 @@ export default function DemoChatPage() {
140
 
141
  if (authLoading) {
142
  return (
143
- <div className="flex items-center justify-center h-screen">
144
  <Loader2 className="w-8 h-8 animate-spin text-violet-500" />
145
  </div>
146
  )
147
  }
148
 
149
  return (
150
- <div className="h-[calc(100vh-56px)] flex flex-col bg-[#0a0a0f]">
151
- {/* Header */}
152
- <header className="flex-shrink-0 flex items-center justify-between px-4 py-3 border-b border-white/5">
153
- <div className="flex items-center gap-3">
154
  <Link href="/settings/brain" className="p-2 text-white/40 hover:text-white rounded-lg">
155
  <ArrowLeft className="w-5 h-5" />
156
  </Link>
157
- <div className="w-10 h-10 rounded-xl bg-gradient-to-br from-violet-600 to-purple-700 flex items-center justify-center">
158
- <Bot className="w-5 h-5 text-white" />
159
  </div>
160
  <div>
161
  <h1 className="font-semibold text-white text-sm">Демо-чат</h1>
162
- <p className="text-[10px] text-white/40">Тестируй AI без сохранения в CRM</p>
163
  </div>
164
  </div>
165
 
@@ -168,29 +168,29 @@ export default function DemoChatPage() {
168
  </button>
169
  </header>
170
 
171
- {/* Messages */}
172
  <div className="flex-1 overflow-y-auto">
173
- <div className="max-w-2xl mx-auto px-4 py-6 space-y-4">
174
  {messages.length === 0 ? (
175
- <div className="flex flex-col items-center justify-center min-h-[50vh] text-center">
176
- <div className="w-16 h-16 rounded-2xl bg-gradient-to-br from-violet-600/20 to-purple-600/20 flex items-center justify-center mb-4">
177
- <Sparkles className="w-8 h-8 text-violet-400" />
178
  </div>
179
  <h3 className="text-lg font-semibold text-white mb-1">Тест AI</h3>
180
- <p className="text-sm text-white/40 max-w-sm mb-6">
181
- Пиши как клиент. 🪄 — режим правки настроек.
182
  </p>
183
 
184
- <div className="grid gap-2 w-full max-w-sm">
185
  <button
186
  onClick={() => setInput('Привет!')}
187
- className="p-3 bg-white/5 border border-white/5 rounded-xl text-sm text-white/70 text-left hover:bg-white/10"
188
  >
189
  💬 "Привет!"
190
  </button>
191
  <button
192
  onClick={() => setInput('Сколько стоит?')}
193
- className="p-3 bg-white/5 border border-white/5 rounded-xl text-sm text-white/70 text-left hover:bg-white/10"
194
  >
195
  💰 "Сколько стоит?"
196
  </button>
@@ -203,29 +203,26 @@ export default function DemoChatPage() {
203
  initial={{ opacity: 0, y: 5 }}
204
  animate={{ opacity: 1, y: 0 }}
205
  className={cn(
206
- "flex gap-3",
207
  msg.role === 'user' && "flex-row-reverse",
208
  msg.role === 'system' && "justify-center"
209
  )}
210
  >
211
  {msg.role === 'system' ? (
212
- <div className="px-4 py-3 bg-violet-500/10 border border-violet-500/20 rounded-xl max-w-[95%]">
213
- <div className="flex items-start gap-2 text-violet-300 text-sm">
214
- <CheckCircle className="w-4 h-4 flex-shrink-0 mt-0.5" />
215
  <div className="whitespace-pre-wrap">{msg.content}</div>
216
  </div>
217
  {msg.changes && msg.changes.length > 0 && (
218
- <div className="mt-3 space-y-2">
219
  {msg.changes.map((c: any, i: number) => (
220
- <div key={i} className="bg-violet-500/10 rounded-lg px-3 py-2 text-xs">
221
  <div className="text-violet-200 font-medium">{c.field}</div>
222
- {c.section && (
223
- <div className="text-violet-400/60 text-[10px]">{c.section}</div>
224
- )}
225
  {(c.old || c.new) && (
226
- <div className="text-violet-300 mt-1">
227
  <span className="text-red-400/70">{c.old}</span>
228
- <span className="text-violet-400 mx-2">→</span>
229
  <span className="text-green-400">{c.new}</span>
230
  </div>
231
  )}
@@ -237,17 +234,17 @@ export default function DemoChatPage() {
237
  ) : (
238
  <>
239
  <div className={cn(
240
- "w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",
241
  msg.role === 'user' ? "bg-white/10" : "bg-gradient-to-br from-violet-600 to-purple-700"
242
  )}>
243
  {msg.role === 'user' ? (
244
- <User className="w-4 h-4 text-white/70" />
245
  ) : (
246
- <Bot className="w-4 h-4 text-white" />
247
  )}
248
  </div>
249
  <div className={cn(
250
- "max-w-[75%] px-4 py-3 rounded-2xl text-sm",
251
  msg.role === 'user'
252
  ? "bg-violet-600 text-white rounded-br-md"
253
  : "bg-white/5 text-white/90 border border-white/5 rounded-bl-md"
@@ -261,15 +258,15 @@ export default function DemoChatPage() {
261
  )}
262
 
263
  {isLoading && (
264
- <div className="flex gap-3">
265
- <div className="w-8 h-8 rounded-lg bg-gradient-to-br from-violet-600 to-purple-700 flex items-center justify-center">
266
- <Bot className="w-4 h-4 text-white" />
267
  </div>
268
- <div className="bg-white/5 border border-white/5 px-4 py-3 rounded-2xl rounded-bl-md">
269
- <div className="flex gap-1.5">
270
- <span className="w-2 h-2 bg-violet-400 rounded-full animate-bounce" style={{ animationDelay: '0ms' }} />
271
- <span className="w-2 h-2 bg-violet-400 rounded-full animate-bounce" style={{ animationDelay: '150ms' }} />
272
- <span className="w-2 h-2 bg-violet-400 rounded-full animate-bounce" style={{ animationDelay: '300ms' }} />
273
  </div>
274
  </div>
275
  </div>
@@ -279,11 +276,11 @@ export default function DemoChatPage() {
279
  </div>
280
  </div>
281
 
282
- {/* Input - Fixed at bottom with proper spacing */}
283
- <div className="flex-shrink-0 border-t border-white/5 bg-[#0a0a0f] px-4 py-4 md:py-6 md:pb-8">
284
  <div className="max-w-2xl mx-auto">
285
  <div className={cn(
286
- "flex items-center gap-2 p-1.5 rounded-xl transition-all",
287
  isCorrectMode
288
  ? "bg-violet-500/10 border-2 border-violet-500/30"
289
  : "bg-white/5 border border-white/10"
@@ -294,14 +291,14 @@ export default function DemoChatPage() {
294
  inputRef.current?.focus()
295
  }}
296
  className={cn(
297
- "p-2.5 rounded-lg transition-all flex-shrink-0",
298
  isCorrectMode
299
  ? "bg-violet-500 text-white"
300
  : "text-white/40 hover:text-violet-400"
301
  )}
302
  title="Режим правки"
303
  >
304
- <Wand2 className="w-5 h-5" />
305
  </button>
306
 
307
  <input
@@ -311,7 +308,7 @@ export default function DemoChatPage() {
311
  onChange={(e) => setInput(e.target.value)}
312
  onKeyPress={handleKeyPress}
313
  placeholder={isCorrectMode ? "Опиши что исправить..." : "Сообщение..."}
314
- className="flex-1 bg-transparent text-white placeholder-white/30 focus:outline-none text-sm px-2"
315
  disabled={isLoading}
316
  />
317
 
@@ -319,19 +316,19 @@ export default function DemoChatPage() {
319
  onClick={handleSend}
320
  disabled={!input.trim() || isLoading}
321
  className={cn(
322
- "p-2.5 rounded-lg transition-all flex-shrink-0",
323
  input.trim()
324
  ? "bg-violet-600 hover:bg-violet-500 text-white"
325
  : "bg-white/5 text-white/20"
326
  )}
327
  >
328
- <Send className="w-5 h-5" />
329
  </button>
330
  </div>
331
 
332
  {isCorrectMode && (
333
- <p className="text-center text-xs text-violet-400/80 mt-2">
334
- 🪄 Опиши проблему: "не говори бот", "ты Анна а не менеджер"
335
  </p>
336
  )}
337
  </div>
 
1
  'use client'
2
 
3
  import { useState, useRef, useEffect } from 'react'
4
+ import { motion } from 'framer-motion'
5
  import { Send, Bot, User, Loader2, Sparkles, Wand2, ArrowLeft, Trash2, CheckCircle } from 'lucide-react'
6
  import { api } from '@/lib/api'
7
  import { useToast } from '@/contexts/ToastContext'
 
140
 
141
  if (authLoading) {
142
  return (
143
+ <div className="flex items-center justify-center h-full bg-background">
144
  <Loader2 className="w-8 h-8 animate-spin text-violet-500" />
145
  </div>
146
  )
147
  }
148
 
149
  return (
150
+ <div className="flex flex-col h-full bg-[#0a0a0f]">
151
+ {/* Header - sticky at top */}
152
+ <header className="flex-shrink-0 flex items-center justify-between px-3 py-2 border-b border-white/5 bg-[#0a0a0f] safe-area-top">
153
+ <div className="flex items-center gap-2">
154
  <Link href="/settings/brain" className="p-2 text-white/40 hover:text-white rounded-lg">
155
  <ArrowLeft className="w-5 h-5" />
156
  </Link>
157
+ <div className="w-9 h-9 rounded-xl bg-gradient-to-br from-violet-600 to-purple-700 flex items-center justify-center">
158
+ <Bot className="w-4 h-4 text-white" />
159
  </div>
160
  <div>
161
  <h1 className="font-semibold text-white text-sm">Демо-чат</h1>
162
+ <p className="text-[10px] text-white/40 hidden sm:block">Тест без сохранения в CRM</p>
163
  </div>
164
  </div>
165
 
 
168
  </button>
169
  </header>
170
 
171
+ {/* Messages - scrollable middle area */}
172
  <div className="flex-1 overflow-y-auto">
173
+ <div className="max-w-2xl mx-auto px-3 py-4 space-y-3">
174
  {messages.length === 0 ? (
175
+ <div className="flex flex-col items-center justify-center min-h-[40vh] text-center py-8">
176
+ <div className="w-14 h-14 rounded-2xl bg-gradient-to-br from-violet-600/20 to-purple-600/20 flex items-center justify-center mb-3">
177
+ <Sparkles className="w-7 h-7 text-violet-400" />
178
  </div>
179
  <h3 className="text-lg font-semibold text-white mb-1">Тест AI</h3>
180
+ <p className="text-xs text-white/40 max-w-[280px] mb-5">
181
+ Пиши как клиент. 🪄 — режим правки.
182
  </p>
183
 
184
+ <div className="grid gap-2 w-full max-w-[280px]">
185
  <button
186
  onClick={() => setInput('Привет!')}
187
+ className="p-2.5 bg-white/5 border border-white/5 rounded-xl text-xs text-white/70 text-left"
188
  >
189
  💬 "Привет!"
190
  </button>
191
  <button
192
  onClick={() => setInput('Сколько стоит?')}
193
+ className="p-2.5 bg-white/5 border border-white/5 rounded-xl text-xs text-white/70 text-left"
194
  >
195
  💰 "Сколько стоит?"
196
  </button>
 
203
  initial={{ opacity: 0, y: 5 }}
204
  animate={{ opacity: 1, y: 0 }}
205
  className={cn(
206
+ "flex gap-2",
207
  msg.role === 'user' && "flex-row-reverse",
208
  msg.role === 'system' && "justify-center"
209
  )}
210
  >
211
  {msg.role === 'system' ? (
212
+ <div className="px-3 py-2 bg-violet-500/10 border border-violet-500/20 rounded-xl max-w-[95%]">
213
+ <div className="flex items-start gap-2 text-violet-300 text-xs">
214
+ <CheckCircle className="w-3.5 h-3.5 flex-shrink-0 mt-0.5" />
215
  <div className="whitespace-pre-wrap">{msg.content}</div>
216
  </div>
217
  {msg.changes && msg.changes.length > 0 && (
218
+ <div className="mt-2 space-y-1 text-[10px]">
219
  {msg.changes.map((c: any, i: number) => (
220
+ <div key={i} className="bg-violet-500/10 rounded-lg px-2 py-1">
221
  <div className="text-violet-200 font-medium">{c.field}</div>
 
 
 
222
  {(c.old || c.new) && (
223
+ <div className="text-violet-300">
224
  <span className="text-red-400/70">{c.old}</span>
225
+ <span className="text-violet-400 mx-1">→</span>
226
  <span className="text-green-400">{c.new}</span>
227
  </div>
228
  )}
 
234
  ) : (
235
  <>
236
  <div className={cn(
237
+ "w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",
238
  msg.role === 'user' ? "bg-white/10" : "bg-gradient-to-br from-violet-600 to-purple-700"
239
  )}>
240
  {msg.role === 'user' ? (
241
+ <User className="w-3.5 h-3.5 text-white/70" />
242
  ) : (
243
+ <Bot className="w-3.5 h-3.5 text-white" />
244
  )}
245
  </div>
246
  <div className={cn(
247
+ "max-w-[80%] px-3 py-2 rounded-2xl text-sm",
248
  msg.role === 'user'
249
  ? "bg-violet-600 text-white rounded-br-md"
250
  : "bg-white/5 text-white/90 border border-white/5 rounded-bl-md"
 
258
  )}
259
 
260
  {isLoading && (
261
+ <div className="flex gap-2">
262
+ <div className="w-7 h-7 rounded-lg bg-gradient-to-br from-violet-600 to-purple-700 flex items-center justify-center">
263
+ <Bot className="w-3.5 h-3.5 text-white" />
264
  </div>
265
+ <div className="bg-white/5 border border-white/5 px-3 py-2 rounded-2xl rounded-bl-md">
266
+ <div className="flex gap-1">
267
+ <span className="w-1.5 h-1.5 bg-violet-400 rounded-full animate-bounce" style={{ animationDelay: '0ms' }} />
268
+ <span className="w-1.5 h-1.5 bg-violet-400 rounded-full animate-bounce" style={{ animationDelay: '150ms' }} />
269
+ <span className="w-1.5 h-1.5 bg-violet-400 rounded-full animate-bounce" style={{ animationDelay: '300ms' }} />
270
  </div>
271
  </div>
272
  </div>
 
276
  </div>
277
  </div>
278
 
279
+ {/* Input - fixed at bottom with safe area */}
280
+ <div className="flex-shrink-0 border-t border-white/5 bg-[#0a0a0f] px-3 py-2 pb-safe">
281
  <div className="max-w-2xl mx-auto">
282
  <div className={cn(
283
+ "flex items-center gap-1.5 p-1 rounded-xl transition-all",
284
  isCorrectMode
285
  ? "bg-violet-500/10 border-2 border-violet-500/30"
286
  : "bg-white/5 border border-white/10"
 
291
  inputRef.current?.focus()
292
  }}
293
  className={cn(
294
+ "p-2 rounded-lg transition-all flex-shrink-0",
295
  isCorrectMode
296
  ? "bg-violet-500 text-white"
297
  : "text-white/40 hover:text-violet-400"
298
  )}
299
  title="Режим правки"
300
  >
301
+ <Wand2 className="w-4 h-4" />
302
  </button>
303
 
304
  <input
 
308
  onChange={(e) => setInput(e.target.value)}
309
  onKeyPress={handleKeyPress}
310
  placeholder={isCorrectMode ? "Опиши что исправить..." : "Сообщение..."}
311
+ className="flex-1 bg-transparent text-white placeholder-white/30 focus:outline-none text-sm px-1"
312
  disabled={isLoading}
313
  />
314
 
 
316
  onClick={handleSend}
317
  disabled={!input.trim() || isLoading}
318
  className={cn(
319
+ "p-2 rounded-lg transition-all flex-shrink-0",
320
  input.trim()
321
  ? "bg-violet-600 hover:bg-violet-500 text-white"
322
  : "bg-white/5 text-white/20"
323
  )}
324
  >
325
+ <Send className="w-4 h-4" />
326
  </button>
327
  </div>
328
 
329
  {isCorrectMode && (
330
+ <p className="text-center text-[10px] text-violet-400/80 mt-1.5">
331
+ 🪄 Опиши проблему: "не говори бот", "ты Анна"
332
  </p>
333
  )}
334
  </div>
frontend/components/settings/ProductSettings.tsx CHANGED
@@ -253,14 +253,15 @@ export default function ProductSettings() {
253
  {/* Modal - Clean */}
254
  <AnimatePresence>
255
  {isModalOpen && (
256
- <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm overflow-y-auto">
257
  <motion.div
258
- initial={{ opacity: 0, scale: 0.95 }}
259
- animate={{ opacity: 1, scale: 1 }}
260
- exit={{ opacity: 0, scale: 0.95 }}
261
- className="bg-[#12131F] rounded-xl border border-white/10 w-full max-w-md max-h-[90vh] overflow-y-auto my-4">
262
- <form onSubmit={handleSave}>
263
- <div className="p-4 border-b border-white/10 flex items-center justify-between">
 
264
  <h2 className="text-white font-medium">
265
  {editingProduct ? t('productsSettings.editing') : t('productsSettings.newProduct')}
266
  </h2>
@@ -273,7 +274,8 @@ export default function ProductSettings() {
273
  </button>
274
  </div>
275
 
276
- <div className="p-4 space-y-4">
 
277
  <div>
278
  <label className="block text-xs text-slate-400 mb-1.5">{t('productsSettings.name')}</label>
279
  <input
@@ -403,7 +405,8 @@ export default function ProductSettings() {
403
  </div>
404
  </div>
405
 
406
- <div className="sticky bottom-0 p-4 border-t border-white/10 flex justify-end gap-2 bg-[#12131F]">
 
407
  <button
408
  type="button"
409
  onClick={() => setIsModalOpen(false)}
 
253
  {/* Modal - Clean */}
254
  <AnimatePresence>
255
  {isModalOpen && (
256
+ <div className="fixed inset-0 z-50 flex items-end sm:items-center justify-center p-0 sm:p-4 bg-black/70 backdrop-blur-sm">
257
  <motion.div
258
+ initial={{ opacity: 0, y: 50 }}
259
+ animate={{ opacity: 1, y: 0 }}
260
+ exit={{ opacity: 0, y: 50 }}
261
+ className="bg-[#12131F] rounded-t-2xl sm:rounded-xl border border-white/10 w-full sm:max-w-md max-h-[85vh] sm:max-h-[90vh] flex flex-col">
262
+ <form onSubmit={handleSave} className="flex flex-col h-full max-h-[85vh] sm:max-h-[90vh]">
263
+ {/* Fixed Header */}
264
+ <div className="flex-shrink-0 p-4 border-b border-white/10 flex items-center justify-between">
265
  <h2 className="text-white font-medium">
266
  {editingProduct ? t('productsSettings.editing') : t('productsSettings.newProduct')}
267
  </h2>
 
274
  </button>
275
  </div>
276
 
277
+ {/* Scrollable Content */}
278
+ <div className="flex-1 overflow-y-auto p-4 space-y-4">
279
  <div>
280
  <label className="block text-xs text-slate-400 mb-1.5">{t('productsSettings.name')}</label>
281
  <input
 
405
  </div>
406
  </div>
407
 
408
+ {/* Fixed Footer */}
409
+ <div className="flex-shrink-0 p-4 border-t border-white/10 flex justify-end gap-2 bg-[#12131F]">
410
  <button
411
  type="button"
412
  onClick={() => setIsModalOpen(false)}