@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.
- 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/mock.d.ts.map +1 -1
- package/dist/data/registries.d.ts.map +1 -0
- package/dist/data/types.d.ts +4 -1
- package/dist/data/types.d.ts.map +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +609 -493
- 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/lib/timeline-source.d.ts +10 -0
- package/dist/lib/timeline-source.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/src/data/tables.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// Central physical-table-name registry for plugin-crm. Providers import T and
|
|
2
|
-
// never hardcode the plg_crm_* strings, so a future rename touches one file.
|
|
3
|
-
export const T = {
|
|
4
|
-
activities: 'plg_crm_activities',
|
|
5
|
-
tags: 'plg_crm_tags',
|
|
6
|
-
activityTypes: 'plg_crm_activity_types',
|
|
7
|
-
pipelines: 'plg_crm_pipelines',
|
|
8
|
-
pipelineStages: 'plg_crm_pipeline_stages',
|
|
9
|
-
dealExtensions: 'plg_crm_deal_extensions',
|
|
10
|
-
leadSources: 'plg_crm_lead_sources',
|
|
11
|
-
} as const
|
package/src/data/types.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Pipeline, PipelineStage, Lead, Deal, Activity, ActivityTypeDef, TagDef, Quote,
|
|
3
|
-
CreateLeadInput, CreateDealInput, CreateActivityInput, CreateQuoteInput,
|
|
4
|
-
LeadQuery, DealQuery, ActivityQuery, QuoteQuery, BoardFilter,
|
|
5
|
-
PaginatedResult, CrmSummary, FunnelStage,
|
|
6
|
-
} from '../types'
|
|
7
|
-
|
|
8
|
-
export interface CrmDataProvider {
|
|
9
|
-
// Pipelines
|
|
10
|
-
getPipelines(): Promise<Pipeline[]>
|
|
11
|
-
getPipelineStages(pipelineId: string): Promise<PipelineStage[]>
|
|
12
|
-
|
|
13
|
-
// Leads
|
|
14
|
-
getLeads(query: LeadQuery): Promise<PaginatedResult<Lead>>
|
|
15
|
-
getLeadById(id: string): Promise<Lead | null>
|
|
16
|
-
createLead(input: CreateLeadInput): Promise<Lead>
|
|
17
|
-
updateLead(id: string, data: Partial<Lead>): Promise<Lead>
|
|
18
|
-
convertLeadToDeal(leadId: string, dealInput: CreateDealInput): Promise<Deal>
|
|
19
|
-
|
|
20
|
-
// Deals
|
|
21
|
-
getDeals(query: DealQuery): Promise<PaginatedResult<Deal>>
|
|
22
|
-
getDealById(id: string): Promise<Deal | null>
|
|
23
|
-
getDealsByStage(pipelineId: string, filter?: BoardFilter): Promise<Map<string, Deal[]>>
|
|
24
|
-
createDeal(input: CreateDealInput): Promise<Deal>
|
|
25
|
-
updateDeal(id: string, data: Partial<Deal>): Promise<Deal>
|
|
26
|
-
moveDealToStage(dealId: string, stageId: string): Promise<Deal>
|
|
27
|
-
/** Soft-remove from the board (status='archived') — never a hard delete. */
|
|
28
|
-
archiveDeal(dealId: string): Promise<void>
|
|
29
|
-
/** Soft-remove a lead (is_active=false) and archive its deal. */
|
|
30
|
-
archiveLead(leadId: string): Promise<void>
|
|
31
|
-
/** Soft-remove a quote (status='archived') — never a hard delete. */
|
|
32
|
-
archiveQuote(quoteId: string): Promise<void>
|
|
33
|
-
|
|
34
|
-
// Activities
|
|
35
|
-
getActivities(query: ActivityQuery): Promise<PaginatedResult<Activity>>
|
|
36
|
-
createActivity(input: CreateActivityInput): Promise<Activity>
|
|
37
|
-
completeActivity(id: string): Promise<Activity>
|
|
38
|
-
/** Tenant's manual interaction types (activity-types registry rows). */
|
|
39
|
-
getActivityTypes(): Promise<ActivityTypeDef[]>
|
|
40
|
-
|
|
41
|
-
/** Cadastro de tags (tags registry rows) — rótulo e cor por slug. */
|
|
42
|
-
getTagDefs(): Promise<TagDef[]>
|
|
43
|
-
|
|
44
|
-
// Quotes
|
|
45
|
-
getQuotes(query: QuoteQuery): Promise<PaginatedResult<Quote>>
|
|
46
|
-
getQuoteById(id: string): Promise<Quote | null>
|
|
47
|
-
createQuote(input: CreateQuoteInput): Promise<Quote>
|
|
48
|
-
updateQuote(id: string, input: CreateQuoteInput): Promise<Quote>
|
|
49
|
-
sendQuote(id: string): Promise<Quote>
|
|
50
|
-
approveQuote(id: string): Promise<Quote>
|
|
51
|
-
rejectQuote(id: string, reason: string): Promise<Quote>
|
|
52
|
-
expireQuote(id: string): Promise<Quote>
|
|
53
|
-
|
|
54
|
-
// Cross-entity lookups
|
|
55
|
-
getQuotesByDealId(dealId: string): Promise<Quote[]>
|
|
56
|
-
getDealByLeadId(leadId: string): Promise<Deal | null>
|
|
57
|
-
|
|
58
|
-
// Summary
|
|
59
|
-
getSummary(): Promise<CrmSummary>
|
|
60
|
-
getFunnel(pipelineId: string): Promise<FunnelStage[]>
|
|
61
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,429 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import type { PluginManifest, PluginScope, VerticalId } from '@fayz-ai/core'
|
|
3
|
-
import { PluginSettingsPanel, type EntityLookupMap } from '@fayz-ai/saas'
|
|
4
|
-
import { CrmPage } from './CrmPage'
|
|
5
|
-
import { createCrmDashboardWidgets } from './views/dashboardWidgets'
|
|
6
|
-
import { CrmContextProvider, type ResolvedCrmConfig } from './CrmContext'
|
|
7
|
-
import type { CrmDataProvider } from './data/types'
|
|
8
|
-
import { createMockCrmProvider } from './data/mock'
|
|
9
|
-
import { createSafeDataProvider, registerTranslations } from '@fayz-ai/core'
|
|
10
|
-
import { createSupabaseCrmProvider } from './data/supabase'
|
|
11
|
-
import { createCrmStore } from './store'
|
|
12
|
-
import { buildCrmRegistries, DEFAULT_ACTIVITY_TYPES } from './registries'
|
|
13
|
-
import { crmLocales } from './locales'
|
|
14
|
-
import { CrmGeneralSettings } from './components/CrmGeneralSettings'
|
|
15
|
-
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
// Public types
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
export interface CrmPluginLabels {
|
|
21
|
-
pageTitle: string
|
|
22
|
-
pageSubtitle: string
|
|
23
|
-
dashboard: string
|
|
24
|
-
pipeline: string
|
|
25
|
-
leads: string
|
|
26
|
-
leadsNew: string
|
|
27
|
-
leadsList: string
|
|
28
|
-
deals: string
|
|
29
|
-
quotes: string
|
|
30
|
-
quotesNew: string
|
|
31
|
-
quotesList: string
|
|
32
|
-
activities: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface CrmPluginOptions {
|
|
36
|
-
modules?: {
|
|
37
|
-
quotes?: boolean
|
|
38
|
-
activities?: boolean
|
|
39
|
-
pipeline?: boolean
|
|
40
|
-
}
|
|
41
|
-
labels?: Partial<CrmPluginLabels>
|
|
42
|
-
currency?: { code?: string; locale?: string; symbol?: string }
|
|
43
|
-
leadSources?: Array<{ value: string; label: string }>
|
|
44
|
-
dealStages?: Array<{ name: string; color: string; probability: number }>
|
|
45
|
-
activityTypes?: Array<{ value: string; label: string; icon?: string }>
|
|
46
|
-
itemTypes?: Array<{ value: string; label: string }>
|
|
47
|
-
dataProvider?: CrmDataProvider
|
|
48
|
-
navPosition?: number
|
|
49
|
-
navSection?: 'main' | 'secondary'
|
|
50
|
-
scope?: PluginScope
|
|
51
|
-
verticalId?: VerticalId
|
|
52
|
-
/** Entity lookups for cross-plugin references (e.g., product/service search in quotes) */
|
|
53
|
-
entityLookups?: EntityLookupMap
|
|
54
|
-
/** Contact/person lookup for client search in quotes and leads */
|
|
55
|
-
contactLookup?: import('@fayz-ai/saas').EntityLookup
|
|
56
|
-
/** Client conversion config — when a lead is approved, CRM converts the person
|
|
57
|
-
* to a client by updating `people.kind` and creating the extension table record.
|
|
58
|
-
* @example { archetypeKind: 'customer', extensionTable: 'clients', fkColumn: 'person_id' } */
|
|
59
|
-
clientConversion?: {
|
|
60
|
-
/** The archetype kind to set on people.kind (e.g., 'customer') */
|
|
61
|
-
archetypeKind: string
|
|
62
|
-
/** Extension table name (e.g., 'clients') in public schema */
|
|
63
|
-
extensionTable: string
|
|
64
|
-
/** FK column pointing to people.id (e.g., 'person_id') */
|
|
65
|
-
fkColumn: string
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// Defaults
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
|
|
73
|
-
const DEFAULT_LABELS: CrmPluginLabels = {
|
|
74
|
-
pageTitle: 'Sales',
|
|
75
|
-
pageSubtitle: 'CRM, leads, deals, and pipeline management',
|
|
76
|
-
dashboard: 'Dashboard',
|
|
77
|
-
pipeline: 'Pipeline',
|
|
78
|
-
leads: 'Leads',
|
|
79
|
-
leadsNew: 'New',
|
|
80
|
-
leadsList: 'List',
|
|
81
|
-
deals: 'Deals',
|
|
82
|
-
quotes: 'Quotes',
|
|
83
|
-
quotesNew: 'New',
|
|
84
|
-
quotesList: 'List',
|
|
85
|
-
activities: 'Activities',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const DEFAULT_CURRENCY = { code: 'BRL', locale: 'pt-BR', symbol: 'R$' }
|
|
89
|
-
|
|
90
|
-
const DEFAULT_ITEM_TYPES = [
|
|
91
|
-
{ value: 'service', label: 'Service' },
|
|
92
|
-
{ value: 'product', label: 'Product' },
|
|
93
|
-
{ value: 'other', label: 'Other' },
|
|
94
|
-
]
|
|
95
|
-
|
|
96
|
-
// ---------------------------------------------------------------------------
|
|
97
|
-
// Config resolver
|
|
98
|
-
// ---------------------------------------------------------------------------
|
|
99
|
-
|
|
100
|
-
function resolveConfig(options?: CrmPluginOptions): ResolvedCrmConfig {
|
|
101
|
-
return {
|
|
102
|
-
modules: {
|
|
103
|
-
quotes: options?.modules?.quotes !== false,
|
|
104
|
-
activities: options?.modules?.activities !== false,
|
|
105
|
-
pipeline: options?.modules?.pipeline !== false,
|
|
106
|
-
},
|
|
107
|
-
labels: { ...DEFAULT_LABELS, ...options?.labels },
|
|
108
|
-
currency: { ...DEFAULT_CURRENCY, ...options?.currency },
|
|
109
|
-
itemTypes: options?.itemTypes ?? DEFAULT_ITEM_TYPES,
|
|
110
|
-
entityLookups: options?.entityLookups ?? {},
|
|
111
|
-
contactLookup: options?.contactLookup,
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
// Factory
|
|
117
|
-
// ---------------------------------------------------------------------------
|
|
118
|
-
|
|
119
|
-
export function createCrmPlugin(options?: CrmPluginOptions): PluginManifest {
|
|
120
|
-
const config = resolveConfig(options)
|
|
121
|
-
registerTranslations(crmLocales)
|
|
122
|
-
const activityTypes = options?.activityTypes ?? DEFAULT_ACTIVITY_TYPES
|
|
123
|
-
const crmRegistries = buildCrmRegistries(activityTypes)
|
|
124
|
-
const provider = options?.dataProvider ?? createSafeDataProvider(
|
|
125
|
-
() => createSupabaseCrmProvider({ clientConversion: options?.clientConversion, activityTypes }),
|
|
126
|
-
() => createMockCrmProvider({ activityTypes }),
|
|
127
|
-
)
|
|
128
|
-
const store = createCrmStore(provider)
|
|
129
|
-
|
|
130
|
-
const PageComponent: React.FC<any> = () =>
|
|
131
|
-
React.createElement(CrmPage, { config, provider, store, registries: crmRegistries })
|
|
132
|
-
|
|
133
|
-
const dashboardWidgets = createCrmDashboardWidgets({ config, provider, store })
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
id: 'crm',
|
|
137
|
-
name: config.labels.pageTitle,
|
|
138
|
-
icon: 'Filter',
|
|
139
|
-
version: '1.0.0',
|
|
140
|
-
scope: options?.scope ?? 'universal',
|
|
141
|
-
verticalId: options?.verticalId,
|
|
142
|
-
// Sales-pipeline/lead-management is a business-ops tool — targets the
|
|
143
|
-
// saas/admin Panel world, not the ecommerce storefront.
|
|
144
|
-
scaffolds: ['saas'],
|
|
145
|
-
defaultEnabled: true,
|
|
146
|
-
dependencies: [],
|
|
147
|
-
declaredFeatures: [
|
|
148
|
-
{ id: 'sales', label: config.labels.pageTitle, group: config.labels.pageTitle },
|
|
149
|
-
{ id: 'crm.leads', label: config.labels.leads, group: config.labels.pageTitle },
|
|
150
|
-
{ id: 'crm.quotes', label: config.labels.quotes, group: config.labels.pageTitle },
|
|
151
|
-
{ id: 'crm.pipeline', label: config.labels.pipeline, group: config.labels.pageTitle },
|
|
152
|
-
],
|
|
153
|
-
// Stock quantity caps. leads/deals/quotes share core tables partitioned by
|
|
154
|
-
// `kind` (people/orders), so each declaration carries a kindFilter. A lead
|
|
155
|
-
// create auto-spawns a deal, so the lead guard also gates deal creation;
|
|
156
|
-
// `deals` has no standalone create UI (declared for usage banners/counts).
|
|
157
|
-
declaredLimits: [
|
|
158
|
-
{ key: 'leads', label: 'Leads', table: 'people', kindFilter: 'lead' },
|
|
159
|
-
{ key: 'deals', label: 'Deals', table: 'orders', kindFilter: 'deal' },
|
|
160
|
-
{ key: 'quotes', label: 'Quotes', table: 'orders', kindFilter: 'quote' },
|
|
161
|
-
],
|
|
162
|
-
// Read-models for the agent's data primitives (searchRecords/queryData).
|
|
163
|
-
// Without these the assistant cannot see leads/deals/activities at all and
|
|
164
|
-
// guesses wrong entities ("quem tá aguardando contato?" → invented filter
|
|
165
|
-
// on Cliente). Keys are stable ASCII; fields are camelCase output shape.
|
|
166
|
-
queryEntities: [
|
|
167
|
-
{
|
|
168
|
-
key: 'crm:leads',
|
|
169
|
-
writable: false,
|
|
170
|
-
entity: {
|
|
171
|
-
name: 'Lead',
|
|
172
|
-
namePlural: 'Leads',
|
|
173
|
-
icon: 'UserPlus',
|
|
174
|
-
permission: { feature: 'crm.leads', action: 'read' as const },
|
|
175
|
-
fields: [
|
|
176
|
-
{ key: 'name', label: 'Name', type: 'text' as const, searchable: true },
|
|
177
|
-
{ key: 'email', label: 'Email', type: 'text' as const, searchable: true },
|
|
178
|
-
{ key: 'phone', label: 'Phone', type: 'text' as const, searchable: true },
|
|
179
|
-
{ key: 'company', label: 'Company', type: 'text' as const },
|
|
180
|
-
{ key: 'status', label: 'Status (new=awaiting first contact, contacted, qualified, converted, lost)', type: 'text' as const },
|
|
181
|
-
{ key: 'sourceName', label: 'Source', type: 'text' as const },
|
|
182
|
-
{ key: 'createdAt', label: 'Created at', type: 'text' as const },
|
|
183
|
-
],
|
|
184
|
-
data: {
|
|
185
|
-
table: 'v_leads',
|
|
186
|
-
tenantScoped: true,
|
|
187
|
-
searchColumns: ['name', 'email', 'phone'],
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
key: 'crm:deals',
|
|
193
|
-
writable: false,
|
|
194
|
-
entity: {
|
|
195
|
-
name: 'Deal',
|
|
196
|
-
namePlural: 'Deals',
|
|
197
|
-
icon: 'Target',
|
|
198
|
-
permission: { feature: 'crm.pipeline', action: 'read' as const },
|
|
199
|
-
fields: [
|
|
200
|
-
{ key: 'title', label: 'Title', type: 'text' as const, searchable: true },
|
|
201
|
-
{ key: 'value', label: 'Value', type: 'number' as const },
|
|
202
|
-
{ key: 'status', label: 'Status (open/won/lost)', type: 'text' as const },
|
|
203
|
-
{ key: 'stage', label: 'Pipeline stage name', type: 'text' as const },
|
|
204
|
-
{ key: 'contactName', label: 'Contact', type: 'text' as const, searchable: true },
|
|
205
|
-
{ key: 'probability', label: 'Probability %', type: 'number' as const },
|
|
206
|
-
{ key: 'expectedCloseDate', label: 'Expected close', type: 'text' as const },
|
|
207
|
-
{ key: 'createdAt', label: 'Created at', type: 'text' as const },
|
|
208
|
-
],
|
|
209
|
-
data: {
|
|
210
|
-
table: 'v_deals',
|
|
211
|
-
tenantScoped: true,
|
|
212
|
-
searchColumns: ['title', 'contact_name'],
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
key: 'crm:activities',
|
|
218
|
-
writable: false,
|
|
219
|
-
entity: {
|
|
220
|
-
name: 'CRM activity',
|
|
221
|
-
namePlural: 'CRM activities',
|
|
222
|
-
icon: 'MessageCircle',
|
|
223
|
-
permission: { feature: 'sales', action: 'read' as const },
|
|
224
|
-
fields: [
|
|
225
|
-
{ key: 'activityType', label: 'Type (call/email/note… or system events: lead_created, deal_won, quote_approved…)', type: 'text' as const },
|
|
226
|
-
{ key: 'title', label: 'Title', type: 'text' as const, searchable: true },
|
|
227
|
-
{ key: 'description', label: 'Description', type: 'text' as const, searchable: true },
|
|
228
|
-
{ key: 'contactName', label: 'Contact', type: 'text' as const, searchable: true },
|
|
229
|
-
{ key: 'dueDate', label: 'Due date', type: 'text' as const },
|
|
230
|
-
{ key: 'completedAt', label: 'Completed at', type: 'text' as const },
|
|
231
|
-
{ key: 'assignedToName', label: 'Assigned to', type: 'text' as const },
|
|
232
|
-
{ key: 'createdAt', label: 'Created at', type: 'text' as const },
|
|
233
|
-
],
|
|
234
|
-
data: {
|
|
235
|
-
table: 'plg_crm_activities',
|
|
236
|
-
tenantScoped: true,
|
|
237
|
-
searchColumns: ['title', 'contact_name', 'description'],
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
navigation: [
|
|
243
|
-
{
|
|
244
|
-
section: options?.navSection ?? 'main',
|
|
245
|
-
position: options?.navPosition ?? 5,
|
|
246
|
-
label: config.labels.pageTitle,
|
|
247
|
-
route: '/sales',
|
|
248
|
-
icon: 'Filter',
|
|
249
|
-
permission: { feature: 'sales', action: 'read' as const },
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
routes: [
|
|
253
|
-
{
|
|
254
|
-
path: '/sales',
|
|
255
|
-
component: PageComponent,
|
|
256
|
-
permission: { feature: 'sales', action: 'read' as const },
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
widgets: [],
|
|
260
|
-
dashboardWidgets,
|
|
261
|
-
aiTools: [
|
|
262
|
-
{
|
|
263
|
-
id: 'crm.count-customers',
|
|
264
|
-
name: 'countCustomers',
|
|
265
|
-
description: 'Returns the number of active customers/clients.',
|
|
266
|
-
icon: 'Users',
|
|
267
|
-
mode: 'read' as const,
|
|
268
|
-
category: 'Sales',
|
|
269
|
-
parameters: {
|
|
270
|
-
type: 'object' as const,
|
|
271
|
-
properties: {
|
|
272
|
-
status: { type: 'string' as const, enum: ['active', 'inactive', 'all'] },
|
|
273
|
-
},
|
|
274
|
-
},
|
|
275
|
-
suggestions: [
|
|
276
|
-
{ label: 'How many customers do we have?', verticalId: 'beauty' as const },
|
|
277
|
-
{ label: 'How many clients do we have?', verticalId: 'services' as const },
|
|
278
|
-
{ label: 'How many patients today?', verticalId: 'health' as const },
|
|
279
|
-
{ label: 'Who are my top customers?' },
|
|
280
|
-
],
|
|
281
|
-
permission: { feature: 'sales', action: 'read' as const },
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
id: 'crm.list-leads',
|
|
285
|
-
name: 'listLeads',
|
|
286
|
-
description: 'Lists leads with optional filters.',
|
|
287
|
-
icon: 'Target',
|
|
288
|
-
mode: 'read' as const,
|
|
289
|
-
category: 'Sales',
|
|
290
|
-
parameters: {
|
|
291
|
-
type: 'object' as const,
|
|
292
|
-
properties: {
|
|
293
|
-
source: { type: 'string' as const, description: 'Lead source filter' },
|
|
294
|
-
status: { type: 'string' as const, enum: ['new', 'contacted', 'qualified', 'lost'] },
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
permission: { feature: 'sales', action: 'read' as const },
|
|
298
|
-
suggestions: [
|
|
299
|
-
{ label: 'Show new leads from this week' },
|
|
300
|
-
{ label: 'Which leads need follow-up?' },
|
|
301
|
-
{ label: "What's our conversion rate?" },
|
|
302
|
-
],
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
id: 'crm.create-lead',
|
|
306
|
-
name: 'createLead',
|
|
307
|
-
description:
|
|
308
|
-
'Opens a NEW lead. This is the ONLY way to create one — the leads entity is a read-only view, so createRecord cannot. ' +
|
|
309
|
-
'Only `name` is required; send whatever else the user gave and omit the rest. Status defaults to "new" and belongs to a closed set: new, contacted, qualified, converted, lost. ' +
|
|
310
|
-
'A lead whose e-mail or phone already exists is NOT duplicated — the existing one comes back with deduped:true, and changing it is updateLead. The user confirms before anything is written.',
|
|
311
|
-
icon: 'UserPlus',
|
|
312
|
-
mode: 'persist' as const,
|
|
313
|
-
limitKey: 'leads',
|
|
314
|
-
execution: { plane: 'server' as const, kind: 'rpc' as const, rpc: 'agent_crm_create_lead' },
|
|
315
|
-
category: 'Sales',
|
|
316
|
-
parameters: {
|
|
317
|
-
type: 'object' as const,
|
|
318
|
-
properties: {
|
|
319
|
-
name: { type: 'string' as const, description: "The person's name" },
|
|
320
|
-
email: { type: 'string' as const, description: 'E-mail' },
|
|
321
|
-
phone: { type: 'string' as const, description: 'Phone' },
|
|
322
|
-
company: { type: 'string' as const, description: 'Company' },
|
|
323
|
-
status: {
|
|
324
|
-
type: 'string' as const,
|
|
325
|
-
description: 'Funnel stage — defaults to "new"',
|
|
326
|
-
enum: ['new', 'contacted', 'qualified', 'converted', 'lost'],
|
|
327
|
-
},
|
|
328
|
-
value: { type: 'string' as const, description: 'Estimated value' },
|
|
329
|
-
source_name: { type: 'string' as const, description: 'Where the lead came from' },
|
|
330
|
-
assigned_to_id: { type: 'string' as const, description: 'Person the lead is assigned to (id)' },
|
|
331
|
-
notes: { type: 'string' as const, description: 'Notes' },
|
|
332
|
-
},
|
|
333
|
-
required: ['name'],
|
|
334
|
-
},
|
|
335
|
-
suggestions: [
|
|
336
|
-
{ label: 'Cria um lead Noronha, interessado em tratamento facial' },
|
|
337
|
-
],
|
|
338
|
-
permission: { feature: 'sales', action: 'create' as const },
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
id: 'crm.update-lead',
|
|
342
|
-
name: 'updateLead',
|
|
343
|
-
description:
|
|
344
|
-
'Changes a lead that ALREADY EXISTS: move its status through the funnel, reassign it, or fix its data (name, email, phone, company, value, notes). ' +
|
|
345
|
-
'This is the ONLY way to change a lead — the leads entity is a read-only view, so updateRecord cannot touch it. ' +
|
|
346
|
-
'Status is a closed set: new (awaiting first contact), contacted, qualified, converted, lost. A proposal that went out is usually "qualified"; a closed sale is "converted". ' +
|
|
347
|
-
'Takes the lead id from a previous search. The user confirms before anything changes.',
|
|
348
|
-
icon: 'UserCheck',
|
|
349
|
-
mode: 'persist' as const,
|
|
350
|
-
execution: { plane: 'server' as const, kind: 'rpc' as const, rpc: 'agent_crm_update_lead' },
|
|
351
|
-
category: 'Sales',
|
|
352
|
-
parameters: {
|
|
353
|
-
type: 'object' as const,
|
|
354
|
-
properties: {
|
|
355
|
-
lead_id: { type: 'string' as const, description: 'Id of the lead to change (from a search)' },
|
|
356
|
-
status: {
|
|
357
|
-
type: 'string' as const,
|
|
358
|
-
description: 'New funnel stage',
|
|
359
|
-
enum: ['new', 'contacted', 'qualified', 'converted', 'lost'],
|
|
360
|
-
},
|
|
361
|
-
name: { type: 'string' as const, description: 'Corrected name' },
|
|
362
|
-
email: { type: 'string' as const, description: 'Corrected e-mail' },
|
|
363
|
-
phone: { type: 'string' as const, description: 'Corrected phone' },
|
|
364
|
-
company: { type: 'string' as const, description: 'Company' },
|
|
365
|
-
value: { type: 'string' as const, description: 'Estimated value' },
|
|
366
|
-
assigned_to_id: { type: 'string' as const, description: 'Person the lead is assigned to (id)' },
|
|
367
|
-
notes: { type: 'string' as const, description: 'Notes' },
|
|
368
|
-
},
|
|
369
|
-
required: ['lead_id'],
|
|
370
|
-
},
|
|
371
|
-
suggestions: [
|
|
372
|
-
{ label: 'Mandei a proposta pro Vini, atualiza o status' },
|
|
373
|
-
{ label: 'Marca esse lead como perdido' },
|
|
374
|
-
],
|
|
375
|
-
permission: { feature: 'sales', action: 'edit' as const },
|
|
376
|
-
},
|
|
377
|
-
],
|
|
378
|
-
declaredRpcs: [
|
|
379
|
-
{
|
|
380
|
-
name: 'agent_crm_create_lead',
|
|
381
|
-
kind: 'write' as const,
|
|
382
|
-
description:
|
|
383
|
-
'Guarded lead create: agent_guard (role→plan→leads cap), closed status set, e-mail/phone dedupe, audited.',
|
|
384
|
-
audits: true,
|
|
385
|
-
},
|
|
386
|
-
{
|
|
387
|
-
name: 'agent_crm_update_lead',
|
|
388
|
-
kind: 'write' as const,
|
|
389
|
-
description:
|
|
390
|
-
'Guarded lead update: agent_guard (role→plan, no cap), closed status set, tenant+kind checked, audited.',
|
|
391
|
-
audits: true,
|
|
392
|
-
},
|
|
393
|
-
],
|
|
394
|
-
registries: crmRegistries,
|
|
395
|
-
settings: [
|
|
396
|
-
{
|
|
397
|
-
id: 'crm',
|
|
398
|
-
label: 'Sales & CRM',
|
|
399
|
-
icon: 'Filter',
|
|
400
|
-
component: (() => {
|
|
401
|
-
const Tab: React.FC = () =>
|
|
402
|
-
React.createElement(CrmContextProvider, { config, provider, store },
|
|
403
|
-
React.createElement(PluginSettingsPanel, {
|
|
404
|
-
title: 'Sales & CRM',
|
|
405
|
-
subtitle: 'Pipeline, lead management, and CRM properties',
|
|
406
|
-
generalSettings: React.createElement(CrmGeneralSettings),
|
|
407
|
-
registries: crmRegistries,
|
|
408
|
-
hostPluginId: 'crm',
|
|
409
|
-
routeBase: '/settings/crm',
|
|
410
|
-
}),
|
|
411
|
-
)
|
|
412
|
-
Tab.displayName = 'CrmSettingsTab'
|
|
413
|
-
return Tab
|
|
414
|
-
})() as unknown as React.ComponentType<unknown>,
|
|
415
|
-
order: 12,
|
|
416
|
-
permission: { feature: 'sales', action: 'read' as const },
|
|
417
|
-
},
|
|
418
|
-
],
|
|
419
|
-
locales: crmLocales,
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
export type { CrmDataProvider } from './data/types'
|
|
424
|
-
export type { ResolvedCrmConfig } from './CrmContext'
|
|
425
|
-
// Tags: o chip e o tipo do cadastro. Exportados para uma app renderizar a mesma
|
|
426
|
-
// leitura fora do funil (ex.: numa aba de pessoa) em vez de reinventar o chip.
|
|
427
|
-
export { TagChips, humanizeTag } from './components/TagChips'
|
|
428
|
-
export type { TagChipsProps } from './components/TagChips'
|
|
429
|
-
export type { TagDef } from './types'
|
package/src/lib/access.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useAccessOptional } from '@fayz-ai/saas'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Single resolver for "can this user archive CRM records?" (deals, leads).
|
|
5
|
-
* One feature/action pair resolved in ONE place — call sites render or hide
|
|
6
|
-
* the affordance off this boolean and never repeat the check. Degrades to
|
|
7
|
-
* allow under a bare host shell (useAccessOptional's contract).
|
|
8
|
-
*/
|
|
9
|
-
export function useCanArchive(): boolean {
|
|
10
|
-
return useAccessOptional().can('sales', 'delete').allowed
|
|
11
|
-
}
|
package/src/lib/form-answers.tsx
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
// ---------------------------------------------------------------------------
|
|
4
|
-
// Rendering whatever a public form captured.
|
|
5
|
-
//
|
|
6
|
-
// Deliberately schema-free. Every landing page asks something different — hair
|
|
7
|
-
// coverage on one, a coupon on another, subject/message on a third — and the
|
|
8
|
-
// capture side (create_public_lead) already stores the answers as an opaque bag
|
|
9
|
-
// so a new campaign ships with no migration. The display side needs the same
|
|
10
|
-
// property: anything typed here makes the NEXT form invisible.
|
|
11
|
-
//
|
|
12
|
-
// Shared because two views show the same data and had drifted: the lead detail
|
|
13
|
-
// page rendered answers with private helpers, while the pipeline card rendered
|
|
14
|
-
// none at all.
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
/** `hair_remaining` / `hairRemaining` → "Hair remaining". Keys that arrive
|
|
18
|
-
* already humanized ("Assunto") come back unchanged. */
|
|
19
|
-
export function humanizeKey(key: string): string {
|
|
20
|
-
const spaced = key.replace(/[_-]+/g, ' ').replace(/([a-z\d])([A-Z])/g, '$1 $2')
|
|
21
|
-
return spaced.charAt(0).toUpperCase() + spaced.slice(1)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Arrays are joined rather than dropped: a multi-select ("Preocupações") is
|
|
25
|
-
* often the most qualifying answer on the form. */
|
|
26
|
-
export function renderFieldValue(value: unknown): React.ReactNode {
|
|
27
|
-
if (value === null || value === undefined || value === '') return null
|
|
28
|
-
if (Array.isArray(value)) return value.length ? value.join(', ') : null
|
|
29
|
-
if (typeof value === 'boolean') return value ? 'Sim' : 'Não'
|
|
30
|
-
if (typeof value === 'object') return JSON.stringify(value)
|
|
31
|
-
return String(value)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Answer entries worth showing, empty values already removed. */
|
|
35
|
-
export function answerEntries(fields: unknown): Array<[string, unknown]> {
|
|
36
|
-
if (!fields || typeof fields !== 'object' || Array.isArray(fields)) return []
|
|
37
|
-
return Object.entries(fields as Record<string, unknown>)
|
|
38
|
-
.filter(([, v]) => v !== null && v !== undefined && v !== '')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Um arquivo que veio com o lead. O que fica gravado é o PONTEIRO — o conteúdo
|
|
43
|
-
* está no Storage, num bucket privado (ver plugin-crm 015).
|
|
44
|
-
*/
|
|
45
|
-
export interface LeadAttachmentRef {
|
|
46
|
-
/** Bucket gravado junto com a linha, para o dia em que ele mudar de nome. */
|
|
47
|
-
bucket: string
|
|
48
|
-
path: string
|
|
49
|
-
slot?: string
|
|
50
|
-
mime?: string
|
|
51
|
-
size?: number
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Bucket usado quando a linha é anterior ao campo `bucket`. */
|
|
55
|
-
const DEFAULT_ATTACHMENT_BUCKET = 'crm-lead-uploads'
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Lê os anexos do metadata do lead, ignorando qualquer coisa sem caminho.
|
|
59
|
-
*
|
|
60
|
-
* Defensivo pelo mesmo motivo que `answerEntries` é: o metadata é uma bolsa
|
|
61
|
-
* opaca escrita por versões diferentes do SDK ao longo do tempo, e uma tela de
|
|
62
|
-
* CRM que quebra por causa de uma linha antiga é pior do que uma que mostra
|
|
63
|
-
* menos.
|
|
64
|
-
*/
|
|
65
|
-
export function leadAttachments(metadata: unknown): LeadAttachmentRef[] {
|
|
66
|
-
const raw = (metadata as { attachments?: unknown } | null | undefined)?.attachments
|
|
67
|
-
if (!Array.isArray(raw)) return []
|
|
68
|
-
return raw.flatMap((entry) => {
|
|
69
|
-
if (!entry || typeof entry !== 'object') return []
|
|
70
|
-
const a = entry as Record<string, unknown>
|
|
71
|
-
if (typeof a.path !== 'string' || !a.path) return []
|
|
72
|
-
return [{
|
|
73
|
-
bucket: typeof a.bucket === 'string' && a.bucket ? a.bucket : DEFAULT_ATTACHMENT_BUCKET,
|
|
74
|
-
path: a.path,
|
|
75
|
-
slot: typeof a.slot === 'string' ? a.slot : undefined,
|
|
76
|
-
mime: typeof a.mime === 'string' ? a.mime : undefined,
|
|
77
|
-
size: typeof a.size === 'number' ? a.size : undefined,
|
|
78
|
-
}]
|
|
79
|
-
})
|
|
80
|
-
}
|
package/src/lib/relative-time.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// "há 2 dias" — a idade de um registro, do jeito que se lê num funil.
|
|
3
|
-
//
|
|
4
|
-
// Data absoluta responde "quando"; o funil pergunta outra coisa: "há quanto
|
|
5
|
-
// tempo isso está parado aqui?". Um card com "12/03" obriga quem lê a fazer a
|
|
6
|
-
// conta de cabeça, card por card, toda vez. Por isso o CARD mostra o relativo
|
|
7
|
-
// (a leitura é na diagonal) e o DETALHE mostra os dois — lá a data exata volta
|
|
8
|
-
// a importar, porque é de onde se combina retorno e se justifica prazo.
|
|
9
|
-
//
|
|
10
|
-
// Intl faz o trabalho pesado: plural, gênero e preposição saem certos em cada
|
|
11
|
-
// idioma sem tabela de tradução própria.
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
|
|
14
|
-
const MINUTE = 60
|
|
15
|
-
const HOUR = 60 * MINUTE
|
|
16
|
-
const DAY = 24 * HOUR
|
|
17
|
-
const WEEK = 7 * DAY
|
|
18
|
-
const MONTH = 30 * DAY
|
|
19
|
-
const YEAR = 365 * DAY
|
|
20
|
-
|
|
21
|
-
/** Escadinha do maior para o menor: a primeira unidade que "cabe" é a que sai. */
|
|
22
|
-
const STEPS: Array<[Intl.RelativeTimeFormatUnit, number]> = [
|
|
23
|
-
['year', YEAR],
|
|
24
|
-
['month', MONTH],
|
|
25
|
-
['week', WEEK],
|
|
26
|
-
['day', DAY],
|
|
27
|
-
['hour', HOUR],
|
|
28
|
-
['minute', MINUTE],
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* "há 5 minutos", "há 2 dias". Segundos viram "agora mesmo": ninguém precisa
|
|
33
|
-
* de precisão de segundo, e "há 12 segundos" envelhece errado na tela.
|
|
34
|
-
*
|
|
35
|
-
* `now` é injetável para teste.
|
|
36
|
-
*/
|
|
37
|
-
export function formatRelativeTime(
|
|
38
|
-
iso: string | undefined | null,
|
|
39
|
-
locale = 'pt-BR',
|
|
40
|
-
now: Date = new Date(),
|
|
41
|
-
): string {
|
|
42
|
-
if (!iso) return ''
|
|
43
|
-
const then = new Date(iso)
|
|
44
|
-
const at = then.getTime()
|
|
45
|
-
if (Number.isNaN(at)) return ''
|
|
46
|
-
|
|
47
|
-
const elapsed = Math.round((now.getTime() - at) / 1000)
|
|
48
|
-
const abs = Math.abs(elapsed)
|
|
49
|
-
|
|
50
|
-
if (abs < 45) {
|
|
51
|
-
// 'second' com numeric:'auto' devolve "agora" em pt-BR e "now" em en.
|
|
52
|
-
return new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }).format(0, 'second')
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// numeric:'always' → "há 1 dia", nunca "ontem"/"semana passada". Numa coluna
|
|
56
|
-
// de funil a idade se compara de relance entre cards, e as formas literais
|
|
57
|
-
// quebram isso: "semana passada" cobre de 7 a 13 dias, e fica lado a lado com
|
|
58
|
-
// "há 6 dias" parecendo mais recente do que é.
|
|
59
|
-
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'always' })
|
|
60
|
-
for (const [unit, seconds] of STEPS) {
|
|
61
|
-
if (abs >= seconds) {
|
|
62
|
-
// Negativo = passado, que é o caso normal aqui (data de criação).
|
|
63
|
-
return rtf.format(-Math.round(elapsed / seconds), unit)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return rtf.format(0, 'second')
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** "12/03/2026, 14:07" — a data exata, para quando ela volta a importar. */
|
|
70
|
-
export function formatDateTime(
|
|
71
|
-
iso: string | undefined | null,
|
|
72
|
-
locale = 'pt-BR',
|
|
73
|
-
): string {
|
|
74
|
-
if (!iso) return ''
|
|
75
|
-
const at = new Date(iso)
|
|
76
|
-
if (Number.isNaN(at.getTime())) return ''
|
|
77
|
-
return at.toLocaleString(locale, {
|
|
78
|
-
day: '2-digit',
|
|
79
|
-
month: '2-digit',
|
|
80
|
-
year: 'numeric',
|
|
81
|
-
hour: '2-digit',
|
|
82
|
-
minute: '2-digit',
|
|
83
|
-
})
|
|
84
|
-
}
|