@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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"fayz": {
|
|
4
4
|
"status": "beta"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.9.
|
|
6
|
+
"version": "0.9.1",
|
|
7
7
|
"description": "Fayz SDK — plugin-crm plugin",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"sideEffects": false,
|
|
@@ -12,25 +12,21 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"source": "./src/index.ts",
|
|
16
15
|
"types": "./dist/index.d.ts",
|
|
17
16
|
"import": "./dist/index.js"
|
|
18
17
|
},
|
|
19
18
|
"./schema": {
|
|
20
|
-
"source": "./src/schema/index.ts",
|
|
21
19
|
"types": "./dist/schema/index.d.ts",
|
|
22
20
|
"import": "./dist/schema.js",
|
|
23
21
|
"require": "./dist/schema.cjs"
|
|
24
22
|
},
|
|
25
23
|
"./public": {
|
|
26
|
-
"source": "./src/public/index.ts",
|
|
27
24
|
"types": "./dist/public/index.d.ts",
|
|
28
25
|
"import": "./dist/public/index.js"
|
|
29
26
|
}
|
|
30
27
|
},
|
|
31
28
|
"files": [
|
|
32
|
-
"dist"
|
|
33
|
-
"src"
|
|
29
|
+
"dist"
|
|
34
30
|
],
|
|
35
31
|
"peerDependencies": {
|
|
36
32
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -40,10 +36,10 @@
|
|
|
40
36
|
},
|
|
41
37
|
"dependencies": {
|
|
42
38
|
"@tanstack/react-table": "^8.20.0",
|
|
43
|
-
"@fayz-ai/core": "^0.
|
|
44
|
-
"@fayz-ai/ui": "^0.
|
|
45
|
-
"@fayz-ai/
|
|
46
|
-
"@fayz-ai/db": "^0.
|
|
39
|
+
"@fayz-ai/core": "^0.10.0",
|
|
40
|
+
"@fayz-ai/ui": "^0.10.0",
|
|
41
|
+
"@fayz-ai/admin": "^0.10.0",
|
|
42
|
+
"@fayz-ai/db": "^0.10.0"
|
|
47
43
|
},
|
|
48
44
|
"devDependencies": {
|
|
49
45
|
"@types/react": "^18.3.0",
|
package/dist/CrmContext.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CrmContext.d.ts","sourceRoot":"","sources":["../src/CrmContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AACjI,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEzC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;IACnB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,WAAW,GAAG,cAAc,CAAA;AAExC,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,UAAU,CAAA;IACnB,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,WAAW,CAAA;IACrB,SAAS,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAClD,aAAa,EAAE,eAAe,CAAA;IAC9B,aAAa,CAAC,EAAE,YAAY,CAAA;CAC7B;AAID,eAAO,MAAM,kBAAkB;;;;;EAAsB,CAAA;AACrD,eAAO,MAAM,YAAY,yBAAgB,CAAA;AACzC,eAAO,MAAM,cAAc,uBAAkB,CAAA;AAC7C,eAAO,MAAM,WAAW,8CAAe,CAAA;AAEvC,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
package/dist/CrmPage.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CrmPage.d.ts","sourceRoot":"","sources":["../src/CrmPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG/C,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,eAAe,CAAA;AAgDzE,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;IAC/D,MAAM,EAAE,iBAAiB,CAAA;IACzB,QAAQ,EAAE,eAAe,CAAA;IACzB,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;IAC3B,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAA;CACjC,qBAyFA"}
|
package/dist/cascade.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cascade.d.ts","sourceRoot":"","sources":["../src/cascade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErE;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAMjE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,GAAG,WAAW,CAMzF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data.supabase.d.ts","sourceRoot":"","sources":["../../src/public/data.supabase.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAEtE,MAAM,WAAW,yBAAyB;IACxC,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAA;CACjB;AA8BD,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,yBAAyB,GACjC,sBAAsB,CAoCxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inbox.d.ts","sourceRoot":"","sources":["../../src/public/inbox.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,SAAS,CAAA;AAEvD,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAwDD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,wBAA6B,GAAG,YAAY,CA4C5F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploads.d.ts","sourceRoot":"","sources":["../../src/public/uploads.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAE9D;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,qBAAqB,CAAA;AAErD,gDAAgD;AAChD,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAEtC,4EAA4E;AAC5E,eAAO,MAAM,yBAAyB,QAAmB,CAAA;AAEzD,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,mGAO7B,CAAA;AAyCV;;;GAGG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAA;IACpB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,IAAI,CAAA;CACX;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAQtE;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;IACjB,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CACxD;AAED,MAAM,WAAW,2BAA2B;IAC1C,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAA;CACjB;AAoBD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,2BAA2B,GAAG,YAAY,CA0C7F"}
|
package/dist/registries.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registries.d.ts","sourceRoot":"","sources":["../src/registries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AA2EtD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAOzF,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,iBAAiB,EA4D5C,CAAA;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAChC,aAAa,CAAC,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,iBAAiB,EAAE,CAYrB"}
|
package/src/CrmContext.tsx
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createPluginContext, formatCurrency, type CurrencyConfig, type EntityLookupMap, type EntityLookup } from '@fayz-ai/saas'
|
|
2
|
-
import type { CrmPluginLabels } from './index'
|
|
3
|
-
import type { CrmDataProvider } from './data/types'
|
|
4
|
-
import type { CrmUIState } from './store'
|
|
5
|
-
|
|
6
|
-
export interface CrmModules {
|
|
7
|
-
quotes: boolean
|
|
8
|
-
activities: boolean
|
|
9
|
-
pipeline: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type CrmCurrency = CurrencyConfig
|
|
13
|
-
|
|
14
|
-
export interface ResolvedCrmConfig {
|
|
15
|
-
modules: CrmModules
|
|
16
|
-
labels: CrmPluginLabels
|
|
17
|
-
currency: CrmCurrency
|
|
18
|
-
itemTypes: Array<{ value: string; label: string }>
|
|
19
|
-
entityLookups: EntityLookupMap
|
|
20
|
-
contactLookup?: EntityLookup
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const ctx = createPluginContext<ResolvedCrmConfig, CrmDataProvider, CrmUIState>('CrmPage')
|
|
24
|
-
|
|
25
|
-
export const CrmContextProvider = ctx.ContextProvider
|
|
26
|
-
export const useCrmConfig = ctx.useConfig
|
|
27
|
-
export const useCrmProvider = ctx.useProvider
|
|
28
|
-
export const useCrmStore = ctx.useStore
|
|
29
|
-
|
|
30
|
-
export { formatCurrency }
|
package/src/CrmPage.tsx
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import React, { useState, useMemo } from 'react'
|
|
2
|
-
import type { StoreApi } from 'zustand/vanilla'
|
|
3
|
-
import { useTranslation } from '@fayz-ai/core'
|
|
4
|
-
import { ModulePage, PageTransition, type ModuleNavItem } from '@fayz-ai/ui'
|
|
5
|
-
import { CrmContextProvider, type ResolvedCrmConfig } from './CrmContext'
|
|
6
|
-
import type { CrmDataProvider } from './data/types'
|
|
7
|
-
import type { CrmUIState } from './store'
|
|
8
|
-
import type { PluginRegistryDef, PluginQuickAction } from '@fayz-ai/core'
|
|
9
|
-
import { useModuleNavigation, ModuleActionBar, createViewRouter } from '@fayz-ai/saas'
|
|
10
|
-
import { CrmGeneralSettings } from './components/CrmGeneralSettings'
|
|
11
|
-
import { CrmOnboarding } from './components/CrmOnboarding'
|
|
12
|
-
import { DashboardView } from './views/DashboardView'
|
|
13
|
-
import { PipelineView } from './views/PipelineView'
|
|
14
|
-
import { LeadListView } from './views/LeadListView'
|
|
15
|
-
import { LeadFormView } from './views/LeadFormView'
|
|
16
|
-
import { QuoteListView } from './views/QuoteListView'
|
|
17
|
-
import { QuoteFormView } from './views/QuoteFormView'
|
|
18
|
-
import { QuoteDetailView } from './views/QuoteDetailView'
|
|
19
|
-
import { LeadDetailView } from './views/LeadDetailView'
|
|
20
|
-
import { ActivityListView } from './views/ActivityListView'
|
|
21
|
-
|
|
22
|
-
function buildNav(config: ResolvedCrmConfig, view: string, navigate: (v: string) => void): ModuleNavItem[] {
|
|
23
|
-
const items: ModuleNavItem[] = [
|
|
24
|
-
{ id: 'dashboard', label: config.labels.dashboard, icon: 'BarChart3', active: view === 'dashboard', onClick: () => navigate('dashboard') },
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
if (config.modules.pipeline) {
|
|
28
|
-
items.push({ id: 'pipeline', label: config.labels.pipeline, icon: 'Filter', active: view === 'pipeline', onClick: () => navigate('pipeline') })
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
items.push({
|
|
32
|
-
id: 'leads', label: config.labels.leads, icon: 'UserPlus',
|
|
33
|
-
children: [
|
|
34
|
-
{ id: 'leads-new', label: config.labels.leadsNew, active: view === 'leads-new', onClick: () => navigate('leads-new') },
|
|
35
|
-
{ id: 'leads-list', label: config.labels.leadsList, active: view === 'leads-list' || view.startsWith('leads-detail:'), onClick: () => navigate('leads-list') },
|
|
36
|
-
],
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
if (config.modules.quotes) {
|
|
40
|
-
items.push({
|
|
41
|
-
id: 'quotes', label: config.labels.quotes, icon: 'FileText',
|
|
42
|
-
children: [
|
|
43
|
-
{ id: 'quotes-new', label: config.labels.quotesNew, active: view === 'quotes-new', onClick: () => navigate('quotes-new') },
|
|
44
|
-
{ id: 'quotes-list', label: config.labels.quotesList, active: view === 'quotes-list' || view.startsWith('quotes-detail:') || view.startsWith('quotes-edit:'), onClick: () => navigate('quotes-list') },
|
|
45
|
-
],
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (config.modules.activities) {
|
|
50
|
-
items.push({ id: 'activities', label: config.labels.activities, icon: 'MessageCircle', active: view === 'activities', onClick: () => navigate('activities') })
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return items
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function CrmPage({ config, provider, store, registries }: {
|
|
57
|
-
config: ResolvedCrmConfig
|
|
58
|
-
provider: CrmDataProvider
|
|
59
|
-
store: StoreApi<CrmUIState>
|
|
60
|
-
registries?: PluginRegistryDef[]
|
|
61
|
-
}) {
|
|
62
|
-
const { view, direction, navigate } = useModuleNavigation('/sales', {
|
|
63
|
-
dashboard: 0, pipeline: 0,
|
|
64
|
-
'leads-list': 0, 'leads-new': 1, 'leads-detail': 1,
|
|
65
|
-
'quotes-list': 0, 'quotes-new': 1, 'quotes-detail': 1, 'quotes-edit': 2,
|
|
66
|
-
activities: 0,
|
|
67
|
-
settings: 1,
|
|
68
|
-
}, 'dashboard')
|
|
69
|
-
|
|
70
|
-
const [onboardingComplete, setOnboardingComplete] = useState(() => {
|
|
71
|
-
try { return localStorage.getItem('saas-core:crm-onboarded') === 'true' } catch { return false }
|
|
72
|
-
})
|
|
73
|
-
const isSettings = view === 'settings'
|
|
74
|
-
const isSummary = view === 'dashboard'
|
|
75
|
-
const nav = buildNav(config, view, navigate)
|
|
76
|
-
|
|
77
|
-
const t = useTranslation()
|
|
78
|
-
|
|
79
|
-
const quickActions = useMemo<PluginQuickAction[]>(() => [
|
|
80
|
-
{ id: 'new-lead', label: t('crm.quickActions.newLead'), icon: 'UserPlus', description: t('crm.quickActions.newLeadDesc'), action: () => navigate('leads-new') },
|
|
81
|
-
{ id: 'new-deal', label: t('crm.quickActions.newDeal'), icon: 'Target', description: t('crm.quickActions.newDealDesc'), action: () => navigate('pipeline') },
|
|
82
|
-
...(config.modules.quotes ? [{ id: 'new-quote', label: t('crm.quickActions.newQuote'), icon: 'FileText', description: t('crm.quickActions.newQuoteDesc'), action: () => navigate('quotes-new') }] : []),
|
|
83
|
-
...(config.modules.activities ? [{ id: 'log-activity', label: t('crm.quickActions.logActivity'), icon: 'MessageCircle', description: t('crm.quickActions.logActivityDesc'), action: () => navigate('activities') }] : []),
|
|
84
|
-
], [config.modules])
|
|
85
|
-
|
|
86
|
-
if (!onboardingComplete) {
|
|
87
|
-
return (
|
|
88
|
-
<CrmContextProvider config={config} provider={provider} store={store}>
|
|
89
|
-
<CrmOnboarding onComplete={() => { setOnboardingComplete(true); try { localStorage.setItem('saas-core:crm-onboarded', 'true') } catch {} }} />
|
|
90
|
-
</CrmContextProvider>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (isSettings && registries && registries.length > 0) {
|
|
95
|
-
return (
|
|
96
|
-
<CrmContextProvider config={config} provider={provider} store={store}>
|
|
97
|
-
<PageTransition transitionKey="settings" direction={direction}>
|
|
98
|
-
<div style={{ padding: '24px', display: 'flex', flexDirection: 'column', gap: '20px' }}>
|
|
99
|
-
<div>
|
|
100
|
-
<h1 style={{ fontSize: '20px', fontWeight: 600, margin: 0 }}>{t('crm.settingsPage.title')}</h1>
|
|
101
|
-
<p style={{ color: 'var(--muted-foreground, #6b7280)', margin: '4px 0 0', fontSize: '14px' }}>
|
|
102
|
-
{t('crm.settingsPage.subtitle')}
|
|
103
|
-
</p>
|
|
104
|
-
</div>
|
|
105
|
-
<CrmGeneralSettings />
|
|
106
|
-
</div>
|
|
107
|
-
</PageTransition>
|
|
108
|
-
</CrmContextProvider>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const renderView = createViewRouter([
|
|
113
|
-
{ id: 'pipeline', render: () => <PipelineView onViewLead={(id) => navigate(`leads-detail:${id}`)} onViewQuote={(id) => navigate(`quotes-detail:${id}`)} onAddLead={() => navigate('leads-new')} /> },
|
|
114
|
-
{ id: 'leads-list', render: () => <LeadListView onNew={() => navigate('leads-new')} onEdit={(id) => navigate(`leads-detail:${id}`)} /> },
|
|
115
|
-
{ id: 'leads-new', render: () => <LeadFormView onSaved={(id) => id ? navigate(`leads-detail:${id}`) : navigate('leads-list')} /> },
|
|
116
|
-
{ id: 'quotes-new', render: () => {
|
|
117
|
-
const hashParams = new URLSearchParams(window.location.hash.split('?')[1] ?? '')
|
|
118
|
-
const lid = hashParams.get('leadId') ?? undefined
|
|
119
|
-
return <QuoteFormView leadId={lid} onSaved={(id) => id ? navigate(`quotes-detail:${id}`) : navigate('quotes-list')} />
|
|
120
|
-
} },
|
|
121
|
-
{ id: 'quotes-list', render: () => <QuoteListView onNew={() => navigate('quotes-new')} onEdit={(id) => navigate(`quotes-detail:${id}`)} onEditQuote={(id) => navigate(`quotes-edit:${id}`)} /> },
|
|
122
|
-
{ id: 'activities', render: () => <ActivityListView onOpenLead={(id) => navigate(`leads-detail:${id}`)} onOpenQuote={(id) => navigate(`quotes-detail:${id}`)} /> },
|
|
123
|
-
{ id: 'leads-detail', render: ({ id }) => <LeadDetailView leadId={id!} onBack={() => navigate('leads-list')} onCreateQuote={(lid) => navigate('quotes-new', `/sales/quotes/new?leadId=${lid}`)} onViewQuote={(qid) => navigate(`quotes-detail:${qid}`)} /> },
|
|
124
|
-
{ id: 'quotes-detail', render: ({ id }) => <QuoteDetailView quoteId={id!} onBack={() => navigate('quotes-list')} onEdit={() => navigate(`quotes-edit:${id}`)} onInvoiceCreated={(invoiceId) => { window.location.hash = `/financial/receivables/detail/${invoiceId}` }} /> },
|
|
125
|
-
{ id: 'quotes-edit', render: ({ id }) => <QuoteFormView quoteId={id!} onSaved={() => navigate(`quotes-detail:${id}`)} /> },
|
|
126
|
-
{ id: 'dashboard', render: () => <DashboardView /> },
|
|
127
|
-
], 'dashboard')
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
<CrmContextProvider config={config} provider={provider} store={store}>
|
|
131
|
-
<ModulePage
|
|
132
|
-
title={config.labels.pageTitle}
|
|
133
|
-
subtitle={config.labels.pageSubtitle}
|
|
134
|
-
nav={nav}
|
|
135
|
-
showHeader={isSummary}
|
|
136
|
-
viewKey={view}
|
|
137
|
-
direction={direction}
|
|
138
|
-
headerAction={
|
|
139
|
-
<ModuleActionBar
|
|
140
|
-
quickActions={quickActions}
|
|
141
|
-
settingsPath={registries && registries.length > 0 ? '/settings/crm' : undefined}
|
|
142
|
-
settingsLabel="CRM Settings"
|
|
143
|
-
/>
|
|
144
|
-
}
|
|
145
|
-
>
|
|
146
|
-
{renderView(view)}
|
|
147
|
-
</ModulePage>
|
|
148
|
-
</CrmContextProvider>
|
|
149
|
-
)
|
|
150
|
-
}
|
package/src/README.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Sales & CRM Plugin
|
|
2
|
-
|
|
3
|
-
Lead management, sales pipeline, deal tracking, quotes, and activity logging for any SaaS vertical.
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { createCrmPlugin } from '@fayz-ai/saas-core/plugins/crm'
|
|
9
|
-
|
|
10
|
-
plugins: [
|
|
11
|
-
createCrmPlugin({
|
|
12
|
-
currency: { code: 'BRL', locale: 'pt-BR', symbol: 'R$' },
|
|
13
|
-
}),
|
|
14
|
-
]
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Configuration
|
|
18
|
-
|
|
19
|
-
| Option | Type | Default | Description |
|
|
20
|
-
|--------|------|---------|-------------|
|
|
21
|
-
| `modules.pipeline` | boolean | true | Visual kanban deal board |
|
|
22
|
-
| `modules.quotes` | boolean | true | Quote management |
|
|
23
|
-
| `modules.activities` | boolean | true | Activity logging |
|
|
24
|
-
| `modules.contacts` | boolean | true | Contact segmentation |
|
|
25
|
-
| `currency` | object | BRL/pt-BR | Currency formatting |
|
|
26
|
-
| `dealStages` | array | 7 default stages | Custom pipeline stages |
|
|
27
|
-
| `itemTypes` | array | service, product, other | Quote line item types |
|
|
28
|
-
| `leadSources` | array | — | Custom lead sources |
|
|
29
|
-
| `dataProvider` | CrmDataProvider | mock | Custom data provider |
|
|
30
|
-
| `navPosition` | number | 5 | Navigation order |
|
|
31
|
-
|
|
32
|
-
## Architecture
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
src/plugins/crm/
|
|
36
|
-
index.ts # createCrmPlugin() factory
|
|
37
|
-
types.ts # Pipeline, Lead, Deal, Activity, Quote types
|
|
38
|
-
registries.ts # Lead Sources, Tags, Activity Types
|
|
39
|
-
store.ts # Zustand UI state
|
|
40
|
-
CrmContext.tsx # React contexts + hooks
|
|
41
|
-
CrmPage.tsx # Main page with ModulePage layout
|
|
42
|
-
data/ # Provider interface + mock
|
|
43
|
-
views/ # Dashboard, Pipeline, Leads, Quotes, Activities, Contacts
|
|
44
|
-
components/ # Settings, GeneralSettings, Onboarding
|
|
45
|
-
migrations/ # SQL files
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Type System
|
|
49
|
-
|
|
50
|
-
| Entity | Purpose |
|
|
51
|
-
|--------|---------|
|
|
52
|
-
| `Pipeline` | Named pipeline with stages |
|
|
53
|
-
| `PipelineStage` | Stage with order, color, probability, won/lost flags |
|
|
54
|
-
| `Lead` | Contact with source, status, value, tags |
|
|
55
|
-
| `Deal` | Opportunity in pipeline with stage, value, probability |
|
|
56
|
-
| `Activity` | Interaction log: call, email, meeting, note, task |
|
|
57
|
-
| `Quote` | Proposal with line items, status lifecycle |
|
|
58
|
-
| `Tag` | Colored label for organizing leads/deals |
|
|
59
|
-
| `LeadSource` | Where leads come from |
|
|
60
|
-
|
|
61
|
-
### Pipeline Stages (default)
|
|
62
|
-
|
|
63
|
-
New → Contacted → Qualified → Proposal → Negotiation → Won / Lost
|
|
64
|
-
|
|
65
|
-
### Lead Status Flow
|
|
66
|
-
|
|
67
|
-
new → contacted → qualified → converted (to deal) / unqualified / lost
|
|
68
|
-
|
|
69
|
-
### Quote Lifecycle
|
|
70
|
-
|
|
71
|
-
draft → sent → approved / rejected / expired
|
|
72
|
-
|
|
73
|
-
## Settings
|
|
74
|
-
|
|
75
|
-
Plugin settings have two sections:
|
|
76
|
-
|
|
77
|
-
**General** — Module toggles, lead management config, deal behavior
|
|
78
|
-
**Registries** — Lead Sources (seeded), Tags (editable), Activity Types (read-only)
|
|
79
|
-
|
|
80
|
-
## Views
|
|
81
|
-
|
|
82
|
-
| View | Route | Description |
|
|
83
|
-
|------|-------|-------------|
|
|
84
|
-
| Dashboard | `/sales` | KPIs, funnel chart, won deals |
|
|
85
|
-
| Pipeline | `/sales/pipeline` | Kanban board by stage |
|
|
86
|
-
| Lead List | `/sales/leads/list` | Filterable by status/source |
|
|
87
|
-
| Lead Form | `/sales/leads/new` | Capture new lead |
|
|
88
|
-
| Quotes | `/sales/quotes/list` | Quote management |
|
|
89
|
-
| Activities | `/sales/activities` | Activity log |
|
|
90
|
-
| Contacts | `/sales/contacts/*` | Active/Inactive/VIP segments |
|
|
91
|
-
| Settings | `/sales/settings/*` | General + Registries |
|
|
92
|
-
|
|
93
|
-
## Database Migrations
|
|
94
|
-
|
|
95
|
-
1. `001_crm_base.sql` — pipelines, pipeline_stages, lead_sources, crm_tags, leads, deals
|
|
96
|
-
2. `002_quotes.sql` — crm_quotes, crm_quote_items
|
|
97
|
-
3. `003_activities.sql` — crm_activity_types, crm_activities
|
package/src/cascade.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { PipelineStage, LeadStatus, QuoteStatus } from './types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Derives the lead status from the pipeline stage the deal is in.
|
|
5
|
-
* Pipeline stages are the single source of truth for lead lifecycle.
|
|
6
|
-
*/
|
|
7
|
-
export function deriveLeadStatus(stage: PipelineStage): LeadStatus {
|
|
8
|
-
if (stage.isWon) return 'converted'
|
|
9
|
-
if (stage.isLost) return 'lost'
|
|
10
|
-
if (stage.probability <= 10) return 'new'
|
|
11
|
-
if (stage.probability <= 25) return 'contacted'
|
|
12
|
-
return 'qualified'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Derives the quote status from the pipeline stage.
|
|
17
|
-
* Never downgrades — if the quote is already 'sent', moving the deal
|
|
18
|
-
* backward won't revert it to 'draft'.
|
|
19
|
-
*/
|
|
20
|
-
export function deriveQuoteStatus(stage: PipelineStage, current: QuoteStatus): QuoteStatus {
|
|
21
|
-
// Archived is terminal — a stage cascade must never resurrect the quote.
|
|
22
|
-
if (current === 'archived') return current
|
|
23
|
-
if (stage.isWon) return 'approved'
|
|
24
|
-
if (stage.isLost) return 'rejected'
|
|
25
|
-
return current
|
|
26
|
-
}
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
-
import { ArrowRight, Tag as TagIcon, X } from 'lucide-react'
|
|
3
|
-
import { SegmentedControl, DatePicker } from '@fayz-ai/ui'
|
|
4
|
-
import { useTranslation } from '@fayz-ai/core'
|
|
5
|
-
import { humanizeTag } from './TagChips'
|
|
6
|
-
import type { BoardFilter, BoardPeriod, TagDef } from '../types'
|
|
7
|
-
|
|
8
|
-
// ---------------------------------------------------------------------------
|
|
9
|
-
// Filtros do quadro: período + tags.
|
|
10
|
-
//
|
|
11
|
-
// Período é SEGMENTADO (não um select): são quatro opções, três delas de um
|
|
12
|
-
// clique, e a pergunta "o que entrou hoje?" é a mais frequente do funil — não
|
|
13
|
-
// merece dois cliques. "Personalizado" abre os dois datepickers ao lado, em vez
|
|
14
|
-
// de num modal, para a pessoa ver o quadro mudar enquanto escolhe.
|
|
15
|
-
//
|
|
16
|
-
// Tags é um popover com checkbox, porque o vocabulário cresce: um segmentado com
|
|
17
|
-
// quinze tags vira uma barra de rolagem horizontal.
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
/** Converte o preset no recorte que o provider entende. */
|
|
21
|
-
export function periodToRange(
|
|
22
|
-
period: BoardPeriod,
|
|
23
|
-
customFrom?: string,
|
|
24
|
-
customTo?: string,
|
|
25
|
-
): { createdFrom?: string; createdTo?: string } {
|
|
26
|
-
if (period === 'all') return {}
|
|
27
|
-
if (period === '24h') {
|
|
28
|
-
return { createdFrom: new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString() }
|
|
29
|
-
}
|
|
30
|
-
if (period === '7d') {
|
|
31
|
-
return { createdFrom: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString() }
|
|
32
|
-
}
|
|
33
|
-
// Personalizado: as datas vêm como YYYY-MM-DD e valem o DIA INTEIRO no fuso
|
|
34
|
-
// de quem está olhando. Sem o fim do dia em `to`, escolher hoje→hoje devolve
|
|
35
|
-
// um intervalo de largura zero e o quadro vem vazio.
|
|
36
|
-
return {
|
|
37
|
-
...(customFrom ? { createdFrom: new Date(`${customFrom}T00:00:00`).toISOString() } : {}),
|
|
38
|
-
...(customTo ? { createdTo: new Date(`${customTo}T23:59:59.999`).toISOString() } : {}),
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface BoardFiltersProps {
|
|
43
|
-
period: BoardPeriod
|
|
44
|
-
onPeriodChange: (period: BoardPeriod) => void
|
|
45
|
-
customFrom: string
|
|
46
|
-
customTo: string
|
|
47
|
-
onCustomChange: (from: string, to: string) => void
|
|
48
|
-
selectedTags: string[]
|
|
49
|
-
onTagsChange: (tags: string[]) => void
|
|
50
|
-
/** Cadastro (rótulo + cor). */
|
|
51
|
-
tagDefs: Map<string, TagDef>
|
|
52
|
-
/** Slugs presentes no quadro — o que dá para filtrar de fato. */
|
|
53
|
-
availableTags: string[]
|
|
54
|
-
className?: string
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function BoardFilters({
|
|
58
|
-
period, onPeriodChange,
|
|
59
|
-
customFrom, customTo, onCustomChange,
|
|
60
|
-
selectedTags, onTagsChange,
|
|
61
|
-
tagDefs, availableTags,
|
|
62
|
-
className,
|
|
63
|
-
}: BoardFiltersProps) {
|
|
64
|
-
const t = useTranslation()
|
|
65
|
-
const [tagsOpen, setTagsOpen] = useState(false)
|
|
66
|
-
const tagsRef = useRef<HTMLDivElement>(null)
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (!tagsOpen) return
|
|
70
|
-
const onDown = (e: MouseEvent) => {
|
|
71
|
-
if (!tagsRef.current?.contains(e.target as Node)) setTagsOpen(false)
|
|
72
|
-
}
|
|
73
|
-
document.addEventListener('mousedown', onDown)
|
|
74
|
-
return () => document.removeEventListener('mousedown', onDown)
|
|
75
|
-
}, [tagsOpen])
|
|
76
|
-
|
|
77
|
-
// A união do que existe no quadro com o que já está marcado: sem isso, filtrar
|
|
78
|
-
// por uma tag esvazia o quadro, ela some da lista de opções e não há como
|
|
79
|
-
// desmarcá-la a não ser limpando tudo.
|
|
80
|
-
const options = useMemo(() => {
|
|
81
|
-
const all = new Set([...availableTags, ...selectedTags])
|
|
82
|
-
return [...all].sort((a, b) =>
|
|
83
|
-
(tagDefs.get(a)?.name ?? humanizeTag(a)).localeCompare(tagDefs.get(b)?.name ?? humanizeTag(b)),
|
|
84
|
-
)
|
|
85
|
-
}, [availableTags, selectedTags, tagDefs])
|
|
86
|
-
|
|
87
|
-
const toggle = (slug: string) => {
|
|
88
|
-
onTagsChange(
|
|
89
|
-
selectedTags.includes(slug) ? selectedTags.filter((s) => s !== slug) : [...selectedTags, slug],
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<div className={`flex flex-wrap items-center gap-2 ${className ?? ''}`}>
|
|
95
|
-
<SegmentedControl<BoardPeriod>
|
|
96
|
-
options={[
|
|
97
|
-
{ value: 'all', label: t('crm.filters.periodAll') },
|
|
98
|
-
{ value: '24h', label: t('crm.filters.period24h') },
|
|
99
|
-
{ value: '7d', label: t('crm.filters.period7d') },
|
|
100
|
-
{ value: 'custom', label: t('crm.filters.periodCustom') },
|
|
101
|
-
]}
|
|
102
|
-
value={period}
|
|
103
|
-
onChange={onPeriodChange}
|
|
104
|
-
aria-label={t('crm.filters.period')}
|
|
105
|
-
/>
|
|
106
|
-
|
|
107
|
-
{period === 'custom' && (
|
|
108
|
-
// As duas pontas usam a MESMA chrome do segmentado ao lado (variant
|
|
109
|
-
// toolbar), com a seta ligando uma à outra — antes eram dois campos de
|
|
110
|
-
// formulário em altura cheia no meio de uma barra de pills.
|
|
111
|
-
<div className="inline-flex items-center gap-1.5">
|
|
112
|
-
<DatePicker
|
|
113
|
-
variant="toolbar"
|
|
114
|
-
value={customFrom}
|
|
115
|
-
// Arrastar o início para depois do fim (ou o contrário) devolvia um
|
|
116
|
-
// quadro vazio sem dizer por quê; a outra ponta acompanha.
|
|
117
|
-
onChange={(v) => onCustomChange(v, v > customTo ? v : customTo)}
|
|
118
|
-
/>
|
|
119
|
-
<ArrowRight className="h-3 w-3 shrink-0 text-muted-foreground" aria-hidden />
|
|
120
|
-
<DatePicker
|
|
121
|
-
variant="toolbar"
|
|
122
|
-
value={customTo}
|
|
123
|
-
onChange={(v) => onCustomChange(v < customFrom ? v : customFrom, v)}
|
|
124
|
-
/>
|
|
125
|
-
</div>
|
|
126
|
-
)}
|
|
127
|
-
|
|
128
|
-
{options.length > 0 && (
|
|
129
|
-
<div className="relative" ref={tagsRef}>
|
|
130
|
-
{/* Mesma chrome do SegmentedControl ao lado (raio, borda, bevel): eram
|
|
131
|
-
dois controles da mesma barra desenhados de dois jeitos. */}
|
|
132
|
-
<button
|
|
133
|
-
type="button"
|
|
134
|
-
onClick={() => setTagsOpen((o) => !o)}
|
|
135
|
-
className={`inline-flex h-[26px] items-center gap-1.5 rounded-button border px-2.5 text-xs font-medium shadow-button transition-colors ${
|
|
136
|
-
selectedTags.length
|
|
137
|
-
? 'border-primary/40 bg-primary/10 text-primary'
|
|
138
|
-
: 'border-border bg-card text-muted-foreground hover:bg-muted/60'
|
|
139
|
-
}`}
|
|
140
|
-
>
|
|
141
|
-
<TagIcon className="h-3 w-3" />
|
|
142
|
-
{selectedTags.length
|
|
143
|
-
? t('crm.filters.tagsSelected', { count: selectedTags.length })
|
|
144
|
-
: t('crm.filters.tags')}
|
|
145
|
-
</button>
|
|
146
|
-
|
|
147
|
-
{tagsOpen && (
|
|
148
|
-
<div className="absolute left-0 z-50 mt-1 max-h-72 w-56 overflow-y-auto rounded-lg border bg-popover p-1 shadow-md">
|
|
149
|
-
{options.map((slug) => {
|
|
150
|
-
const def = tagDefs.get(slug)
|
|
151
|
-
const checked = selectedTags.includes(slug)
|
|
152
|
-
return (
|
|
153
|
-
<button
|
|
154
|
-
key={slug}
|
|
155
|
-
type="button"
|
|
156
|
-
onClick={() => toggle(slug)}
|
|
157
|
-
className="flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs hover:bg-muted"
|
|
158
|
-
>
|
|
159
|
-
<span
|
|
160
|
-
className={`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border ${
|
|
161
|
-
checked ? 'border-primary bg-primary text-primary-foreground' : 'border-border'
|
|
162
|
-
}`}
|
|
163
|
-
>
|
|
164
|
-
{checked && <span className="text-[9px] leading-none">✓</span>}
|
|
165
|
-
</span>
|
|
166
|
-
{def?.color && (
|
|
167
|
-
<span className="h-2 w-2 shrink-0 rounded-full" style={{ backgroundColor: def.color }} />
|
|
168
|
-
)}
|
|
169
|
-
<span className="truncate">{def?.name ?? humanizeTag(slug)}</span>
|
|
170
|
-
</button>
|
|
171
|
-
)
|
|
172
|
-
})}
|
|
173
|
-
</div>
|
|
174
|
-
)}
|
|
175
|
-
</div>
|
|
176
|
-
)}
|
|
177
|
-
|
|
178
|
-
{selectedTags.length > 0 && (
|
|
179
|
-
<button
|
|
180
|
-
type="button"
|
|
181
|
-
onClick={() => onTagsChange([])}
|
|
182
|
-
className="inline-flex h-[26px] items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground hover:text-foreground"
|
|
183
|
-
title={t('crm.filters.clearTags')}
|
|
184
|
-
>
|
|
185
|
-
<X className="h-3 w-3" />
|
|
186
|
-
</button>
|
|
187
|
-
)}
|
|
188
|
-
</div>
|
|
189
|
-
)
|
|
190
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { SettingsGroup, ToggleRow, useTenantPluginSettings } from '@fayz-ai/saas'
|
|
3
|
-
import { useTranslation } from '@fayz-ai/core'
|
|
4
|
-
|
|
5
|
-
// Per-tenant defaults = the values that used to be hardcoded here. Persisted +
|
|
6
|
-
// re-hydrated per tenant; behavioural consumption is a follow-up.
|
|
7
|
-
const CRM_DEFAULTS = {
|
|
8
|
-
autoAssign: false,
|
|
9
|
-
requireSource: true,
|
|
10
|
-
leadScoring: false,
|
|
11
|
-
duplicateDetection: true,
|
|
12
|
-
autoCreateDeal: true,
|
|
13
|
-
requireCloseDate: false,
|
|
14
|
-
rottingDeals: true,
|
|
15
|
-
weightedPipeline: true,
|
|
16
|
-
autoNumberQuotes: true,
|
|
17
|
-
defaultValidity: true,
|
|
18
|
-
requireApproval: false,
|
|
19
|
-
overdueAlerts: true,
|
|
20
|
-
stageChangeAlerts: false,
|
|
21
|
-
newLeadNotif: true,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function CrmGeneralSettings() {
|
|
25
|
-
const t = useTranslation()
|
|
26
|
-
const s = useTenantPluginSettings('crm', CRM_DEFAULTS)
|
|
27
|
-
return (
|
|
28
|
-
<div className="space-y-4">
|
|
29
|
-
<SettingsGroup title={t('crm.settings.leadManagement')} description={t('crm.settings.leadManagementDesc')}>
|
|
30
|
-
<ToggleRow label={t('crm.settings.autoAssign')} description={t('crm.settings.autoAssignDesc')} checked={s.get('autoAssign')} onChange={(v) => s.set('autoAssign', v)} />
|
|
31
|
-
<ToggleRow label={t('crm.settings.requireSource')} description={t('crm.settings.requireSourceDesc')} checked={s.get('requireSource')} onChange={(v) => s.set('requireSource', v)} />
|
|
32
|
-
<ToggleRow label={t('crm.settings.leadScoring')} description={t('crm.settings.leadScoringDesc')} checked={s.get('leadScoring')} onChange={(v) => s.set('leadScoring', v)} />
|
|
33
|
-
<ToggleRow label={t('crm.settings.duplicateDetection')} description={t('crm.settings.duplicateDetectionDesc')} checked={s.get('duplicateDetection')} onChange={(v) => s.set('duplicateDetection', v)} />
|
|
34
|
-
</SettingsGroup>
|
|
35
|
-
|
|
36
|
-
<SettingsGroup title={t('crm.settings.deals')} description={t('crm.settings.dealsDesc')}>
|
|
37
|
-
<ToggleRow label={t('crm.settings.autoCreateDeal')} description={t('crm.settings.autoCreateDealDesc')} checked={s.get('autoCreateDeal')} onChange={(v) => s.set('autoCreateDeal', v)} />
|
|
38
|
-
<ToggleRow label={t('crm.settings.requireCloseDate')} description={t('crm.settings.requireCloseDateDesc')} checked={s.get('requireCloseDate')} onChange={(v) => s.set('requireCloseDate', v)} />
|
|
39
|
-
<ToggleRow label={t('crm.settings.rottingDeals')} description={t('crm.settings.rottingDealsDesc')} checked={s.get('rottingDeals')} onChange={(v) => s.set('rottingDeals', v)} />
|
|
40
|
-
<ToggleRow label={t('crm.settings.weightedPipeline')} description={t('crm.settings.weightedPipelineDesc')} checked={s.get('weightedPipeline')} onChange={(v) => s.set('weightedPipeline', v)} />
|
|
41
|
-
</SettingsGroup>
|
|
42
|
-
|
|
43
|
-
<SettingsGroup title={t('crm.settings.quotes')} description={t('crm.settings.quotesDesc')}>
|
|
44
|
-
<ToggleRow label={t('crm.settings.autoNumberQuotes')} description={t('crm.settings.autoNumberQuotesDesc')} checked={s.get('autoNumberQuotes')} onChange={(v) => s.set('autoNumberQuotes', v)} />
|
|
45
|
-
<ToggleRow label={t('crm.settings.defaultValidity')} description={t('crm.settings.defaultValidityDesc')} checked={s.get('defaultValidity')} onChange={(v) => s.set('defaultValidity', v)} />
|
|
46
|
-
<ToggleRow label={t('crm.settings.requireApproval')} description={t('crm.settings.requireApprovalDesc')} checked={s.get('requireApproval')} onChange={(v) => s.set('requireApproval', v)} />
|
|
47
|
-
</SettingsGroup>
|
|
48
|
-
|
|
49
|
-
<SettingsGroup title={t('crm.settings.notifications')} description={t('crm.settings.notificationsDesc')}>
|
|
50
|
-
<ToggleRow label={t('crm.settings.overdueAlerts')} description={t('crm.settings.overdueAlertsDesc')} checked={s.get('overdueAlerts')} onChange={(v) => s.set('overdueAlerts', v)} />
|
|
51
|
-
<ToggleRow label={t('crm.settings.stageChangeAlerts')} description={t('crm.settings.stageChangeAlertsDesc')} checked={s.get('stageChangeAlerts')} onChange={(v) => s.set('stageChangeAlerts', v)} />
|
|
52
|
-
<ToggleRow label={t('crm.settings.newLeadNotif')} description={t('crm.settings.newLeadNotifDesc')} checked={s.get('newLeadNotif')} onChange={(v) => s.set('newLeadNotif', v)} />
|
|
53
|
-
</SettingsGroup>
|
|
54
|
-
</div>
|
|
55
|
-
)
|
|
56
|
-
}
|