@aglyn/plugins-crm 1.0.0-beta.200 → 1.0.0-beta.202
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/package.json +13 -13
- package/src/lib/components/activity-list.d.ts +36 -5
- package/src/lib/components/activity-list.js +159 -137
- package/src/lib/components/activity-list.js.map +1 -1
- package/src/lib/components/activity-timeline.d.ts +84 -0
- package/src/lib/components/activity-timeline.js +224 -0
- package/src/lib/components/activity-timeline.js.map +1 -0
- package/src/lib/components/company-properties-card.js +53 -36
- package/src/lib/components/company-properties-card.js.map +1 -1
- package/src/lib/components/contact-associations-card.d.ts +3 -2
- package/src/lib/components/contact-associations-card.js +12 -12
- package/src/lib/components/contact-associations-card.js.map +1 -1
- package/src/lib/components/contact-detail-page.d.ts +4 -3
- package/src/lib/components/contact-detail-page.js +4 -10
- package/src/lib/components/contact-detail-page.js.map +1 -1
- package/src/lib/components/contact-properties-card.d.ts +21 -4
- package/src/lib/components/contact-properties-card.js +129 -29
- package/src/lib/components/contact-properties-card.js.map +1 -1
- package/src/lib/components/contact-timeline-card.d.ts +12 -6
- package/src/lib/components/contact-timeline-card.js +132 -174
- package/src/lib/components/contact-timeline-card.js.map +1 -1
- package/src/lib/components/contacts-section.js +197 -198
- package/src/lib/components/contacts-section.js.map +1 -1
- package/src/lib/components/crm-email-state-chip.js +4 -1
- package/src/lib/components/crm-email-state-chip.js.map +1 -1
- package/src/lib/components/deal-products-card.js +15 -13
- package/src/lib/components/deal-products-card.js.map +1 -1
- package/src/lib/components/deal-properties-card.js +7 -0
- package/src/lib/components/deal-properties-card.js.map +1 -1
- package/src/lib/components/deal-stage-card.js +31 -29
- package/src/lib/components/deal-stage-card.js.map +1 -1
- package/src/lib/components/deals-section.js +9 -14
- package/src/lib/components/deals-section.js.map +1 -1
- package/src/lib/components/fields-section.d.ts +4 -0
- package/src/lib/components/fields-section.js +368 -154
- package/src/lib/components/fields-section.js.map +1 -1
- package/src/lib/components/form-contact-fields-card.js +24 -20
- package/src/lib/components/form-contact-fields-card.js.map +1 -1
- package/src/lib/components/lead-campaigns-card.d.ts +1 -1
- package/src/lib/components/lead-campaigns-card.js +32 -35
- package/src/lib/components/lead-campaigns-card.js.map +1 -1
- package/src/lib/components/lead-properties-card.d.ts +14 -6
- package/src/lib/components/lead-properties-card.js +317 -313
- package/src/lib/components/lead-properties-card.js.map +1 -1
- package/src/lib/components/lead-surfaces-note.js +13 -2
- package/src/lib/components/lead-surfaces-note.js.map +1 -1
- package/src/lib/components/linked-deals-card.js +12 -10
- package/src/lib/components/linked-deals-card.js.map +1 -1
- package/src/lib/components/recent-activity-feed.d.ts +12 -8
- package/src/lib/components/recent-activity-feed.js +54 -29
- package/src/lib/components/recent-activity-feed.js.map +1 -1
- package/src/lib/components/record-activity-card.d.ts +4 -2
- package/src/lib/components/record-activity-card.js +29 -11
- package/src/lib/components/record-activity-card.js.map +1 -1
- package/src/lib/components/reports/activity-card.js +18 -12
- package/src/lib/components/reports/activity-card.js.map +1 -1
- package/src/lib/components/reports/lead-funnel-card.js +47 -37
- package/src/lib/components/reports/lead-funnel-card.js.map +1 -1
- package/src/lib/components/reports/pipeline-card.js +22 -16
- package/src/lib/components/reports/pipeline-card.js.map +1 -1
- package/src/lib/components/reports/report-export.d.ts +4 -11
- package/src/lib/components/reports/report-export.js +16 -33
- package/src/lib/components/reports/report-export.js.map +1 -1
- package/src/lib/components/reports/source-conversion-card.js +18 -12
- package/src/lib/components/reports/source-conversion-card.js.map +1 -1
- package/src/lib/components/reports/tasks-card.js +35 -25
- package/src/lib/components/reports/tasks-card.js.map +1 -1
- package/src/lib/components/tasks-section.js +23 -23
- package/src/lib/components/tasks-section.js.map +1 -1
- package/src/lib/constants/field-list-query.d.ts +23 -0
- package/src/lib/constants/field-list-query.js +80 -0
- package/src/lib/constants/field-list-query.js.map +1 -0
- package/src/lib/model/lead-filters.d.ts +1 -1
- package/src/lib/server/capture-contact.js +7 -5
- package/src/lib/server/capture-contact.js.map +1 -1
- package/src/lib/components/contact-custom-fields-card.d.ts +0 -39
- package/src/lib/components/contact-custom-fields-card.js +0 -204
- package/src/lib/components/contact-custom-fields-card.js.map +0 -1
|
@@ -14,33 +14,38 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ 'use client';
|
|
17
|
-
import { jsx as _jsx
|
|
17
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import * as Aglyn from "@aglyn/aglyn";
|
|
19
|
-
import { AppLink } from "@aglyn/shared-ui-jsx";
|
|
20
|
-
import {
|
|
21
|
-
import { useCallback, useMemo } from "react";
|
|
19
|
+
import { AppLink, CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
20
|
+
import { Typography } from "@mui/material";
|
|
21
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
22
22
|
import { crmRoutes } from "../model/crm-routes.js";
|
|
23
23
|
import { ActivityList } from "./activity-list.js";
|
|
24
24
|
import { useActivityScope, useActivityWindow } from "./activity-queries.js";
|
|
25
|
+
import { TimelineExpandAllButton, useTimelineExpansion } from "./activity-timeline.js";
|
|
25
26
|
/** How the record an activity is about reads in the feed. */ const RECORD_LABELS = {
|
|
26
27
|
contact: 'Contact',
|
|
27
28
|
deal: 'Deal',
|
|
28
29
|
company: 'Company',
|
|
29
30
|
lead: 'Lead'
|
|
30
31
|
};
|
|
31
|
-
/**
|
|
32
|
+
/** One page of the feed, and the step its listener widens by — a glance, not a log. */ export const RECENT_ACTIVITY_LIMIT = 10;
|
|
32
33
|
/** The empty link: nothing to render, the query returns nothing. */ const NO_RECORD = Object.freeze({});
|
|
33
34
|
/**
|
|
34
35
|
* The newest logged activity across the CRM (AGL-2600): the last few calls,
|
|
35
36
|
* emails, meetings and notes anyone on the team filed against any record,
|
|
36
37
|
* each linking to the record it is about.
|
|
37
38
|
*
|
|
38
|
-
*
|
|
39
|
-
* answers "what has the team been doing" before
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
39
|
+
* The contacts landing shows it as a card of its own under the list card,
|
|
40
|
+
* so that opening the CRM answers "what has the team been doing" before
|
|
41
|
+
* anybody opens a record, without the list running on into it. One bounded
|
|
42
|
+
* listener on `(visibleTo, atMs DESC)` — the index that exists for exactly
|
|
43
|
+
* this query — filtered to what this reader may see, the same predicate the
|
|
44
|
+
* rules evaluate. It reads one page, `limit`, and widens by a page only
|
|
45
|
+
* when the reader turns to the next one.
|
|
46
|
+
*
|
|
47
|
+
* Every row is collapsed to its kind, its heading, who and when, and opens
|
|
48
|
+
* in place to the body; **Expand all** in the card header opens them all.
|
|
44
49
|
*
|
|
45
50
|
* A row links to its CONTACT when it has one, else its deal, else its
|
|
46
51
|
* company — `crmActivityRecordLink`'s precedence — through `crmRoutes`, so
|
|
@@ -51,6 +56,17 @@ import { useActivityScope, useActivityWindow } from "./activity-queries.js";
|
|
|
51
56
|
const { hostId, org, limit = RECENT_ACTIVITY_LIMIT, basePath } = props;
|
|
52
57
|
const scope = useActivityScope(hostId, org);
|
|
53
58
|
const activities = useActivityWindow(scope, NO_RECORD, limit);
|
|
59
|
+
const expansion = useTimelineExpansion();
|
|
60
|
+
/*
|
|
61
|
+
* Whether the feed has ever had a row. A page turned past the window
|
|
62
|
+
* re-reads it, and the listener holds nothing while it does; the card has
|
|
63
|
+
* to stay through that rather than vanish with its page.
|
|
64
|
+
*/ const [seen, setSeen] = useState(false);
|
|
65
|
+
useEffect(()=>{
|
|
66
|
+
if (activities.rows.length) setSeen(true);
|
|
67
|
+
}, [
|
|
68
|
+
activities.rows.length
|
|
69
|
+
]);
|
|
54
70
|
const routes = useMemo(()=>basePath ? crmRoutes(basePath) : null, [
|
|
55
71
|
basePath
|
|
56
72
|
]);
|
|
@@ -76,25 +92,34 @@ import { useActivityScope, useActivityWindow } from "./activity-queries.js";
|
|
|
76
92
|
// Nothing to show and nothing to say: a landing with no activity yet
|
|
77
93
|
// should not carry an empty heading for a feature the reader has not
|
|
78
94
|
// used, and the record pages are where the "log one" affordance lives.
|
|
79
|
-
if (activities.status !== 'error' && !activities.rows.length) return null;
|
|
80
|
-
return /*#__PURE__*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}) : /*#__PURE__*/ _jsx(ActivityList, {
|
|
92
|
-
rows: activities.rows,
|
|
93
|
-
scope: scope,
|
|
94
|
-
subjectFor: subjectFor,
|
|
95
|
-
readOnly: true
|
|
95
|
+
if (activities.status !== 'error' && !activities.rows.length && !seen) return null;
|
|
96
|
+
return /*#__PURE__*/ _jsx(CardDisplay, {
|
|
97
|
+
header: 'Recent activity',
|
|
98
|
+
help: Aglyn.pluginDocsHelp('contactActivities', {
|
|
99
|
+
anchor: '#the-recent-activity-feed'
|
|
100
|
+
}),
|
|
101
|
+
contentGutterX: true,
|
|
102
|
+
contentGutterY: true,
|
|
103
|
+
HeaderProps: {
|
|
104
|
+
action: /*#__PURE__*/ _jsx(TimelineExpandAllButton, {
|
|
105
|
+
expansion: expansion,
|
|
106
|
+
disabled: !activities.rows.length
|
|
96
107
|
})
|
|
97
|
-
|
|
108
|
+
},
|
|
109
|
+
children: activities.status === 'error' ? /*#__PURE__*/ _jsx(Typography, {
|
|
110
|
+
variant: "body2",
|
|
111
|
+
color: "error",
|
|
112
|
+
children: 'Recent activity could not be loaded.'
|
|
113
|
+
}) : /*#__PURE__*/ _jsx(ActivityList, {
|
|
114
|
+
rows: activities.rows,
|
|
115
|
+
scope: scope,
|
|
116
|
+
subjectFor: subjectFor,
|
|
117
|
+
readOnly: true,
|
|
118
|
+
hasMore: activities.hasMore,
|
|
119
|
+
onShowMore: activities.showMore,
|
|
120
|
+
loading: activities.status === 'loading',
|
|
121
|
+
expansion: expansion
|
|
122
|
+
})
|
|
98
123
|
});
|
|
99
124
|
}
|
|
100
125
|
RecentActivityFeed.displayName = 'RecentActivityFeed';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/recent-activity-feed.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport type { CrmActivityRow } from '@aglyn/aglyn'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/recent-activity-feed.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport type { CrmActivityRow } from '@aglyn/aglyn'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { Typography } from '@mui/material'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { crmRoutes } from '../model/crm-routes'\nimport { ActivityList } from './activity-list'\nimport {\n type CrmOrg,\n useActivityScope,\n useActivityWindow,\n} from './activity-queries'\nimport { TimelineExpandAllButton, useTimelineExpansion } from './activity-timeline'\n\n/** How the record an activity is about reads in the feed. */\nconst RECORD_LABELS = {\n contact: 'Contact',\n deal: 'Deal',\n company: 'Company',\n lead: 'Lead',\n} as const\n\n/** One page of the feed, and the step its listener widens by — a glance, not a log. */\nexport const RECENT_ACTIVITY_LIMIT = 10\n\n/** The empty link: nothing to render, the query returns nothing. */\nconst NO_RECORD = Object.freeze({})\n\nexport interface RecentActivityFeedProps {\n /** The site the record is read under, or `null` at the organization level. */\n hostId: string | null\n org: CrmOrg\n /** A page of the feed, and how far its listener widens when a page is turned past it. */\n limit?: number\n /**\n * The hub's mount path, for the link each row carries to its record. The\n * shell supplies it on every hub page; a mount without one draws the\n * record's label with no link rather than a link into nowhere.\n */\n basePath?: string\n}\n\n/**\n * The newest logged activity across the CRM (AGL-2600): the last few calls,\n * emails, meetings and notes anyone on the team filed against any record,\n * each linking to the record it is about.\n *\n * The contacts landing shows it as a card of its own under the list card,\n * so that opening the CRM answers \"what has the team been doing\" before\n * anybody opens a record, without the list running on into it. One bounded\n * listener on `(visibleTo, atMs DESC)` — the index that exists for exactly\n * this query — filtered to what this reader may see, the same predicate the\n * rules evaluate. It reads one page, `limit`, and widens by a page only\n * when the reader turns to the next one.\n *\n * Every row is collapsed to its kind, its heading, who and when, and opens\n * in place to the body; **Expand all** in the card header opens them all.\n *\n * A row links to its CONTACT when it has one, else its deal, else its\n * company — `crmActivityRecordLink`'s precedence — through `crmRoutes`, so\n * the address it builds is the one the hub resolves. Nothing is looked up\n * to name the record: a name per row would be a document read per row of a\n * feed drawn on every visit to the list, and the record's page names itself.\n */\nexport function RecentActivityFeed(props: RecentActivityFeedProps) {\n const { hostId, org, limit = RECENT_ACTIVITY_LIMIT, basePath } = props\n const scope = useActivityScope(hostId, org)\n const activities = useActivityWindow(scope, NO_RECORD, limit)\n const expansion = useTimelineExpansion()\n /*\n * Whether the feed has ever had a row. A page turned past the window\n * re-reads it, and the listener holds nothing while it does; the card has\n * to stay through that rather than vanish with its page.\n */\n const [seen, setSeen] = useState(false)\n useEffect(() => {\n if (activities.rows.length) setSeen(true)\n }, [activities.rows.length])\n const routes = useMemo(\n () => (basePath ? crmRoutes(basePath) : null),\n [basePath],\n )\n const subjectFor = useCallback(\n (activity: CrmActivityRow) => {\n const target = Aglyn.crmActivityRecordLink(activity)\n if (!target) return null\n const label = RECORD_LABELS[target.record]\n const href = routes ? routes[target.record](target.id) : null\n return href ? (\n <Typography variant=\"caption\">\n <AppLink href={href}>{label}</AppLink>\n </Typography>\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {label}\n </Typography>\n )\n },\n [routes],\n )\n\n // Nothing to show and nothing to say: a landing with no activity yet\n // should not carry an empty heading for a feature the reader has not\n // used, and the record pages are where the \"log one\" affordance lives.\n if (activities.status !== 'error' && !activities.rows.length && !seen) return null\n\n return (\n <CardDisplay\n header={'Recent activity'}\n help={Aglyn.pluginDocsHelp('contactActivities', { anchor: '#the-recent-activity-feed' })}\n contentGutterX\n contentGutterY\n HeaderProps={{\n action: (\n <TimelineExpandAllButton\n expansion={expansion}\n disabled={!activities.rows.length}\n />\n ),\n }}\n >\n {activities.status === 'error' ? (\n <Typography variant=\"body2\" color=\"error\">\n {'Recent activity could not be loaded.'}\n </Typography>\n ) : (\n <ActivityList\n rows={activities.rows}\n scope={scope}\n subjectFor={subjectFor}\n readOnly\n hasMore={activities.hasMore}\n onShowMore={activities.showMore}\n loading={activities.status === 'loading'}\n expansion={expansion}\n />\n )}\n </CardDisplay>\n )\n}\nRecentActivityFeed.displayName = 'RecentActivityFeed'\n\nexport default RecentActivityFeed\n"],"names":["Aglyn","AppLink","CardDisplay","Typography","useCallback","useEffect","useMemo","useState","crmRoutes","ActivityList","useActivityScope","useActivityWindow","TimelineExpandAllButton","useTimelineExpansion","RECORD_LABELS","contact","deal","company","lead","RECENT_ACTIVITY_LIMIT","NO_RECORD","Object","freeze","RecentActivityFeed","props","hostId","org","limit","basePath","scope","activities","expansion","seen","setSeen","rows","length","routes","subjectFor","activity","target","crmActivityRecordLink","label","record","href","id","variant","color","status","header","help","pluginDocsHelp","anchor","contentGutterX","contentGutterY","HeaderProps","action","disabled","readOnly","hasMore","onShowMore","showMore","loading","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,YAAYA,WAAW,eAAc;AAErC,SAASC,OAAO,EAAEC,WAAW,QAAQ,uBAAsB;AAC3D,SAASC,UAAU,QAAQ,gBAAe;AAC1C,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SAASC,SAAS,QAAQ,yBAAqB;AAC/C,SAASC,YAAY,QAAQ,qBAAiB;AAC9C,SAEEC,gBAAgB,EAChBC,iBAAiB,QACZ,wBAAoB;AAC3B,SAASC,uBAAuB,EAAEC,oBAAoB,QAAQ,yBAAqB;AAEnF,2DAA2D,GAC3D,MAAMC,gBAAgB;IACpBC,SAAS;IACTC,MAAM;IACNC,SAAS;IACTC,MAAM;AACR;AAEA,qFAAqF,GACrF,OAAO,MAAMC,wBAAwB,GAAE;AAEvC,kEAAkE,GAClE,MAAMC,YAAYC,OAAOC,MAAM,CAAC,CAAC;AAgBjC;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,mBAAmBC,KAA8B;IAC/D,MAAM,EAAEC,MAAM,EAAEC,GAAG,EAAEC,QAAQR,qBAAqB,EAAES,QAAQ,EAAE,GAAGJ;IACjE,MAAMK,QAAQnB,iBAAiBe,QAAQC;IACvC,MAAMI,aAAanB,kBAAkBkB,OAAOT,WAAWO;IACvD,MAAMI,YAAYlB;IAClB;;;;GAIC,GACD,MAAM,CAACmB,MAAMC,QAAQ,GAAG1B,SAAS;IACjCF,UAAU;QACR,IAAIyB,WAAWI,IAAI,CAACC,MAAM,EAAEF,QAAQ;IACtC,GAAG;QAACH,WAAWI,IAAI,CAACC,MAAM;KAAC;IAC3B,MAAMC,SAAS9B,QACb,IAAOsB,WAAWpB,UAAUoB,YAAY,MACxC;QAACA;KAAS;IAEZ,MAAMS,aAAajC,YACjB,CAACkC;QACC,MAAMC,SAASvC,MAAMwC,qBAAqB,CAACF;QAC3C,IAAI,CAACC,QAAQ,OAAO;QACpB,MAAME,QAAQ3B,aAAa,CAACyB,OAAOG,MAAM,CAAC;QAC1C,MAAMC,OAAOP,SAASA,MAAM,CAACG,OAAOG,MAAM,CAAC,CAACH,OAAOK,EAAE,IAAI;QACzD,OAAOD,qBACL,KAACxC;YAAW0C,SAAQ;sBAClB,cAAA,KAAC5C;gBAAQ0C,MAAMA;0BAAOF;;2BAGxB,KAACtC;YAAW0C,SAAQ;YAAUC,OAAM;sBACjCL;;IAGP,GACA;QAACL;KAAO;IAGV,qEAAqE;IACrE,qEAAqE;IACrE,uEAAuE;IACvE,IAAIN,WAAWiB,MAAM,KAAK,WAAW,CAACjB,WAAWI,IAAI,CAACC,MAAM,IAAI,CAACH,MAAM,OAAO;IAE9E,qBACE,KAAC9B;QACC8C,QAAQ;QACRC,MAAMjD,MAAMkD,cAAc,CAAC,qBAAqB;YAAEC,QAAQ;QAA4B;QACtFC,cAAc;QACdC,cAAc;QACdC,aAAa;YACXC,sBACE,KAAC3C;gBACCmB,WAAWA;gBACXyB,UAAU,CAAC1B,WAAWI,IAAI,CAACC,MAAM;;QAGvC;kBAECL,WAAWiB,MAAM,KAAK,wBACrB,KAAC5C;YAAW0C,SAAQ;YAAQC,OAAM;sBAC/B;2BAGH,KAACrC;YACCyB,MAAMJ,WAAWI,IAAI;YACrBL,OAAOA;YACPQ,YAAYA;YACZoB,QAAQ;YACRC,SAAS5B,WAAW4B,OAAO;YAC3BC,YAAY7B,WAAW8B,QAAQ;YAC/BC,SAAS/B,WAAWiB,MAAM,KAAK;YAC/BhB,WAAWA;;;AAKrB;AACAR,mBAAmBuC,WAAW,GAAG;AAEjC,eAAevC,mBAAkB"}
|
|
@@ -9,8 +9,10 @@ export type RecordActivityCardProps = ActivityRecordLink & {
|
|
|
9
9
|
* (AGL-2615) — with the button that adds to it (AGL-2600).
|
|
10
10
|
*
|
|
11
11
|
* One card for all four record pages, because the log is the same thing on
|
|
12
|
-
* each of them: what people did about this record, newest first,
|
|
13
|
-
*
|
|
12
|
+
* each of them: what people did about this record, newest first, one
|
|
13
|
+
* collapsed entry each and paged by the console's footer over a listener
|
|
14
|
+
* bounded to a hundred, which a page turned past it widens by the next
|
|
15
|
+
* hundred. **Log activity** and **Expand all** sit in the card header. Which
|
|
14
16
|
* record is decided by whichever of the four ids the page passes, and that
|
|
15
17
|
* id is what the dialog files a new activity against — the page fixes it,
|
|
16
18
|
* the reader does not pick it.
|
|
@@ -17,18 +17,21 @@
|
|
|
17
17
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
18
|
import { pluginDocsHelp } from "@aglyn/aglyn";
|
|
19
19
|
import { CardDisplay } from "@aglyn/shared-ui-jsx";
|
|
20
|
-
import { Button, Typography } from "@mui/material";
|
|
20
|
+
import { Button, Stack, Typography } from "@mui/material";
|
|
21
21
|
import { useCallback, useMemo, useState } from "react";
|
|
22
22
|
import { ActivityList } from "./activity-list.js";
|
|
23
23
|
import { useActivityScope, useActivityWindow } from "./activity-queries.js";
|
|
24
|
+
import { TimelineExpandAllButton, useTimelineExpansion } from "./activity-timeline.js";
|
|
24
25
|
import { LogActivityDialog } from "./log-activity-dialog.js";
|
|
25
26
|
/**
|
|
26
27
|
* The activity log of one record — a contact, a company, a deal or a lead
|
|
27
28
|
* (AGL-2615) — with the button that adds to it (AGL-2600).
|
|
28
29
|
*
|
|
29
30
|
* One card for all four record pages, because the log is the same thing on
|
|
30
|
-
* each of them: what people did about this record, newest first,
|
|
31
|
-
*
|
|
31
|
+
* each of them: what people did about this record, newest first, one
|
|
32
|
+
* collapsed entry each and paged by the console's footer over a listener
|
|
33
|
+
* bounded to a hundred, which a page turned past it widens by the next
|
|
34
|
+
* hundred. **Log activity** and **Expand all** sit in the card header. Which
|
|
32
35
|
* record is decided by whichever of the four ids the page passes, and that
|
|
33
36
|
* id is what the dialog files a new activity against — the page fixes it,
|
|
34
37
|
* the reader does not pick it.
|
|
@@ -56,6 +59,7 @@ import { LogActivityDialog } from "./log-activity-dialog.js";
|
|
|
56
59
|
leadId
|
|
57
60
|
]);
|
|
58
61
|
const activities = useActivityWindow(scope, link);
|
|
62
|
+
const expansion = useTimelineExpansion();
|
|
59
63
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
60
64
|
const [editing, setEditing] = useState(null);
|
|
61
65
|
const openNew = useCallback(()=>{
|
|
@@ -74,14 +78,26 @@ import { LogActivityDialog } from "./log-activity-dialog.js";
|
|
|
74
78
|
help: pluginDocsHelp('contactActivities', {
|
|
75
79
|
anchor: '#logging-an-activity'
|
|
76
80
|
}),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
HeaderProps: {
|
|
82
|
+
action: /*#__PURE__*/ _jsxs(Stack, {
|
|
83
|
+
direction: "row",
|
|
84
|
+
spacing: 1,
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ _jsx(TimelineExpandAllButton, {
|
|
87
|
+
expansion: expansion,
|
|
88
|
+
disabled: !activities.rows.length
|
|
89
|
+
}),
|
|
90
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
91
|
+
size: "small",
|
|
92
|
+
variant: "contained",
|
|
93
|
+
color: "primary",
|
|
94
|
+
onClick: openNew,
|
|
95
|
+
disabled: !activities.ready,
|
|
96
|
+
children: 'Log activity'
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
})
|
|
100
|
+
},
|
|
85
101
|
contentGutterX: true,
|
|
86
102
|
contentGutterY: true,
|
|
87
103
|
children: activities.status === 'error' ? /*#__PURE__*/ _jsx(Typography, {
|
|
@@ -94,6 +110,8 @@ import { LogActivityDialog } from "./log-activity-dialog.js";
|
|
|
94
110
|
onEdit: openEdit,
|
|
95
111
|
hasMore: activities.hasMore,
|
|
96
112
|
onShowMore: activities.showMore,
|
|
113
|
+
loading: activities.status === 'loading',
|
|
114
|
+
expansion: expansion,
|
|
97
115
|
emptyText: "A call, an email, a meeting or a note about this record goes here.",
|
|
98
116
|
emptyAction: /*#__PURE__*/ _jsx(Button, {
|
|
99
117
|
size: "small",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/record-activity-card.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { CrmActivityRow } from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { Button, Typography } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport { ActivityList } from './activity-list'\nimport {\n type ActivityRecordLink,\n type CrmOrg,\n useActivityScope,\n useActivityWindow,\n} from './activity-queries'\nimport { LogActivityDialog } from './log-activity-dialog'\n\nexport type RecordActivityCardProps = ActivityRecordLink & {\n /** The site the record is read under, or `null` at the organization level. */\n hostId: string | null\n org: CrmOrg\n}\n\n/**\n * The activity log of one record — a contact, a company, a deal or a lead\n * (AGL-2615) — with the button that adds to it (AGL-2600).\n *\n * One card for all four record pages, because the log is the same thing on\n * each of them: what people did about this record, newest first,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/record-activity-card.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { CrmActivityRow } from '@aglyn/aglyn'\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { Button, Stack, Typography } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport { ActivityList } from './activity-list'\nimport {\n type ActivityRecordLink,\n type CrmOrg,\n useActivityScope,\n useActivityWindow,\n} from './activity-queries'\nimport { TimelineExpandAllButton, useTimelineExpansion } from './activity-timeline'\nimport { LogActivityDialog } from './log-activity-dialog'\n\nexport type RecordActivityCardProps = ActivityRecordLink & {\n /** The site the record is read under, or `null` at the organization level. */\n hostId: string | null\n org: CrmOrg\n}\n\n/**\n * The activity log of one record — a contact, a company, a deal or a lead\n * (AGL-2615) — with the button that adds to it (AGL-2600).\n *\n * One card for all four record pages, because the log is the same thing on\n * each of them: what people did about this record, newest first, one\n * collapsed entry each and paged by the console's footer over a listener\n * bounded to a hundred, which a page turned past it widens by the next\n * hundred. **Log activity** and **Expand all** sit in the card header. Which\n * record is decided by whichever of the four ids the page passes, and that\n * id is what the dialog files a new activity against — the page fixes it,\n * the reader does not pick it.\n *\n * The contact's page does NOT use this card. A person has a second history\n * the platform captured on the row itself, and the two belong in one\n * stream; see `contact-timeline-card.tsx`, which is this card's superset.\n */\nexport function RecordActivityCard(props: RecordActivityCardProps) {\n const { hostId, org, contactId, companyId, dealId, leadId } = props\n const scope = useActivityScope(hostId, org)\n /*\n * Memoized because the link is a listener dependency by value inside\n * `useActivityWindow` and the dialog's prop by reference: a fresh object\n * each render would be harmless to the query, which reads the ids, and\n * noisy for anything that compares the object.\n */\n const link = useMemo<ActivityRecordLink>(\n () => ({ contactId, companyId, dealId, leadId }),\n [contactId, companyId, dealId, leadId],\n )\n const activities = useActivityWindow(scope, link)\n const expansion = useTimelineExpansion()\n const [dialogOpen, setDialogOpen] = useState(false)\n const [editing, setEditing] = useState<CrmActivityRow | null>(null)\n const openNew = useCallback(() => {\n setEditing(null)\n setDialogOpen(true)\n }, [])\n const openEdit = useCallback((activity: CrmActivityRow) => {\n setEditing(activity)\n setDialogOpen(true)\n }, [])\n const close = useCallback(() => setDialogOpen(false), [])\n\n return (\n <>\n <CardDisplay\n header={'Activity'}\n help={pluginDocsHelp('contactActivities', { anchor: '#logging-an-activity' })}\n HeaderProps={{\n action: (\n <Stack direction=\"row\" spacing={1}>\n <TimelineExpandAllButton\n expansion={expansion}\n disabled={!activities.rows.length}\n />\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n onClick={openNew}\n disabled={!activities.ready}\n >\n {'Log activity'}\n </Button>\n </Stack>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n {activities.status === 'error' ? (\n <Typography variant=\"body2\" color=\"error\">\n {'The activity log could not be loaded.'}\n </Typography>\n ) : (\n <ActivityList\n rows={activities.rows}\n scope={scope}\n onEdit={openEdit}\n hasMore={activities.hasMore}\n onShowMore={activities.showMore}\n loading={activities.status === 'loading'}\n expansion={expansion}\n emptyText=\"A call, an email, a meeting or a note about this record goes here.\"\n emptyAction={\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n onClick={openNew}\n disabled={!activities.ready}\n >\n {'Log activity'}\n </Button>\n }\n />\n )}\n </CardDisplay>\n <LogActivityDialog\n open={dialogOpen}\n onClose={close}\n scope={scope}\n link={link}\n activity={editing}\n />\n </>\n )\n}\nRecordActivityCard.displayName = 'RecordActivityCard'\n\nexport default RecordActivityCard\n"],"names":["pluginDocsHelp","CardDisplay","Button","Stack","Typography","useCallback","useMemo","useState","ActivityList","useActivityScope","useActivityWindow","TimelineExpandAllButton","useTimelineExpansion","LogActivityDialog","RecordActivityCard","props","hostId","org","contactId","companyId","dealId","leadId","scope","link","activities","expansion","dialogOpen","setDialogOpen","editing","setEditing","openNew","openEdit","activity","close","header","help","anchor","HeaderProps","action","direction","spacing","disabled","rows","length","size","variant","color","onClick","ready","contentGutterX","contentGutterY","status","onEdit","hasMore","onShowMore","showMore","loading","emptyText","emptyAction","open","onClose","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,MAAM,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACzD,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACtD,SAASC,YAAY,QAAQ,qBAAiB;AAC9C,SAGEC,gBAAgB,EAChBC,iBAAiB,QACZ,wBAAoB;AAC3B,SAASC,uBAAuB,EAAEC,oBAAoB,QAAQ,yBAAqB;AACnF,SAASC,iBAAiB,QAAQ,2BAAuB;AAQzD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,mBAAmBC,KAA8B;IAC/D,MAAM,EAAEC,MAAM,EAAEC,GAAG,EAAEC,SAAS,EAAEC,SAAS,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGN;IAC9D,MAAMO,QAAQb,iBAAiBO,QAAQC;IACvC;;;;;GAKC,GACD,MAAMM,OAAOjB,QACX,IAAO,CAAA;YAAEY;YAAWC;YAAWC;YAAQC;QAAO,CAAA,GAC9C;QAACH;QAAWC;QAAWC;QAAQC;KAAO;IAExC,MAAMG,aAAad,kBAAkBY,OAAOC;IAC5C,MAAME,YAAYb;IAClB,MAAM,CAACc,YAAYC,cAAc,GAAGpB,SAAS;IAC7C,MAAM,CAACqB,SAASC,WAAW,GAAGtB,SAAgC;IAC9D,MAAMuB,UAAUzB,YAAY;QAC1BwB,WAAW;QACXF,cAAc;IAChB,GAAG,EAAE;IACL,MAAMI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HeaderProps: {
|
|
176
|
+
action: /*#__PURE__*/ _jsx(ReportExport, {
|
|
177
|
+
filename: reportFilename('activity', period),
|
|
178
|
+
columns: COLUMNS,
|
|
179
|
+
rows: ()=>rows.map((row)=>[
|
|
180
|
+
nameOf(row),
|
|
181
|
+
...Aglyn.CRM_ACTIVITY_KINDS.map((kind)=>row.kinds[kind]),
|
|
182
|
+
row.activities,
|
|
183
|
+
tasksRead ? row.tasksDone : ''
|
|
184
|
+
]),
|
|
185
|
+
disabled: !activitiesRead || !rows.length
|
|
186
|
+
})
|
|
187
|
+
},
|
|
175
188
|
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
176
189
|
spacing: 2,
|
|
177
190
|
children: [
|
|
@@ -257,18 +270,11 @@ const TASK_DONE_CEILING = 1000;
|
|
|
257
270
|
color: "text.secondary",
|
|
258
271
|
children: 'No teammate — activities an automation logged, and tasks completed with nobody assigned.'
|
|
259
272
|
}) : null,
|
|
260
|
-
/*#__PURE__*/ _jsx(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
...Aglyn.CRM_ACTIVITY_KINDS.map((kind)=>row.kinds[kind]),
|
|
266
|
-
row.activities,
|
|
267
|
-
tasksRead ? row.tasksDone : ''
|
|
268
|
-
]),
|
|
269
|
-
disabled: !activitiesRead || !rows.length,
|
|
270
|
-
caption: caption ? `${caption}; the tiles are counted on the server.` : undefined
|
|
271
|
-
})
|
|
273
|
+
caption ? /*#__PURE__*/ _jsx(Typography, {
|
|
274
|
+
variant: "caption",
|
|
275
|
+
color: "text.secondary",
|
|
276
|
+
children: `${caption}; the tiles are counted on the server.`
|
|
277
|
+
}) : null
|
|
272
278
|
]
|
|
273
279
|
})
|
|
274
280
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/crm/src/lib/components/reports/activity-card.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { Section } from '@aglyn/shared-ui-jsx/components/measured-figures.component'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport {\n Alert,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material'\nimport {\n getCountFromServer,\n limit,\n orderBy,\n query,\n where,\n} from 'firebase/firestore'\nimport { useMemo } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport { useOrgMemberOptions } from '../../hooks/use-org-member-options'\nimport { ReportExport } from './report-export'\nimport { reportFilename } from './report-format'\nimport {\n type CrmReportScope,\n reportCacheKey,\n scopedCollection,\n visibleToClause,\n} from './report-scope'\nimport { ReportStatTile } from './report-stat-tile'\nimport { useAggregateRead, useWindowRead } from './use-aggregate-read'\n\n/**\n * How many activities and how many completed tasks the leaderboard is\n * grouped from.\n *\n * The tiles are server counts and never meet these bounds; the table needs\n * each activity's kind and author and each task's completer, so it reads\n * the period's newest thousand of each and says when there were more —\n * the contacts list's bound, and the one every window on this page shares.\n */\nconst ACTIVITY_CEILING = 1000\nconst TASK_DONE_CEILING = 1000\n\ntype ActivityRow = Aglyn.CrmActivityRow\ntype TaskRow = Aglyn.CrmTask & { $id: string }\n\n/** The table's columns, which are also the CSV's. */\nconst COLUMNS = [\n 'Teammate',\n ...Aglyn.CRM_ACTIVITY_KINDS.map((kind) => Aglyn.CRM_ACTIVITY_KIND_LABELS[kind]),\n 'Activities',\n 'Tasks done',\n] as const\n\nexport interface ActivityCardProps {\n report: CrmReportScope\n}\n\n/**\n * Activity by teammate (AGL-2624): the calls, emails, meetings and notes\n * each member logged in the period, and the tasks they ticked off,\n * busiest first.\n *\n * ## Two windows, two indexes, one table\n *\n * Activities are counted within the period on `atMs`; completed tasks are\n * counted the same way on `completedAtMs`, under `status == 'done'`. Each\n * count is also drawn as a window, newest first, for the leaderboard.\n *\n * ## Why that is four indexes and not one\n *\n * The counts and the windows do not share an index, and neither do the two\n * audiences.\n *\n * A COUNT here names no `orderBy`. Firestore then orders implicitly by the\n * range field, ASCENDING, so a count wants `completedAtMs` ascending — while\n * the window beside it asks for `desc` explicitly and wants the descending\n * one. A composite index serves one direction or its exact reverse, never\n * both, so declaring only the direction the window reads leaves the count\n * with nothing: `FAILED_PRECONDITION`, one column of dashes, and a card that\n * otherwise looks fine.\n *\n * Then the visibility clause doubles it. `visibleToClause` contributes\n * nothing when the reader's tokens are null, which is every organization-level\n * read, so the shape arriving at Firestore has no leading array field — a\n * different index, not a prefix of the one with it. `(visibleTo, status,\n * completedAtMs)` serves a site and `(status, completedAtMs)` the org above\n * it; one without the other is a card that works for exactly one audience.\n *\n * The two reads are independent so that a missing task index degrades ONE\n * column to a dash and a notice rather than the whole card: the activities\n * were read, and the leaderboard draws them.\n *\n * A task ordered by `completedAtMs` is a task the complete route stamped;\n * a task marked done some other way, without the stamp, is not in the\n * window and the caption says what the column is grouped from.\n *\n * ## Names\n *\n * Every activity carries the name it was signed with, for the reason\n * `CrmActivity.byName` gives — a scoped reader cannot resolve a colleague's\n * uid. The roster is read too, through the members route any member may\n * ask, and wins when it knows the uid, so a renamed teammate reads by\n * their current name; the signed name covers a uid the roster no longer\n * has, and the uid itself covers the rest.\n */\nexport function ActivityCard(props: ActivityCardProps) {\n const { report } = props\n const { scope, tokens, range, period, routes } = report\n const firestore = useFirestore()\n const roster = useOrgMemberOptions(scope[1])\n\n const activitiesBetween = (from: number, to: number) =>\n query(\n scopedCollection(firestore, scope, Aglyn.CRM_COLLECTIONS.activities),\n ...visibleToClause(tokens),\n where('atMs', '>=', from),\n where('atMs', '<', to),\n )\n const tasksDoneBetween = (from: number, to: number) =>\n query(\n scopedCollection(firestore, scope, Aglyn.CRM_COLLECTIONS.tasks),\n ...visibleToClause(tokens),\n where('status', '==', 'done'),\n where('completedAtMs', '>=', from),\n where('completedAtMs', '<', to),\n )\n const countOf = (target: ReturnType<typeof query>) =>\n getCountFromServer(target).then((snapshot) => snapshot.data().count)\n\n const activityCounts = useAggregateRead(\n () =>\n Promise.all([\n countOf(activitiesBetween(range.from, range.to)),\n countOf(activitiesBetween(range.previousFrom, range.previousTo)),\n ]).then(([current, previous]) => ({ current, previous })),\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:counts') },\n )\n const taskCounts = useAggregateRead(\n () =>\n Promise.all([\n countOf(tasksDoneBetween(range.from, range.to)),\n countOf(tasksDoneBetween(range.previousFrom, range.previousTo)),\n ]).then(([current, previous]) => ({ current, previous })),\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:tasks-counts') },\n )\n\n const activityWindow = useWindowRead<ActivityRow>(\n () =>\n query(\n activitiesBetween(range.from, range.to),\n orderBy('atMs', 'desc'),\n limit(ACTIVITY_CEILING + 1),\n ),\n ACTIVITY_CEILING,\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:window') },\n )\n const taskWindow = useWindowRead<TaskRow>(\n () =>\n query(\n tasksDoneBetween(range.from, range.to),\n orderBy('completedAtMs', 'desc'),\n limit(TASK_DONE_CEILING + 1),\n ),\n TASK_DONE_CEILING,\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:tasks-window') },\n )\n\n const rows = useMemo(\n () => Aglyn.activityLeaderboard(activityWindow.rows, taskWindow.rows),\n [activityWindow, taskWindow],\n )\n const nameOf = (row: Aglyn.ActivityLeaderboardRow): string => {\n if (!row.uid) return 'No teammate'\n return Aglyn.findOrgMember(roster.options, row.uid)?.label ?? row.name ?? row.uid\n }\n const teammates = rows.filter((row) => row.uid).length\n\n const activitiesRead = activityWindow.status === 'success'\n const tasksRead = taskWindow.status === 'success'\n const settled = activityWindow.status !== 'loading' && taskWindow.status !== 'loading'\n const caption = [\n activityWindow.truncated\n ? `Grouped from the ${ACTIVITY_CEILING.toLocaleString()} most recent activities in the period`\n : null,\n taskWindow.truncated\n ? `the ${TASK_DONE_CEILING.toLocaleString()} most recently completed tasks`\n : null,\n ]\n .filter(Boolean)\n .join(' and ')\n const activityFigures = activityCounts.value\n const taskFigures = taskCounts.value\n\n return (\n <CardDisplay\n header={'Activity by teammate'}\n help={Aglyn.pluginDocsHelp('crmReports', {\n anchor: '#activity-by-teammate',\n excerpt:\n 'The calls, emails, meetings and notes each teammate logged in ' +\n 'the period, and the tasks they completed, busiest first. ' +\n 'Grouped from the period’s newest thousand of each.',\n })}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n <Stack direction=\"row\" spacing={3} sx={{ flexWrap: 'wrap' }}>\n <ReportStatTile\n label={'Activities logged'}\n value={activityFigures ? activityFigures.current.toLocaleString() : null}\n deltaPct={\n activityFigures\n ? Aglyn.deltaPercent(activityFigures.current, activityFigures.previous)\n : null\n }\n note={'counted on the server'}\n href={routes.section('contacts')}\n />\n <ReportStatTile\n label={'Tasks completed'}\n value={taskFigures ? taskFigures.current.toLocaleString() : null}\n deltaPct={\n taskFigures\n ? Aglyn.deltaPercent(taskFigures.current, taskFigures.previous)\n : null\n }\n note={'ticked off in the period'}\n href={routes.section('tasks')}\n />\n <ReportStatTile\n label={'Teammates active'}\n value={settled ? teammates.toLocaleString() : null}\n note={'logged or completed something'}\n />\n </Stack>\n {activityCounts.status === 'error' || activityWindow.status === 'error' ? (\n <Alert severity=\"warning\">{'The activities could not be read.'}</Alert>\n ) : null}\n {taskCounts.status === 'error' || taskWindow.status === 'error' ? (\n <Alert severity=\"warning\">\n {'The completed-task counts could not be read; the Tasks done column is left blank.'}\n </Alert>\n ) : null}\n <Section title={'Who did what'}>\n {rows.length ? (\n <ScrollTable size=\"small\">\n <TableHead>\n <TableRow>\n {COLUMNS.map((column, index) => (\n <TableCell key={column} align={index ? 'right' : 'left'}>\n {column}\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {rows.map((row) => (\n <TableRow key={row.uid || '$nobody'}>\n <TableCell>{nameOf(row)}</TableCell>\n {Aglyn.CRM_ACTIVITY_KINDS.map((kind) => (\n <TableCell key={kind} align=\"right\">\n {row.kinds[kind].toLocaleString()}\n </TableCell>\n ))}\n <TableCell align=\"right\">{row.activities.toLocaleString()}</TableCell>\n <TableCell align=\"right\">\n {tasksRead ? row.tasksDone.toLocaleString() : '—'}\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {settled ? 'Nothing logged or completed in this period.' : 'Reading…'}\n </Typography>\n )}\n {rows.some((row) => !row.uid) ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'No teammate — activities an automation logged, and tasks completed with nobody assigned.'}\n </Typography>\n ) : null}\n <ReportExport\n filename={reportFilename('activity', period)}\n columns={COLUMNS}\n rows={() =>\n rows.map((row) => [\n nameOf(row),\n ...Aglyn.CRM_ACTIVITY_KINDS.map((kind) => row.kinds[kind]),\n row.activities,\n tasksRead ? row.tasksDone : '',\n ])\n }\n disabled={!activitiesRead || !rows.length}\n caption={caption ? `${caption}; the tiles are counted on the server.` : undefined}\n />\n </Section>\n </Stack>\n </CardDisplay>\n )\n}\nActivityCard.displayName = 'ActivityCard'\n\nexport default ActivityCard\n"],"names":["Aglyn","CardDisplay","Section","ScrollTable","Alert","Stack","TableBody","TableCell","TableHead","TableRow","Typography","getCountFromServer","limit","orderBy","query","where","useMemo","useFirestore","useOrgMemberOptions","ReportExport","reportFilename","reportCacheKey","scopedCollection","visibleToClause","ReportStatTile","useAggregateRead","useWindowRead","ACTIVITY_CEILING","TASK_DONE_CEILING","COLUMNS","CRM_ACTIVITY_KINDS","map","kind","CRM_ACTIVITY_KIND_LABELS","ActivityCard","props","report","scope","tokens","range","period","routes","firestore","roster","activitiesBetween","from","to","CRM_COLLECTIONS","activities","tasksDoneBetween","tasks","countOf","target","then","snapshot","data","count","activityCounts","Promise","all","previousFrom","previousTo","current","previous","cacheKey","taskCounts","activityWindow","taskWindow","rows","activityLeaderboard","nameOf","row","uid","findOrgMember","options","label","name","teammates","filter","length","activitiesRead","status","tasksRead","settled","caption","truncated","toLocaleString","Boolean","join","activityFigures","value","taskFigures","header","help","pluginDocsHelp","anchor","excerpt","contentGutterX","contentGutterY","spacing","direction","sx","flexWrap","deltaPct","deltaPercent","note","href","section","severity","title","size","column","index","align","kinds","tasksDone","variant","color","some","filename","columns","disabled","undefined","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,YAAYA,WAAW,eAAc;AACrC,SAASC,WAAW,QAAQ,uBAAsB;AAClD,SAASC,OAAO,QAAQ,6DAA4D;AACpF,SAASC,WAAW,QAAQ,yDAAwD;AACpF,SACEC,KAAK,EACLC,KAAK,EACLC,SAAS,EACTC,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,UAAU,QACL,gBAAe;AACtB,SACEC,kBAAkB,EAClBC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,KAAK,QACA,qBAAoB;AAC3B,SAASC,OAAO,QAAQ,QAAO;AAC/B,SAASC,YAAY,QAAQ,iCAAgC;AAC7D,SAASC,mBAAmB,QAAQ,wCAAoC;AACxE,SAASC,YAAY,QAAQ,qBAAiB;AAC9C,SAASC,cAAc,QAAQ,qBAAiB;AAChD,SAEEC,cAAc,EACdC,gBAAgB,EAChBC,eAAe,QACV,oBAAgB;AACvB,SAASC,cAAc,QAAQ,wBAAoB;AACnD,SAASC,gBAAgB,EAAEC,aAAa,QAAQ,0BAAsB;AAEtE;;;;;;;;CAQC,GACD,MAAMC,mBAAmB;AACzB,MAAMC,oBAAoB;AA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BACrCgF,SAAS3F;4BACTuC,MAAM,IACJA,KAAKrC,GAAG,CAAC,CAACwC,MAAQ;wCAChBD,OAAOC;2CACJvE,MAAM8B,kBAAkB,CAACC,GAAG,CAAC,CAACC,OAASuC,IAAI2C,KAAK,CAAClF,KAAK;wCACzDuC,IAAIvB,UAAU;wCACdkC,YAAYX,IAAI4C,SAAS,GAAG;qCAC7B;4BAEHM,UAAU,CAACzC,kBAAkB,CAACZ,KAAKW,MAAM;4BACzCK,SAASA,UAAU,GAAGA,QAAQ,sCAAsC,CAAC,GAAGsC;;;;;;;AAMpF;AACAxF,aAAayF,WAAW,GAAG;AAE3B,eAAezF,aAAY"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/crm/src/lib/components/reports/activity-card.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport { CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { Section } from '@aglyn/shared-ui-jsx/components/measured-figures.component'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport {\n Alert,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n Typography,\n} from '@mui/material'\nimport {\n getCountFromServer,\n limit,\n orderBy,\n query,\n where,\n} from 'firebase/firestore'\nimport { useMemo } from 'react'\nimport { useFirestore } from '@aglyn/tenant-feature-instance'\nimport { useOrgMemberOptions } from '../../hooks/use-org-member-options'\nimport { ReportExport } from './report-export'\nimport { reportFilename } from './report-format'\nimport {\n type CrmReportScope,\n reportCacheKey,\n scopedCollection,\n visibleToClause,\n} from './report-scope'\nimport { ReportStatTile } from './report-stat-tile'\nimport { useAggregateRead, useWindowRead } from './use-aggregate-read'\n\n/**\n * How many activities and how many completed tasks the leaderboard is\n * grouped from.\n *\n * The tiles are server counts and never meet these bounds; the table needs\n * each activity's kind and author and each task's completer, so it reads\n * the period's newest thousand of each and says when there were more —\n * the contacts list's bound, and the one every window on this page shares.\n */\nconst ACTIVITY_CEILING = 1000\nconst TASK_DONE_CEILING = 1000\n\ntype ActivityRow = Aglyn.CrmActivityRow\ntype TaskRow = Aglyn.CrmTask & { $id: string }\n\n/** The table's columns, which are also the CSV's. */\nconst COLUMNS = [\n 'Teammate',\n ...Aglyn.CRM_ACTIVITY_KINDS.map((kind) => Aglyn.CRM_ACTIVITY_KIND_LABELS[kind]),\n 'Activities',\n 'Tasks done',\n] as const\n\nexport interface ActivityCardProps {\n report: CrmReportScope\n}\n\n/**\n * Activity by teammate (AGL-2624): the calls, emails, meetings and notes\n * each member logged in the period, and the tasks they ticked off,\n * busiest first.\n *\n * ## Two windows, two indexes, one table\n *\n * Activities are counted within the period on `atMs`; completed tasks are\n * counted the same way on `completedAtMs`, under `status == 'done'`. Each\n * count is also drawn as a window, newest first, for the leaderboard.\n *\n * ## Why that is four indexes and not one\n *\n * The counts and the windows do not share an index, and neither do the two\n * audiences.\n *\n * A COUNT here names no `orderBy`. Firestore then orders implicitly by the\n * range field, ASCENDING, so a count wants `completedAtMs` ascending — while\n * the window beside it asks for `desc` explicitly and wants the descending\n * one. A composite index serves one direction or its exact reverse, never\n * both, so declaring only the direction the window reads leaves the count\n * with nothing: `FAILED_PRECONDITION`, one column of dashes, and a card that\n * otherwise looks fine.\n *\n * Then the visibility clause doubles it. `visibleToClause` contributes\n * nothing when the reader's tokens are null, which is every organization-level\n * read, so the shape arriving at Firestore has no leading array field — a\n * different index, not a prefix of the one with it. `(visibleTo, status,\n * completedAtMs)` serves a site and `(status, completedAtMs)` the org above\n * it; one without the other is a card that works for exactly one audience.\n *\n * The two reads are independent so that a missing task index degrades ONE\n * column to a dash and a notice rather than the whole card: the activities\n * were read, and the leaderboard draws them.\n *\n * A task ordered by `completedAtMs` is a task the complete route stamped;\n * a task marked done some other way, without the stamp, is not in the\n * window and the caption says what the column is grouped from.\n *\n * ## Names\n *\n * Every activity carries the name it was signed with, for the reason\n * `CrmActivity.byName` gives — a scoped reader cannot resolve a colleague's\n * uid. The roster is read too, through the members route any member may\n * ask, and wins when it knows the uid, so a renamed teammate reads by\n * their current name; the signed name covers a uid the roster no longer\n * has, and the uid itself covers the rest.\n */\nexport function ActivityCard(props: ActivityCardProps) {\n const { report } = props\n const { scope, tokens, range, period, routes } = report\n const firestore = useFirestore()\n const roster = useOrgMemberOptions(scope[1])\n\n const activitiesBetween = (from: number, to: number) =>\n query(\n scopedCollection(firestore, scope, Aglyn.CRM_COLLECTIONS.activities),\n ...visibleToClause(tokens),\n where('atMs', '>=', from),\n where('atMs', '<', to),\n )\n const tasksDoneBetween = (from: number, to: number) =>\n query(\n scopedCollection(firestore, scope, Aglyn.CRM_COLLECTIONS.tasks),\n ...visibleToClause(tokens),\n where('status', '==', 'done'),\n where('completedAtMs', '>=', from),\n where('completedAtMs', '<', to),\n )\n const countOf = (target: ReturnType<typeof query>) =>\n getCountFromServer(target).then((snapshot) => snapshot.data().count)\n\n const activityCounts = useAggregateRead(\n () =>\n Promise.all([\n countOf(activitiesBetween(range.from, range.to)),\n countOf(activitiesBetween(range.previousFrom, range.previousTo)),\n ]).then(([current, previous]) => ({ current, previous })),\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:counts') },\n )\n const taskCounts = useAggregateRead(\n () =>\n Promise.all([\n countOf(tasksDoneBetween(range.from, range.to)),\n countOf(tasksDoneBetween(range.previousFrom, range.previousTo)),\n ]).then(([current, previous]) => ({ current, previous })),\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:tasks-counts') },\n )\n\n const activityWindow = useWindowRead<ActivityRow>(\n () =>\n query(\n activitiesBetween(range.from, range.to),\n orderBy('atMs', 'desc'),\n limit(ACTIVITY_CEILING + 1),\n ),\n ACTIVITY_CEILING,\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:window') },\n )\n const taskWindow = useWindowRead<TaskRow>(\n () =>\n query(\n tasksDoneBetween(range.from, range.to),\n orderBy('completedAtMs', 'desc'),\n limit(TASK_DONE_CEILING + 1),\n ),\n TASK_DONE_CEILING,\n [firestore, scope, tokens, range],\n { cacheKey: reportCacheKey(report, 'activity:tasks-window') },\n )\n\n const rows = useMemo(\n () => Aglyn.activityLeaderboard(activityWindow.rows, taskWindow.rows),\n [activityWindow, taskWindow],\n )\n const nameOf = (row: Aglyn.ActivityLeaderboardRow): string => {\n if (!row.uid) return 'No teammate'\n return Aglyn.findOrgMember(roster.options, row.uid)?.label ?? row.name ?? row.uid\n }\n const teammates = rows.filter((row) => row.uid).length\n\n const activitiesRead = activityWindow.status === 'success'\n const tasksRead = taskWindow.status === 'success'\n const settled = activityWindow.status !== 'loading' && taskWindow.status !== 'loading'\n const caption = [\n activityWindow.truncated\n ? `Grouped from the ${ACTIVITY_CEILING.toLocaleString()} most recent activities in the period`\n : null,\n taskWindow.truncated\n ? `the ${TASK_DONE_CEILING.toLocaleString()} most recently completed tasks`\n : null,\n ]\n .filter(Boolean)\n .join(' and ')\n const activityFigures = activityCounts.value\n const taskFigures = taskCounts.value\n\n return (\n <CardDisplay\n header={'Activity by teammate'}\n help={Aglyn.pluginDocsHelp('crmReports', {\n anchor: '#activity-by-teammate',\n excerpt:\n 'The calls, emails, meetings and notes each teammate logged in ' +\n 'the period, and the tasks they completed, busiest first. ' +\n 'Grouped from the period’s newest thousand of each.',\n })}\n contentGutterX\n contentGutterY\n HeaderProps={{\n action: (\n <ReportExport\n filename={reportFilename('activity', period)}\n columns={COLUMNS}\n rows={() =>\n rows.map((row) => [\n nameOf(row),\n ...Aglyn.CRM_ACTIVITY_KINDS.map((kind) => row.kinds[kind]),\n row.activities,\n tasksRead ? row.tasksDone : '',\n ])\n }\n disabled={!activitiesRead || !rows.length}\n />\n ),\n }}\n >\n <Stack spacing={2}>\n <Stack direction=\"row\" spacing={3} sx={{ flexWrap: 'wrap' }}>\n <ReportStatTile\n label={'Activities logged'}\n value={activityFigures ? activityFigures.current.toLocaleString() : null}\n deltaPct={\n activityFigures\n ? Aglyn.deltaPercent(activityFigures.current, activityFigures.previous)\n : null\n }\n note={'counted on the server'}\n href={routes.section('contacts')}\n />\n <ReportStatTile\n label={'Tasks completed'}\n value={taskFigures ? taskFigures.current.toLocaleString() : null}\n deltaPct={\n taskFigures\n ? Aglyn.deltaPercent(taskFigures.current, taskFigures.previous)\n : null\n }\n note={'ticked off in the period'}\n href={routes.section('tasks')}\n />\n <ReportStatTile\n label={'Teammates active'}\n value={settled ? teammates.toLocaleString() : null}\n note={'logged or completed something'}\n />\n </Stack>\n {activityCounts.status === 'error' || activityWindow.status === 'error' ? (\n <Alert severity=\"warning\">{'The activities could not be read.'}</Alert>\n ) : null}\n {taskCounts.status === 'error' || taskWindow.status === 'error' ? (\n <Alert severity=\"warning\">\n {'The completed-task counts could not be read; the Tasks done column is left blank.'}\n </Alert>\n ) : null}\n <Section title={'Who did what'}>\n {rows.length ? (\n <ScrollTable size=\"small\">\n <TableHead>\n <TableRow>\n {COLUMNS.map((column, index) => (\n <TableCell key={column} align={index ? 'right' : 'left'}>\n {column}\n </TableCell>\n ))}\n </TableRow>\n </TableHead>\n <TableBody>\n {rows.map((row) => (\n <TableRow key={row.uid || '$nobody'}>\n <TableCell>{nameOf(row)}</TableCell>\n {Aglyn.CRM_ACTIVITY_KINDS.map((kind) => (\n <TableCell key={kind} align=\"right\">\n {row.kinds[kind].toLocaleString()}\n </TableCell>\n ))}\n <TableCell align=\"right\">{row.activities.toLocaleString()}</TableCell>\n <TableCell align=\"right\">\n {tasksRead ? row.tasksDone.toLocaleString() : '—'}\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {settled ? 'Nothing logged or completed in this period.' : 'Reading…'}\n </Typography>\n )}\n {rows.some((row) => !row.uid) ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'No teammate — activities an automation logged, and tasks completed with nobody assigned.'}\n </Typography>\n ) : null}\n {/* What the table, and so the export, is grouped from when that is not everything. */}\n {caption ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`${caption}; the tiles are counted on the server.`}\n </Typography>\n ) : null}\n </Section>\n </Stack>\n </CardDisplay>\n )\n}\nActivityCard.displayName = 'ActivityCard'\n\nexport default ActivityCard\n"],"names":["Aglyn","CardDisplay","Section","ScrollTable","Alert","Stack","TableBody","TableCell","TableHead","TableRow","Typography","getCountFromServer","limit","orderBy","query","where","useMemo","useFirestore","useOrgMemberOptions","ReportExport","reportFilename","reportCacheKey","scopedCollection","visibleToClause","ReportStatTile","useAggregateRead","useWindowRead","ACTIVITY_CEILING","TASK_DONE_CEILING","COLUMNS","CRM_ACTIVITY_KINDS","map","kind","CRM_ACTIVITY_KIND_LABELS","ActivityCard","props","report","scope","tokens","range","period","routes","firestore","roster","activitiesBetween","from","to","CRM_COLLECTIONS","activities","tasksDoneBetween","tasks","countOf","target","then","snapshot","data","count","activityCounts","Promise","all","previousFrom","previousTo","current","previous","cacheKey","taskCounts","activityWindow","taskWindow","rows","activityLeaderboard","nameOf","row","uid","findOrgMember","options","label","name","teammates","filter","length","activitiesRead","status","tasksRead","settled","caption","truncated","toLocaleString","Boolean","join","activityFigures","value","taskFigures","header","help","pluginDocsHelp","anchor","excerpt","contentGutterX","contentGutterY","HeaderProps","action","filename","columns","kinds","tasksDone","disabled","spacing","direction","sx","flexWrap","deltaPct","deltaPercent","note","href","section","severity","title","size","column","index","align","variant","color","some","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,YAAYA,WAAW,eAAc;AACrC,SAASC,WA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|
contentGutterY: true,
|
|
246
246
|
HeaderProps: {
|
|
247
|
-
action: /*#__PURE__*/
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
247
|
+
action: /*#__PURE__*/ _jsxs(Stack, {
|
|
248
|
+
direction: "row",
|
|
249
|
+
spacing: 1,
|
|
250
|
+
children: [
|
|
251
|
+
/*#__PURE__*/ _jsx(ReportExport, {
|
|
252
|
+
filename: reportFilename('lead-funnel', period),
|
|
253
|
+
columns: COLUMNS,
|
|
254
|
+
rows: ()=>[
|
|
255
|
+
...Aglyn.CRM_LEAD_STATUSES.map((leadStatus)=>{
|
|
256
|
+
var _share;
|
|
257
|
+
return [
|
|
258
|
+
'Status',
|
|
259
|
+
Aglyn.CRM_LEAD_STATUS_LABELS[leadStatus],
|
|
260
|
+
funnel.byStatus[leadStatus],
|
|
261
|
+
(_share = share(funnel.byStatus[leadStatus], funnel.total)) != null ? _share : ''
|
|
262
|
+
];
|
|
263
|
+
}),
|
|
264
|
+
...funnel.reasons.map((reason)=>{
|
|
265
|
+
var _share;
|
|
266
|
+
return [
|
|
267
|
+
'Unqualified reason',
|
|
268
|
+
reason.label,
|
|
269
|
+
reason.count,
|
|
270
|
+
(_share = share(reason.count, funnel.byStatus.unqualified)) != null ? _share : ''
|
|
271
|
+
];
|
|
272
|
+
})
|
|
273
|
+
],
|
|
274
|
+
disabled: !read || !funnel.total
|
|
275
|
+
}),
|
|
276
|
+
/*#__PURE__*/ _jsx(Button, _extends({
|
|
277
|
+
component: AppLink
|
|
278
|
+
}, {
|
|
279
|
+
componentVariant: 'naked',
|
|
280
|
+
nativeButton: false
|
|
281
|
+
}, {
|
|
282
|
+
href: routes.section('leads'),
|
|
283
|
+
size: "small",
|
|
284
|
+
color: "primary",
|
|
285
|
+
children: 'Open leads'
|
|
286
|
+
}))
|
|
287
|
+
]
|
|
288
|
+
})
|
|
258
289
|
},
|
|
259
290
|
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
260
291
|
spacing: 2,
|
|
@@ -342,32 +373,11 @@ OrgLeadFunnelCard.displayName = 'OrgLeadFunnelCard';
|
|
|
342
373
|
}) : null
|
|
343
374
|
]
|
|
344
375
|
}),
|
|
345
|
-
/*#__PURE__*/ _jsx(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
var _share;
|
|
351
|
-
return [
|
|
352
|
-
'Status',
|
|
353
|
-
Aglyn.CRM_LEAD_STATUS_LABELS[leadStatus],
|
|
354
|
-
funnel.byStatus[leadStatus],
|
|
355
|
-
(_share = share(funnel.byStatus[leadStatus], funnel.total)) != null ? _share : ''
|
|
356
|
-
];
|
|
357
|
-
}),
|
|
358
|
-
...funnel.reasons.map((reason)=>{
|
|
359
|
-
var _share;
|
|
360
|
-
return [
|
|
361
|
-
'Unqualified reason',
|
|
362
|
-
reason.label,
|
|
363
|
-
reason.count,
|
|
364
|
-
(_share = share(reason.count, funnel.byStatus.unqualified)) != null ? _share : ''
|
|
365
|
-
];
|
|
366
|
-
})
|
|
367
|
-
],
|
|
368
|
-
disabled: !read || !funnel.total,
|
|
369
|
-
caption: caption
|
|
370
|
-
})
|
|
376
|
+
caption ? /*#__PURE__*/ _jsx(Typography, {
|
|
377
|
+
variant: "caption",
|
|
378
|
+
color: "text.secondary",
|
|
379
|
+
children: caption
|
|
380
|
+
}) : null
|
|
371
381
|
]
|
|
372
382
|
})
|
|
373
383
|
});
|