@hed-hog/contact 0.0.278 → 0.0.285
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/dist/person/dto/create-followup.dto.d.ts +5 -0
- package/dist/person/dto/create-followup.dto.d.ts.map +1 -0
- package/dist/person/dto/create-followup.dto.js +31 -0
- package/dist/person/dto/create-followup.dto.js.map +1 -0
- package/dist/person/dto/create-interaction.dto.d.ts +12 -0
- package/dist/person/dto/create-interaction.dto.d.ts.map +1 -0
- package/dist/person/dto/create-interaction.dto.js +39 -0
- package/dist/person/dto/create-interaction.dto.js.map +1 -0
- package/dist/person/dto/create.dto.d.ts +24 -0
- package/dist/person/dto/create.dto.d.ts.map +1 -1
- package/dist/person/dto/create.dto.js +56 -1
- package/dist/person/dto/create.dto.js.map +1 -1
- package/dist/person/dto/duplicates-query.dto.d.ts +8 -0
- package/dist/person/dto/duplicates-query.dto.d.ts.map +1 -0
- package/dist/person/dto/duplicates-query.dto.js +45 -0
- package/dist/person/dto/duplicates-query.dto.js.map +1 -0
- package/dist/person/dto/merge.dto.d.ts +6 -0
- package/dist/person/dto/merge.dto.d.ts.map +1 -0
- package/dist/person/dto/merge.dto.js +35 -0
- package/dist/person/dto/merge.dto.js.map +1 -0
- package/dist/person/dto/update-lifecycle-stage.dto.d.ts +13 -0
- package/dist/person/dto/update-lifecycle-stage.dto.d.ts.map +1 -0
- package/dist/person/dto/update-lifecycle-stage.dto.js +34 -0
- package/dist/person/dto/update-lifecycle-stage.dto.js.map +1 -0
- package/dist/person/dto/update.dto.d.ts +8 -1
- package/dist/person/dto/update.dto.d.ts.map +1 -1
- package/dist/person/dto/update.dto.js +36 -0
- package/dist/person/dto/update.dto.js.map +1 -1
- package/dist/person/person.controller.d.ts +57 -1
- package/dist/person/person.controller.d.ts.map +1 -1
- package/dist/person/person.controller.js +85 -3
- package/dist/person/person.controller.js.map +1 -1
- package/dist/person/person.service.d.ts +79 -0
- package/dist/person/person.service.d.ts.map +1 -1
- package/dist/person/person.service.js +730 -9
- package/dist/person/person.service.js.map +1 -1
- package/hedhog/data/route.yaml +18 -0
- package/hedhog/frontend/app/_components/crm-coming-soon.tsx.ejs +110 -110
- package/hedhog/frontend/app/_components/crm-nav.tsx.ejs +73 -73
- package/hedhog/frontend/app/_lib/crm-mocks.ts.ejs +498 -256
- package/hedhog/frontend/app/_lib/crm-sections.tsx.ejs +81 -81
- package/hedhog/frontend/app/accounts/_components/account-form-sheet.tsx.ejs +477 -0
- package/hedhog/frontend/app/accounts/_components/account-types.ts.ejs +62 -0
- package/hedhog/frontend/app/accounts/page.tsx.ejs +886 -15
- package/hedhog/frontend/app/activities/page.tsx.ejs +15 -15
- package/hedhog/frontend/app/contact-type/page.tsx.ejs +105 -91
- package/hedhog/frontend/app/dashboard/page.tsx.ejs +506 -573
- package/hedhog/frontend/app/document-type/page.tsx.ejs +105 -91
- package/hedhog/frontend/app/follow-ups/page.tsx.ejs +15 -15
- package/hedhog/frontend/app/page.tsx.ejs +5 -5
- package/hedhog/frontend/app/person/_components/person-form-sheet.tsx.ejs +1440 -1103
- package/hedhog/frontend/app/person/_components/person-interaction-dialog.tsx.ejs +4 -3
- package/hedhog/frontend/app/person/_components/person-types.ts.ejs +14 -0
- package/hedhog/frontend/app/person/page.tsx.ejs +108 -190
- package/hedhog/frontend/app/pipeline/_components/lead-detail-sheet.tsx.ejs +599 -0
- package/hedhog/frontend/app/pipeline/page.tsx.ejs +1074 -299
- package/hedhog/frontend/app/reports/page.tsx.ejs +15 -15
- package/hedhog/frontend/messages/en.json +107 -0
- package/hedhog/frontend/messages/pt.json +106 -0
- package/package.json +6 -6
- package/src/person/dto/create-followup.dto.ts +15 -0
- package/src/person/dto/create-interaction.dto.ts +23 -0
- package/src/person/dto/create.dto.ts +50 -0
- package/src/person/dto/duplicates-query.dto.ts +34 -0
- package/src/person/dto/merge.dto.ts +15 -0
- package/src/person/dto/update-lifecycle-stage.dto.ts +19 -0
- package/src/person/dto/update.dto.ts +31 -1
- package/src/person/person.controller.ts +63 -2
- package/src/person/person.service.ts +1096 -7
|
@@ -1,573 +1,506 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
'#
|
|
53
|
-
'#
|
|
54
|
-
'#
|
|
55
|
-
'#
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
)
|
|
80
|
-
).length;
|
|
81
|
-
const
|
|
82
|
-
(lead) => lead.lifecycle_stage === '
|
|
83
|
-
).length;
|
|
84
|
-
const
|
|
85
|
-
(lead) => lead.lifecycle_stage === '
|
|
86
|
-
).length;
|
|
87
|
-
const
|
|
88
|
-
(lead) => lead.
|
|
89
|
-
).length;
|
|
90
|
-
const
|
|
91
|
-
(lead) =>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
<
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
>
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
<
|
|
273
|
-
<
|
|
274
|
-
<
|
|
275
|
-
{
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
{
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
<
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
<
|
|
391
|
-
<
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
{unattendedLeads.map((lead) => (
|
|
508
|
-
<div
|
|
509
|
-
key={lead.id}
|
|
510
|
-
className="rounded-2xl border border-border/70 px-4 py-3"
|
|
511
|
-
>
|
|
512
|
-
<p className="font-medium">{lead.name}</p>
|
|
513
|
-
<p className="text-xs text-muted-foreground">
|
|
514
|
-
{lead.owner_user?.name || t('common.unassigned')}
|
|
515
|
-
</p>
|
|
516
|
-
<p className="mt-2 text-sm text-muted-foreground">
|
|
517
|
-
{t('blocks.unattended.meta', {
|
|
518
|
-
stage: t(
|
|
519
|
-
`stageLabels.${lead.lifecycle_stage ?? 'new'}`
|
|
520
|
-
),
|
|
521
|
-
source: t(`sourceLabels.${lead.source ?? 'other'}`),
|
|
522
|
-
})}
|
|
523
|
-
</p>
|
|
524
|
-
</div>
|
|
525
|
-
))}
|
|
526
|
-
</div>
|
|
527
|
-
</ScrollArea>
|
|
528
|
-
</CardContent>
|
|
529
|
-
</Card>
|
|
530
|
-
|
|
531
|
-
<Card className="min-w-0 overflow-hidden xl:col-span-1">
|
|
532
|
-
<CardHeader>
|
|
533
|
-
<CardTitle>{t('blocks.quickAccess.title')}</CardTitle>
|
|
534
|
-
<CardDescription>
|
|
535
|
-
{t('blocks.quickAccess.description')}
|
|
536
|
-
</CardDescription>
|
|
537
|
-
</CardHeader>
|
|
538
|
-
<CardContent className="space-y-3">
|
|
539
|
-
{crmImplementedSections.map((section) => {
|
|
540
|
-
const Icon = section.icon;
|
|
541
|
-
|
|
542
|
-
return (
|
|
543
|
-
<Link
|
|
544
|
-
key={section.href}
|
|
545
|
-
href={section.href}
|
|
546
|
-
className="flex min-w-0 items-center justify-between gap-3 rounded-2xl border border-border/70 px-4 py-3 transition-colors hover:bg-muted/40"
|
|
547
|
-
>
|
|
548
|
-
<div className="flex min-w-0 items-center gap-3">
|
|
549
|
-
<div className={`rounded-2xl p-3 ${section.glowClass}`}>
|
|
550
|
-
<Icon className="size-4" />
|
|
551
|
-
</div>
|
|
552
|
-
<div className="min-w-0">
|
|
553
|
-
<p className="truncate font-medium">
|
|
554
|
-
{menuT(`sections.${section.translationKey}.title`)}
|
|
555
|
-
</p>
|
|
556
|
-
<p className="truncate text-xs text-muted-foreground">
|
|
557
|
-
{menuT(
|
|
558
|
-
`sections.${section.translationKey}.description`
|
|
559
|
-
)}
|
|
560
|
-
</p>
|
|
561
|
-
</div>
|
|
562
|
-
</div>
|
|
563
|
-
<ArrowUpRight className="size-4 shrink-0 text-muted-foreground" />
|
|
564
|
-
</Link>
|
|
565
|
-
);
|
|
566
|
-
})}
|
|
567
|
-
</CardContent>
|
|
568
|
-
</Card>
|
|
569
|
-
</div>
|
|
570
|
-
</div>
|
|
571
|
-
</Page>
|
|
572
|
-
);
|
|
573
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Page, PageHeader } from '@/components/entity-list';
|
|
4
|
+
import { Badge } from '@/components/ui/badge';
|
|
5
|
+
import {
|
|
6
|
+
Card,
|
|
7
|
+
CardContent,
|
|
8
|
+
CardDescription,
|
|
9
|
+
CardHeader,
|
|
10
|
+
CardTitle,
|
|
11
|
+
} from '@/components/ui/card';
|
|
12
|
+
import { ScrollArea } from '@/components/ui/scroll-area';
|
|
13
|
+
import { useApp } from '@hed-hog/next-app-provider';
|
|
14
|
+
import {
|
|
15
|
+
AlertTriangle,
|
|
16
|
+
ArrowUpRight,
|
|
17
|
+
BriefcaseBusiness,
|
|
18
|
+
CalendarClock,
|
|
19
|
+
ChartNoAxesCombined,
|
|
20
|
+
CircleDollarSign,
|
|
21
|
+
RefreshCcw,
|
|
22
|
+
Target,
|
|
23
|
+
TrendingUp,
|
|
24
|
+
UserRoundX,
|
|
25
|
+
} from 'lucide-react';
|
|
26
|
+
import { useTranslations } from 'next-intl';
|
|
27
|
+
import Link from 'next/link';
|
|
28
|
+
import {
|
|
29
|
+
Bar,
|
|
30
|
+
BarChart,
|
|
31
|
+
CartesianGrid,
|
|
32
|
+
Cell,
|
|
33
|
+
Pie,
|
|
34
|
+
PieChart,
|
|
35
|
+
ResponsiveContainer,
|
|
36
|
+
Tooltip,
|
|
37
|
+
XAxis,
|
|
38
|
+
YAxis,
|
|
39
|
+
} from 'recharts';
|
|
40
|
+
import {
|
|
41
|
+
crmMockLeads,
|
|
42
|
+
crmOwners,
|
|
43
|
+
crmSourceOrder,
|
|
44
|
+
crmStageOrder,
|
|
45
|
+
} from '../_lib/crm-mocks';
|
|
46
|
+
import { crmImplementedSections } from '../_lib/crm-sections';
|
|
47
|
+
|
|
48
|
+
const chartPalette = [
|
|
49
|
+
'#f97316',
|
|
50
|
+
'#14b8a6',
|
|
51
|
+
'#0ea5e9',
|
|
52
|
+
'#84cc16',
|
|
53
|
+
'#f59e0b',
|
|
54
|
+
'#ef4444',
|
|
55
|
+
'#8b5cf6',
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const chartTooltipStyle = {
|
|
59
|
+
backgroundColor: 'hsl(var(--card))',
|
|
60
|
+
border: '1px solid hsl(var(--border))',
|
|
61
|
+
borderRadius: '12px',
|
|
62
|
+
fontSize: '12px',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const fallbackKpiAccentClass =
|
|
66
|
+
'from-orange-500/20 via-amber-500/10 to-transparent';
|
|
67
|
+
|
|
68
|
+
export default function CrmDashboardPage() {
|
|
69
|
+
const t = useTranslations('contact.CrmDashboard');
|
|
70
|
+
const menuT = useTranslations('contact.CrmMenu');
|
|
71
|
+
const { currentLocaleCode } = useApp();
|
|
72
|
+
|
|
73
|
+
const qualifiedCount = crmMockLeads.filter((lead) =>
|
|
74
|
+
['qualified', 'proposal', 'negotiation', 'customer'].includes(
|
|
75
|
+
lead.lifecycle_stage ?? ''
|
|
76
|
+
)
|
|
77
|
+
).length;
|
|
78
|
+
const proposalCount = crmMockLeads.filter(
|
|
79
|
+
(lead) => lead.lifecycle_stage === 'proposal'
|
|
80
|
+
).length;
|
|
81
|
+
const customerCount = crmMockLeads.filter(
|
|
82
|
+
(lead) => lead.lifecycle_stage === 'customer'
|
|
83
|
+
).length;
|
|
84
|
+
const lostCount = crmMockLeads.filter(
|
|
85
|
+
(lead) => lead.lifecycle_stage === 'lost'
|
|
86
|
+
).length;
|
|
87
|
+
const unassignedCount = crmMockLeads.filter(
|
|
88
|
+
(lead) => !lead.owner_user_id
|
|
89
|
+
).length;
|
|
90
|
+
const overdueFollowups = crmMockLeads.filter(
|
|
91
|
+
(lead) =>
|
|
92
|
+
lead.next_action_at &&
|
|
93
|
+
new Date(lead.next_action_at) < new Date('2026-03-16T00:00:00.000Z')
|
|
94
|
+
).length;
|
|
95
|
+
|
|
96
|
+
const totalDealValue = crmMockLeads.reduce(
|
|
97
|
+
(sum, lead) => sum + lead.dealValue,
|
|
98
|
+
0
|
|
99
|
+
);
|
|
100
|
+
const conversionRate = Math.round(
|
|
101
|
+
(customerCount / Math.max(crmMockLeads.length, 1)) * 100
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const stageChartData = crmStageOrder.map((stage, index) => ({
|
|
105
|
+
name: t(`stageLabels.${stage}`),
|
|
106
|
+
total: crmMockLeads.filter((lead) => lead.lifecycle_stage === stage).length,
|
|
107
|
+
fill: chartPalette[index % chartPalette.length],
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
const sourceChartData = crmSourceOrder.map((source, index) => ({
|
|
111
|
+
name: t(`sourceLabels.${source}`),
|
|
112
|
+
total: crmMockLeads.filter((lead) => lead.source === source).length,
|
|
113
|
+
fill: chartPalette[index % chartPalette.length],
|
|
114
|
+
}));
|
|
115
|
+
|
|
116
|
+
const ownerPerformanceData = crmOwners.map((owner) => {
|
|
117
|
+
const leads = crmMockLeads.filter(
|
|
118
|
+
(lead) => lead.owner_user_id === owner.id
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
name: owner.name,
|
|
123
|
+
leads: leads.length,
|
|
124
|
+
customers: leads.filter((lead) => lead.lifecycle_stage === 'customer')
|
|
125
|
+
.length,
|
|
126
|
+
pipeline: leads
|
|
127
|
+
.filter((lead) => lead.lifecycle_stage !== 'lost')
|
|
128
|
+
.reduce((sum, lead) => sum + lead.dealValue, 0),
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const nextActions = [...crmMockLeads]
|
|
133
|
+
.filter((lead) => lead.next_action_at)
|
|
134
|
+
.sort(
|
|
135
|
+
(left, right) =>
|
|
136
|
+
new Date(left.next_action_at ?? 0).getTime() -
|
|
137
|
+
new Date(right.next_action_at ?? 0).getTime()
|
|
138
|
+
)
|
|
139
|
+
.slice(0, 5);
|
|
140
|
+
|
|
141
|
+
const unattendedLeads = crmMockLeads
|
|
142
|
+
.filter((lead) => !lead.owner_user_id || lead.lifecycle_stage === 'new')
|
|
143
|
+
.slice(0, 5);
|
|
144
|
+
|
|
145
|
+
const topOwners = [...ownerPerformanceData]
|
|
146
|
+
.sort((left, right) => right.pipeline - left.pipeline)
|
|
147
|
+
.slice(0, 4);
|
|
148
|
+
|
|
149
|
+
const currencyFormatter = new Intl.NumberFormat(
|
|
150
|
+
currentLocaleCode === 'pt' ? 'pt-BR' : 'en-US',
|
|
151
|
+
{
|
|
152
|
+
style: 'currency',
|
|
153
|
+
currency: 'BRL',
|
|
154
|
+
maximumFractionDigits: 0,
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<Page>
|
|
160
|
+
<PageHeader
|
|
161
|
+
title={t('title')}
|
|
162
|
+
description={t('subtitle')}
|
|
163
|
+
breadcrumbs={[
|
|
164
|
+
{ label: t('breadcrumbs.home'), href: '/' },
|
|
165
|
+
{ label: t('breadcrumbs.crm') },
|
|
166
|
+
]}
|
|
167
|
+
actions={[
|
|
168
|
+
{
|
|
169
|
+
label: t('refresh'),
|
|
170
|
+
onClick: () => window.location.reload(),
|
|
171
|
+
variant: 'outline',
|
|
172
|
+
icon: <RefreshCcw className="size-4" />,
|
|
173
|
+
},
|
|
174
|
+
]}
|
|
175
|
+
/>
|
|
176
|
+
|
|
177
|
+
<div className="min-w-0 space-y-6 overflow-x-hidden">
|
|
178
|
+
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
|
179
|
+
{[
|
|
180
|
+
{ key: 'totalLeads', value: crmMockLeads.length, icon: TrendingUp },
|
|
181
|
+
{ key: 'qualified', value: qualifiedCount, icon: Target },
|
|
182
|
+
{ key: 'proposal', value: proposalCount, icon: BriefcaseBusiness },
|
|
183
|
+
{ key: 'customers', value: customerCount, icon: CircleDollarSign },
|
|
184
|
+
{ key: 'lost', value: lostCount, icon: AlertTriangle },
|
|
185
|
+
{ key: 'unassigned', value: unassignedCount, icon: UserRoundX },
|
|
186
|
+
{ key: 'overdue', value: overdueFollowups, icon: CalendarClock },
|
|
187
|
+
{
|
|
188
|
+
key: 'nextActions',
|
|
189
|
+
value: nextActions.length,
|
|
190
|
+
icon: ChartNoAxesCombined,
|
|
191
|
+
},
|
|
192
|
+
].map((item, index) => {
|
|
193
|
+
const sectionStyle =
|
|
194
|
+
crmImplementedSections[index % crmImplementedSections.length] ??
|
|
195
|
+
crmImplementedSections[0];
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<Card
|
|
199
|
+
key={item.key}
|
|
200
|
+
className="min-w-0 overflow-hidden border-border/70 py-0"
|
|
201
|
+
>
|
|
202
|
+
<div
|
|
203
|
+
className={`h-1 w-full bg-gradient-to-r ${sectionStyle?.colorClass ?? fallbackKpiAccentClass}`}
|
|
204
|
+
/>
|
|
205
|
+
<CardContent className="flex items-start justify-between gap-3 px-6 py-5">
|
|
206
|
+
<div className="min-w-0">
|
|
207
|
+
<p className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
|
208
|
+
{t(`kpis.${item.key}.title`)}
|
|
209
|
+
</p>
|
|
210
|
+
<p className="mt-2 text-3xl font-semibold tracking-tight">
|
|
211
|
+
{item.value}
|
|
212
|
+
</p>
|
|
213
|
+
<p className="mt-1 text-sm text-muted-foreground">
|
|
214
|
+
{t(`kpis.${item.key}.description`)}
|
|
215
|
+
</p>
|
|
216
|
+
</div>
|
|
217
|
+
<div className="rounded-2xl bg-muted p-3 text-muted-foreground">
|
|
218
|
+
<item.icon className="size-5" />
|
|
219
|
+
</div>
|
|
220
|
+
</CardContent>
|
|
221
|
+
</Card>
|
|
222
|
+
);
|
|
223
|
+
})}
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<div className="grid min-w-0 gap-6 xl:grid-cols-[minmax(0,1.2fr)_minmax(320px,0.8fr)]">
|
|
227
|
+
<Card className="min-w-0">
|
|
228
|
+
<CardHeader>
|
|
229
|
+
<CardTitle>{t('charts.stage.title')}</CardTitle>
|
|
230
|
+
<CardDescription>{t('charts.stage.description')}</CardDescription>
|
|
231
|
+
</CardHeader>
|
|
232
|
+
<CardContent className="h-[320px]">
|
|
233
|
+
<ResponsiveContainer width="100%" height="100%">
|
|
234
|
+
<BarChart data={stageChartData}>
|
|
235
|
+
<CartesianGrid
|
|
236
|
+
strokeDasharray="3 3"
|
|
237
|
+
stroke="hsl(var(--border))"
|
|
238
|
+
vertical={false}
|
|
239
|
+
/>
|
|
240
|
+
<XAxis
|
|
241
|
+
dataKey="name"
|
|
242
|
+
tickLine={false}
|
|
243
|
+
axisLine={false}
|
|
244
|
+
fontSize={12}
|
|
245
|
+
/>
|
|
246
|
+
<YAxis
|
|
247
|
+
tickLine={false}
|
|
248
|
+
axisLine={false}
|
|
249
|
+
fontSize={12}
|
|
250
|
+
allowDecimals={false}
|
|
251
|
+
/>
|
|
252
|
+
<Tooltip contentStyle={chartTooltipStyle} />
|
|
253
|
+
<Bar dataKey="total" radius={[8, 8, 0, 0]}>
|
|
254
|
+
{stageChartData.map((entry) => (
|
|
255
|
+
<Cell key={entry.name} fill={entry.fill} />
|
|
256
|
+
))}
|
|
257
|
+
</Bar>
|
|
258
|
+
</BarChart>
|
|
259
|
+
</ResponsiveContainer>
|
|
260
|
+
</CardContent>
|
|
261
|
+
</Card>
|
|
262
|
+
|
|
263
|
+
<Card className="min-w-0 overflow-hidden">
|
|
264
|
+
<CardHeader>
|
|
265
|
+
<CardTitle>{t('charts.source.title')}</CardTitle>
|
|
266
|
+
<CardDescription>
|
|
267
|
+
{t('charts.source.description')}
|
|
268
|
+
</CardDescription>
|
|
269
|
+
</CardHeader>
|
|
270
|
+
<CardContent className="grid min-w-0 gap-4 overflow-hidden lg:h-[320px] lg:grid-cols-[minmax(220px,0.9fr)_minmax(0,1fr)]">
|
|
271
|
+
<div className="h-[220px] min-w-0 lg:h-full">
|
|
272
|
+
<ResponsiveContainer width="100%" height="100%">
|
|
273
|
+
<PieChart>
|
|
274
|
+
<Pie
|
|
275
|
+
data={sourceChartData}
|
|
276
|
+
dataKey="total"
|
|
277
|
+
nameKey="name"
|
|
278
|
+
innerRadius={58}
|
|
279
|
+
outerRadius={94}
|
|
280
|
+
paddingAngle={2}
|
|
281
|
+
>
|
|
282
|
+
{sourceChartData.map((entry) => (
|
|
283
|
+
<Cell key={entry.name} fill={entry.fill} />
|
|
284
|
+
))}
|
|
285
|
+
</Pie>
|
|
286
|
+
<Tooltip contentStyle={chartTooltipStyle} />
|
|
287
|
+
</PieChart>
|
|
288
|
+
</ResponsiveContainer>
|
|
289
|
+
</div>
|
|
290
|
+
<ScrollArea className="min-w-0 lg:h-full">
|
|
291
|
+
<div className="space-y-3 lg:pr-3">
|
|
292
|
+
{sourceChartData.map((item) => (
|
|
293
|
+
<div
|
|
294
|
+
key={item.name}
|
|
295
|
+
className="flex min-w-0 items-center justify-between gap-3 rounded-2xl border border-border/70 px-4 py-3"
|
|
296
|
+
>
|
|
297
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
298
|
+
<span
|
|
299
|
+
className="inline-block size-3 rounded-full"
|
|
300
|
+
style={{ backgroundColor: item.fill }}
|
|
301
|
+
/>
|
|
302
|
+
<span className="truncate font-medium">
|
|
303
|
+
{item.name}
|
|
304
|
+
</span>
|
|
305
|
+
</div>
|
|
306
|
+
<span className="shrink-0 text-sm text-muted-foreground">
|
|
307
|
+
{item.total}
|
|
308
|
+
</span>
|
|
309
|
+
</div>
|
|
310
|
+
))}
|
|
311
|
+
</div>
|
|
312
|
+
</ScrollArea>
|
|
313
|
+
</CardContent>
|
|
314
|
+
</Card>
|
|
315
|
+
</div>
|
|
316
|
+
|
|
317
|
+
<div className="grid min-w-0 gap-6 xl:grid-cols-[minmax(0,1.1fr)_minmax(320px,0.9fr)]">
|
|
318
|
+
<Card className="min-w-0">
|
|
319
|
+
<CardHeader>
|
|
320
|
+
<CardTitle>{t('charts.owner.title')}</CardTitle>
|
|
321
|
+
<CardDescription>{t('charts.owner.description')}</CardDescription>
|
|
322
|
+
</CardHeader>
|
|
323
|
+
<CardContent className="h-[320px]">
|
|
324
|
+
<ResponsiveContainer width="100%" height="100%">
|
|
325
|
+
<BarChart data={ownerPerformanceData}>
|
|
326
|
+
<CartesianGrid
|
|
327
|
+
strokeDasharray="3 3"
|
|
328
|
+
stroke="hsl(var(--border))"
|
|
329
|
+
vertical={false}
|
|
330
|
+
/>
|
|
331
|
+
<XAxis
|
|
332
|
+
dataKey="name"
|
|
333
|
+
tickLine={false}
|
|
334
|
+
axisLine={false}
|
|
335
|
+
fontSize={12}
|
|
336
|
+
/>
|
|
337
|
+
<YAxis
|
|
338
|
+
tickLine={false}
|
|
339
|
+
axisLine={false}
|
|
340
|
+
fontSize={12}
|
|
341
|
+
allowDecimals={false}
|
|
342
|
+
/>
|
|
343
|
+
<Tooltip contentStyle={chartTooltipStyle} />
|
|
344
|
+
<Bar dataKey="leads" fill="#f97316" radius={[8, 8, 0, 0]} />
|
|
345
|
+
<Bar
|
|
346
|
+
dataKey="customers"
|
|
347
|
+
fill="#0ea5e9"
|
|
348
|
+
radius={[8, 8, 0, 0]}
|
|
349
|
+
/>
|
|
350
|
+
</BarChart>
|
|
351
|
+
</ResponsiveContainer>
|
|
352
|
+
</CardContent>
|
|
353
|
+
</Card>
|
|
354
|
+
|
|
355
|
+
<Card className="min-w-0 overflow-hidden">
|
|
356
|
+
<CardHeader>
|
|
357
|
+
<CardTitle>{t('bestOwners.title')}</CardTitle>
|
|
358
|
+
<CardDescription>{t('bestOwners.description')}</CardDescription>
|
|
359
|
+
</CardHeader>
|
|
360
|
+
<CardContent>
|
|
361
|
+
<div className="space-y-3">
|
|
362
|
+
{topOwners.map((owner, index) => (
|
|
363
|
+
<div
|
|
364
|
+
key={owner.name}
|
|
365
|
+
className="flex min-w-0 items-center justify-between gap-3 rounded-2xl border border-border/70 px-4 py-3"
|
|
366
|
+
>
|
|
367
|
+
<div className="min-w-0">
|
|
368
|
+
<p className="truncate font-medium">
|
|
369
|
+
{index + 1}. {owner.name}
|
|
370
|
+
</p>
|
|
371
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
372
|
+
{t('bestOwners.meta', {
|
|
373
|
+
leads: owner.leads,
|
|
374
|
+
customers: owner.customers,
|
|
375
|
+
})}
|
|
376
|
+
</p>
|
|
377
|
+
</div>
|
|
378
|
+
<span className="shrink-0 text-sm font-medium text-foreground">
|
|
379
|
+
{currencyFormatter.format(owner.pipeline)}
|
|
380
|
+
</span>
|
|
381
|
+
</div>
|
|
382
|
+
))}
|
|
383
|
+
</div>
|
|
384
|
+
</CardContent>
|
|
385
|
+
</Card>
|
|
386
|
+
</div>
|
|
387
|
+
|
|
388
|
+
<div className="grid gap-6 xl:grid-cols-3">
|
|
389
|
+
<Card className="min-w-0 overflow-hidden xl:col-span-1">
|
|
390
|
+
<CardHeader>
|
|
391
|
+
<CardTitle>{t('blocks.nextActions.title')}</CardTitle>
|
|
392
|
+
<CardDescription>
|
|
393
|
+
{t('blocks.nextActions.description')}
|
|
394
|
+
</CardDescription>
|
|
395
|
+
</CardHeader>
|
|
396
|
+
<CardContent>
|
|
397
|
+
<ScrollArea className="h-[320px] pr-3">
|
|
398
|
+
<div className="space-y-3">
|
|
399
|
+
{nextActions.map((lead) => (
|
|
400
|
+
<div
|
|
401
|
+
key={lead.id}
|
|
402
|
+
className="rounded-2xl border border-border/70 px-4 py-3"
|
|
403
|
+
>
|
|
404
|
+
<p className="font-medium">{lead.name}</p>
|
|
405
|
+
<p className="text-xs text-muted-foreground">
|
|
406
|
+
{lead.owner_user?.name || t('common.unassigned')}
|
|
407
|
+
</p>
|
|
408
|
+
<div className="mt-2 flex flex-wrap gap-2">
|
|
409
|
+
<Badge variant="outline">
|
|
410
|
+
{t(`stageLabels.${lead.lifecycle_stage ?? 'new'}`)}
|
|
411
|
+
</Badge>
|
|
412
|
+
<Badge variant="secondary">
|
|
413
|
+
{t(`sourceLabels.${lead.source ?? 'other'}`)}
|
|
414
|
+
</Badge>
|
|
415
|
+
</div>
|
|
416
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
417
|
+
{t('blocks.nextActions.when', {
|
|
418
|
+
date: new Date(
|
|
419
|
+
lead.next_action_at ?? ''
|
|
420
|
+
).toLocaleString(),
|
|
421
|
+
})}
|
|
422
|
+
</p>
|
|
423
|
+
</div>
|
|
424
|
+
))}
|
|
425
|
+
</div>
|
|
426
|
+
</ScrollArea>
|
|
427
|
+
</CardContent>
|
|
428
|
+
</Card>
|
|
429
|
+
|
|
430
|
+
<Card className="min-w-0 overflow-hidden xl:col-span-1">
|
|
431
|
+
<CardHeader>
|
|
432
|
+
<CardTitle>{t('blocks.unattended.title')}</CardTitle>
|
|
433
|
+
<CardDescription>
|
|
434
|
+
{t('blocks.unattended.description')}
|
|
435
|
+
</CardDescription>
|
|
436
|
+
</CardHeader>
|
|
437
|
+
<CardContent>
|
|
438
|
+
<ScrollArea className="h-[320px] pr-3">
|
|
439
|
+
<div className="space-y-3">
|
|
440
|
+
{unattendedLeads.map((lead) => (
|
|
441
|
+
<div
|
|
442
|
+
key={lead.id}
|
|
443
|
+
className="rounded-2xl border border-border/70 px-4 py-3"
|
|
444
|
+
>
|
|
445
|
+
<p className="font-medium">{lead.name}</p>
|
|
446
|
+
<p className="text-xs text-muted-foreground">
|
|
447
|
+
{lead.owner_user?.name || t('common.unassigned')}
|
|
448
|
+
</p>
|
|
449
|
+
<p className="mt-2 text-sm text-muted-foreground">
|
|
450
|
+
{t('blocks.unattended.meta', {
|
|
451
|
+
stage: t(
|
|
452
|
+
`stageLabels.${lead.lifecycle_stage ?? 'new'}`
|
|
453
|
+
),
|
|
454
|
+
source: t(`sourceLabels.${lead.source ?? 'other'}`),
|
|
455
|
+
})}
|
|
456
|
+
</p>
|
|
457
|
+
</div>
|
|
458
|
+
))}
|
|
459
|
+
</div>
|
|
460
|
+
</ScrollArea>
|
|
461
|
+
</CardContent>
|
|
462
|
+
</Card>
|
|
463
|
+
|
|
464
|
+
<Card className="min-w-0 overflow-hidden xl:col-span-1">
|
|
465
|
+
<CardHeader>
|
|
466
|
+
<CardTitle>{t('blocks.quickAccess.title')}</CardTitle>
|
|
467
|
+
<CardDescription>
|
|
468
|
+
{t('blocks.quickAccess.description')}
|
|
469
|
+
</CardDescription>
|
|
470
|
+
</CardHeader>
|
|
471
|
+
<CardContent className="space-y-3">
|
|
472
|
+
{crmImplementedSections.map((section) => {
|
|
473
|
+
const Icon = section.icon;
|
|
474
|
+
|
|
475
|
+
return (
|
|
476
|
+
<Link
|
|
477
|
+
key={section.href}
|
|
478
|
+
href={section.href}
|
|
479
|
+
className="flex min-w-0 items-center justify-between gap-3 rounded-2xl border border-border/70 px-4 py-3 transition-colors hover:bg-muted/40"
|
|
480
|
+
>
|
|
481
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
482
|
+
<div className={`rounded-2xl p-3 ${section.glowClass}`}>
|
|
483
|
+
<Icon className="size-4" />
|
|
484
|
+
</div>
|
|
485
|
+
<div className="min-w-0">
|
|
486
|
+
<p className="truncate font-medium">
|
|
487
|
+
{menuT(`sections.${section.translationKey}.title`)}
|
|
488
|
+
</p>
|
|
489
|
+
<p className="truncate text-xs text-muted-foreground">
|
|
490
|
+
{menuT(
|
|
491
|
+
`sections.${section.translationKey}.description`
|
|
492
|
+
)}
|
|
493
|
+
</p>
|
|
494
|
+
</div>
|
|
495
|
+
</div>
|
|
496
|
+
<ArrowUpRight className="size-4 shrink-0 text-muted-foreground" />
|
|
497
|
+
</Link>
|
|
498
|
+
);
|
|
499
|
+
})}
|
|
500
|
+
</CardContent>
|
|
501
|
+
</Card>
|
|
502
|
+
</div>
|
|
503
|
+
</div>
|
|
504
|
+
</Page>
|
|
505
|
+
);
|
|
506
|
+
}
|