Spaces:
Running

axeronis commited on
Commit
f1fbc6a
·
1 Parent(s): 060043c

feat: complete i18n for ClientCard summary with clientCard/psychotypes keys (RU/EN/KY)

Browse files
frontend/components/ClientCard.tsx CHANGED
@@ -12,6 +12,7 @@ import {
12
  } from 'lucide-react'
13
  import { useToast } from '@/contexts/ToastContext'
14
  import { motion, AnimatePresence } from 'framer-motion'
 
15
 
16
  interface ClientCardProps {
17
  lead: Lead
@@ -24,6 +25,7 @@ interface ClientCardProps {
24
 
25
  export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversationId, tenantId }: ClientCardProps) {
26
  const { success, error } = useToast()
 
27
  const summary = (lead.ai_summary_json || {}) as any
28
  const [expandedSection, setExpandedSection] = useState<string | null>(null)
29
  const [isReanalyzing, setIsReanalyzing] = useState(false)
@@ -69,12 +71,12 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
69
  const updatedLead = await updatedRes.json()
70
  // Trigger parent refresh with new data
71
  onRefresh?.()
72
- success('Анализ завершен', 'Саммари обновлен')
73
  } else {
74
  throw new Error('Failed to fetch updated data')
75
  }
76
  } catch {
77
- error('Ошибка', 'Не удалось запустить анализ')
78
  } finally {
79
  setIsReanalyzing(false)
80
  }
@@ -89,12 +91,12 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
89
 
90
  // Structured Data
91
  const data = {
92
- intent: cleanValue(summary.intent, 'Не определено'),
93
- need: cleanValue(summary.need || lead.need, 'Не определено'),
94
- budget: cleanValue(summary.budget || lead.budget, 'Не определён'),
95
- authority: cleanValue(summary.authority || lead.authority, 'Неизвестно'),
96
- timeline: cleanValue(summary.timeline || lead.timeline, 'Не указаны'),
97
- industry: cleanValue(summary.industry || (lead as any).industry || summary.business_type, 'Не указана'), // Try multiple sources for Niche
98
  pain_points: Array.isArray(summary.pain_points) ? summary.pain_points : [],
99
  objections: Array.isArray(summary.objections) ? summary.objections : [],
100
  psychotype: cleanValue(summary.psychotype || lead.psychotype, 'unknown'),
@@ -107,11 +109,11 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
107
  // Psychotype Colors & Labels
108
  const getPsychotypeInfo = (type: string) => {
109
  const map: Record<string, { label: string; color: string; bg: string; icon: any }> = {
110
- 'dominant': { label: 'Доминантный', color: 'text-red-600', bg: 'bg-red-50', icon: Zap },
111
- 'influential': { label: 'Влияющий', color: 'text-amber-600', bg: 'bg-amber-50', icon: StarIcon },
112
- 'steady': { label: 'Стабильный', color: 'text-emerald-600', bg: 'bg-emerald-50', icon: Shield },
113
- 'conscientious': { label: 'Аналитический', color: 'text-blue-600', bg: 'bg-blue-50', icon: Database },
114
- 'unknown': { label: 'Не определён', color: 'text-slate-500', bg: 'bg-slate-50', icon: UserIcon }
115
  }
116
  return map[type.toLowerCase()] || map['unknown']
117
  }
@@ -127,7 +129,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
127
 
128
  const copyToClipboard = (text: string, label: string) => {
129
  navigator.clipboard.writeText(text)
130
- success("Скопировано", `${label} скопировано в буфер обмена`)
131
  }
132
 
133
  const toggleSection = (section: string) => {
@@ -136,24 +138,23 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
136
 
137
  // Construct real summary points from 11-point AI data
138
  const realSummaryPoints = [
139
- `Имя: ${lead.name || 'Неизвестно'}`,
140
- data.intent && `Цели: ${data.intent}`, // User asked for "Goals", mapping Intent to it
141
- data.industry && `Ниша: ${data.industry}`,
142
- data.need !== 'Не определено' && `Потребность: ${data.need}`,
143
- data.budget !== 'Не определён' && `Бюджет: ${data.budget}`,
144
- data.authority !== 'Неизвестно' && `ЛПР: ${data.authority}`,
145
- data.timeline !== 'Не указаны' && `Сроки: ${data.timeline}`,
146
- (data.pain_points.length > 0) && `Боли: ${data.pain_points.join(', ')}`,
147
- (data.objections.length > 0) && `Возражения: ${data.objections.join(', ')}`,
148
- data.hidden_signals && `Сигналы: ${data.hidden_signals}`,
149
- data.psychotype !== 'unknown' && `Психотип: ${getPsychotypeInfo(data.psychotype).label}`,
150
- data.recommendation && `Рекомендация: ${data.recommendation}`,
151
- // data.draft_reply && `Следующий шаг: ${data.draft_reply}`
152
  ].filter(Boolean) as string[]
153
 
154
  const summaryPoints = realSummaryPoints.length > 0 ? realSummaryPoints : [
155
- "Анализ диалога еще не проведен",
156
- "Ожидание первого сообщения..."
157
  ]
158
 
159
  return (
@@ -164,7 +165,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
164
 
165
  {/* Header Title */}
166
  <div>
167
- <h2 className="text-lg font-medium text-slate-200">Саммари чата</h2>
168
  </div>
169
 
170
  {/* Numbered Summary List */}
@@ -185,7 +186,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
185
  {/* Glow Effect */}
186
  <div className="absolute top-0 right-0 w-32 h-32 bg-orange-500/10 blur-[40px] rounded-full pointer-events-none group-hover:bg-orange-500/20 transition-all duration-500" />
187
 
188
- <h3 className="text-sm font-medium text-slate-300 mb-4 relative z-10">Степень горячести клиента</h3>
189
 
190
  <div className="flex items-center gap-4 relative z-10">
191
  {/* Thermometer Icon Placeholder (Custom Graphic) */}
@@ -204,7 +205,7 @@ export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversat
204
  <Flame className={cn("w-6 h-6 animate-pulse", getScoreColor(data.heat_score))} />
205
  </div>
206
  <p className={cn("text-sm font-medium mt-1", getScoreColor(data.heat_score))}>
207
- {data.heat_score >= 80 ? 'Высокая' : data.heat_score >= 50 ? 'Средняя' : 'Низкая'}
208
  </p>
209
  </div>
210
  </div>
 
12
  } from 'lucide-react'
13
  import { useToast } from '@/contexts/ToastContext'
14
  import { motion, AnimatePresence } from 'framer-motion'
15
+ import { useTranslation } from '@/lib/i18n'
16
 
17
  interface ClientCardProps {
18
  lead: Lead
 
25
 
26
  export function ClientCard({ lead, onTakeover, isAnalyzing, onRefresh, conversationId, tenantId }: ClientCardProps) {
27
  const { success, error } = useToast()
28
+ const { t } = useTranslation()
29
  const summary = (lead.ai_summary_json || {}) as any
30
  const [expandedSection, setExpandedSection] = useState<string | null>(null)
31
  const [isReanalyzing, setIsReanalyzing] = useState(false)
 
71
  const updatedLead = await updatedRes.json()
72
  // Trigger parent refresh with new data
73
  onRefresh?.()
74
+ success(t('clientCard.analysisComplete'), t('clientCard.summaryUpdated'))
75
  } else {
76
  throw new Error('Failed to fetch updated data')
77
  }
78
  } catch {
79
+ error(t('common.error'), t('clientCard.failedToAnalyze'))
80
  } finally {
81
  setIsReanalyzing(false)
82
  }
 
91
 
92
  // Structured Data
93
  const data = {
94
+ intent: cleanValue(summary.intent, t('clientCard.notDetermined')),
95
+ need: cleanValue(summary.need || lead.need, t('clientCard.notDetermined')),
96
+ budget: cleanValue(summary.budget || lead.budget, t('clientCard.notDefined')),
97
+ authority: cleanValue(summary.authority || lead.authority, t('common.unknown')),
98
+ timeline: cleanValue(summary.timeline || lead.timeline, t('clientCard.notSpecified')),
99
+ industry: cleanValue(summary.industry || (lead as any).industry || summary.business_type, t('clientCard.notSpecified')),
100
  pain_points: Array.isArray(summary.pain_points) ? summary.pain_points : [],
101
  objections: Array.isArray(summary.objections) ? summary.objections : [],
102
  psychotype: cleanValue(summary.psychotype || lead.psychotype, 'unknown'),
 
109
  // Psychotype Colors & Labels
110
  const getPsychotypeInfo = (type: string) => {
111
  const map: Record<string, { label: string; color: string; bg: string; icon: any }> = {
112
+ 'dominant': { label: t('psychotypes.dominant'), color: 'text-red-600', bg: 'bg-red-50', icon: Zap },
113
+ 'influential': { label: t('psychotypes.influential'), color: 'text-amber-600', bg: 'bg-amber-50', icon: StarIcon },
114
+ 'steady': { label: t('psychotypes.steady'), color: 'text-emerald-600', bg: 'bg-emerald-50', icon: Shield },
115
+ 'conscientious': { label: t('psychotypes.conscientious'), color: 'text-blue-600', bg: 'bg-blue-50', icon: Database },
116
+ 'unknown': { label: t('clientCard.notDetermined'), color: 'text-slate-500', bg: 'bg-slate-50', icon: UserIcon }
117
  }
118
  return map[type.toLowerCase()] || map['unknown']
119
  }
 
129
 
130
  const copyToClipboard = (text: string, label: string) => {
131
  navigator.clipboard.writeText(text)
132
+ success(t('common.copied'), `${label} ${t('clientCard.copiedToClipboard')}`)
133
  }
134
 
135
  const toggleSection = (section: string) => {
 
138
 
139
  // Construct real summary points from 11-point AI data
140
  const realSummaryPoints = [
141
+ `${t('clientCard.name')}: ${lead.name || t('common.unknown')}`,
142
+ data.intent && `${t('clientCard.goals')}: ${data.intent}`,
143
+ data.industry && `${t('clientCard.niche')}: ${data.industry}`,
144
+ data.need !== t('clientCard.notDetermined') && `${t('clientCard.need')}: ${data.need}`,
145
+ data.budget !== t('clientCard.notDefined') && `${t('clientCard.budget')}: ${data.budget}`,
146
+ data.authority !== t('common.unknown') && `${t('clientCard.decisionMaker')}: ${data.authority}`,
147
+ data.timeline !== t('clientCard.notSpecified') && `${t('clientCard.timeline')}: ${data.timeline}`,
148
+ (data.pain_points.length > 0) && `${t('clientCard.painPoints')}: ${data.pain_points.join(', ')}`,
149
+ (data.objections.length > 0) && `${t('clientCard.objections')}: ${data.objections.join(', ')}`,
150
+ data.hidden_signals && `${t('clientCard.signals')}: ${data.hidden_signals}`,
151
+ data.psychotype !== 'unknown' && `${t('clientCard.psychotype')}: ${getPsychotypeInfo(data.psychotype).label}`,
152
+ data.recommendation && `${t('clientCard.recommendation')}: ${data.recommendation}`,
 
153
  ].filter(Boolean) as string[]
154
 
155
  const summaryPoints = realSummaryPoints.length > 0 ? realSummaryPoints : [
156
+ t('clientCard.analysisNotDone'),
157
+ t('clientCard.waitingFirstMessage')
158
  ]
159
 
160
  return (
 
165
 
166
  {/* Header Title */}
167
  <div>
168
+ <h2 className="text-lg font-medium text-slate-200">{t('clientCard.chatSummary')}</h2>
169
  </div>
170
 
171
  {/* Numbered Summary List */}
 
186
  {/* Glow Effect */}
187
  <div className="absolute top-0 right-0 w-32 h-32 bg-orange-500/10 blur-[40px] rounded-full pointer-events-none group-hover:bg-orange-500/20 transition-all duration-500" />
188
 
189
+ <h3 className="text-sm font-medium text-slate-300 mb-4 relative z-10">{t('clientCard.heatLevel')}</h3>
190
 
191
  <div className="flex items-center gap-4 relative z-10">
192
  {/* Thermometer Icon Placeholder (Custom Graphic) */}
 
205
  <Flame className={cn("w-6 h-6 animate-pulse", getScoreColor(data.heat_score))} />
206
  </div>
207
  <p className={cn("text-sm font-medium mt-1", getScoreColor(data.heat_score))}>
208
+ {data.heat_score >= 80 ? t('clientCard.high') : data.heat_score >= 50 ? t('clientCard.medium') : t('clientCard.low')}
209
  </p>
210
  </div>
211
  </div>
frontend/lib/i18n/translations/en.ts CHANGED
@@ -379,4 +379,42 @@ export const en = {
379
  today: 'Today',
380
  yesterday: 'Yesterday',
381
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
 
379
  today: 'Today',
380
  yesterday: 'Yesterday',
381
  },
382
+
383
+ // ClientCard - Lead Summary
384
+ clientCard: {
385
+ chatSummary: 'Chat Summary',
386
+ name: 'Name',
387
+ goals: 'Goals',
388
+ niche: 'Niche',
389
+ need: 'Need',
390
+ budget: 'Budget',
391
+ decisionMaker: 'Decision Maker',
392
+ timeline: 'Timeline',
393
+ painPoints: 'Pain Points',
394
+ objections: 'Objections',
395
+ signals: 'Signals',
396
+ psychotype: 'Psychotype',
397
+ recommendation: 'Recommendation',
398
+ heatLevel: 'Client Heat Level',
399
+ high: 'High',
400
+ medium: 'Medium',
401
+ low: 'Low',
402
+ notDetermined: 'Not determined',
403
+ notDefined: 'Not defined',
404
+ notSpecified: 'Not specified',
405
+ analysisNotDone: 'Chat analysis not yet done',
406
+ waitingFirstMessage: 'Waiting for first message...',
407
+ analysisComplete: 'Analysis complete',
408
+ summaryUpdated: 'Summary updated',
409
+ failedToAnalyze: 'Failed to run analysis',
410
+ copiedToClipboard: 'copied to clipboard',
411
+ },
412
+
413
+ // Psychotypes
414
+ psychotypes: {
415
+ dominant: 'Dominant',
416
+ influential: 'Influential',
417
+ steady: 'Steady',
418
+ conscientious: 'Conscientious',
419
+ },
420
  }
frontend/lib/i18n/translations/ky.ts CHANGED
@@ -379,4 +379,42 @@ export const ky = {
379
  today: 'Бүгүн',
380
  yesterday: 'Кечээ',
381
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
 
379
  today: 'Бүгүн',
380
  yesterday: 'Кечээ',
381
  },
382
+
383
+ // ClientCard - Lead Summary
384
+ clientCard: {
385
+ chatSummary: 'Чат жыйынтыгы',
386
+ name: 'Аты',
387
+ goals: 'Максаттар',
388
+ niche: 'Ниша',
389
+ need: 'Керектөө',
390
+ budget: 'Бюджет',
391
+ decisionMaker: 'Чечим кабыл алуучу',
392
+ timeline: 'Мөөнөт',
393
+ painPoints: 'Оору чекиттери',
394
+ objections: 'Каршылыктар',
395
+ signals: 'Сигналдар',
396
+ psychotype: 'Психотип',
397
+ recommendation: 'Сунуш',
398
+ heatLevel: 'Кардардын ысыктык деңгээли',
399
+ high: 'Жогорку',
400
+ medium: 'Орточо',
401
+ low: 'Төмөн',
402
+ notDetermined: 'Аныкталган эмес',
403
+ notDefined: 'Аныкталбаган',
404
+ notSpecified: 'Көрсөтүлгөн эмес',
405
+ analysisNotDone: 'Чат талдоосу али жүргүзүлгөн эмес',
406
+ waitingFirstMessage: 'Биринчи билдирүүнү күтүүдө...',
407
+ analysisComplete: 'Талдоо аяктады',
408
+ summaryUpdated: 'Жыйынтык жаңыртылды',
409
+ failedToAnalyze: 'Талдоону баштоо ишке ашкан жок',
410
+ copiedToClipboard: 'алмашуу буферине көчүрүлдү',
411
+ },
412
+
413
+ // Psychotypes
414
+ psychotypes: {
415
+ dominant: 'Доминанттык',
416
+ influential: 'Таасирдүү',
417
+ steady: 'Туруктуу',
418
+ conscientious: 'Аналитикалык',
419
+ },
420
  }
frontend/lib/i18n/translations/ru.ts CHANGED
@@ -379,4 +379,42 @@ export const ru = {
379
  today: 'Сегодня',
380
  yesterday: 'Вчера',
381
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
 
379
  today: 'Сегодня',
380
  yesterday: 'Вчера',
381
  },
382
+
383
+ // ClientCard - Lead Summary
384
+ clientCard: {
385
+ chatSummary: 'Саммари чата',
386
+ name: 'Имя',
387
+ goals: 'Цели',
388
+ niche: 'Ниша',
389
+ need: 'Потребность',
390
+ budget: 'Бюджет',
391
+ decisionMaker: 'ЛПР',
392
+ timeline: 'Сроки',
393
+ painPoints: 'Боли',
394
+ objections: 'Возражения',
395
+ signals: 'Сигналы',
396
+ psychotype: 'Психотип',
397
+ recommendation: 'Рекомендация',
398
+ heatLevel: 'Степень горячести клиента',
399
+ high: 'Высокая',
400
+ medium: 'Средняя',
401
+ low: 'Низкая',
402
+ notDetermined: 'Не определено',
403
+ notDefined: 'Не определён',
404
+ notSpecified: 'Не указано',
405
+ analysisNotDone: 'Анализ диалога еще не проведен',
406
+ waitingFirstMessage: 'Ожидание первого сообщения...',
407
+ analysisComplete: 'Анализ завершен',
408
+ summaryUpdated: 'Саммари обновлен',
409
+ failedToAnalyze: 'Не удалось запустить анализ',
410
+ copiedToClipboard: 'скопировано в буфер обмена',
411
+ },
412
+
413
+ // Psychotypes
414
+ psychotypes: {
415
+ dominant: 'Доминантный',
416
+ influential: 'Влияющий',
417
+ steady: 'Стабильный',
418
+ conscientious: 'Аналитический',
419
+ },
420
  }