@fayz-ai/plugin-crm 0.8.3 → 0.8.5
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/dist/cascade.d.ts.map +1 -1
- package/dist/components/BoardFilters.d.ts +23 -0
- package/dist/components/BoardFilters.d.ts.map +1 -0
- package/dist/components/QuoteStatusDropdown.d.ts.map +1 -1
- package/dist/components/TagChips.d.ts +16 -0
- package/dist/components/TagChips.d.ts.map +1 -0
- package/dist/data/mock.d.ts +5 -0
- package/dist/data/mock.d.ts.map +1 -1
- package/dist/data/supabase.d.ts +6 -0
- package/dist/data/supabase.d.ts.map +1 -1
- package/dist/data/types.d.ts +12 -2
- package/dist/data/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1136 -164
- package/dist/index.js.map +1 -1
- package/dist/lib/access.d.ts +8 -0
- package/dist/lib/access.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/migrations/index.d.ts +9 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/public/context.d.ts +3 -3
- package/dist/public/context.d.ts.map +1 -1
- package/dist/public/createPublicFormsPlugin.d.ts +18 -2
- package/dist/public/createPublicFormsPlugin.d.ts.map +1 -1
- package/dist/public/data.supabase.d.ts.map +1 -1
- package/dist/public/index.js +31 -7
- package/dist/public/index.js.map +1 -1
- package/dist/public/types.d.ts +27 -0
- package/dist/public/types.d.ts.map +1 -1
- package/dist/registries.d.ts +11 -0
- package/dist/registries.d.ts.map +1 -1
- package/dist/store.d.ts +12 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/types.d.ts +51 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/views/ActivityListView.d.ts +6 -1
- package/dist/views/ActivityListView.d.ts.map +1 -1
- package/dist/views/DealSidebar.d.ts.map +1 -1
- package/dist/views/LeadDetailView.d.ts.map +1 -1
- package/dist/views/PipelineView.d.ts.map +1 -1
- package/dist/views/QuoteDetailView.d.ts.map +1 -1
- package/dist/views/QuoteListView.d.ts.map +1 -1
- package/package.json +15 -14
- package/src/CrmPage.tsx +1 -1
- package/src/cascade.ts +2 -0
- package/src/components/BoardFilters.tsx +190 -0
- package/src/components/QuoteStatusDropdown.tsx +15 -3
- package/src/components/TagChips.tsx +80 -0
- package/src/data/mock.ts +140 -7
- package/src/data/supabase.ts +256 -11
- package/src/data/types.ts +14 -3
- package/src/index.ts +179 -3
- package/src/lib/access.ts +11 -0
- package/src/locales/en.ts +13 -0
- package/src/locales/pt-BR.ts +18 -5
- package/src/migrations/003_crm_views_rls.sql +10 -2
- package/src/migrations/007_activity_log.sql +55 -0
- package/src/migrations/008_view_field_aliases.sql +43 -0
- package/src/migrations/009_deal_archived_status.sql +30 -0
- package/src/migrations/010_quote_archived_status.sql +40 -0
- package/src/migrations/011_agent_rpc_update_lead.sql +153 -0
- package/src/migrations/012_agent_rpc_create_lead.sql +128 -0
- package/src/migrations/013_tag_slugs.sql +177 -0
- package/src/migrations/014_public_lead_tags.sql +172 -0
- package/src/migrations/index.ts +833 -3
- package/src/public/context.tsx +4 -4
- package/src/public/createPublicFormsPlugin.ts +72 -2
- package/src/public/data.supabase.ts +3 -2
- package/src/public/types.ts +28 -0
- package/src/registries.ts +44 -11
- package/src/store.ts +135 -38
- package/src/types.ts +59 -2
- package/src/views/ActivityListView.tsx +79 -11
- package/src/views/DealSidebar.tsx +48 -39
- package/src/views/LeadDetailView.tsx +29 -10
- package/src/views/PipelineView.tsx +112 -11
- package/src/views/QuoteDetailView.tsx +7 -3
- package/src/views/QuoteListView.tsx +26 -12
- package/dist/index.cjs +0 -4759
- package/dist/index.cjs.map +0 -1
- package/dist/public/index.cjs +0 -306
- package/dist/public/index.cjs.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { TagDef } from '../types'
|
|
3
|
+
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Chips de tag — a mesma leitura no card do funil e no detalhe.
|
|
6
|
+
//
|
|
7
|
+
// O array do registro guarda SLUG; rótulo e cor vêm do cadastro (plg_crm_tags).
|
|
8
|
+
// Um slug sem cadastro não é erro: é uma tag que uma campanha usou antes de
|
|
9
|
+
// alguém curar o vocabulário. Ela renderiza com o rótulo derivado do slug num
|
|
10
|
+
// chip neutro, e passa a ter cor no momento em que a linha existir.
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/** 'camp:promo-verao' -> 'Promo Verao'. O namespace some do rótulo: quem lê o
|
|
14
|
+
* card quer ver a campanha, não o prefixo que a marcou. */
|
|
15
|
+
export function humanizeTag(slug: string): string {
|
|
16
|
+
return slug
|
|
17
|
+
.replace(/^[a-z]+:/, '')
|
|
18
|
+
.replace(/-/g, ' ')
|
|
19
|
+
.replace(/\b\w/g, (c) => c.toUpperCase())
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Fundo translúcido derivado da cor da tag.
|
|
24
|
+
*
|
|
25
|
+
* `${cor}1f` é a mesma cor a ~12% de opacidade: o chip fica legível em tema
|
|
26
|
+
* claro e escuro sem precisar de duas paletas, e o texto usa a cor cheia.
|
|
27
|
+
*/
|
|
28
|
+
function chipStyle(color?: string): React.CSSProperties | undefined {
|
|
29
|
+
if (!color || !/^#[0-9a-f]{6}$/i.test(color)) return undefined
|
|
30
|
+
return { backgroundColor: `${color}1f`, color, borderColor: `${color}59` }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TagChipsProps {
|
|
34
|
+
tags?: string[]
|
|
35
|
+
/** Cadastro por slug. Ausente = todos os chips saem neutros. */
|
|
36
|
+
defs?: Map<string, TagDef>
|
|
37
|
+
/** Acima disso vira "+N" — um card de funil não pode virar nuvem de tags. */
|
|
38
|
+
max?: number
|
|
39
|
+
size?: 'xs' | 'sm'
|
|
40
|
+
className?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function TagChips({ tags, defs, max, size = 'xs', className }: TagChipsProps) {
|
|
44
|
+
if (!tags?.length) return null
|
|
45
|
+
|
|
46
|
+
const shown = max ? tags.slice(0, max) : tags
|
|
47
|
+
const hidden = max ? tags.length - shown.length : 0
|
|
48
|
+
const text = size === 'xs' ? 'text-[9px] px-1.5 py-px' : 'text-[10px] px-2 py-0.5'
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className={`flex flex-wrap items-center gap-1 ${className ?? ''}`}>
|
|
52
|
+
{shown.map((slug) => {
|
|
53
|
+
const def = defs?.get(slug)
|
|
54
|
+
const style = chipStyle(def?.color)
|
|
55
|
+
return (
|
|
56
|
+
<span
|
|
57
|
+
key={slug}
|
|
58
|
+
// title completo: o chip trunca, e "de qual campanha veio" é
|
|
59
|
+
// exatamente o que a pessoa quer confirmar ao passar o mouse.
|
|
60
|
+
title={def?.name ?? humanizeTag(slug)}
|
|
61
|
+
className={`inline-flex max-w-[10rem] items-center truncate rounded-full border font-medium ${text} ${
|
|
62
|
+
style ? '' : 'border-border bg-muted text-muted-foreground'
|
|
63
|
+
}`}
|
|
64
|
+
style={style}
|
|
65
|
+
>
|
|
66
|
+
{def?.name ?? humanizeTag(slug)}
|
|
67
|
+
</span>
|
|
68
|
+
)
|
|
69
|
+
})}
|
|
70
|
+
{hidden > 0 && (
|
|
71
|
+
<span
|
|
72
|
+
title={tags.slice(shown.length).map((s) => defs?.get(s)?.name ?? humanizeTag(s)).join(', ')}
|
|
73
|
+
className={`inline-flex items-center rounded-full border border-border bg-muted font-medium text-muted-foreground ${text}`}
|
|
74
|
+
>
|
|
75
|
+
+{hidden}
|
|
76
|
+
</span>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}
|
package/src/data/mock.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CrmDataProvider } from './types'
|
|
2
2
|
import type {
|
|
3
|
-
Pipeline, PipelineStage, Lead, Deal, Activity, Quote, QuoteItem,
|
|
3
|
+
Pipeline, PipelineStage, Lead, Deal, Activity, ActivityTypeDef, TagDef, Quote, QuoteItem,
|
|
4
4
|
CreateLeadInput, CreateDealInput, CreateActivityInput, CreateQuoteInput,
|
|
5
|
-
LeadQuery, DealQuery, ActivityQuery, QuoteQuery,
|
|
5
|
+
LeadQuery, DealQuery, ActivityQuery, QuoteQuery, BoardFilter,
|
|
6
6
|
PaginatedResult, CrmSummary, FunnelStage,
|
|
7
|
-
LeadStatus, DealStatus, QuoteStatus,
|
|
7
|
+
LeadStatus, DealStatus, QuoteStatus, SystemActivityType,
|
|
8
8
|
} from '../types'
|
|
9
9
|
import { deriveLeadStatus, deriveQuoteStatus } from '../cascade'
|
|
10
10
|
|
|
@@ -13,6 +13,9 @@ function uid(): string { return String(nextId++) }
|
|
|
13
13
|
function now(): string { return new Date().toISOString() }
|
|
14
14
|
function today(): string { return new Date().toISOString().slice(0, 10) }
|
|
15
15
|
|
|
16
|
+
/** Mesma paleta do `crm_tag_default_color` do banco, para o mock não parecer outro produto. */
|
|
17
|
+
const MOCK_TAG_COLORS = ['#6366f1', '#0ea5e9', '#10b981', '#f59e0b', '#ef4444', '#ec4899', '#8b5cf6', '#14b8a6']
|
|
18
|
+
|
|
16
19
|
function paginate<T>(items: T[], page?: number, pageSize?: number): PaginatedResult<T> {
|
|
17
20
|
const p = page ?? 1
|
|
18
21
|
const ps = pageSize ?? 50
|
|
@@ -76,10 +79,31 @@ function createStore(seedStages?: Array<{ name: string; color: string; probabili
|
|
|
76
79
|
|
|
77
80
|
export function createMockCrmProvider(options?: {
|
|
78
81
|
dealStages?: Array<{ name: string; color: string; probability: number }>
|
|
82
|
+
activityTypes?: Array<{ value: string; label: string; icon?: string }>
|
|
79
83
|
}): CrmDataProvider {
|
|
80
84
|
const store = createStore(options?.dealStages)
|
|
81
85
|
const tenantId = 'mock-tenant'
|
|
82
86
|
|
|
87
|
+
// Parity with the Supabase provider's silent system timeline.
|
|
88
|
+
function logEvent(input: {
|
|
89
|
+
activityType: SystemActivityType
|
|
90
|
+
title: string
|
|
91
|
+
description?: string
|
|
92
|
+
leadId?: string
|
|
93
|
+
dealId?: string
|
|
94
|
+
contactId?: string
|
|
95
|
+
contactName?: string
|
|
96
|
+
}): void {
|
|
97
|
+
store.activities.push({
|
|
98
|
+
id: uid(),
|
|
99
|
+
dealId: input.dealId, leadId: input.leadId, contactId: input.contactId,
|
|
100
|
+
contactName: input.contactName,
|
|
101
|
+
activityType: input.activityType,
|
|
102
|
+
title: input.title, description: input.description,
|
|
103
|
+
completedAt: now(), tenantId, createdAt: now(),
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
83
107
|
// --- Cascade helper: sync lead + quote statuses when a deal moves ---
|
|
84
108
|
function cascadeFromStage(deal: Deal, stage: PipelineStage) {
|
|
85
109
|
// Cascade to lead
|
|
@@ -105,7 +129,7 @@ export function createMockCrmProvider(options?: {
|
|
|
105
129
|
|
|
106
130
|
// Leads
|
|
107
131
|
async getLeads(query: LeadQuery) {
|
|
108
|
-
let results =
|
|
132
|
+
let results = store.leads.filter((l) => (l as Lead & { isActive?: boolean }).isActive !== false)
|
|
109
133
|
if (query.status) {
|
|
110
134
|
const statuses = Array.isArray(query.status) ? query.status : [query.status]
|
|
111
135
|
results = results.filter((l) => statuses.includes(l.status))
|
|
@@ -130,6 +154,7 @@ export function createMockCrmProvider(options?: {
|
|
|
130
154
|
createdAt: now(), updatedAt: now(),
|
|
131
155
|
}
|
|
132
156
|
store.leads.push(lead)
|
|
157
|
+
logEvent({ activityType: 'lead_created', title: lead.name, leadId: lead.id, contactName: lead.name })
|
|
133
158
|
return lead
|
|
134
159
|
},
|
|
135
160
|
|
|
@@ -145,6 +170,7 @@ export function createMockCrmProvider(options?: {
|
|
|
145
170
|
if (!lead) throw new Error(`Lead ${leadId} not found`)
|
|
146
171
|
lead.status = 'converted'
|
|
147
172
|
lead.updatedAt = now()
|
|
173
|
+
logEvent({ activityType: 'lead_converted', title: lead.name, leadId, contactName: lead.name })
|
|
148
174
|
const deal = await provider.createDeal({ ...dealInput, leadId })
|
|
149
175
|
return deal
|
|
150
176
|
},
|
|
@@ -157,6 +183,8 @@ export function createMockCrmProvider(options?: {
|
|
|
157
183
|
if (query.status) {
|
|
158
184
|
const statuses = Array.isArray(query.status) ? query.status : [query.status]
|
|
159
185
|
results = results.filter((d) => statuses.includes(d.status))
|
|
186
|
+
} else {
|
|
187
|
+
results = results.filter((d) => d.status !== 'archived')
|
|
160
188
|
}
|
|
161
189
|
if (query.search) {
|
|
162
190
|
const s = query.search.toLowerCase()
|
|
@@ -168,11 +196,19 @@ export function createMockCrmProvider(options?: {
|
|
|
168
196
|
|
|
169
197
|
async getDealById(id) { return store.deals.find((d) => d.id === id) ?? null },
|
|
170
198
|
|
|
171
|
-
async getDealsByStage(pipelineId) {
|
|
199
|
+
async getDealsByStage(pipelineId, filter?: BoardFilter) {
|
|
172
200
|
const stages = store.stages.filter((s) => s.pipelineId === pipelineId).sort((a, b) => a.order - b.order)
|
|
201
|
+
// Mesmas regras do provider real, para o mock não mentir sobre o filtro:
|
|
202
|
+
// tags é OU, e o período corta por createdAt.
|
|
203
|
+
const matches = (d: Deal) => {
|
|
204
|
+
if (filter?.tags?.length && !filter.tags.some((t) => (d.tags ?? []).includes(t))) return false
|
|
205
|
+
if (filter?.createdFrom && d.createdAt < filter.createdFrom) return false
|
|
206
|
+
if (filter?.createdTo && d.createdAt > filter.createdTo) return false
|
|
207
|
+
return true
|
|
208
|
+
}
|
|
173
209
|
const map = new Map<string, Deal[]>()
|
|
174
210
|
for (const stage of stages) {
|
|
175
|
-
map.set(stage.id, store.deals.filter((d) => d.stageId === stage.id && d.status === 'open'))
|
|
211
|
+
map.set(stage.id, store.deals.filter((d) => d.stageId === stage.id && d.status === 'open' && matches(d)))
|
|
176
212
|
}
|
|
177
213
|
return map
|
|
178
214
|
},
|
|
@@ -190,6 +226,10 @@ export function createMockCrmProvider(options?: {
|
|
|
190
226
|
createdAt: now(), updatedAt: now(),
|
|
191
227
|
}
|
|
192
228
|
store.deals.push(deal)
|
|
229
|
+
logEvent({
|
|
230
|
+
activityType: 'deal_created', title: deal.title, dealId: deal.id,
|
|
231
|
+
leadId: deal.leadId, contactId: deal.contactId, contactName: deal.contactName,
|
|
232
|
+
})
|
|
193
233
|
return deal
|
|
194
234
|
},
|
|
195
235
|
|
|
@@ -216,9 +256,34 @@ export function createMockCrmProvider(options?: {
|
|
|
216
256
|
// Cascade to lead + quotes
|
|
217
257
|
cascadeFromStage(deal, stage)
|
|
218
258
|
|
|
259
|
+
logEvent({
|
|
260
|
+
activityType: stage.isWon ? 'deal_won' : stage.isLost ? 'deal_lost' : 'stage_changed',
|
|
261
|
+
title: deal.title || 'Deal',
|
|
262
|
+
description: stage.name,
|
|
263
|
+
dealId: deal.id,
|
|
264
|
+
contactName: deal.contactName,
|
|
265
|
+
})
|
|
219
266
|
return deal
|
|
220
267
|
},
|
|
221
268
|
|
|
269
|
+
async archiveDeal(dealId) {
|
|
270
|
+
const deal = store.deals.find((d) => d.id === dealId)
|
|
271
|
+
if (!deal) throw new Error(`Deal ${dealId} not found`)
|
|
272
|
+
deal.status = 'archived'
|
|
273
|
+
deal.updatedAt = now()
|
|
274
|
+
logEvent({ activityType: 'deal_archived', title: deal.title || 'Deal', dealId, contactName: deal.contactName })
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
async archiveLead(leadId) {
|
|
278
|
+
const lead = store.leads.find((l) => l.id === leadId)
|
|
279
|
+
if (!lead) throw new Error(`Lead ${leadId} not found`)
|
|
280
|
+
;(lead as Lead & { isActive?: boolean }).isActive = false
|
|
281
|
+
lead.updatedAt = now()
|
|
282
|
+
const deal = store.deals.find((d) => d.leadId === leadId && d.status === 'open')
|
|
283
|
+
if (deal) await provider.archiveDeal(deal.id)
|
|
284
|
+
logEvent({ activityType: 'lead_archived', title: lead.name, leadId, contactName: lead.name })
|
|
285
|
+
},
|
|
286
|
+
|
|
222
287
|
// Activities
|
|
223
288
|
async getActivities(query: ActivityQuery) {
|
|
224
289
|
let results = [...store.activities]
|
|
@@ -251,9 +316,37 @@ export function createMockCrmProvider(options?: {
|
|
|
251
316
|
return activity
|
|
252
317
|
},
|
|
253
318
|
|
|
319
|
+
async getActivityTypes(): Promise<ActivityTypeDef[]> {
|
|
320
|
+
const seed = options?.activityTypes ?? [
|
|
321
|
+
{ value: 'call', label: 'Call', icon: 'Phone' },
|
|
322
|
+
{ value: 'email', label: 'Email', icon: 'Mail' },
|
|
323
|
+
{ value: 'meeting', label: 'Meeting', icon: 'Users' },
|
|
324
|
+
{ value: 'note', label: 'Note', icon: 'FileText' },
|
|
325
|
+
{ value: 'task', label: 'Task', icon: 'CheckSquare' },
|
|
326
|
+
{ value: 'whatsapp', label: 'WhatsApp', icon: 'MessageCircle' },
|
|
327
|
+
]
|
|
328
|
+
return seed.map((t, i) => ({ id: `at-${i}`, name: t.label, icon: t.icon, isActive: true }))
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
async getTagDefs(): Promise<TagDef[]> {
|
|
332
|
+
// Derivado do que os registros mock realmente carregam, em vez de uma
|
|
333
|
+
// lista fixa: assim o mock exercita o mesmo caminho do banco, onde o
|
|
334
|
+
// cadastro se alimenta do uso.
|
|
335
|
+
const used = new Set<string>()
|
|
336
|
+
for (const l of store.leads) for (const t of l.tags ?? []) used.add(t)
|
|
337
|
+
for (const d of store.deals) for (const t of d.tags ?? []) used.add(t)
|
|
338
|
+
return [...used].sort().map((slug, i) => ({
|
|
339
|
+
id: `tag-${i}`,
|
|
340
|
+
slug,
|
|
341
|
+
name: slug.replace(/^[a-z]+:/, '').replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()),
|
|
342
|
+
color: MOCK_TAG_COLORS[i % MOCK_TAG_COLORS.length],
|
|
343
|
+
isActive: true,
|
|
344
|
+
}))
|
|
345
|
+
},
|
|
346
|
+
|
|
254
347
|
// Quotes
|
|
255
348
|
async getQuotes(query: QuoteQuery) {
|
|
256
|
-
let results =
|
|
349
|
+
let results = store.quotes.filter((q) => q.status !== 'archived' || (query.status && (Array.isArray(query.status) ? query.status : [query.status]).includes('archived')))
|
|
257
350
|
if (query.status) {
|
|
258
351
|
const statuses = Array.isArray(query.status) ? query.status : [query.status]
|
|
259
352
|
results = results.filter((q) => statuses.includes(q.status))
|
|
@@ -285,6 +378,15 @@ export function createMockCrmProvider(options?: {
|
|
|
285
378
|
createdAt: now(), updatedAt: now(),
|
|
286
379
|
}
|
|
287
380
|
store.quotes.push(quote)
|
|
381
|
+
if (quote.dealId && totalAmount > 0) {
|
|
382
|
+
const deal = store.deals.find((d) => d.id === quote.dealId)
|
|
383
|
+
if (deal) { deal.value = totalAmount; deal.updatedAt = now() }
|
|
384
|
+
}
|
|
385
|
+
logEvent({
|
|
386
|
+
activityType: 'quote_created', title: quote.quoteNumber ?? 'Quote',
|
|
387
|
+
description: quote.contactName, dealId: quote.dealId, leadId: quote.leadId,
|
|
388
|
+
contactId: quote.contactId, contactName: quote.contactName,
|
|
389
|
+
})
|
|
288
390
|
return quote
|
|
289
391
|
},
|
|
290
392
|
|
|
@@ -306,6 +408,10 @@ export function createMockCrmProvider(options?: {
|
|
|
306
408
|
quote.items = items
|
|
307
409
|
quote.totalAmount = totalAmount
|
|
308
410
|
quote.updatedAt = now()
|
|
411
|
+
if (quote.dealId && totalAmount > 0) {
|
|
412
|
+
const deal = store.deals.find((d) => d.id === quote.dealId)
|
|
413
|
+
if (deal) { deal.value = totalAmount; deal.updatedAt = now() }
|
|
414
|
+
}
|
|
309
415
|
return quote
|
|
310
416
|
},
|
|
311
417
|
|
|
@@ -314,6 +420,11 @@ export function createMockCrmProvider(options?: {
|
|
|
314
420
|
if (!quote) throw new Error(`Quote ${id} not found`)
|
|
315
421
|
quote.status = 'sent'
|
|
316
422
|
quote.updatedAt = now()
|
|
423
|
+
logEvent({
|
|
424
|
+
activityType: 'quote_sent', title: quote.quoteNumber ?? 'Quote',
|
|
425
|
+
description: quote.contactName, dealId: quote.dealId, leadId: quote.leadId,
|
|
426
|
+
contactName: quote.contactName,
|
|
427
|
+
})
|
|
317
428
|
return quote
|
|
318
429
|
},
|
|
319
430
|
|
|
@@ -345,6 +456,11 @@ export function createMockCrmProvider(options?: {
|
|
|
345
456
|
}
|
|
346
457
|
}
|
|
347
458
|
|
|
459
|
+
logEvent({
|
|
460
|
+
activityType: 'quote_approved', title: quote.quoteNumber ?? 'Quote',
|
|
461
|
+
description: quote.contactName, dealId: quote.dealId, leadId: quote.leadId,
|
|
462
|
+
contactName: quote.contactName,
|
|
463
|
+
})
|
|
348
464
|
return quote
|
|
349
465
|
},
|
|
350
466
|
|
|
@@ -365,6 +481,11 @@ export function createMockCrmProvider(options?: {
|
|
|
365
481
|
}
|
|
366
482
|
}
|
|
367
483
|
}
|
|
484
|
+
logEvent({
|
|
485
|
+
activityType: 'quote_rejected', title: quote.quoteNumber ?? 'Quote',
|
|
486
|
+
description: reason, dealId: quote.dealId, leadId: quote.leadId,
|
|
487
|
+
contactName: quote.contactName,
|
|
488
|
+
})
|
|
368
489
|
return quote
|
|
369
490
|
},
|
|
370
491
|
|
|
@@ -376,6 +497,18 @@ export function createMockCrmProvider(options?: {
|
|
|
376
497
|
return quote
|
|
377
498
|
},
|
|
378
499
|
|
|
500
|
+
async archiveQuote(id) {
|
|
501
|
+
const quote = store.quotes.find((q) => q.id === id)
|
|
502
|
+
if (!quote) throw new Error(`Quote ${id} not found`)
|
|
503
|
+
quote.status = 'archived'
|
|
504
|
+
quote.updatedAt = now()
|
|
505
|
+
logEvent({
|
|
506
|
+
activityType: 'quote_archived', title: quote.quoteNumber ?? 'Quote',
|
|
507
|
+
description: quote.contactName, dealId: quote.dealId, leadId: quote.leadId,
|
|
508
|
+
contactName: quote.contactName,
|
|
509
|
+
})
|
|
510
|
+
},
|
|
511
|
+
|
|
379
512
|
// Cross-entity lookups
|
|
380
513
|
async getQuotesByDealId(dealId) {
|
|
381
514
|
return store.quotes.filter((q) => q.dealId === dealId)
|