@fayz-ai/plugin-crm 0.9.0 → 0.9.1
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 +3 -3
- package/dist/components/AutomationBolt.d.ts +22 -0
- package/dist/components/AutomationBolt.d.ts.map +1 -0
- package/dist/{CrmContext.d.ts → context.d.ts} +4 -2
- package/dist/context.d.ts.map +1 -0
- package/dist/data/registries.d.ts.map +1 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +573 -488
- package/dist/index.js.map +1 -1
- package/dist/{cascade.d.ts → lib/cascade.d.ts} +1 -1
- package/dist/lib/cascade.d.ts.map +1 -0
- package/dist/lib/message-events.d.ts +13 -0
- package/dist/lib/message-events.d.ts.map +1 -0
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/public/context.d.ts +1 -1
- package/dist/public/context.d.ts.map +1 -1
- package/dist/public/createPublicFormsPlugin.d.ts +1 -1
- package/dist/public/createPublicFormsPlugin.d.ts.map +1 -1
- package/dist/public/{data.supabase.d.ts → data/supabase.d.ts} +2 -2
- package/dist/public/data/supabase.d.ts.map +1 -0
- package/dist/public/index.d.ts +6 -6
- package/dist/public/index.d.ts.map +1 -1
- package/dist/public/index.js +2 -2
- package/dist/public/index.js.map +1 -1
- package/dist/public/{inbox.d.ts → lib/inbox.d.ts} +1 -1
- package/dist/public/lib/inbox.d.ts.map +1 -0
- package/dist/public/{uploads.d.ts → lib/uploads.d.ts} +1 -1
- package/dist/public/lib/uploads.d.ts.map +1 -0
- package/dist/store.d.ts +9 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/views/ActivityListView.d.ts.map +1 -1
- package/dist/{CrmPage.d.ts → views/CrmPage.d.ts} +3 -3
- package/dist/views/CrmPage.d.ts.map +1 -0
- package/dist/views/DealSidebar.d.ts.map +1 -1
- package/dist/views/LeadListView.d.ts.map +1 -1
- package/dist/views/PipelineView.d.ts +3 -1
- package/dist/views/PipelineView.d.ts.map +1 -1
- package/dist/views/QuoteDetailView.d.ts.map +1 -1
- package/dist/views/QuoteFormView.d.ts.map +1 -1
- package/dist/views/QuoteListView.d.ts.map +1 -1
- package/dist/views/dashboardWidgets.d.ts +1 -1
- package/dist/views/dashboardWidgets.d.ts.map +1 -1
- package/package.json +6 -10
- package/dist/CrmContext.d.ts.map +0 -1
- package/dist/CrmPage.d.ts.map +0 -1
- package/dist/cascade.d.ts.map +0 -1
- package/dist/public/data.supabase.d.ts.map +0 -1
- package/dist/public/inbox.d.ts.map +0 -1
- package/dist/public/uploads.d.ts.map +0 -1
- package/dist/registries.d.ts.map +0 -1
- package/src/CrmContext.tsx +0 -30
- package/src/CrmPage.tsx +0 -150
- package/src/README.md +0 -97
- package/src/cascade.ts +0 -26
- package/src/components/BoardFilters.tsx +0 -190
- package/src/components/CrmGeneralSettings.tsx +0 -56
- package/src/components/CrmOnboarding.tsx +0 -52
- package/src/components/LeadAttachments.tsx +0 -140
- package/src/components/PipelineSettings.tsx +0 -45
- package/src/components/QuoteStatusDropdown.tsx +0 -226
- package/src/components/TagChips.tsx +0 -80
- package/src/data/index.ts +0 -2
- package/src/data/mock.ts +0 -559
- package/src/data/supabase.ts +0 -928
- package/src/data/tables.ts +0 -11
- package/src/data/types.ts +0 -61
- package/src/index.ts +0 -429
- package/src/lib/access.ts +0 -11
- package/src/lib/form-answers.tsx +0 -80
- package/src/lib/relative-time.ts +0 -84
- package/src/lib/tenant.ts +0 -4
- package/src/locales/en.ts +0 -307
- package/src/locales/index.ts +0 -7
- package/src/locales/pt-BR.ts +0 -307
- package/src/migrations/000_plg_rename.sql +0 -28
- package/src/migrations/001_crm_base.sql +0 -73
- package/src/migrations/002_activities.sql +0 -33
- package/src/migrations/003_crm_views_rls.sql +0 -69
- package/src/migrations/004_seed_default_pipeline.sql +0 -31
- package/src/migrations/005_public_lead.sql +0 -189
- package/src/migrations/006_lead_enters_pipeline.sql +0 -265
- package/src/migrations/007_activity_log.sql +0 -55
- package/src/migrations/008_view_field_aliases.sql +0 -43
- package/src/migrations/009_deal_archived_status.sql +0 -30
- package/src/migrations/010_quote_archived_status.sql +0 -40
- package/src/migrations/011_agent_rpc_update_lead.sql +0 -153
- package/src/migrations/012_agent_rpc_create_lead.sql +0 -128
- package/src/migrations/013_tag_slugs.sql +0 -177
- package/src/migrations/014_public_lead_tags.sql +0 -172
- package/src/migrations/015_lead_attachments.sql +0 -357
- package/src/migrations/016_public_lead_activity.sql +0 -123
- package/src/migrations/index.ts +0 -2023
- package/src/public/context.tsx +0 -150
- package/src/public/createPublicFormsPlugin.ts +0 -282
- package/src/public/data.supabase.ts +0 -92
- package/src/public/inbox.ts +0 -143
- package/src/public/index.ts +0 -51
- package/src/public/types.ts +0 -173
- package/src/public/uploads.ts +0 -205
- package/src/registries.ts +0 -162
- package/src/schema/index.ts +0 -104
- package/src/store.ts +0 -472
- package/src/types.ts +0 -337
- package/src/views/ActivityListView.tsx +0 -264
- package/src/views/DashboardView.tsx +0 -12
- package/src/views/DealSidebar.tsx +0 -482
- package/src/views/LeadDetailView.tsx +0 -378
- package/src/views/LeadFormView.tsx +0 -66
- package/src/views/LeadListView.tsx +0 -100
- package/src/views/PipelineView.tsx +0 -446
- package/src/views/QuoteDetailView.tsx +0 -412
- package/src/views/QuoteFormView.tsx +0 -494
- package/src/views/QuoteListView.tsx +0 -115
- package/src/views/dashboardWidgets.tsx +0 -248
- /package/dist/{registries.d.ts → data/registries.d.ts} +0 -0
package/src/types.ts
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// CRM/Sales Plugin — Pure TypeScript types
|
|
3
|
-
// Zero dependencies. Generic CRM abstracted from beautyplace.
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
5
|
-
|
|
6
|
-
// ============================================================
|
|
7
|
-
// ENUMS / LITERALS
|
|
8
|
-
// ============================================================
|
|
9
|
-
|
|
10
|
-
export type LeadStatus = 'new' | 'contacted' | 'qualified' | 'unqualified' | 'converted' | 'lost'
|
|
11
|
-
export type DealStatus = 'open' | 'won' | 'lost' | 'archived'
|
|
12
|
-
export type QuoteStatus = 'draft' | 'sent' | 'approved' | 'rejected' | 'expired' | 'archived'
|
|
13
|
-
export type ActivityType = 'call' | 'email' | 'meeting' | 'note' | 'task' | 'whatsapp' | (string & {})
|
|
14
|
-
|
|
15
|
-
/** System timeline events auto-logged by the data provider at every CRM write.
|
|
16
|
-
* Product-defined (not tenant-editable); manual interaction TYPES live in the
|
|
17
|
-
* activity-types registry and are editable in settings. */
|
|
18
|
-
export const SYSTEM_ACTIVITY_TYPES = [
|
|
19
|
-
'lead_created', 'lead_converted', 'lead_archived', 'deal_created', 'stage_changed',
|
|
20
|
-
'deal_won', 'deal_lost', 'deal_archived', 'quote_created', 'quote_sent', 'quote_approved', 'quote_rejected', 'quote_archived',
|
|
21
|
-
] as const
|
|
22
|
-
export type SystemActivityType = (typeof SYSTEM_ACTIVITY_TYPES)[number]
|
|
23
|
-
|
|
24
|
-
/** A tenant-editable manual interaction type (activity-types registry row). */
|
|
25
|
-
export interface ActivityTypeDef {
|
|
26
|
-
id: string
|
|
27
|
-
name: string
|
|
28
|
-
icon?: string
|
|
29
|
-
isActive: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Uma tag do cadastro (plg_crm_tags).
|
|
34
|
-
*
|
|
35
|
-
* `slug` é o contrato: é isso que vive em Lead.tags / Deal.tags. `name` e
|
|
36
|
-
* `color` são só apresentação, e por isso renomear uma tag no cadastro não
|
|
37
|
-
* toca em nenhum registro.
|
|
38
|
-
*
|
|
39
|
-
* Um slug SEM linha de cadastro continua sendo uma tag válida — a UI mostra o
|
|
40
|
-
* slug humanizado num chip neutro. É o que deixa uma campanha marcar leads hoje
|
|
41
|
-
* sem esperar alguém cadastrar a tag antes.
|
|
42
|
-
*/
|
|
43
|
-
export interface TagDef {
|
|
44
|
-
id: string
|
|
45
|
-
slug: string
|
|
46
|
-
name: string
|
|
47
|
-
color?: string
|
|
48
|
-
isActive: boolean
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// ============================================================
|
|
52
|
-
// CORE ENTITIES
|
|
53
|
-
// ============================================================
|
|
54
|
-
|
|
55
|
-
export interface Pipeline {
|
|
56
|
-
id: string
|
|
57
|
-
name: string
|
|
58
|
-
isDefault: boolean
|
|
59
|
-
isActive: boolean
|
|
60
|
-
tenantId: string
|
|
61
|
-
createdAt: string
|
|
62
|
-
updatedAt: string
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface PipelineStage {
|
|
66
|
-
id: string
|
|
67
|
-
pipelineId: string
|
|
68
|
-
name: string
|
|
69
|
-
order: number
|
|
70
|
-
color: string
|
|
71
|
-
probability: number
|
|
72
|
-
isWon: boolean
|
|
73
|
-
isLost: boolean
|
|
74
|
-
tenantId: string
|
|
75
|
-
createdAt: string
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface Lead {
|
|
79
|
-
id: string
|
|
80
|
-
name: string
|
|
81
|
-
email?: string
|
|
82
|
-
phone?: string
|
|
83
|
-
company?: string
|
|
84
|
-
sourceId?: string
|
|
85
|
-
sourceName?: string
|
|
86
|
-
status: LeadStatus
|
|
87
|
-
assignedToId?: string
|
|
88
|
-
assignedToName?: string
|
|
89
|
-
pipelineId?: string
|
|
90
|
-
stageId?: string
|
|
91
|
-
stageName?: string
|
|
92
|
-
value?: number
|
|
93
|
-
tags: string[]
|
|
94
|
-
notes?: string
|
|
95
|
-
metadata?: Record<string, unknown>
|
|
96
|
-
tenantId: string
|
|
97
|
-
createdAt: string
|
|
98
|
-
updatedAt: string
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface Deal {
|
|
102
|
-
id: string
|
|
103
|
-
leadId?: string
|
|
104
|
-
title: string
|
|
105
|
-
value: number
|
|
106
|
-
pipelineId: string
|
|
107
|
-
stageId: string
|
|
108
|
-
stageName?: string
|
|
109
|
-
stageColor?: string
|
|
110
|
-
probability: number
|
|
111
|
-
expectedCloseDate?: string
|
|
112
|
-
assignedToId?: string
|
|
113
|
-
assignedToName?: string
|
|
114
|
-
contactId?: string
|
|
115
|
-
contactName?: string
|
|
116
|
-
status: DealStatus
|
|
117
|
-
lostReason?: string
|
|
118
|
-
tags: string[]
|
|
119
|
-
notes?: string
|
|
120
|
-
metadata?: Record<string, unknown>
|
|
121
|
-
tenantId: string
|
|
122
|
-
createdAt: string
|
|
123
|
-
updatedAt: string
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export interface Activity {
|
|
127
|
-
id: string
|
|
128
|
-
dealId?: string
|
|
129
|
-
leadId?: string
|
|
130
|
-
contactId?: string
|
|
131
|
-
contactName?: string
|
|
132
|
-
activityType: ActivityType
|
|
133
|
-
title: string
|
|
134
|
-
description?: string
|
|
135
|
-
dueDate?: string
|
|
136
|
-
completedAt?: string
|
|
137
|
-
assignedToId?: string
|
|
138
|
-
assignedToName?: string
|
|
139
|
-
tenantId: string
|
|
140
|
-
createdAt: string
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export interface Quote {
|
|
144
|
-
id: string
|
|
145
|
-
dealId?: string
|
|
146
|
-
leadId?: string
|
|
147
|
-
contactId?: string
|
|
148
|
-
contactName?: string
|
|
149
|
-
quoteNumber: string
|
|
150
|
-
quoteDate: string
|
|
151
|
-
validUntil: string
|
|
152
|
-
status: QuoteStatus
|
|
153
|
-
totalAmount: number
|
|
154
|
-
observations?: string
|
|
155
|
-
paymentConditions?: string
|
|
156
|
-
rejectionReason?: string
|
|
157
|
-
convertedInvoiceId?: string
|
|
158
|
-
items: QuoteItem[]
|
|
159
|
-
tenantId: string
|
|
160
|
-
createdAt: string
|
|
161
|
-
updatedAt: string
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export interface QuoteItem {
|
|
165
|
-
id: string
|
|
166
|
-
quoteId: string
|
|
167
|
-
itemKind: string
|
|
168
|
-
description: string
|
|
169
|
-
quantity: number
|
|
170
|
-
unitPrice: number
|
|
171
|
-
discount: number
|
|
172
|
-
totalAmount: number
|
|
173
|
-
referenceId?: string
|
|
174
|
-
createdAt: string
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface LeadSource {
|
|
178
|
-
id: string
|
|
179
|
-
name: string
|
|
180
|
-
isActive: boolean
|
|
181
|
-
tenantId: string
|
|
182
|
-
createdAt: string
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export interface Tag {
|
|
186
|
-
id: string
|
|
187
|
-
name: string
|
|
188
|
-
color: string
|
|
189
|
-
tenantId: string
|
|
190
|
-
createdAt: string
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// ============================================================
|
|
194
|
-
// INPUT TYPES
|
|
195
|
-
// ============================================================
|
|
196
|
-
|
|
197
|
-
export interface CreateLeadInput {
|
|
198
|
-
name: string
|
|
199
|
-
email?: string
|
|
200
|
-
phone?: string
|
|
201
|
-
company?: string
|
|
202
|
-
sourceId?: string
|
|
203
|
-
value?: number
|
|
204
|
-
notes?: string
|
|
205
|
-
tags?: string[]
|
|
206
|
-
assignedToId?: string
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export interface CreateDealInput {
|
|
210
|
-
leadId?: string
|
|
211
|
-
title: string
|
|
212
|
-
value: number
|
|
213
|
-
pipelineId: string
|
|
214
|
-
stageId: string
|
|
215
|
-
expectedCloseDate?: string
|
|
216
|
-
contactId?: string
|
|
217
|
-
contactName?: string
|
|
218
|
-
assignedToId?: string
|
|
219
|
-
notes?: string
|
|
220
|
-
tags?: string[]
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
export interface CreateActivityInput {
|
|
224
|
-
dealId?: string
|
|
225
|
-
leadId?: string
|
|
226
|
-
contactId?: string
|
|
227
|
-
activityType: ActivityType
|
|
228
|
-
title: string
|
|
229
|
-
description?: string
|
|
230
|
-
dueDate?: string
|
|
231
|
-
assignedToId?: string
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export interface CreateQuoteInput {
|
|
235
|
-
dealId?: string
|
|
236
|
-
leadId?: string
|
|
237
|
-
contactId?: string
|
|
238
|
-
contactName?: string
|
|
239
|
-
quoteDate: string
|
|
240
|
-
validUntil: string
|
|
241
|
-
observations?: string
|
|
242
|
-
paymentConditions?: string
|
|
243
|
-
items: Omit<QuoteItem, 'id' | 'quoteId' | 'createdAt'>[]
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// ============================================================
|
|
247
|
-
// QUERY TYPES
|
|
248
|
-
// ============================================================
|
|
249
|
-
|
|
250
|
-
export interface DateRange { from: string; to: string }
|
|
251
|
-
|
|
252
|
-
export interface LeadQuery {
|
|
253
|
-
status?: LeadStatus | LeadStatus[]
|
|
254
|
-
sourceId?: string
|
|
255
|
-
search?: string
|
|
256
|
-
page?: number
|
|
257
|
-
pageSize?: number
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export interface DealQuery {
|
|
261
|
-
pipelineId?: string
|
|
262
|
-
stageId?: string
|
|
263
|
-
status?: DealStatus | DealStatus[]
|
|
264
|
-
assignedToId?: string
|
|
265
|
-
search?: string
|
|
266
|
-
page?: number
|
|
267
|
-
pageSize?: number
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/** Presets de período do funil. `custom` usa `createdFrom`/`createdTo`. */
|
|
271
|
-
export type BoardPeriod = 'all' | '24h' | '7d' | 'custom'
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Filtro do quadro do funil.
|
|
275
|
-
*
|
|
276
|
-
* Vazio = quadro inteiro, que é o estado em que ele abre. Um funil filtrado por
|
|
277
|
-
* padrão esconde negócio sem avisar, e a pessoa conclui que o card sumiu.
|
|
278
|
-
*/
|
|
279
|
-
export interface BoardFilter {
|
|
280
|
-
/**
|
|
281
|
-
* Slugs. Semântica OU: marcar duas tags mostra quem tem QUALQUER uma delas.
|
|
282
|
-
* É o que um multi-select de chips dá a entender ("me mostra estes
|
|
283
|
-
* segmentos"); E seria uma interseção que quase sempre volta vazia.
|
|
284
|
-
*/
|
|
285
|
-
tags?: string[]
|
|
286
|
-
/** ISO. Filtram por `created_at` do negócio. */
|
|
287
|
-
createdFrom?: string
|
|
288
|
-
createdTo?: string
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
export interface ActivityQuery {
|
|
292
|
-
dealId?: string
|
|
293
|
-
leadId?: string
|
|
294
|
-
activityType?: ActivityType
|
|
295
|
-
completed?: boolean
|
|
296
|
-
dateRange?: DateRange
|
|
297
|
-
page?: number
|
|
298
|
-
pageSize?: number
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export interface QuoteQuery {
|
|
302
|
-
status?: QuoteStatus | QuoteStatus[]
|
|
303
|
-
contactId?: string
|
|
304
|
-
search?: string
|
|
305
|
-
page?: number
|
|
306
|
-
pageSize?: number
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export interface PaginatedResult<T> {
|
|
310
|
-
data: T[]
|
|
311
|
-
total: number
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// ============================================================
|
|
315
|
-
// AGGREGATION
|
|
316
|
-
// ============================================================
|
|
317
|
-
|
|
318
|
-
export interface CrmSummary {
|
|
319
|
-
totalLeads: number
|
|
320
|
-
newLeadsThisMonth: number
|
|
321
|
-
totalDeals: number
|
|
322
|
-
openDealsValue: number
|
|
323
|
-
wonDealsThisMonth: number
|
|
324
|
-
wonDealsValueThisMonth: number
|
|
325
|
-
conversionRate: number
|
|
326
|
-
averageDealValue: number
|
|
327
|
-
pendingActivities: number
|
|
328
|
-
overdueActivities: number
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
export interface FunnelStage {
|
|
332
|
-
stageId: string
|
|
333
|
-
stageName: string
|
|
334
|
-
stageColor: string
|
|
335
|
-
dealCount: number
|
|
336
|
-
totalValue: number
|
|
337
|
-
}
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Phone, Mail, Users, FileText, CheckSquare, MessageCircle, Check, Clock, Filter, Calendar,
|
|
4
|
-
UserPlus, ArrowRightLeft, Target, MoveRight, Trophy, XCircle, FilePlus2, Send, FileCheck2, FileX2, Sparkles, ArrowRight, Archive,
|
|
5
|
-
} from 'lucide-react'
|
|
6
|
-
import { useCrmStore, useCrmProvider, useCrmConfig } from '../CrmContext'
|
|
7
|
-
import { useTranslation } from '@fayz-ai/core'
|
|
8
|
-
import { SubpageHeader } from '@fayz-ai/ui'
|
|
9
|
-
import { DealSidebar } from './DealSidebar'
|
|
10
|
-
import { formatDateTime, formatRelativeTime } from '../lib/relative-time'
|
|
11
|
-
import { SYSTEM_ACTIVITY_TYPES, type ActivityType } from '../types'
|
|
12
|
-
|
|
13
|
-
const TYPE_CONFIG: Record<string, { icon: React.ElementType; color: string; label: string }> = {
|
|
14
|
-
call: { icon: Phone, color: 'bg-info/15 text-info dark:bg-info/20', label: 'Call' },
|
|
15
|
-
email: { icon: Mail, color: 'bg-magic/15 text-magic dark:bg-magic/20', label: 'Email' },
|
|
16
|
-
meeting: { icon: Users, color: 'bg-success-soft text-success-soft-foreground', label: 'Meeting' },
|
|
17
|
-
note: { icon: FileText, color: 'bg-warning/15 text-warning dark:bg-warning/20', label: 'Note' },
|
|
18
|
-
task: { icon: CheckSquare, color: 'bg-pink-100 text-pink-600 dark:bg-pink-500/20 dark:text-pink-400', label: 'Task' },
|
|
19
|
-
whatsapp: { icon: MessageCircle, color: 'bg-success/15 text-success dark:bg-success/20', label: 'WhatsApp' },
|
|
20
|
-
// System timeline events (auto-logged by the data provider on every CRM write)
|
|
21
|
-
lead_created: { icon: UserPlus, color: 'bg-info/15 text-info dark:bg-info/20', label: 'Lead created' },
|
|
22
|
-
lead_converted: { icon: ArrowRightLeft, color: 'bg-magic/15 text-magic dark:bg-magic/20', label: 'Lead converted' },
|
|
23
|
-
deal_created: { icon: Target, color: 'bg-info/15 text-info dark:bg-info/20', label: 'Deal created' },
|
|
24
|
-
stage_changed: { icon: MoveRight, color: 'bg-warning/15 text-warning dark:bg-warning/20', label: 'Stage changed' },
|
|
25
|
-
deal_won: { icon: Trophy, color: 'bg-success/15 text-success dark:bg-success/20', label: 'Deal won' },
|
|
26
|
-
deal_lost: { icon: XCircle, color: 'bg-destructive/15 text-destructive dark:bg-destructive/20', label: 'Deal lost' },
|
|
27
|
-
quote_created: { icon: FilePlus2, color: 'bg-info/15 text-info dark:bg-info/20', label: 'Quote created' },
|
|
28
|
-
quote_sent: { icon: Send, color: 'bg-magic/15 text-magic dark:bg-magic/20', label: 'Quote sent' },
|
|
29
|
-
quote_approved: { icon: FileCheck2, color: 'bg-success/15 text-success dark:bg-success/20', label: 'Quote approved' },
|
|
30
|
-
quote_rejected: { icon: FileX2, color: 'bg-destructive/15 text-destructive dark:bg-destructive/20', label: 'Quote rejected' },
|
|
31
|
-
lead_archived: { icon: Archive, color: 'bg-muted text-muted-foreground', label: 'Lead archived' },
|
|
32
|
-
deal_archived: { icon: Archive, color: 'bg-muted text-muted-foreground', label: 'Deal archived' },
|
|
33
|
-
quote_archived: { icon: Archive, color: 'bg-muted text-muted-foreground', label: 'Quote archived' },
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const SYSTEM_TYPES = new Set<string>(SYSTEM_ACTIVITY_TYPES)
|
|
37
|
-
const MANUAL_TYPES = Object.keys(TYPE_CONFIG).filter((t) => !SYSTEM_TYPES.has(t))
|
|
38
|
-
|
|
39
|
-
function ActivitySkeleton() {
|
|
40
|
-
return (
|
|
41
|
-
<div className="space-y-2">
|
|
42
|
-
{[1, 2, 3, 4, 5].map((i) => (
|
|
43
|
-
<div key={i} className="flex items-start gap-3 rounded-lg border bg-card shadow-sm p-4">
|
|
44
|
-
<div className="h-9 w-9 rounded-lg bg-muted/40 animate-pulse shrink-0" />
|
|
45
|
-
<div className="flex-1 space-y-2 pt-0.5">
|
|
46
|
-
<div className="flex items-center gap-2">
|
|
47
|
-
<div className="h-3.5 w-32 rounded bg-muted/40 animate-pulse" />
|
|
48
|
-
<div className="h-4 w-12 rounded-full bg-muted/30 animate-pulse" />
|
|
49
|
-
</div>
|
|
50
|
-
<div className="h-3 w-48 rounded bg-muted/30 animate-pulse" />
|
|
51
|
-
<div className="h-2.5 w-24 rounded bg-muted/20 animate-pulse" />
|
|
52
|
-
</div>
|
|
53
|
-
<div className="h-3 w-16 rounded bg-muted/30 animate-pulse shrink-0" />
|
|
54
|
-
</div>
|
|
55
|
-
))}
|
|
56
|
-
</div>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function ActivityListView({ onOpenLead, onOpenQuote }: {
|
|
61
|
-
/** Navigate to the lead detail (fallback for activities with no deal behind them). */
|
|
62
|
-
onOpenLead?: (leadId: string) => void
|
|
63
|
-
/** Navigate to a quote detail (links inside the deal sidebar). */
|
|
64
|
-
onOpenQuote?: (quoteId: string) => void
|
|
65
|
-
} = {}) {
|
|
66
|
-
const t = useTranslation()
|
|
67
|
-
const provider = useCrmProvider()
|
|
68
|
-
// Mesmo idioma configurado para dinheiro — as datas não podem sair em outro.
|
|
69
|
-
const { currency } = useCrmConfig()
|
|
70
|
-
// Clicking a row opens the SAME right-hand deal sheet the pipeline uses —
|
|
71
|
-
// the timeline stays underneath instead of navigating away.
|
|
72
|
-
const [selectedDealId, setSelectedDealId] = useState<string | null>(null)
|
|
73
|
-
const activities = useCrmStore((s) => s.activities)
|
|
74
|
-
const activitiesLoading = useCrmStore((s) => s.activitiesLoading)
|
|
75
|
-
const fetchActivities = useCrmStore((s) => s.fetchActivities)
|
|
76
|
-
const [typeFilter, setTypeFilter] = useState<string | null>(null)
|
|
77
|
-
const [showCompleted, setShowCompleted] = useState<boolean | null>(null)
|
|
78
|
-
// 'events' = all system timeline types (filtered client-side; the provider
|
|
79
|
-
// query takes a single activityType).
|
|
80
|
-
const eventsFilter = typeFilter === 'events'
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
fetchActivities({
|
|
84
|
-
activityType: eventsFilter ? undefined : (typeFilter as ActivityType | undefined),
|
|
85
|
-
completed: eventsFilter ? undefined : (showCompleted ?? undefined),
|
|
86
|
-
})
|
|
87
|
-
}, [typeFilter, showCompleted])
|
|
88
|
-
|
|
89
|
-
const filtered = eventsFilter ? activities.filter((a) => SYSTEM_TYPES.has(a.activityType)) : activities
|
|
90
|
-
|
|
91
|
-
// Stats
|
|
92
|
-
const pendingCount = activities.filter((a) => !a.completedAt).length
|
|
93
|
-
const overdueCount = activities.filter((a) => !a.completedAt && a.dueDate && a.dueDate < new Date().toISOString().slice(0, 10)).length
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<div className="space-y-4">
|
|
97
|
-
<SubpageHeader
|
|
98
|
-
title={t('crm.activities.title')}
|
|
99
|
-
subtitle={`${activities.length} ${t('crm.activities.title').toLowerCase()}${pendingCount > 0 ? ` · ${pendingCount} ${t('crm.activities.pending')}` : ''}${overdueCount > 0 ? ` · ${overdueCount} ${t('crm.activities.overdue')}` : ''}`}
|
|
100
|
-
/>
|
|
101
|
-
|
|
102
|
-
{/* Filters */}
|
|
103
|
-
<div className="flex flex-col sm:flex-row gap-3 sm:items-center">
|
|
104
|
-
{/* Type filter */}
|
|
105
|
-
<div className="flex gap-1.5 flex-wrap">
|
|
106
|
-
<button
|
|
107
|
-
onClick={() => setTypeFilter(null)}
|
|
108
|
-
className={`rounded-full px-2.5 py-1 text-xs font-medium transition-colors ${typeFilter === null ? 'bg-primary text-primary-foreground' : 'bg-muted/50 text-muted-foreground hover:bg-muted'}`}
|
|
109
|
-
>
|
|
110
|
-
{t('crm.activities.all')}
|
|
111
|
-
</button>
|
|
112
|
-
{MANUAL_TYPES.map((type) => {
|
|
113
|
-
const cfg = TYPE_CONFIG[type]
|
|
114
|
-
const Icon = cfg.icon
|
|
115
|
-
return (
|
|
116
|
-
<button
|
|
117
|
-
key={type}
|
|
118
|
-
onClick={() => setTypeFilter(typeFilter === type ? null : type)}
|
|
119
|
-
className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium transition-colors ${typeFilter === type ? cfg.color : 'bg-muted/50 text-muted-foreground hover:bg-muted'}`}
|
|
120
|
-
>
|
|
121
|
-
<Icon className="h-3 w-3" />
|
|
122
|
-
{cfg.label}
|
|
123
|
-
</button>
|
|
124
|
-
)
|
|
125
|
-
})}
|
|
126
|
-
<button
|
|
127
|
-
onClick={() => setTypeFilter(eventsFilter ? null : 'events')}
|
|
128
|
-
className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium transition-colors ${eventsFilter ? 'bg-primary/15 text-primary' : 'bg-muted/50 text-muted-foreground hover:bg-muted'}`}
|
|
129
|
-
>
|
|
130
|
-
<Sparkles className="h-3 w-3" />
|
|
131
|
-
{t('crm.activities.systemEvents')}
|
|
132
|
-
</button>
|
|
133
|
-
</div>
|
|
134
|
-
|
|
135
|
-
<div className="flex-1" />
|
|
136
|
-
|
|
137
|
-
{/* Completion filter */}
|
|
138
|
-
<div className="flex gap-1.5">
|
|
139
|
-
<button
|
|
140
|
-
onClick={() => setShowCompleted(showCompleted === false ? null : false)}
|
|
141
|
-
className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium transition-colors ${showCompleted === false ? 'bg-warning-soft text-warning-soft-foreground' : 'bg-muted/50 text-muted-foreground hover:bg-muted'}`}
|
|
142
|
-
>
|
|
143
|
-
<Clock className="h-3 w-3" /> {t('crm.activities.pendingFilter')}
|
|
144
|
-
</button>
|
|
145
|
-
<button
|
|
146
|
-
onClick={() => setShowCompleted(showCompleted === true ? null : true)}
|
|
147
|
-
className={`inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium transition-colors ${showCompleted === true ? 'bg-success-soft text-success-soft-foreground' : 'bg-muted/50 text-muted-foreground hover:bg-muted'}`}
|
|
148
|
-
>
|
|
149
|
-
<Check className="h-3 w-3" /> {t('crm.activities.completedFilter')}
|
|
150
|
-
</button>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
|
|
154
|
-
{/* List */}
|
|
155
|
-
{activitiesLoading ? (
|
|
156
|
-
<ActivitySkeleton />
|
|
157
|
-
) : filtered.length === 0 ? (
|
|
158
|
-
<div className="flex flex-col items-center justify-center py-16 text-center rounded-lg border-2 border-dashed border-muted">
|
|
159
|
-
<div className="flex h-12 w-12 items-center justify-center rounded-2xl bg-muted/30 mb-3">
|
|
160
|
-
<Calendar className="h-5 w-5 text-muted-foreground/40" />
|
|
161
|
-
</div>
|
|
162
|
-
<p className="text-sm text-muted-foreground">{typeFilter ? t('crm.activities.noActivitiesOfType', { type: TYPE_CONFIG[typeFilter]?.label ?? typeFilter }) : t('crm.activities.noActivities')}</p>
|
|
163
|
-
<p className="text-[10px] text-muted-foreground/60 mt-0.5">{t('crm.activities.activitiesLogged')}</p>
|
|
164
|
-
</div>
|
|
165
|
-
) : (
|
|
166
|
-
<div className="space-y-2">
|
|
167
|
-
{filtered.map((a) => {
|
|
168
|
-
const cfg = TYPE_CONFIG[a.activityType] ?? { icon: FileText, color: 'bg-muted text-muted-foreground', label: a.activityType }
|
|
169
|
-
const Icon = cfg.icon
|
|
170
|
-
const isSystem = SYSTEM_TYPES.has(a.activityType)
|
|
171
|
-
const isOverdue = !a.completedAt && a.dueDate && a.dueDate < new Date().toISOString().slice(0, 10)
|
|
172
|
-
const openRecord = a.dealId
|
|
173
|
-
? () => setSelectedDealId(a.dealId!)
|
|
174
|
-
: a.leadId
|
|
175
|
-
? () => {
|
|
176
|
-
// Lead-only activity: its deal (auto-created with the lead)
|
|
177
|
-
// opens in the sheet; a dealless lead falls back to detail.
|
|
178
|
-
void provider.getDealByLeadId(a.leadId!).then((deal) => {
|
|
179
|
-
if (deal) setSelectedDealId(deal.id)
|
|
180
|
-
else onOpenLead?.(a.leadId!)
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
: undefined
|
|
184
|
-
|
|
185
|
-
return (
|
|
186
|
-
<div
|
|
187
|
-
key={a.id}
|
|
188
|
-
onClick={openRecord}
|
|
189
|
-
role={openRecord ? 'button' : undefined}
|
|
190
|
-
className={`group flex items-start gap-3 rounded-lg border bg-card p-4 transition-colors ${isOverdue ? 'border-destructive/30 dark:border-destructive/20' : ''} ${openRecord ? 'cursor-pointer hover:bg-muted/30' : ''}`}
|
|
191
|
-
>
|
|
192
|
-
<div className={`flex h-9 w-9 items-center justify-center rounded-lg shrink-0 ${cfg.color}`}>
|
|
193
|
-
<Icon className="h-4 w-4" />
|
|
194
|
-
</div>
|
|
195
|
-
<div className="flex-1 min-w-0 pt-0.5">
|
|
196
|
-
<div className="flex items-center gap-2">
|
|
197
|
-
<p className="text-sm font-medium truncate">{a.title}</p>
|
|
198
|
-
{/* System events are facts, not tasks — no "done" badge noise. */}
|
|
199
|
-
{a.completedAt && !isSystem && (
|
|
200
|
-
<span className="inline-flex items-center gap-0.5 rounded-full bg-success/15 px-1.5 py-0.5 text-[9px] font-medium text-success dark:bg-success/20">
|
|
201
|
-
<Check className="h-2.5 w-2.5" /> {t('crm.activities.done')}
|
|
202
|
-
</span>
|
|
203
|
-
)}
|
|
204
|
-
{isOverdue && (
|
|
205
|
-
<span className="inline-flex items-center gap-0.5 rounded-full bg-destructive/15 px-1.5 py-0.5 text-[9px] font-medium text-destructive dark:bg-destructive/20">
|
|
206
|
-
{t('crm.activities.overdueLabel')}
|
|
207
|
-
</span>
|
|
208
|
-
)}
|
|
209
|
-
</div>
|
|
210
|
-
{a.description && <p className="text-xs text-muted-foreground mt-0.5 line-clamp-2">{a.description}</p>}
|
|
211
|
-
<div className="flex items-center gap-3 mt-1.5 text-[10px] text-muted-foreground/60">
|
|
212
|
-
<span className="capitalize">{cfg.label}</span>
|
|
213
|
-
{a.dueDate && (
|
|
214
|
-
<>
|
|
215
|
-
<span>·</span>
|
|
216
|
-
<span className={isOverdue ? 'text-destructive font-medium' : ''}>Due {a.dueDate}</span>
|
|
217
|
-
</>
|
|
218
|
-
)}
|
|
219
|
-
{a.assignedToName && (
|
|
220
|
-
<>
|
|
221
|
-
<span>·</span>
|
|
222
|
-
<span>{a.assignedToName}</span>
|
|
223
|
-
</>
|
|
224
|
-
)}
|
|
225
|
-
{a.contactName && (
|
|
226
|
-
<>
|
|
227
|
-
<span>·</span>
|
|
228
|
-
<span>{a.contactName}</span>
|
|
229
|
-
</>
|
|
230
|
-
)}
|
|
231
|
-
</div>
|
|
232
|
-
</div>
|
|
233
|
-
{/* Quando aconteceu. A lista mostrava só o dia, e numa linha do
|
|
234
|
-
tempo o horário é metade da informação — "chegou hoje" não
|
|
235
|
-
diz se foi antes ou depois da última ligação. Idade em
|
|
236
|
-
destaque (é como se lê uma timeline), data e hora embaixo. */}
|
|
237
|
-
<span
|
|
238
|
-
className="flex items-center gap-1.5 text-[10px] text-muted-foreground shrink-0 pt-1"
|
|
239
|
-
title={formatDateTime(a.createdAt, currency.locale)}
|
|
240
|
-
>
|
|
241
|
-
<span className="text-right leading-tight">
|
|
242
|
-
<span className="block">{formatRelativeTime(a.createdAt, currency.locale)}</span>
|
|
243
|
-
<span className="block opacity-70">{formatDateTime(a.createdAt, currency.locale)}</span>
|
|
244
|
-
</span>
|
|
245
|
-
{openRecord && (
|
|
246
|
-
<ArrowRight className="h-3 w-3 opacity-0 transition-opacity group-hover:opacity-60" />
|
|
247
|
-
)}
|
|
248
|
-
</span>
|
|
249
|
-
</div>
|
|
250
|
-
)
|
|
251
|
-
})}
|
|
252
|
-
</div>
|
|
253
|
-
)}
|
|
254
|
-
|
|
255
|
-
<DealSidebar
|
|
256
|
-
dealId={selectedDealId ?? ''}
|
|
257
|
-
open={!!selectedDealId}
|
|
258
|
-
onClose={() => setSelectedDealId(null)}
|
|
259
|
-
onViewLead={onOpenLead}
|
|
260
|
-
onViewQuote={onOpenQuote}
|
|
261
|
-
/>
|
|
262
|
-
</div>
|
|
263
|
-
)
|
|
264
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { DashboardCanvas } from '@fayz-ai/ui'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* CRM overview. The KPI cards, charts and recent-data tables are now registered
|
|
6
|
-
* dashboard widgets (see ./dashboardWidgets) and rendered through the shared
|
|
7
|
-
* DashboardCanvas — the same widgets also appear on the global app home. This
|
|
8
|
-
* view simply mounts the CRM-scoped plugin-home surface.
|
|
9
|
-
*/
|
|
10
|
-
export function DashboardView() {
|
|
11
|
-
return <DashboardCanvas surface="plugin-home" domain="crm" showHeader={false} className="space-y-6" />
|
|
12
|
-
}
|