@fayz-ai/plugin-crm 0.1.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.
Files changed (103) hide show
  1. package/dist/CrmContext.d.ts +32 -0
  2. package/dist/CrmContext.d.ts.map +1 -0
  3. package/dist/CrmPage.d.ts +13 -0
  4. package/dist/CrmPage.d.ts.map +1 -0
  5. package/dist/cascade.d.ts +13 -0
  6. package/dist/cascade.d.ts.map +1 -0
  7. package/dist/components/CrmGeneralSettings.d.ts +3 -0
  8. package/dist/components/CrmGeneralSettings.d.ts.map +1 -0
  9. package/dist/components/CrmOnboarding.d.ts +5 -0
  10. package/dist/components/CrmOnboarding.d.ts.map +1 -0
  11. package/dist/components/PipelineSettings.d.ts +3 -0
  12. package/dist/components/PipelineSettings.d.ts.map +1 -0
  13. package/dist/components/QuoteStatusDropdown.d.ts +8 -0
  14. package/dist/components/QuoteStatusDropdown.d.ts.map +1 -0
  15. package/dist/data/index.d.ts +3 -0
  16. package/dist/data/index.d.ts.map +1 -0
  17. package/dist/data/mock.d.ts +9 -0
  18. package/dist/data/mock.d.ts.map +1 -0
  19. package/dist/data/supabase.d.ts +9 -0
  20. package/dist/data/supabase.d.ts.map +1 -0
  21. package/dist/data/types.d.ts +32 -0
  22. package/dist/data/types.d.ts.map +1 -0
  23. package/dist/index.cjs +4601 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.ts +72 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +4595 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/lib/tenant.d.ts +3 -0
  30. package/dist/lib/tenant.d.ts.map +1 -0
  31. package/dist/locales/en.d.ts +2 -0
  32. package/dist/locales/en.d.ts.map +1 -0
  33. package/dist/locales/index.d.ts +2 -0
  34. package/dist/locales/index.d.ts.map +1 -0
  35. package/dist/locales/pt-BR.d.ts +2 -0
  36. package/dist/locales/pt-BR.d.ts.map +1 -0
  37. package/dist/registries.d.ts +3 -0
  38. package/dist/registries.d.ts.map +1 -0
  39. package/dist/schema/index.d.ts +1036 -0
  40. package/dist/schema/index.d.ts.map +1 -0
  41. package/dist/store.d.ts +43 -0
  42. package/dist/store.d.ts.map +1 -0
  43. package/dist/types.d.ts +238 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/views/ActivityListView.d.ts +3 -0
  46. package/dist/views/ActivityListView.d.ts.map +1 -0
  47. package/dist/views/DashboardView.d.ts +9 -0
  48. package/dist/views/DashboardView.d.ts.map +1 -0
  49. package/dist/views/DealSidebar.d.ts +9 -0
  50. package/dist/views/DealSidebar.d.ts.map +1 -0
  51. package/dist/views/LeadDetailView.d.ts +8 -0
  52. package/dist/views/LeadDetailView.d.ts.map +1 -0
  53. package/dist/views/LeadFormView.d.ts +5 -0
  54. package/dist/views/LeadFormView.d.ts.map +1 -0
  55. package/dist/views/LeadListView.d.ts +6 -0
  56. package/dist/views/LeadListView.d.ts.map +1 -0
  57. package/dist/views/PipelineView.d.ts +8 -0
  58. package/dist/views/PipelineView.d.ts.map +1 -0
  59. package/dist/views/QuoteDetailView.d.ts +8 -0
  60. package/dist/views/QuoteDetailView.d.ts.map +1 -0
  61. package/dist/views/QuoteFormView.d.ts +7 -0
  62. package/dist/views/QuoteFormView.d.ts.map +1 -0
  63. package/dist/views/QuoteListView.d.ts +7 -0
  64. package/dist/views/QuoteListView.d.ts.map +1 -0
  65. package/dist/views/dashboardWidgets.d.ts +11 -0
  66. package/dist/views/dashboardWidgets.d.ts.map +1 -0
  67. package/package.json +55 -0
  68. package/src/CrmContext.tsx +30 -0
  69. package/src/CrmPage.tsx +152 -0
  70. package/src/README.md +97 -0
  71. package/src/cascade.ts +24 -0
  72. package/src/components/CrmGeneralSettings.tsx +36 -0
  73. package/src/components/CrmOnboarding.tsx +52 -0
  74. package/src/components/PipelineSettings.tsx +45 -0
  75. package/src/components/QuoteStatusDropdown.tsx +214 -0
  76. package/src/data/index.ts +2 -0
  77. package/src/data/mock.ts +426 -0
  78. package/src/data/supabase.ts +634 -0
  79. package/src/data/types.ts +50 -0
  80. package/src/index.ts +240 -0
  81. package/src/lib/tenant.ts +4 -0
  82. package/src/locales/en.ts +292 -0
  83. package/src/locales/index.ts +7 -0
  84. package/src/locales/pt-BR.ts +292 -0
  85. package/src/migrations/001_crm_base.sql +73 -0
  86. package/src/migrations/002_activities.sql +33 -0
  87. package/src/migrations/003_crm_views_rls.sql +61 -0
  88. package/src/migrations/004_seed_default_pipeline.sql +31 -0
  89. package/src/registries.ts +88 -0
  90. package/src/schema/index.ts +102 -0
  91. package/src/store.ts +375 -0
  92. package/src/types.ts +280 -0
  93. package/src/views/ActivityListView.tsx +183 -0
  94. package/src/views/DashboardView.tsx +12 -0
  95. package/src/views/DealSidebar.tsx +414 -0
  96. package/src/views/LeadDetailView.tsx +264 -0
  97. package/src/views/LeadFormView.tsx +56 -0
  98. package/src/views/LeadListView.tsx +81 -0
  99. package/src/views/PipelineView.tsx +299 -0
  100. package/src/views/QuoteDetailView.tsx +408 -0
  101. package/src/views/QuoteFormView.tsx +489 -0
  102. package/src/views/QuoteListView.tsx +101 -0
  103. package/src/views/dashboardWidgets.tsx +248 -0
@@ -0,0 +1,292 @@
1
+ // crm.* — merged plugin-own + saas-core central i18n
2
+ export const ptBR: Record<string, string> = {
3
+ "crm.activities.activitiesLogged": "Atividades são registradas a partir de interações com leads e negócios",
4
+ "crm.activities.all": "Todas",
5
+ "crm.activities.completedFilter": "Concluídas",
6
+ "crm.activities.done": "Concluído",
7
+ "crm.activities.noActivities": "Nenhuma atividade",
8
+ "crm.activities.noActivitiesOfType": "Nenhuma atividade do tipo \"{{type}}\"",
9
+ "crm.activities.overdue": "atrasada",
10
+ "crm.activities.overdueLabel": "Atrasada",
11
+ "crm.activities.pending": "pendente",
12
+ "crm.activities.pendingFilter": "Pendentes",
13
+ "crm.activities.title": "Atividades",
14
+ "crm.dashboard.activeDeals": "{{count}} negócios ativos",
15
+ "crm.dashboard.avgDealValue": "Valor médio do negócio",
16
+ "crm.dashboard.leadsCount": "{{count}} leads",
17
+ "crm.dashboard.quotesCount": "{{count}} orçamentos",
18
+ "crm.dashboard.conversionRate": "Taxa de Conversão",
19
+ "crm.dashboard.conversionRateLabel": "Taxa de conversão",
20
+ "crm.dashboard.createFirstLead": "Crie seu primeiro lead para ver o funil",
21
+ "crm.dashboard.dealsWon": "Negócios fechados neste mês",
22
+ "crm.dashboard.leadToDeal": "Lead para negócio",
23
+ "crm.dashboard.newThisMonth": "{{count}} novos neste mês",
24
+ "crm.dashboard.noLeadsYet": "Nenhum lead ainda. Capture seu primeiro lead para começar.",
25
+ "crm.dashboard.noPipelineData": "Nenhum dado de pipeline ainda",
26
+ "crm.dashboard.noQuotesYet": "Nenhum orçamento ainda.",
27
+ "crm.dashboard.openPipeline": "Pipeline Aberto",
28
+ "crm.dashboard.overdueCount": "{{count}} atrasados",
29
+ "crm.dashboard.pendingTasks": "Tarefas Pendentes",
30
+ "crm.dashboard.performance": "Desempenho",
31
+ "crm.dashboard.pipelineOverview": "Visão Geral do Pipeline",
32
+ "crm.dashboard.pipelineValue": "Valor do Pipeline",
33
+ "crm.dashboard.recentLeads": "Leads Recentes",
34
+ "crm.dashboard.recentQuotes": "Orçamentos Recentes",
35
+ "crm.dashboard.revenueWon": "Receita ganha",
36
+ "crm.dashboard.totalDeals": "{{count}} negócios no total",
37
+ "crm.dashboard.totalLeads": "Total de Leads",
38
+ "crm.dealSidebar.activitiesAppear": "As atividades aparecerão aqui conforme forem registradas",
39
+ "crm.dealSidebar.activity": "Atividade",
40
+ "crm.dealSidebar.assignedTo": "Atribuído a",
41
+ "crm.dealSidebar.contact": "Contato",
42
+ "crm.dealSidebar.created": "Criado",
43
+ "crm.dealSidebar.deal": "Negócio",
44
+ "crm.dealSidebar.dealNotFound": "Negócio não encontrado",
45
+ "crm.dealSidebar.expectedClose": "Fechamento previsto",
46
+ "crm.dealSidebar.noActivities": "Nenhuma atividade ainda",
47
+ "crm.dealSidebar.noQuotes": "Nenhum orçamento vinculado",
48
+ "crm.dealSidebar.notes": "Observações",
49
+ "crm.dealSidebar.overview": "Visão Geral",
50
+ "crm.dealSidebar.probability": "Probabilidade",
51
+ "crm.dealSidebar.quotes": "Orçamentos",
52
+ "crm.dealSidebar.quotesAppear": "Orçamentos criados para este lead aparecerão aqui",
53
+ "crm.dealSidebar.stage": "Etapa",
54
+ "crm.dealSidebar.tags": "Tags",
55
+ "crm.dealSidebar.updated": "Atualizado",
56
+ "crm.dealSidebar.value": "Valor",
57
+ "crm.dealSidebar.viewLeadProfile": "Ver Perfil Completo do Lead",
58
+ "crm.leadDetail.assignedTo": "Atribuído a",
59
+ "crm.leadDetail.backToList": "Voltar à lista",
60
+ "crm.leadDetail.company": "Empresa",
61
+ "crm.leadDetail.contactInfo": "Informações de Contato",
62
+ "crm.leadDetail.createQuote": "Criar Orçamento",
63
+ "crm.leadDetail.created": "Criado",
64
+ "crm.leadDetail.dealStatus": "Status do negócio",
65
+ "crm.leadDetail.dealValue": "Valor do negócio",
66
+ "crm.leadDetail.details": "Detalhes",
67
+ "crm.leadDetail.email": "E-mail",
68
+ "crm.leadDetail.leadNotFound": "Lead não encontrado",
69
+ "crm.leadDetail.leads": "Leads",
70
+ "crm.leadDetail.loading": "Carregando...",
71
+ "crm.leadDetail.notFound": "Não encontrado",
72
+ "crm.leadDetail.notes": "Observações",
73
+ "crm.leadDetail.phone": "Telefone",
74
+ "crm.leadDetail.pipeline": "Pipeline",
75
+ "crm.leadDetail.probability": "Probabilidade",
76
+ "crm.leadDetail.quotes": "Orçamentos",
77
+ "crm.leadDetail.source": "Origem",
78
+ "crm.leadDetail.stage": "Etapa",
79
+ "crm.leadDetail.tags": "Tags",
80
+ "crm.leadDetail.updated": "Atualizado",
81
+ "crm.leadDetail.value": "Valor",
82
+ "crm.leadForm.cancel": "Cancelar",
83
+ "crm.leadForm.company": "Empresa",
84
+ "crm.leadForm.companyPlaceholder": "Nome da empresa",
85
+ "crm.leadForm.email": "E-mail",
86
+ "crm.leadForm.emailPlaceholder": "email@exemplo.com",
87
+ "crm.leadForm.name": "Nome *",
88
+ "crm.leadForm.namePlaceholder": "Nome do contato",
89
+ "crm.leadForm.notes": "Observações",
90
+ "crm.leadForm.notesPlaceholder": "Observações adicionais...",
91
+ "crm.leadForm.phone": "Telefone",
92
+ "crm.leadForm.phonePlaceholder": "+55 11 99999-9999",
93
+ "crm.leadForm.save": "Salvar",
94
+ "crm.leadForm.saving": "Salvando...",
95
+ "crm.leadForm.subtitle": "Capturar um novo lead",
96
+ "crm.leadForm.title": "Novo Lead",
97
+ "crm.leads.captureFirst": "Capture seu primeiro lead",
98
+ "crm.leads.contactCol": "Contato",
99
+ "crm.leads.name": "Nome",
100
+ "crm.leads.newLead": "Novo Lead",
101
+ "crm.leads.noLeads": "Nenhum lead ainda",
102
+ "crm.leads.searchPlaceholder": "Buscar leads...",
103
+ "crm.leads.source": "Origem",
104
+ "crm.leads.statusCol": "Status",
105
+ "crm.leads.title": "Leads",
106
+ "crm.page.logActivity": "Registrar Atividade",
107
+ "crm.page.logActivityDesc": "Registrar uma ligação, e-mail ou nota",
108
+ "crm.page.newDeal": "Novo Negócio",
109
+ "crm.page.newDealDesc": "Criar um negócio a partir do pipeline",
110
+ "crm.page.newLead": "Novo Lead",
111
+ "crm.page.newLeadDesc": "Capturar um novo lead",
112
+ "crm.page.newQuote": "Novo Orçamento",
113
+ "crm.page.newQuoteDesc": "Enviar uma proposta",
114
+ "crm.page.settingsSubtitle": "Configure pipeline, gestão de leads e cadastros",
115
+ "crm.page.settingsTitle": "Configurações de Vendas e CRM",
116
+ "crm.pipeline.dropHere": "Solte aqui",
117
+ "crm.pipeline.moveFailed": "Falha ao mover negócio",
118
+ "crm.pipeline.movedTo": "Movido para {{stage}}",
119
+ "crm.pipeline.noDeals": "Nenhum negócio",
120
+ "crm.pipeline.subtitle": "Arraste negócios entre etapas",
121
+ "crm.pipeline.title": "Pipeline",
122
+ "crm.quoteDetail.backToList": "Voltar à lista",
123
+ "crm.quoteDetail.client": "Cliente",
124
+ "crm.quoteDetail.date": "Data",
125
+ "crm.quoteDetail.description": "Descrição",
126
+ "crm.quoteDetail.discount": "Desconto",
127
+ "crm.quoteDetail.edit": "Editar",
128
+ "crm.quoteDetail.send": "Enviar",
129
+ "crm.quoteDetail.sending": "Enviando...",
130
+ "crm.quoteDetail.sendPrint": "Imprimir",
131
+ "crm.quoteDetail.sendEmail": "Enviar por E-mail",
132
+ "crm.quoteDetail.sendWhatsApp": "Enviar por WhatsApp",
133
+ "crm.quoteDetail.approve": "Aprovar",
134
+ "crm.quoteDetail.approving": "Aprovando...",
135
+ "crm.quoteDetail.reject": "Rejeitar",
136
+ "crm.quoteDetail.rejecting": "Rejeitando...",
137
+ "crm.quoteDetail.confirmReject": "Confirmar Rejeição",
138
+ "crm.quoteDetail.rejectDescription": "Informe o motivo da rejeição deste orçamento.",
139
+ "crm.quoteDetail.rejectReasonPlaceholder": "Motivo da rejeição...",
140
+ "crm.quoteDetail.invoiceCreated": "Fatura criada a partir deste orçamento",
141
+ "crm.quoteDetail.items": "Itens",
142
+ "crm.quoteDetail.loading": "Carregando...",
143
+ "crm.quoteDetail.notFound": "Orçamento não encontrado",
144
+ "crm.quoteDetail.notes": "Observações",
145
+ "crm.quoteDetail.paymentConditions": "Condições de Pagamento",
146
+ "crm.quoteDetail.qty": "Qtd",
147
+ "crm.quoteDetail.quoteNumber": "Orçamento {{number}}",
148
+ "crm.quoteDetail.rejectionReason": "Motivo da rejeição",
149
+ "crm.quoteDetail.subtotal": "Subtotal",
150
+ "crm.quoteDetail.title": "Orçamentos",
151
+ "crm.quoteDetail.total": "Total",
152
+ "crm.quoteDetail.unitPrice": "Preço Unitário",
153
+ "crm.quoteDetail.validUntil": "Válido Até",
154
+ "crm.quoteDetail.viewInvoice": "Ver Fatura",
155
+ "crm.quoteForm.addFirstItem": "Adicione seu primeiro item",
156
+ "crm.quoteForm.addItem": "Adicionar Item",
157
+ "crm.quoteForm.cancel": "Cancelar",
158
+ "crm.quoteForm.client": "Cliente",
159
+ "crm.quoteForm.description": "Descrição",
160
+ "crm.quoteForm.discount": "Desconto",
161
+ "crm.quoteForm.done": "Concluído",
162
+ "crm.quoteForm.editSubtitle": "Atualizar esta proposta",
163
+ "crm.quoteForm.editTitle": "Editar Orçamento",
164
+ "crm.quoteForm.itemCount": "{{count}} itens",
165
+ "crm.quoteForm.itemDescriptionPlaceholder": "Descrição do item",
166
+ "crm.quoteForm.loading": "Carregando...",
167
+ "crm.quoteForm.newSubtitle": "Criar uma proposta para seu cliente",
168
+ "crm.quoteForm.newTitle": "Novo Orçamento",
169
+ "crm.quoteForm.noDescription": "Sem descrição",
170
+ "crm.quoteForm.noItems": "Nenhum item adicionado",
171
+ "crm.quoteForm.errNoItems": "Adicione pelo menos um item antes de salvar.",
172
+ "crm.quoteForm.notes": "Observações",
173
+ "crm.quoteForm.notesPlaceholder": "Observações internas...",
174
+ "crm.quoteForm.paymentConditions": "Condições de Pagamento",
175
+ "crm.quoteForm.paymentConditionsPlaceholder": "ex. 50% antecipado, 50% na entrega",
176
+ "crm.quoteForm.qty": "Qtd",
177
+ "crm.quoteForm.quoteDate": "Data do Orçamento",
178
+ "crm.quoteForm.quoteDetails": "Detalhes do Orçamento",
179
+ "crm.quoteForm.quoteItems": "Itens do Orçamento",
180
+ "crm.quoteForm.saveChanges": "Salvar Alterações",
181
+ "crm.quoteForm.saveQuote": "Salvar Orçamento",
182
+ "crm.quoteForm.saving": "Salvando...",
183
+ "crm.quoteForm.searchClient": "Buscar cliente...",
184
+ "crm.quoteForm.addAsLead": "Adicionar como lead",
185
+ "crm.quoteForm.selectItemType": "Selecione o tipo de item:",
186
+ "crm.quoteForm.statusApproved": "Aprovado",
187
+ "crm.quoteForm.statusDraft": "Rascunho",
188
+ "crm.quoteForm.statusExpired": "Expirado",
189
+ "crm.quoteForm.statusRejected": "Rejeitado",
190
+ "crm.quoteForm.statusSent": "Enviado",
191
+ "crm.quoteForm.total": "Total",
192
+ "crm.quoteForm.unitPrice": "Preço Unitário",
193
+ "crm.quoteForm.validUntil": "Válido Até",
194
+ "crm.quotes.amount": "Valor",
195
+ "crm.quotes.contact": "Contato",
196
+ "crm.quotes.createFirst": "Crie seu primeiro orçamento",
197
+ "crm.quotes.date": "Data",
198
+ "crm.quotes.newQuote": "Novo Orçamento",
199
+ "crm.quotes.noQuotes": "Nenhum orçamento ainda",
200
+ "crm.quotes.quotesCount": "{{count}} orçamentos",
201
+ "crm.quotes.status": "Status",
202
+ "crm.quotes.title": "Orçamentos",
203
+ "crm.quickActions.newLead": "Novo Lead",
204
+ "crm.quickActions.newLeadDesc": "Capturar um novo lead",
205
+ "crm.quickActions.newDeal": "Novo Negócio",
206
+ "crm.quickActions.newDealDesc": "Criar um negócio no pipeline",
207
+ "crm.quickActions.newQuote": "Novo Orçamento",
208
+ "crm.quickActions.newQuoteDesc": "Enviar uma proposta",
209
+ "crm.quickActions.logActivity": "Registrar Atividade",
210
+ "crm.quickActions.logActivityDesc": "Registrar ligação, e-mail ou nota",
211
+ "crm.settingsPage.title": "Configurações de Vendas e CRM",
212
+ "crm.settingsPage.subtitle": "Configurar pipeline, gestão de leads e registros",
213
+ "crm.settingsPage.pipeline": "Pipeline",
214
+ "crm.onboarding.welcome": "Bem-vindo ao Vendas e CRM",
215
+ "crm.onboarding.description": "Acompanhe leads, gerencie seu pipeline de vendas e feche mais negócios.",
216
+ "crm.onboarding.sources.title": "Fontes de Leads",
217
+ "crm.onboarding.sources.description": "Fontes padrão (Instagram, WhatsApp, Google, etc.) estão prontas. Personalize-as em Configurações.",
218
+ "crm.onboarding.pipeline.title": "Pipeline de Vendas",
219
+ "crm.onboarding.pipeline.description": "Seu pipeline padrão com 7 estágios está configurado. Personalize estágios e probabilidades a qualquer momento.",
220
+ "crm.onboarding.startSelling": "Começar a vender",
221
+ "crm.onboarding.getStarted": "Começar",
222
+ "crm.onboarding.next": "Próximo",
223
+ "crm.onboarding.skip": "Pular configuração",
224
+ "crm.settings.leadManagement": "Gestão de Leads",
225
+ "crm.settings.leadManagementDesc": "Como leads são capturados e gerenciados",
226
+ "crm.settings.autoAssign": "Auto-atribuir leads",
227
+ "crm.settings.autoAssignDesc": "Atribuir automaticamente novos leads a membros disponíveis da equipe",
228
+ "crm.settings.requireSource": "Exigir fonte do lead",
229
+ "crm.settings.requireSourceDesc": "Tornar obrigatória a seleção de fonte ao capturar leads",
230
+ "crm.settings.leadScoring": "Pontuação de leads",
231
+ "crm.settings.leadScoringDesc": "Pontuar automaticamente leads com base em sinais de engajamento",
232
+ "crm.settings.duplicateDetection": "Detecção de duplicatas",
233
+ "crm.settings.duplicateDetectionDesc": "Avisar quando um lead com o mesmo e-mail ou telefone já existir",
234
+ "crm.settings.deals": "Negócios",
235
+ "crm.settings.dealsDesc": "Comportamento do pipeline de negócios",
236
+ "crm.settings.autoCreateDeal": "Auto-criar negócio na conversão",
237
+ "crm.settings.autoCreateDealDesc": "Criar um negócio automaticamente quando um lead é qualificado",
238
+ "crm.settings.requireCloseDate": "Exigir data de fechamento prevista",
239
+ "crm.settings.requireCloseDateDesc": "Tornar obrigatória a data de fechamento prevista nos negócios",
240
+ "crm.settings.rottingDeals": "Aviso de negócios parados",
241
+ "crm.settings.rottingDealsDesc": "Destacar negócios que não foram atualizados há X dias",
242
+ "crm.settings.weightedPipeline": "Valor ponderado do pipeline",
243
+ "crm.settings.weightedPipelineDesc": "Calcular valor do pipeline usando probabilidade do estágio",
244
+ "crm.settings.quotes": "Orçamentos",
245
+ "crm.settings.quotesDesc": "Comportamento de orçamentos e propostas",
246
+ "crm.settings.autoNumberQuotes": "Numeração automática de orçamentos",
247
+ "crm.settings.autoNumberQuotesDesc": "Gerar automaticamente números sequenciais de orçamentos",
248
+ "crm.settings.defaultValidity": "Validade padrão (30 dias)",
249
+ "crm.settings.defaultValidityDesc": "Novos orçamentos expiram após 30 dias por padrão",
250
+ "crm.settings.requireApproval": "Exigir aprovação",
251
+ "crm.settings.requireApprovalDesc": "Orçamentos precisam de aprovação do gerente antes do envio",
252
+ "crm.settings.notifications": "Notificações",
253
+ "crm.settings.notificationsDesc": "Alertas e lembretes",
254
+ "crm.settings.overdueAlerts": "Alertas de atividades atrasadas",
255
+ "crm.settings.overdueAlertsDesc": "Notificar quando atividades passarem da data de vencimento",
256
+ "crm.settings.stageChangeAlerts": "Alertas de mudança de estágio",
257
+ "crm.settings.stageChangeAlertsDesc": "Notificar quando negócios mudarem de estágio",
258
+ "crm.settings.newLeadNotif": "Notificação de novo lead",
259
+ "crm.settings.newLeadNotifDesc": "Alertar equipe quando um novo lead é capturado",
260
+ "crm.pipelineSettings.title": "Estágios do Pipeline",
261
+ "crm.pipelineSettings.description": "Defina os estágios pelos quais os negócios passam. Arraste para reordenar.",
262
+ "crm.pipelineSettings.probability": "Probabilidade",
263
+ "crm.pipelineSettings.winStage": "Estágio de ganho",
264
+ "crm.pipelineSettings.lossStage": "Estágio de perda",
265
+ "crm.pipelineSettings.customizationNote": "A personalização dos estágios do pipeline (adicionar, remover, reordenar, editar cores e probabilidades) estará disponível quando conectado ao banco de dados.",
266
+ "crm.title": "CRM",
267
+ "crm.deals.title": "Negócios",
268
+ "crm.deals.create": "Novo Negócio",
269
+ "crm.deals.value": "Valor",
270
+ "crm.deals.stage": "Etapa",
271
+ "crm.deals.probability": "Probabilidade",
272
+ "crm.deals.expectedClose": "Fechamento Previsto",
273
+ "crm.deals.empty": "Nenhum negócio ainda",
274
+ "crm.leads.create": "Novo Lead",
275
+ "crm.leads.status": "Status",
276
+ "crm.leads.convertToDeal": "Converter em Negócio",
277
+ "crm.contacts.title": "Contatos",
278
+ "crm.contacts.create": "Novo Contato",
279
+ "crm.quotes.create": "Novo Orçamento",
280
+ "crm.quotes.edit": "Editar Orçamento",
281
+ "crm.quotes.items": "Itens",
282
+ "crm.quotes.addItem": "Adicionar Item",
283
+ "crm.quotes.subtotal": "Subtotal",
284
+ "crm.quotes.discount": "Desconto",
285
+ "crm.quotes.total": "Total",
286
+ "crm.quotes.save": "Salvar Orçamento",
287
+ "crm.quotes.saving": "Salvando...",
288
+ "crm.quotes.send": "Enviar Orçamento",
289
+ "crm.quotes.loading": "Carregando...",
290
+ "crm.settings.title": "Configurações do CRM",
291
+ "crm.settings.pipeline": "Etapas do Pipeline",
292
+ }
@@ -0,0 +1,73 @@
1
+ -- CRM Plugin: Base Tables
2
+ -- Leads use saas_core.persons (kind='lead')
3
+ -- Deals use saas_core.orders (kind='deal')
4
+ -- Quotes use saas_core.orders (kind='quote') + saas_core.order_items
5
+ -- These are plugin-specific extension tables
6
+
7
+ CREATE TABLE IF NOT EXISTS public.pipelines (
8
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
9
+ tenant_id uuid NOT NULL REFERENCES saas_core.tenants(id) ON DELETE CASCADE,
10
+ name text NOT NULL,
11
+ is_default boolean DEFAULT false,
12
+ is_active boolean NOT NULL DEFAULT true,
13
+ created_at timestamptz NOT NULL DEFAULT now(),
14
+ updated_at timestamptz NOT NULL DEFAULT now()
15
+ );
16
+ ALTER TABLE public.pipelines ENABLE ROW LEVEL SECURITY;
17
+ CREATE INDEX IF NOT EXISTS idx_pipelines_tenant ON public.pipelines(tenant_id);
18
+
19
+ CREATE TABLE IF NOT EXISTS public.pipeline_stages (
20
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
21
+ tenant_id uuid NOT NULL REFERENCES saas_core.tenants(id) ON DELETE CASCADE,
22
+ pipeline_id uuid NOT NULL REFERENCES public.pipelines(id) ON DELETE CASCADE,
23
+ name text NOT NULL,
24
+ "order" integer NOT NULL DEFAULT 0,
25
+ color text DEFAULT '#6366f1',
26
+ probability numeric(5,2) DEFAULT 0,
27
+ is_won boolean DEFAULT false,
28
+ is_lost boolean DEFAULT false,
29
+ created_at timestamptz NOT NULL DEFAULT now()
30
+ );
31
+ ALTER TABLE public.pipeline_stages ENABLE ROW LEVEL SECURITY;
32
+ CREATE INDEX IF NOT EXISTS idx_pipeline_stages_tenant ON public.pipeline_stages(tenant_id);
33
+ CREATE INDEX IF NOT EXISTS idx_pipeline_stages_pipeline ON public.pipeline_stages(pipeline_id);
34
+
35
+ CREATE TABLE IF NOT EXISTS public.lead_sources (
36
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
37
+ tenant_id uuid NOT NULL REFERENCES saas_core.tenants(id) ON DELETE CASCADE,
38
+ name text NOT NULL,
39
+ is_active boolean NOT NULL DEFAULT true,
40
+ created_at timestamptz NOT NULL DEFAULT now()
41
+ );
42
+ ALTER TABLE public.lead_sources ENABLE ROW LEVEL SECURITY;
43
+ CREATE INDEX IF NOT EXISTS idx_lead_sources_tenant ON public.lead_sources(tenant_id);
44
+
45
+ CREATE TABLE IF NOT EXISTS public.crm_tags (
46
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
47
+ tenant_id uuid NOT NULL REFERENCES saas_core.tenants(id) ON DELETE CASCADE,
48
+ name text NOT NULL,
49
+ color text DEFAULT '#6366f1',
50
+ is_active boolean NOT NULL DEFAULT true,
51
+ created_at timestamptz NOT NULL DEFAULT now()
52
+ );
53
+ ALTER TABLE public.crm_tags ENABLE ROW LEVEL SECURITY;
54
+ CREATE INDEX IF NOT EXISTS idx_crm_tags_tenant ON public.crm_tags(tenant_id);
55
+
56
+ -- Deal extension: links saas_core.orders (kind='deal') to pipeline stage
57
+ CREATE TABLE IF NOT EXISTS public.deal_extensions (
58
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
59
+ order_id uuid NOT NULL REFERENCES saas_core.orders(id) ON DELETE CASCADE,
60
+ tenant_id uuid NOT NULL REFERENCES saas_core.tenants(id) ON DELETE CASCADE,
61
+ pipeline_id uuid REFERENCES public.pipelines(id),
62
+ stage_id uuid REFERENCES public.pipeline_stages(id),
63
+ probability numeric(5,2) DEFAULT 0,
64
+ expected_close_date date,
65
+ lead_id uuid REFERENCES saas_core.persons(id),
66
+ lost_reason text,
67
+ created_at timestamptz NOT NULL DEFAULT now(),
68
+ updated_at timestamptz NOT NULL DEFAULT now()
69
+ );
70
+ ALTER TABLE public.deal_extensions ENABLE ROW LEVEL SECURITY;
71
+ CREATE INDEX IF NOT EXISTS idx_deal_extensions_tenant ON public.deal_extensions(tenant_id);
72
+ CREATE INDEX IF NOT EXISTS idx_deal_extensions_order ON public.deal_extensions(order_id);
73
+ CREATE INDEX IF NOT EXISTS idx_deal_extensions_stage ON public.deal_extensions(stage_id);
@@ -0,0 +1,33 @@
1
+ -- CRM Plugin: Activities & Tasks
2
+
3
+ CREATE TABLE IF NOT EXISTS public.crm_activity_types (
4
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
5
+ tenant_id uuid NOT NULL REFERENCES saas_core.tenants(id) ON DELETE CASCADE,
6
+ name text NOT NULL,
7
+ is_active boolean NOT NULL DEFAULT true,
8
+ created_at timestamptz NOT NULL DEFAULT now()
9
+ );
10
+ ALTER TABLE public.crm_activity_types ENABLE ROW LEVEL SECURITY;
11
+ CREATE INDEX IF NOT EXISTS idx_crm_activity_types_tenant ON public.crm_activity_types(tenant_id);
12
+
13
+ CREATE TABLE IF NOT EXISTS public.crm_activities (
14
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
15
+ tenant_id uuid NOT NULL REFERENCES saas_core.tenants(id) ON DELETE CASCADE,
16
+ deal_id uuid REFERENCES saas_core.orders(id),
17
+ lead_id uuid REFERENCES saas_core.persons(id),
18
+ contact_id uuid REFERENCES saas_core.persons(id),
19
+ contact_name text,
20
+ activity_type text NOT NULL,
21
+ title text NOT NULL,
22
+ description text,
23
+ due_date date,
24
+ completed_at timestamptz,
25
+ assigned_to_id uuid,
26
+ assigned_to_name text,
27
+ created_at timestamptz NOT NULL DEFAULT now()
28
+ );
29
+ ALTER TABLE public.crm_activities ENABLE ROW LEVEL SECURITY;
30
+ CREATE INDEX IF NOT EXISTS idx_crm_activities_tenant ON public.crm_activities(tenant_id);
31
+ CREATE INDEX IF NOT EXISTS idx_crm_activities_deal ON public.crm_activities(deal_id);
32
+ CREATE INDEX IF NOT EXISTS idx_crm_activities_lead ON public.crm_activities(lead_id);
33
+ CREATE INDEX IF NOT EXISTS idx_crm_activities_due ON public.crm_activities(tenant_id, due_date);
@@ -0,0 +1,61 @@
1
+ -- CRM plugin — companion SQL (functions/views/RLS Drizzle doesn't diff).
2
+ -- Tables come from the Drizzle schema (src/schema/); this is everything else the
3
+ -- plugin's data provider depends on: RLS policies + grants + the read-views.
4
+ -- Idempotent. Canonical RLS form: tenant_id IN (SELECT public.user_tenant_ids()).
5
+
6
+ DO $$
7
+ DECLARE t text;
8
+ BEGIN
9
+ FOR t IN SELECT unnest(ARRAY[
10
+ 'pipelines','pipeline_stages','lead_sources','crm_tags',
11
+ 'deal_extensions','crm_activity_types','crm_activities'
12
+ ])
13
+ LOOP
14
+ EXECUTE format('ALTER TABLE public.%I ENABLE ROW LEVEL SECURITY', t);
15
+ EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON public.%I TO authenticated', t);
16
+ IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_select') THEN
17
+ EXECUTE format('CREATE POLICY %I ON public.%I FOR SELECT TO authenticated USING (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_select', t);
18
+ END IF;
19
+ IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_insert') THEN
20
+ EXECUTE format('CREATE POLICY %I ON public.%I FOR INSERT TO authenticated WITH CHECK (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_insert', t);
21
+ END IF;
22
+ IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_update') THEN
23
+ EXECUTE format('CREATE POLICY %I ON public.%I FOR UPDATE TO authenticated USING (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_update', t);
24
+ END IF;
25
+ IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_delete') THEN
26
+ EXECUTE format('CREATE POLICY %I ON public.%I FOR DELETE TO authenticated USING (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_delete', t);
27
+ END IF;
28
+ END LOOP;
29
+ END $$;
30
+
31
+ -- v_leads: saas_core.persons (kind='lead')
32
+ CREATE OR REPLACE VIEW public.v_leads WITH (security_invoker=true) AS
33
+ SELECT
34
+ p.id, p.tenant_id, p.name, p.email, p.phone, p.notes, p.tags, p.is_active,
35
+ p.metadata->>'company' AS company,
36
+ p.metadata->>'sourceId' AS source_id,
37
+ p.metadata->>'sourceName' AS source_name,
38
+ COALESCE(p.metadata->>'status','new') AS lead_status,
39
+ p.metadata->>'value' AS lead_value,
40
+ p.metadata->>'assignedToId' AS assigned_to_id,
41
+ p.created_at, p.updated_at
42
+ FROM saas_core.persons p
43
+ WHERE p.kind = 'lead';
44
+ GRANT SELECT ON public.v_leads TO authenticated;
45
+
46
+ -- v_deals: saas_core.orders (kind='deal') JOIN deal_extensions JOIN pipeline_stages
47
+ CREATE OR REPLACE VIEW public.v_deals WITH (security_invoker=true) AS
48
+ SELECT
49
+ o.id, o.tenant_id, o.status,
50
+ o.total AS value, o.notes AS title,
51
+ o.party_id AS contact_id, o.assignee_id AS assigned_to_id, o.tags,
52
+ o.metadata->>'contactName' AS contact_name,
53
+ o.created_at, o.updated_at,
54
+ de.pipeline_id, de.stage_id, de.probability, de.expected_close_date,
55
+ de.lead_id, de.lost_reason,
56
+ ps.name AS stage_name, ps.color AS stage_color, ps."order" AS stage_order
57
+ FROM saas_core.orders o
58
+ LEFT JOIN public.deal_extensions de ON de.order_id = o.id
59
+ LEFT JOIN public.pipeline_stages ps ON ps.id = de.stage_id
60
+ WHERE o.kind = 'deal';
61
+ GRANT SELECT ON public.v_deals TO authenticated;
@@ -0,0 +1,31 @@
1
+ -- CRM plugin — seed: default "Sales Pipeline" + canonical stages.
2
+ -- The pipeline board (#/sales/pipeline) reads public.pipelines / pipeline_stages
3
+ -- directly; a fresh tenant has zero rows and the board renders blank. This
4
+ -- backfills the default pipeline (matching the plugin's mock/offline provider)
5
+ -- for every tenant that has none. Idempotent — tenants with a pipeline are skipped.
6
+ -- Plugin-owned so EVERY app gets it on install (not re-authored per app).
7
+
8
+ DO $$
9
+ DECLARE
10
+ t_id uuid;
11
+ p_id uuid;
12
+ BEGIN
13
+ FOR t_id IN (
14
+ SELECT id FROM saas_core.tenants
15
+ WHERE id NOT IN (SELECT tenant_id FROM public.pipelines)
16
+ )
17
+ LOOP
18
+ INSERT INTO public.pipelines (tenant_id, name, is_default, is_active)
19
+ VALUES (t_id, 'Sales Pipeline', true, true)
20
+ RETURNING id INTO p_id;
21
+
22
+ INSERT INTO public.pipeline_stages (tenant_id, pipeline_id, name, "order", color, probability, is_won, is_lost) VALUES
23
+ (t_id, p_id, 'New', 0, '#6366f1', 10, false, false),
24
+ (t_id, p_id, 'Contacted', 1, '#3b82f6', 25, false, false),
25
+ (t_id, p_id, 'Qualified', 2, '#f59e0b', 50, false, false),
26
+ (t_id, p_id, 'Proposal', 3, '#f97316', 75, false, false),
27
+ (t_id, p_id, 'Negotiation', 4, '#8b5cf6', 90, false, false),
28
+ (t_id, p_id, 'Won', 5, '#22c55e', 100, true, false),
29
+ (t_id, p_id, 'Lost', 6, '#ef4444', 0, false, true);
30
+ END LOOP;
31
+ END $$;
@@ -0,0 +1,88 @@
1
+ import type { PluginRegistryDef } from '@fayz-ai/core'
2
+ import type { EntityDef } from '@fayz-ai/core'
3
+
4
+ const leadSourceEntity: EntityDef = {
5
+ name: 'Lead Source',
6
+ namePlural: 'Lead Sources',
7
+ icon: 'Globe',
8
+ displayField: 'name',
9
+ defaultSort: 'name',
10
+ fields: [
11
+ { key: 'name', label: 'Name', type: 'text', required: true, showInTable: true },
12
+ { key: 'isActive', label: 'Active', type: 'boolean', showInTable: true, defaultValue: true },
13
+ ],
14
+ data: { table: 'lead_sources', tenantScoped: true },
15
+ }
16
+
17
+ const tagEntity: EntityDef = {
18
+ name: 'Tag',
19
+ namePlural: 'Tags',
20
+ icon: 'Tag',
21
+ displayField: 'name',
22
+ defaultSort: 'name',
23
+ fields: [
24
+ { key: 'name', label: 'Name', type: 'text', required: true, showInTable: true },
25
+ { key: 'color', label: 'Color', type: 'text', showInTable: true, defaultValue: '#6366f1' },
26
+ { key: 'isActive', label: 'Active', type: 'boolean', showInTable: true, defaultValue: true },
27
+ ],
28
+ data: { table: 'crm_tags', tenantScoped: true },
29
+ }
30
+
31
+ const activityTypeEntity: EntityDef = {
32
+ name: 'Activity Type',
33
+ namePlural: 'Activity Types',
34
+ icon: 'MessageCircle',
35
+ displayField: 'name',
36
+ defaultSort: 'name',
37
+ fields: [
38
+ { key: 'name', label: 'Name', type: 'text', required: true, showInTable: true },
39
+ { key: 'isActive', label: 'Active', type: 'boolean', showInTable: true, defaultValue: true },
40
+ ],
41
+ data: { table: 'crm_activity_types', tenantScoped: true },
42
+ }
43
+
44
+ export const crmRegistries: PluginRegistryDef[] = [
45
+ {
46
+ id: 'lead-sources',
47
+ entity: leadSourceEntity,
48
+ icon: 'Globe',
49
+ description: 'Where your leads come from',
50
+ display: 'table',
51
+ seedData: [
52
+ { id: 'src-instagram', name: 'Instagram', isActive: true },
53
+ { id: 'src-whatsapp', name: 'WhatsApp', isActive: true },
54
+ { id: 'src-referral', name: 'Referral', isActive: true },
55
+ { id: 'src-google', name: 'Google', isActive: true },
56
+ { id: 'src-website', name: 'Website', isActive: true },
57
+ { id: 'src-walkin', name: 'Walk-in', isActive: true },
58
+ ],
59
+ },
60
+ {
61
+ id: 'tags',
62
+ entity: tagEntity,
63
+ icon: 'Tag',
64
+ description: 'Tags for organizing leads and deals',
65
+ display: 'table',
66
+ seedData: [
67
+ { id: 'tag-vip', name: 'VIP', color: '#f59e0b', isActive: true },
68
+ { id: 'tag-hot', name: 'Hot Lead', color: '#ef4444', isActive: true },
69
+ { id: 'tag-followup', name: 'Follow-up', color: '#3b82f6', isActive: true },
70
+ ],
71
+ },
72
+ {
73
+ id: 'activity-types',
74
+ entity: activityTypeEntity,
75
+ icon: 'MessageCircle',
76
+ description: 'Types of activities and interactions',
77
+ display: 'table',
78
+ readOnly: true,
79
+ seedData: [
80
+ { id: 'at-call', name: 'Call', isActive: true },
81
+ { id: 'at-email', name: 'Email', isActive: true },
82
+ { id: 'at-meeting', name: 'Meeting', isActive: true },
83
+ { id: 'at-note', name: 'Note', isActive: true },
84
+ { id: 'at-task', name: 'Task', isActive: true },
85
+ { id: 'at-whatsapp', name: 'WhatsApp', isActive: true },
86
+ ],
87
+ },
88
+ ]