@fayz-ai/plugin-crm 0.9.0 → 0.9.2

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.
Files changed (122) hide show
  1. package/README.md +3 -3
  2. package/dist/components/AutomationBolt.d.ts +22 -0
  3. package/dist/components/AutomationBolt.d.ts.map +1 -0
  4. package/dist/{CrmContext.d.ts → context.d.ts} +4 -2
  5. package/dist/context.d.ts.map +1 -0
  6. package/dist/data/mock.d.ts.map +1 -1
  7. package/dist/data/registries.d.ts.map +1 -0
  8. package/dist/data/types.d.ts +4 -1
  9. package/dist/data/types.d.ts.map +1 -1
  10. package/dist/index.d.ts +16 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +609 -493
  13. package/dist/index.js.map +1 -1
  14. package/dist/{cascade.d.ts → lib/cascade.d.ts} +1 -1
  15. package/dist/lib/cascade.d.ts.map +1 -0
  16. package/dist/lib/message-events.d.ts +13 -0
  17. package/dist/lib/message-events.d.ts.map +1 -0
  18. package/dist/lib/timeline-source.d.ts +10 -0
  19. package/dist/lib/timeline-source.d.ts.map +1 -0
  20. package/dist/locales/en.d.ts.map +1 -1
  21. package/dist/locales/pt-BR.d.ts.map +1 -1
  22. package/dist/public/context.d.ts +1 -1
  23. package/dist/public/context.d.ts.map +1 -1
  24. package/dist/public/createPublicFormsPlugin.d.ts +1 -1
  25. package/dist/public/createPublicFormsPlugin.d.ts.map +1 -1
  26. package/dist/public/{data.supabase.d.ts → data/supabase.d.ts} +2 -2
  27. package/dist/public/data/supabase.d.ts.map +1 -0
  28. package/dist/public/index.d.ts +6 -6
  29. package/dist/public/index.d.ts.map +1 -1
  30. package/dist/public/index.js +2 -2
  31. package/dist/public/index.js.map +1 -1
  32. package/dist/public/{inbox.d.ts → lib/inbox.d.ts} +1 -1
  33. package/dist/public/lib/inbox.d.ts.map +1 -0
  34. package/dist/public/{uploads.d.ts → lib/uploads.d.ts} +1 -1
  35. package/dist/public/lib/uploads.d.ts.map +1 -0
  36. package/dist/store.d.ts +9 -0
  37. package/dist/store.d.ts.map +1 -1
  38. package/dist/views/ActivityListView.d.ts.map +1 -1
  39. package/dist/{CrmPage.d.ts → views/CrmPage.d.ts} +3 -3
  40. package/dist/views/CrmPage.d.ts.map +1 -0
  41. package/dist/views/DealSidebar.d.ts.map +1 -1
  42. package/dist/views/LeadListView.d.ts.map +1 -1
  43. package/dist/views/PipelineView.d.ts +3 -1
  44. package/dist/views/PipelineView.d.ts.map +1 -1
  45. package/dist/views/QuoteDetailView.d.ts.map +1 -1
  46. package/dist/views/QuoteFormView.d.ts.map +1 -1
  47. package/dist/views/QuoteListView.d.ts.map +1 -1
  48. package/dist/views/dashboardWidgets.d.ts +1 -1
  49. package/dist/views/dashboardWidgets.d.ts.map +1 -1
  50. package/package.json +6 -10
  51. package/dist/CrmContext.d.ts.map +0 -1
  52. package/dist/CrmPage.d.ts.map +0 -1
  53. package/dist/cascade.d.ts.map +0 -1
  54. package/dist/public/data.supabase.d.ts.map +0 -1
  55. package/dist/public/inbox.d.ts.map +0 -1
  56. package/dist/public/uploads.d.ts.map +0 -1
  57. package/dist/registries.d.ts.map +0 -1
  58. package/src/CrmContext.tsx +0 -30
  59. package/src/CrmPage.tsx +0 -150
  60. package/src/README.md +0 -97
  61. package/src/cascade.ts +0 -26
  62. package/src/components/BoardFilters.tsx +0 -190
  63. package/src/components/CrmGeneralSettings.tsx +0 -56
  64. package/src/components/CrmOnboarding.tsx +0 -52
  65. package/src/components/LeadAttachments.tsx +0 -140
  66. package/src/components/PipelineSettings.tsx +0 -45
  67. package/src/components/QuoteStatusDropdown.tsx +0 -226
  68. package/src/components/TagChips.tsx +0 -80
  69. package/src/data/index.ts +0 -2
  70. package/src/data/mock.ts +0 -559
  71. package/src/data/supabase.ts +0 -928
  72. package/src/data/tables.ts +0 -11
  73. package/src/data/types.ts +0 -61
  74. package/src/index.ts +0 -429
  75. package/src/lib/access.ts +0 -11
  76. package/src/lib/form-answers.tsx +0 -80
  77. package/src/lib/relative-time.ts +0 -84
  78. package/src/lib/tenant.ts +0 -4
  79. package/src/locales/en.ts +0 -307
  80. package/src/locales/index.ts +0 -7
  81. package/src/locales/pt-BR.ts +0 -307
  82. package/src/migrations/000_plg_rename.sql +0 -28
  83. package/src/migrations/001_crm_base.sql +0 -73
  84. package/src/migrations/002_activities.sql +0 -33
  85. package/src/migrations/003_crm_views_rls.sql +0 -69
  86. package/src/migrations/004_seed_default_pipeline.sql +0 -31
  87. package/src/migrations/005_public_lead.sql +0 -189
  88. package/src/migrations/006_lead_enters_pipeline.sql +0 -265
  89. package/src/migrations/007_activity_log.sql +0 -55
  90. package/src/migrations/008_view_field_aliases.sql +0 -43
  91. package/src/migrations/009_deal_archived_status.sql +0 -30
  92. package/src/migrations/010_quote_archived_status.sql +0 -40
  93. package/src/migrations/011_agent_rpc_update_lead.sql +0 -153
  94. package/src/migrations/012_agent_rpc_create_lead.sql +0 -128
  95. package/src/migrations/013_tag_slugs.sql +0 -177
  96. package/src/migrations/014_public_lead_tags.sql +0 -172
  97. package/src/migrations/015_lead_attachments.sql +0 -357
  98. package/src/migrations/016_public_lead_activity.sql +0 -123
  99. package/src/migrations/index.ts +0 -2023
  100. package/src/public/context.tsx +0 -150
  101. package/src/public/createPublicFormsPlugin.ts +0 -282
  102. package/src/public/data.supabase.ts +0 -92
  103. package/src/public/inbox.ts +0 -143
  104. package/src/public/index.ts +0 -51
  105. package/src/public/types.ts +0 -173
  106. package/src/public/uploads.ts +0 -205
  107. package/src/registries.ts +0 -162
  108. package/src/schema/index.ts +0 -104
  109. package/src/store.ts +0 -472
  110. package/src/types.ts +0 -337
  111. package/src/views/ActivityListView.tsx +0 -264
  112. package/src/views/DashboardView.tsx +0 -12
  113. package/src/views/DealSidebar.tsx +0 -482
  114. package/src/views/LeadDetailView.tsx +0 -378
  115. package/src/views/LeadFormView.tsx +0 -66
  116. package/src/views/LeadListView.tsx +0 -100
  117. package/src/views/PipelineView.tsx +0 -446
  118. package/src/views/QuoteDetailView.tsx +0 -412
  119. package/src/views/QuoteFormView.tsx +0 -494
  120. package/src/views/QuoteListView.tsx +0 -115
  121. package/src/views/dashboardWidgets.tsx +0 -248
  122. /package/dist/{registries.d.ts → data/registries.d.ts} +0 -0
@@ -1,412 +0,0 @@
1
- import React, { useEffect, useMemo, useState, useRef } from 'react'
2
- import { FileText, Calendar, User, Hash, Ban, Pencil, CircleCheckBig, ArrowRight, Send, Printer, Mail, MessageCircle, ChevronDown, Check, X } from 'lucide-react'
3
- import type { ColumnDef } from '@tanstack/react-table'
4
- import { useCrmConfig, useCrmStore, useCrmProvider, formatCurrency } from '../CrmContext'
5
- import { useTranslation } from '@fayz-ai/core'
6
- import { SubpageHeader, DataTable } from '@fayz-ai/ui'
7
- import { QuoteStatusDropdown } from '../components/QuoteStatusDropdown'
8
- import { PersonLink } from '@fayz-ai/saas'
9
- import { Button } from '@fayz-ai/ui'
10
- import type { Quote, QuoteItem } from '../types'
11
- export function QuoteDetailView({ quoteId, onBack, onEdit, onInvoiceCreated }: {
12
- quoteId: string
13
- onBack: () => void
14
- onEdit?: () => void
15
- onInvoiceCreated?: (invoiceId: string) => void
16
- }) {
17
- const t = useTranslation()
18
- const { currency } = useCrmConfig()
19
- const provider = useCrmProvider()
20
- const sendQuote = useCrmStore((s) => s.sendQuote)
21
- const approveQuote = useCrmStore((s) => s.approveQuote)
22
- const rejectQuote = useCrmStore((s) => s.rejectQuote)
23
- const [quote, setQuote] = useState<Quote | null>(null)
24
- const [loading, setLoading] = useState(true)
25
- const [sendMenuOpen, setSendMenuOpen] = useState(false)
26
- const [sending, setSending] = useState(false)
27
- const [approving, setApproving] = useState(false)
28
- const [rejectOpen, setRejectOpen] = useState(false)
29
- const [rejectReason, setRejectReason] = useState('')
30
- const [rejecting, setRejecting] = useState(false)
31
- const sendMenuRef = useRef<HTMLDivElement>(null)
32
-
33
- useEffect(() => {
34
- setLoading(true)
35
- provider.getQuoteById(quoteId).then((q) => {
36
- setQuote(q)
37
- setLoading(false)
38
- })
39
- }, [quoteId])
40
-
41
- useEffect(() => {
42
- if (!sendMenuOpen) return
43
- const h = (e: MouseEvent) => { if (sendMenuRef.current && !sendMenuRef.current.contains(e.target as Node)) setSendMenuOpen(false) }
44
- document.addEventListener('mousedown', h)
45
- return () => document.removeEventListener('mousedown', h)
46
- }, [sendMenuOpen])
47
-
48
- async function handleSend(channel: string) {
49
- setSending(true)
50
- setSendMenuOpen(false)
51
- try {
52
- const updated = await sendQuote(quoteId)
53
- setQuote(updated)
54
- } finally {
55
- setSending(false)
56
- }
57
- }
58
-
59
- async function handleApprove() {
60
- setApproving(true)
61
- try {
62
- const updated = await approveQuote(quoteId)
63
- setQuote(updated)
64
- // Quote IS the invoice now (in-place promotion) — navigate to its invoice detail
65
- if (onInvoiceCreated) {
66
- onInvoiceCreated(quoteId)
67
- }
68
- } finally {
69
- setApproving(false)
70
- }
71
- }
72
-
73
- async function handleReject() {
74
- if (!rejectReason.trim()) return
75
- setRejecting(true)
76
- try {
77
- const updated = await rejectQuote(quoteId, rejectReason.trim())
78
- setQuote(updated)
79
- setRejectOpen(false)
80
- setRejectReason('')
81
- } finally {
82
- setRejecting(false)
83
- }
84
- }
85
-
86
- if (loading) {
87
- return (
88
- <div className="space-y-5">
89
- <SubpageHeader title="" onBack={onBack} parentLabel={t('crm.quotes.title')} />
90
- <div className="rounded-xl border bg-card shadow-sm overflow-hidden">
91
- <div className="h-1 bg-muted animate-pulse" />
92
- <div className="p-5 pb-4">
93
- <div className="flex items-start justify-between">
94
- <div className="flex items-start gap-3">
95
- <div className="h-10 w-10 rounded-lg bg-muted/40 animate-pulse" />
96
- <div className="space-y-2">
97
- <div className="h-3 w-20 rounded bg-muted/40 animate-pulse" />
98
- <div className="h-6 w-32 rounded bg-muted/40 animate-pulse" />
99
- </div>
100
- </div>
101
- <div className="h-6 w-20 rounded-full bg-muted/40 animate-pulse" />
102
- </div>
103
- <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 mt-4 pt-4 border-t">
104
- {[1, 2, 3, 4].map((i) => (
105
- <div key={i} className="flex items-center gap-2">
106
- <div className="h-3.5 w-3.5 rounded bg-muted/30 animate-pulse" />
107
- <div className="space-y-1">
108
- <div className="h-2 w-10 rounded bg-muted/30 animate-pulse" />
109
- <div className="h-3 w-16 rounded bg-muted/40 animate-pulse" />
110
- </div>
111
- </div>
112
- ))}
113
- </div>
114
- </div>
115
- </div>
116
- </div>
117
- )
118
- }
119
-
120
- if (!quote) {
121
- return (
122
- <div className="space-y-5">
123
- <SubpageHeader title={t('crm.quoteDetail.title')} onBack={onBack} parentLabel={t('crm.quotes.title')} />
124
- <div className="flex flex-col items-center justify-center py-12 text-center rounded-lg border-2 border-dashed border-muted">
125
- <FileText className="h-8 w-8 text-muted-foreground/30 mb-2" />
126
- <p className="text-sm text-muted-foreground">{t('crm.quoteDetail.notFound')}</p>
127
- <button onClick={onBack} className="text-xs text-primary hover:underline mt-1">{t('crm.quoteDetail.backToList')}</button>
128
- </div>
129
- </div>
130
- )
131
- }
132
-
133
- const subtotal = quote.items.reduce((sum, it) => sum + it.quantity * it.unitPrice, 0)
134
- const totalDiscount = quote.items.reduce((sum, it) => sum + it.discount, 0)
135
-
136
- const itemColumns: ColumnDef<QuoteItem, any>[] = [
137
- {
138
- id: 'index', header: '#',
139
- cell: ({ row }) => <span className="text-xs text-muted-foreground">{row.index + 1}</span>,
140
- },
141
- {
142
- accessorKey: 'description', header: t('crm.quoteDetail.description'),
143
- cell: ({ row }) => (
144
- <div className="flex items-center gap-1.5">
145
- <span className="inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium bg-muted text-muted-foreground capitalize">{row.original.itemKind}</span>
146
- <span className="truncate">{row.original.description || '—'}</span>
147
- </div>
148
- ),
149
- },
150
- {
151
- accessorKey: 'quantity', header: () => <span className="block text-right">{t('crm.quoteDetail.qty')}</span>,
152
- cell: ({ getValue }) => <span className="block text-right text-xs tabular-nums">{getValue() as number}</span>,
153
- },
154
- {
155
- accessorKey: 'unitPrice', header: () => <span className="block text-right">{t('crm.quoteDetail.unitPrice')}</span>,
156
- cell: ({ getValue }) => <span className="block text-right text-xs tabular-nums">{formatCurrency(getValue() as number, currency)}</span>,
157
- },
158
- {
159
- accessorKey: 'totalAmount', header: () => <span className="block text-right">{t('crm.quoteDetail.total')}</span>,
160
- cell: ({ getValue }) => <span className="block text-right font-medium tabular-nums">{formatCurrency(getValue() as number, currency)}</span>,
161
- },
162
- ]
163
-
164
- return (
165
- <div className="space-y-5">
166
- <SubpageHeader
167
- title={`#${quote.quoteNumber}`}
168
- onBack={onBack}
169
- parentLabel={t('crm.quotes.title')}
170
- actions={
171
- <div className="flex items-center gap-1.5">
172
- {quote.status === 'draft' && (
173
- <div className="relative" ref={sendMenuRef}>
174
- <button
175
- type="button"
176
- onClick={() => setSendMenuOpen((p) => !p)}
177
- disabled={sending}
178
- className="inline-flex items-center gap-1.5 rounded-lg bg-primary border border-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 shadow-button-primary active:shadow-button-inset transition-colors disabled:opacity-50"
179
- >
180
- <Send className="h-3 w-3" />
181
- {sending ? t('crm.quoteDetail.sending') : t('crm.quoteDetail.send')}
182
- <ChevronDown className="h-3 w-3 opacity-60" />
183
- </button>
184
- {sendMenuOpen && (
185
- <div className="absolute right-0 top-full mt-1 w-48 rounded-lg border bg-card shadow-lg z-20 py-1 animate-in fade-in zoom-in-95 duration-100">
186
- <button type="button" onClick={() => handleSend('print')} className="flex w-full items-center gap-2 px-3 py-2 text-xs hover:bg-muted/50 transition-colors">
187
- <Printer className="h-3.5 w-3.5 text-muted-foreground" /> {t('crm.quoteDetail.sendPrint')}
188
- </button>
189
- <button type="button" onClick={() => handleSend('email')} className="flex w-full items-center gap-2 px-3 py-2 text-xs hover:bg-muted/50 transition-colors">
190
- <Mail className="h-3.5 w-3.5 text-muted-foreground" /> {t('crm.quoteDetail.sendEmail')}
191
- </button>
192
- <button type="button" onClick={() => handleSend('whatsapp')} className="flex w-full items-center gap-2 px-3 py-2 text-xs hover:bg-muted/50 transition-colors">
193
- <MessageCircle className="h-3.5 w-3.5 text-muted-foreground" /> {t('crm.quoteDetail.sendWhatsApp')}
194
- </button>
195
- </div>
196
- )}
197
- </div>
198
- )}
199
- {quote.status === 'sent' && (
200
- <>
201
- <Button
202
- type="button"
203
- variant="default"
204
- size="sm"
205
- onClick={handleApprove}
206
- disabled={approving}
207
- className="bg-success text-success-foreground hover:bg-success/90 border-success"
208
- >
209
- <Check className="h-3.5 w-3.5" />
210
- {approving ? t('crm.quoteDetail.approving') : t('crm.quoteDetail.approve')}
211
- </Button>
212
- <Button
213
- type="button"
214
- variant="outline"
215
- size="sm"
216
- onClick={() => setRejectOpen(true)}
217
- className="border-destructive/30 text-destructive hover:bg-destructive/10"
218
- >
219
- <X className="h-3.5 w-3.5" />
220
- {t('crm.quoteDetail.reject')}
221
- </Button>
222
- </>
223
- )}
224
- {onEdit && quote.status !== 'approved' && quote.status !== 'rejected' && quote.status !== 'expired' && (
225
- <button type="button" onClick={onEdit} className="inline-flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-xs font-medium hover:bg-muted bg-card shadow-button active:shadow-button-inset transition-colors">
226
- <Pencil className="h-3 w-3" /> {t('crm.quoteDetail.edit')}
227
- </button>
228
- )}
229
- </div>
230
- }
231
- />
232
-
233
- {/* Quote document card */}
234
- <div className="rounded-xl border bg-card shadow-sm overflow-hidden">
235
- {/* Top accent stripe */}
236
- <div className="h-1 bg-primary" />
237
-
238
- {/* Header */}
239
- <div className="p-5 pb-4">
240
- <div className="flex items-start justify-between gap-4">
241
- <div className="flex items-start gap-3">
242
- <div className="flex h-10 w-10 items-center justify-center rounded-lg bg-primary/10 shrink-0">
243
- <FileText className="h-5 w-5 text-primary" />
244
- </div>
245
- <div>
246
- <p className="text-xs font-medium text-muted-foreground uppercase tracking-wider">
247
- {t('crm.quoteDetail.quoteNumber', { number: quote.quoteNumber })}
248
- </p>
249
- <p className="text-xl font-bold mt-0.5">{formatCurrency(quote.totalAmount, currency)}</p>
250
- </div>
251
- </div>
252
- <QuoteStatusDropdown quote={quote} onStatusChange={(q) => setQuote(q)} />
253
- </div>
254
-
255
- {/* Meta grid */}
256
- <div className="grid grid-cols-2 sm:grid-cols-4 gap-3 mt-4 pt-4 border-t">
257
- <div className="flex items-center gap-2">
258
- <User className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
259
- <div className="min-w-0">
260
- <p className="text-[10px] text-muted-foreground">{t('crm.quoteDetail.client')}</p>
261
- {quote.contactName ? (
262
- <PersonLink personId={quote.contactId ?? quote.leadId} name={quote.contactName} size="sm" />
263
- ) : (
264
- <p className="text-xs font-medium truncate">—</p>
265
- )}
266
- </div>
267
- </div>
268
- <div className="flex items-center gap-2">
269
- <Calendar className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
270
- <div>
271
- <p className="text-[10px] text-muted-foreground">{t('crm.quoteDetail.date')}</p>
272
- <p className="text-xs font-medium">{quote.quoteDate}</p>
273
- </div>
274
- </div>
275
- <div className="flex items-center gap-2">
276
- <Calendar className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
277
- <div>
278
- <p className="text-[10px] text-muted-foreground">{t('crm.quoteDetail.validUntil')}</p>
279
- <p className="text-xs font-medium">{quote.validUntil}</p>
280
- </div>
281
- </div>
282
- <div className="flex items-center gap-2">
283
- <Hash className="h-3.5 w-3.5 text-muted-foreground shrink-0" />
284
- <div>
285
- <p className="text-[10px] text-muted-foreground">{t('crm.quoteDetail.items')}</p>
286
- <p className="text-xs font-medium">{quote.items.length}</p>
287
- </div>
288
- </div>
289
- </div>
290
- </div>
291
-
292
- {/* Items table */}
293
- {quote.items.length > 0 && (
294
- <>
295
- <div className="px-5 pt-3 pb-1.5">
296
- <h3 className="text-[11px] font-semibold text-muted-foreground uppercase tracking-wider">{t('crm.quoteDetail.items')}</h3>
297
- </div>
298
- <div className="px-5">
299
- <DataTable columns={itemColumns} data={quote.items} variant="flat" compact />
300
- </div>
301
-
302
- {/* Totals */}
303
- <div className="px-5 py-3 mt-1 border-t bg-muted/10">
304
- <div className="flex flex-col items-end gap-0.5">
305
- {totalDiscount > 0 && (
306
- <>
307
- <div className="flex items-center gap-6 text-xs">
308
- <span className="text-muted-foreground">{t('crm.quoteDetail.subtotal')}</span>
309
- <span className="tabular-nums w-24 text-right">{formatCurrency(subtotal, currency)}</span>
310
- </div>
311
- <div className="flex items-center gap-6 text-xs text-success">
312
- <span>{t('crm.quoteDetail.discount')}</span>
313
- <span className="tabular-nums w-24 text-right">-{formatCurrency(totalDiscount, currency)}</span>
314
- </div>
315
- </>
316
- )}
317
- <div className="flex items-center gap-6 text-sm font-bold pt-1">
318
- <span>{t('crm.quoteDetail.total')}</span>
319
- <span className="tabular-nums w-24 text-right">{formatCurrency(quote.totalAmount, currency)}</span>
320
- </div>
321
- </div>
322
- </div>
323
- </>
324
- )}
325
-
326
- {/* Payment conditions inside card */}
327
- {quote.paymentConditions && (
328
- <div className="px-5 py-3 border-t">
329
- <p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1">{t('crm.quoteDetail.paymentConditions')}</p>
330
- <p className="text-xs text-muted-foreground">{quote.paymentConditions}</p>
331
- </div>
332
- )}
333
-
334
- {/* Notes inside card */}
335
- {quote.observations && (
336
- <div className="px-5 py-3 border-t">
337
- <p className="text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-1">{t('crm.quoteDetail.notes')}</p>
338
- <p className="text-xs text-muted-foreground whitespace-pre-wrap">{quote.observations}</p>
339
- </div>
340
- )}
341
- </div>
342
-
343
- {/* Invoice link — the promotion is IN PLACE (fn_invoice_from_order), so
344
- after it the display status is the financial stage, never 'approved';
345
- gating on approved alone hid this banner exactly when it mattered.
346
- Financial has no per-invoice detail route — link to the receivables
347
- list, where the REC-* reference lands. */}
348
- {['approved', 'invoiced', 'paid', 'partial', 'overdue'].includes(quote.status) && (
349
- <div className="flex items-center justify-between rounded-lg border border-success/30 bg-success/5 px-4 py-2.5">
350
- <div className="flex items-center gap-2 text-xs">
351
- <CircleCheckBig className="h-3.5 w-3.5 text-success" />
352
- <span className="text-muted-foreground">{t('crm.quoteDetail.invoiceCreated')}</span>
353
- </div>
354
- <a
355
- href="#/financial/receivables/list"
356
- className="inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline"
357
- >
358
- {t('crm.quoteDetail.viewInvoice')} <ArrowRight className="h-3 w-3" />
359
- </a>
360
- </div>
361
- )}
362
-
363
- {/* Rejection reason — outside the card */}
364
- {quote.status === 'rejected' && quote.rejectionReason && (
365
- <div className="flex items-center justify-between rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-2.5">
366
- <div className="flex items-center gap-2 text-xs">
367
- <Ban className="h-3.5 w-3.5 text-destructive" />
368
- <span className="text-muted-foreground">{t('crm.quoteDetail.rejectionReason')}: <span className="font-medium text-foreground">{quote.rejectionReason}</span></span>
369
- </div>
370
- </div>
371
- )}
372
-
373
- {/* Reject reason dialog */}
374
- {rejectOpen && (
375
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50" onClick={() => setRejectOpen(false)}>
376
- <div className="w-full max-w-sm rounded-modal border bg-card shadow-lg mx-4 p-5" onClick={(e) => e.stopPropagation()}>
377
- <div className="flex items-center gap-3 mb-3">
378
- <div className="flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10 shrink-0">
379
- <X className="h-5 w-5 text-destructive" />
380
- </div>
381
- <div>
382
- <h3 className="text-sm font-semibold">{t('crm.quoteDetail.reject')}</h3>
383
- <p className="text-xs text-muted-foreground">{t('crm.quoteDetail.rejectDescription')}</p>
384
- </div>
385
- </div>
386
- <textarea
387
- value={rejectReason}
388
- onChange={(e) => setRejectReason(e.target.value)}
389
- placeholder={t('crm.quoteDetail.rejectReasonPlaceholder')}
390
- className="w-full rounded-input border border-input bg-card px-3 py-2 text-sm shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] resize-none h-20 focus:outline-none focus:ring-2 focus:ring-ring"
391
- autoFocus
392
- />
393
- <div className="flex justify-end gap-2 mt-3">
394
- <Button type="button" variant="outline" size="sm" onClick={() => setRejectOpen(false)}>
395
- {t('common.cancel')}
396
- </Button>
397
- <Button
398
- type="button"
399
- variant="destructive"
400
- size="sm"
401
- onClick={handleReject}
402
- disabled={rejecting || !rejectReason.trim()}
403
- >
404
- {rejecting ? t('crm.quoteDetail.rejecting') : t('crm.quoteDetail.confirmReject')}
405
- </Button>
406
- </div>
407
- </div>
408
- </div>
409
- )}
410
- </div>
411
- )
412
- }