@fayz-ai/plugin-crm 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { PluginManifest, PluginScope, VerticalId } from '@fayz-ai/core';
2
- import type { EntityLookupMap } from '@fayz-ai/saas';
2
+ import { type EntityLookupMap } from '@fayz-ai/saas';
3
3
  import type { CrmDataProvider } from './data/types';
4
4
  export interface CrmPluginLabels {
5
5
  pageTitle: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAcnD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,UAAU,CAAC,EAAE,OAAO,CAAA;QACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;IACjC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KAAE,CAAC,CAAA;IACrD,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACxE,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACtE,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACnD,YAAY,CAAC,EAAE,eAAe,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;IACjC,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,eAAe,CAAA;IAC/B,kEAAkE;IAClE,aAAa,CAAC,EAAE,OAAO,eAAe,EAAE,YAAY,CAAA;IACpD;;mGAE+F;IAC/F,gBAAgB,CAAC,EAAE;QACjB,mEAAmE;QACnE,aAAa,EAAE,MAAM,CAAA;QACrB,8DAA8D;QAC9D,cAAc,EAAE,MAAM,CAAA;QACtB,2DAA2D;QAC3D,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;CACF;AAoDD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,CAuH1E;AAED,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import React15, { useState, useMemo, useEffect, useRef } from 'react';
1
+ import React14, { useState, useMemo, useRef, useEffect } from 'react';
2
+ import { createPluginContext, PluginSettingsPanel, dedup, useModuleNavigation, createViewRouter, ModuleActionBar, SettingsGroup, ToggleRow, formatCurrency, PersonLink } from '@fayz-ai/saas';
2
3
  import { registerTranslations, createSafeDataProvider, useTranslation, getSupabaseClientOptional, getActiveTenantId } from '@fayz-ai/core';
3
4
  import { toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, PageTransition, ModulePage, Button, SubpageHeader, ListView, useSaveBar, SearchSelect, DatePicker, DataTable, Breadcrumb, DashboardCanvas, Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetBody, SheetFooter, CurrencyInput, Dropdown, DropdownTrigger, DropdownContent, DropdownLabel, DropdownSeparator, DropdownItem, ConfirmDialog, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget } from '@fayz-ai/ui';
4
- import { createPluginContext, dedup, useModuleNavigation, createViewRouter, ModuleActionBar, SettingsGroup, ToggleRow, formatCurrency, PersonLink } from '@fayz-ai/saas';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import { Filter, Globe, Target, Check, ChevronRight, UserPlus, Plus, FileText, MessageCircle, CheckSquare, Users, Mail, Phone, Clock, Calendar, Send, ChevronDown, Printer, X, Pencil, User, Hash, CircleCheckBig, ArrowRight, Ban, Trash2, CircleAlert, CircleDashed, Loader2, DollarSign } from 'lucide-react';
7
7
  import { createPortal } from 'react-dom';
@@ -54,37 +54,6 @@ function CrmGeneralSettings() {
54
54
  ] })
55
55
  ] });
56
56
  }
57
- function PipelineSettings() {
58
- const t2 = useTranslation();
59
- const stages = useCrmStore((s) => s.stages);
60
- useCrmStore((s) => s.pipelines);
61
- const fetchPipelines = useCrmStore((s) => s.fetchPipelines);
62
- useEffect(() => {
63
- fetchPipelines();
64
- }, []);
65
- return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
66
- /* @__PURE__ */ jsx(SettingsGroup, { title: t2("crm.pipelineSettings.title"), description: t2("crm.pipelineSettings.description"), children: stages.length === 0 ? /* @__PURE__ */ jsx("div", { className: "py-6 text-center text-sm text-muted-foreground", children: t2("common.loading") }) : /* @__PURE__ */ jsx("div", { className: "space-y-0", children: stages.map((stage, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 py-3", children: [
67
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground w-5 shrink-0", children: i + 1 }),
68
- /* @__PURE__ */ jsx("div", { className: "h-3 w-3 rounded-full shrink-0", style: { backgroundColor: stage.color } }),
69
- /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
70
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: stage.name }),
71
- /* @__PURE__ */ jsxs("p", { className: "text-[10px] text-muted-foreground", children: [
72
- t2("crm.pipelineSettings.probability"),
73
- ": ",
74
- stage.probability,
75
- "%",
76
- stage.isWon && ` \u2014 ${t2("crm.pipelineSettings.winStage")}`,
77
- stage.isLost && ` \u2014 ${t2("crm.pipelineSettings.lossStage")}`
78
- ] })
79
- ] }),
80
- /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
81
- stage.probability,
82
- "%"
83
- ] })
84
- ] }, stage.id)) }) }),
85
- /* @__PURE__ */ jsx("p", { className: "text-[10px] text-muted-foreground px-1", children: t2("crm.pipelineSettings.customizationNote") })
86
- ] });
87
- }
88
57
  var STEPS = [
89
58
  { id: "welcome", icon: Filter, titleKey: "crm.onboarding.welcome", descKey: "crm.onboarding.description" },
90
59
  { id: "sources", icon: Globe, titleKey: "crm.onboarding.sources.title", descKey: "crm.onboarding.sources.description" },
@@ -1248,7 +1217,7 @@ function QuoteFormView({ quoteId, leadId, onSaved }) {
1248
1217
  observations,
1249
1218
  items: items.map((it) => ({ itemKind: it.itemKind, description: it.description, quantity: it.quantity, unitPrice: it.unitPrice, discount: it.discount }))
1250
1219
  };
1251
- const snapshot = React15.useRef(null);
1220
+ const snapshot = React14.useRef(null);
1252
1221
  useEffect(() => {
1253
1222
  if (!loadingExisting && snapshot.current === null) snapshot.current = JSON.stringify(currentFields);
1254
1223
  }, [loadingExisting]);
@@ -2129,8 +2098,7 @@ function CrmPage({ config, provider, store, registries }) {
2129
2098
  /* @__PURE__ */ jsx("h1", { style: { fontSize: "20px", fontWeight: 600, margin: 0 }, children: t2("crm.settingsPage.title") }),
2130
2099
  /* @__PURE__ */ jsx("p", { style: { color: "var(--muted-foreground, #6b7280)", margin: "4px 0 0", fontSize: "14px" }, children: t2("crm.settingsPage.subtitle") })
2131
2100
  ] }),
2132
- /* @__PURE__ */ jsx(CrmGeneralSettings, {}),
2133
- /* @__PURE__ */ jsx(PipelineSettings, {})
2101
+ /* @__PURE__ */ jsx(CrmGeneralSettings, {})
2134
2102
  ] }) }) });
2135
2103
  }
2136
2104
  const renderView = createViewRouter([
@@ -3784,11 +3752,35 @@ var tagEntity = {
3784
3752
  defaultSort: "name",
3785
3753
  fields: [
3786
3754
  { key: "name", label: "Name", type: "text", required: true, showInTable: true },
3787
- { key: "color", label: "Color", type: "text", showInTable: true, defaultValue: "#6366f1" },
3755
+ { key: "color", label: "Color", type: "color", showInTable: true, defaultValue: "#6366f1" },
3788
3756
  { key: "isActive", label: "Active", type: "boolean", showInTable: true, defaultValue: true }
3789
3757
  ],
3790
3758
  data: { table: "crm_tags", tenantScoped: true }
3791
3759
  };
3760
+ var pipelineStageEntity = {
3761
+ name: "Stage",
3762
+ namePlural: "Stages",
3763
+ icon: "Workflow",
3764
+ displayField: "name",
3765
+ defaultSort: "order",
3766
+ fields: [
3767
+ { key: "name", label: "Name", type: "text", required: true, showInTable: true, searchable: true },
3768
+ {
3769
+ key: "pipelineId",
3770
+ label: "Pipeline",
3771
+ type: "relation",
3772
+ relation: { table: "pipelines", labelField: "name" },
3773
+ required: true,
3774
+ showInTable: true
3775
+ },
3776
+ { key: "order", label: "Order", type: "number", required: true, showInTable: true, defaultValue: 0 },
3777
+ { key: "color", label: "Color", type: "color", showInTable: true, defaultValue: "#6366f1" },
3778
+ { key: "probability", label: "Probability %", type: "number", min: 0, max: 100, showInTable: true, defaultValue: 0 },
3779
+ { key: "isWon", label: "Won Stage", type: "boolean", showInTable: true, defaultValue: false },
3780
+ { key: "isLost", label: "Lost Stage", type: "boolean", showInTable: true, defaultValue: false }
3781
+ ],
3782
+ data: { table: "pipeline_stages", tenantScoped: true }
3783
+ };
3792
3784
  var activityTypeEntity = {
3793
3785
  name: "Activity Type",
3794
3786
  namePlural: "Activity Types",
@@ -3802,6 +3794,21 @@ var activityTypeEntity = {
3802
3794
  data: { table: "crm_activity_types", tenantScoped: true }
3803
3795
  };
3804
3796
  var crmRegistries = [
3797
+ {
3798
+ id: "stages",
3799
+ entity: pipelineStageEntity,
3800
+ icon: "Workflow",
3801
+ description: "Pipeline stages used by CRM deals",
3802
+ display: "table",
3803
+ seedData: [
3804
+ { id: "stage-new", pipelineId: "pipe-default", name: "New Lead", order: 1, color: "#64748b", probability: 10, isWon: false, isLost: false },
3805
+ { id: "stage-qualified", pipelineId: "pipe-default", name: "Qualified", order: 2, color: "#3b82f6", probability: 30, isWon: false, isLost: false },
3806
+ { id: "stage-proposal", pipelineId: "pipe-default", name: "Proposal", order: 3, color: "#8b5cf6", probability: 60, isWon: false, isLost: false },
3807
+ { id: "stage-negotiation", pipelineId: "pipe-default", name: "Negotiation", order: 4, color: "#f59e0b", probability: 80, isWon: false, isLost: false },
3808
+ { id: "stage-won", pipelineId: "pipe-default", name: "Won", order: 5, color: "#10b981", probability: 100, isWon: true, isLost: false },
3809
+ { id: "stage-lost", pipelineId: "pipe-default", name: "Lost", order: 6, color: "#ef4444", probability: 0, isWon: false, isLost: true }
3810
+ ]
3811
+ },
3805
3812
  {
3806
3813
  id: "lead-sources",
3807
3814
  entity: leadSourceEntity,
@@ -4482,7 +4489,7 @@ function createCrmPlugin(options) {
4482
4489
  () => createMockCrmProvider()
4483
4490
  );
4484
4491
  const store = createCrmStore(provider);
4485
- const PageComponent = () => React15.createElement(CrmPage, { config, provider, store, registries: crmRegistries });
4492
+ const PageComponent = () => React14.createElement(CrmPage, { config, provider, store, registries: crmRegistries });
4486
4493
  const dashboardWidgets = createCrmDashboardWidgets({ config, provider, store });
4487
4494
  return {
4488
4495
  id: "crm",
@@ -4569,15 +4576,17 @@ function createCrmPlugin(options) {
4569
4576
  label: "Sales & CRM",
4570
4577
  icon: "Filter",
4571
4578
  component: (() => {
4572
- const Tab = () => React15.createElement(
4579
+ const Tab = () => React14.createElement(
4573
4580
  CrmContextProvider,
4574
4581
  { config, provider, store },
4575
- React15.createElement(
4576
- "div",
4577
- { style: { display: "flex", flexDirection: "column", gap: "20px" } },
4578
- React15.createElement(CrmGeneralSettings),
4579
- React15.createElement(PipelineSettings)
4580
- )
4582
+ React14.createElement(PluginSettingsPanel, {
4583
+ title: "Sales & CRM",
4584
+ subtitle: "Pipeline, lead management, and CRM properties",
4585
+ generalSettings: React14.createElement(CrmGeneralSettings),
4586
+ registries: crmRegistries,
4587
+ hostPluginId: "crm",
4588
+ routeBase: "/settings/crm"
4589
+ })
4581
4590
  );
4582
4591
  Tab.displayName = "CrmSettingsTab";
4583
4592
  return Tab;