@aglyn/plugins-marketing 1.0.0-beta.179 โ 1.0.0-beta.180
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/package.json +15 -15
- package/src/lib/components/campaign-conversions-card.js +22 -4
- package/src/lib/components/campaign-conversions-card.js.map +1 -1
- package/src/lib/components/campaign-detail-card.js +3 -4
- package/src/lib/components/campaign-detail-card.js.map +1 -1
- package/src/lib/components/campaign-report-card.js +3 -3
- package/src/lib/components/campaign-report-card.js.map +1 -1
- package/src/lib/components/email-compose-card.d.ts +5 -2
- package/src/lib/components/email-compose-card.js +2 -3
- package/src/lib/components/email-compose-card.js.map +1 -1
- package/src/lib/components/email-detail.d.ts +5 -2
- package/src/lib/components/email-detail.js +4 -4
- package/src/lib/components/email-detail.js.map +1 -1
- package/src/lib/components/email-messages-widget.d.ts +17 -2
- package/src/lib/components/email-messages-widget.js +33 -2
- package/src/lib/components/email-messages-widget.js.map +1 -1
- package/src/lib/components/emails-list-card.d.ts +9 -6
- package/src/lib/components/emails-list-card.js +9 -9
- package/src/lib/components/emails-list-card.js.map +1 -1
- package/src/lib/components/host-experiments-card.component.d.ts +2 -0
- package/src/lib/components/host-experiments-card.component.js +20 -25
- package/src/lib/components/host-experiments-card.component.js.map +1 -1
- package/src/lib/components/host-marketing-summary-card.component.d.ts +15 -0
- package/src/lib/components/host-marketing-summary-card.component.js +59 -68
- package/src/lib/components/host-marketing-summary-card.component.js.map +1 -1
- package/src/lib/components/host-overlays-card.component.js +15 -37
- package/src/lib/components/host-overlays-card.component.js.map +1 -1
- package/src/lib/components/inbox-campaigns-widget.d.ts +23 -0
- package/src/lib/components/inbox-campaigns-widget.js +63 -0
- package/src/lib/components/inbox-campaigns-widget.js.map +1 -0
- package/src/lib/components/marketing-aggregates.d.ts +95 -0
- package/src/lib/components/marketing-aggregates.js +114 -0
- package/src/lib/components/marketing-aggregates.js.map +1 -0
- package/src/lib/components/marketing-console-page.js +32 -27
- package/src/lib/components/marketing-console-page.js.map +1 -1
- package/src/lib/components/marketing-console-sections.d.ts +24 -13
- package/src/lib/components/marketing-console-sections.js +37 -12
- package/src/lib/components/marketing-console-sections.js.map +1 -1
- package/src/lib/components/org-conversions-section.d.ts +32 -0
- package/src/lib/components/org-conversions-section.js +130 -0
- package/src/lib/components/org-conversions-section.js.map +1 -0
- package/src/lib/components/org-experiments-card.d.ts +32 -0
- package/src/lib/components/org-experiments-card.js +407 -0
- package/src/lib/components/org-experiments-card.js.map +1 -0
- package/src/lib/components/org-marketing-overview-card.d.ts +34 -0
- package/src/lib/components/org-marketing-overview-card.js +342 -0
- package/src/lib/components/org-marketing-overview-card.js.map +1 -0
- package/src/lib/components/org-overlays-card.d.ts +35 -0
- package/src/lib/components/org-overlays-card.js +345 -0
- package/src/lib/components/org-overlays-card.js.map +1 -0
- package/src/lib/components/org-site-picker-button.d.ts +26 -0
- package/src/lib/components/org-site-picker-button.js +104 -0
- package/src/lib/components/org-site-picker-button.js.map +1 -0
- package/src/lib/components/overlay-labels.d.ts +38 -0
- package/src/lib/components/overlay-labels.js +55 -0
- package/src/lib/components/overlay-labels.js.map +1 -0
- package/src/lib/components/use-emails-hub-path.d.ts +17 -8
- package/src/lib/components/use-emails-hub-path.js +29 -11
- package/src/lib/components/use-emails-hub-path.js.map +1 -1
- package/src/lib/components/use-one-shot-reads.d.ts +55 -0
- package/src/lib/components/use-one-shot-reads.js +168 -0
- package/src/lib/components/use-one-shot-reads.js.map +1 -0
- package/src/lib/model/experiments.d.ts +35 -0
- package/src/lib/model/experiments.js +34 -0
- package/src/lib/model/experiments.js.map +1 -1
- package/src/lib/model/overlays.d.ts +13 -2
- package/src/lib/model/overlays.js +18 -6
- package/src/lib/model/overlays.js.map +1 -1
- package/src/lib/plugin.js +13 -8
- package/src/lib/plugin.js.map +1 -1
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ 'use client';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { useMemo } from "react";
|
|
18
19
|
import EmailComposeCard from "./email-compose-card.js";
|
|
19
20
|
import EmailDetail from "./email-detail.js";
|
|
20
21
|
import EmailsListCard from "./emails-list-card.js";
|
|
22
|
+
import { MarketingOrgMountProvider } from "./marketing-org-mount.js";
|
|
23
|
+
import { orgMarketingHubPath } from "./use-emails-hub-path.js";
|
|
21
24
|
/**
|
|
22
25
|
* The Messages section of the Emails page, drawn by the plugin that sends.
|
|
23
26
|
*
|
|
@@ -29,9 +32,33 @@ import EmailsListCard from "./emails-list-card.js";
|
|
|
29
32
|
* Ternaries rather than a lookup: only the branch taken is CONSTRUCTED, and
|
|
30
33
|
* each card opens its listens on mount. Somebody reading a report does not
|
|
31
34
|
* pay for the composer's.
|
|
35
|
+
*
|
|
36
|
+
* ## On the organization's Emails page
|
|
37
|
+
*
|
|
38
|
+
* Handed no site, the same three cards read the org's sends unfiltered โ a
|
|
39
|
+
* Site column on the list, and every action naming the site a message is sent
|
|
40
|
+
* as. They learn the org and its sites from the Marketing org mount, which
|
|
41
|
+
* this widget publishes from the shell's own; its `basePath` is the
|
|
42
|
+
* organization's Marketing page, which is where a campaign's own page is.
|
|
32
43
|
*/ export function EmailMessagesWidget(props) {
|
|
33
|
-
const { hostId, basePath, detail } = props;
|
|
34
|
-
|
|
44
|
+
const { hostId, basePath, detail, orgMount } = props;
|
|
45
|
+
/*
|
|
46
|
+
* Memoized because every card below reads it through context, and a fresh
|
|
47
|
+
* object each render would re-render all of them for nothing.
|
|
48
|
+
*/ const mount = useMemo(()=>hostId == null && orgMount ? {
|
|
49
|
+
orgId: orgMount.orgId,
|
|
50
|
+
orgSlug: orgMount.orgSlug,
|
|
51
|
+
hosts: orgMount.hosts,
|
|
52
|
+
hostsReady: orgMount.hostsReady,
|
|
53
|
+
hostsPath: orgMount.hostsPath,
|
|
54
|
+
basePath: orgMarketingHubPath(orgMount.orgSlug)
|
|
55
|
+
} : null, [
|
|
56
|
+
hostId,
|
|
57
|
+
orgMount
|
|
58
|
+
]);
|
|
59
|
+
// No site and no org to stand in for it: nothing these cards can scope.
|
|
60
|
+
if (hostId == null && !mount) return null;
|
|
61
|
+
const body = detail[0] ? detail[1] === 'edit' ? /*#__PURE__*/ _jsx(EmailComposeCard, {
|
|
35
62
|
hostId: hostId,
|
|
36
63
|
emailId: detail[0],
|
|
37
64
|
basePath: basePath
|
|
@@ -43,6 +70,10 @@ import EmailsListCard from "./emails-list-card.js";
|
|
|
43
70
|
hostId: hostId,
|
|
44
71
|
basePath: basePath
|
|
45
72
|
});
|
|
73
|
+
return mount ? /*#__PURE__*/ _jsx(MarketingOrgMountProvider, {
|
|
74
|
+
value: mount,
|
|
75
|
+
children: body
|
|
76
|
+
}) : body;
|
|
46
77
|
}
|
|
47
78
|
export default EmailMessagesWidget;
|
|
48
79
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/email-messages-widget.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 EmailComposeCard from './email-compose-card'\nimport EmailDetail from './email-detail'\nimport EmailsListCard from './emails-list-card'\n\n/** What the Emails page's Messages zone hands a widget. */\nexport interface EmailMessagesWidgetProps {\n hostId: string\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/email-messages-widget.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 { ConsolePluginOrgMount } from '@aglyn/aglyn'\nimport { useMemo } from 'react'\nimport EmailComposeCard from './email-compose-card'\nimport EmailDetail from './email-detail'\nimport EmailsListCard from './emails-list-card'\nimport {\n MarketingOrgMountProvider,\n type MarketingOrgMount,\n} from './marketing-org-mount'\nimport { orgMarketingHubPath } from './use-emails-hub-path'\n\n/** What the Emails page's Messages zone hands a widget. */\nexport interface EmailMessagesWidgetProps {\n /** The site, or `null` on the organization's Emails page. */\n hostId: string | null\n /**\n * The Emails page's own base path, under the site or the organization.\n * Every link a message draws to another message page is beneath it.\n */\n basePath: string\n /** The segments under `messages`. */\n detail: readonly string[]\n /** The org and its sites, when the page is the organization's. */\n orgMount?: ConsolePluginOrgMount\n}\n\n/**\n * The Messages section of the Emails page, drawn by the plugin that sends.\n *\n * `/emails/messages` lists them, `โฆ/{emailId}` reports on one and\n * `โฆ/{emailId}/edit` writes it. A message is one send of a campaign โ every\n * action on all three pages is a call to this plugin's own routes โ so the\n * pages live here and the page that owns the URL hosts them in a zone.\n *\n * Ternaries rather than a lookup: only the branch taken is CONSTRUCTED, and\n * each card opens its listens on mount. Somebody reading a report does not\n * pay for the composer's.\n *\n * ## On the organization's Emails page\n *\n * Handed no site, the same three cards read the org's sends unfiltered โ a\n * Site column on the list, and every action naming the site a message is sent\n * as. They learn the org and its sites from the Marketing org mount, which\n * this widget publishes from the shell's own; its `basePath` is the\n * organization's Marketing page, which is where a campaign's own page is.\n */\nexport function EmailMessagesWidget(props: EmailMessagesWidgetProps) {\n const { hostId, basePath, detail, orgMount } = props\n /*\n * Memoized because every card below reads it through context, and a fresh\n * object each render would re-render all of them for nothing.\n */\n const mount = useMemo<MarketingOrgMount | null>(\n () =>\n hostId == null && orgMount\n ? {\n orgId: orgMount.orgId,\n orgSlug: orgMount.orgSlug,\n hosts: orgMount.hosts,\n hostsReady: orgMount.hostsReady,\n hostsPath: orgMount.hostsPath,\n basePath: orgMarketingHubPath(orgMount.orgSlug),\n }\n : null,\n [hostId, orgMount],\n )\n // No site and no org to stand in for it: nothing these cards can scope.\n if (hostId == null && !mount) return null\n\n const body = detail[0] ? (\n detail[1] === 'edit' ? (\n <EmailComposeCard hostId={hostId} emailId={detail[0]} basePath={basePath} />\n ) : (\n <EmailDetail hostId={hostId} emailId={detail[0]} basePath={basePath} />\n )\n ) : (\n <EmailsListCard hostId={hostId} basePath={basePath} />\n )\n return mount ? (\n <MarketingOrgMountProvider value={mount}>{body}</MarketingOrgMountProvider>\n ) : (\n body\n )\n}\n\nexport default EmailMessagesWidget\n"],"names":["useMemo","EmailComposeCard","EmailDetail","EmailsListCard","MarketingOrgMountProvider","orgMarketingHubPath","EmailMessagesWidget","props","hostId","basePath","detail","orgMount","mount","orgId","orgSlug","hosts","hostsReady","hostsPath","body","emailId","value"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SAASA,OAAO,QAAQ,QAAO;AAC/B,OAAOC,sBAAsB,0BAAsB;AACnD,OAAOC,iBAAiB,oBAAgB;AACxC,OAAOC,oBAAoB,wBAAoB;AAC/C,SACEC,yBAAyB,QAEpB,2BAAuB;AAC9B,SAASC,mBAAmB,QAAQ,2BAAuB;AAiB3D;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC,oBAAoBC,KAA+B;IACjE,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGJ;IAC/C;;;GAGC,GACD,MAAMK,QAAQZ,QACZ,IACEQ,UAAU,QAAQG,WACd;YACEE,OAAOF,SAASE,KAAK;YACrBC,SAASH,SAASG,OAAO;YACzBC,OAAOJ,SAASI,KAAK;YACrBC,YAAYL,SAASK,UAAU;YAC/BC,WAAWN,SAASM,SAAS;YAC7BR,UAAUJ,oBAAoBM,SAASG,OAAO;QAChD,IACA,MACN;QAACN;QAAQG;KAAS;IAEpB,wEAAwE;IACxE,IAAIH,UAAU,QAAQ,CAACI,OAAO,OAAO;IAErC,MAAMM,OAAOR,MAAM,CAAC,EAAE,GACpBA,MAAM,CAAC,EAAE,KAAK,uBACZ,KAACT;QAAiBO,QAAQA;QAAQW,SAAST,MAAM,CAAC,EAAE;QAAED,UAAUA;uBAEhE,KAACP;QAAYM,QAAQA;QAAQW,SAAST,MAAM,CAAC,EAAE;QAAED,UAAUA;uBAG7D,KAACN;QAAeK,QAAQA;QAAQC,UAAUA;;IAE5C,OAAOG,sBACL,KAACR;QAA0BgB,OAAOR;kBAAQM;SAE1CA;AAEJ;AAEA,eAAeZ,oBAAmB"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export interface EmailsListCardProps {
|
|
2
|
-
/** The site, or `null` on the
|
|
2
|
+
/** The site, or `null` on the organization's Emails page. */
|
|
3
3
|
hostId: string | null;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* The Emails page's own URL, under the site or the organization, so a row
|
|
6
|
+
* can link to the message's own page beneath it.
|
|
7
|
+
*/
|
|
5
8
|
basePath: string;
|
|
6
9
|
}
|
|
7
10
|
/**
|
|
@@ -33,10 +36,10 @@ export interface EmailsListCardProps {
|
|
|
33
36
|
* ## Under a site, and over the organization
|
|
34
37
|
*
|
|
35
38
|
* Sends are the org's. Under a site this lists the ones sent as that site;
|
|
36
|
-
* on the
|
|
37
|
-
* on a row names the site that row is sent as โ the only
|
|
38
|
-
* duplicate it, discard it or open its template. Creating one
|
|
39
|
-
* asks which site it is sent as.
|
|
39
|
+
* on the organization's Emails page it lists every site's, with a Site column,
|
|
40
|
+
* and every action on a row names the site that row is sent as โ the only
|
|
41
|
+
* site that can duplicate it, discard it or open its template. Creating one
|
|
42
|
+
* there first asks which site it is sent as.
|
|
40
43
|
*/
|
|
41
44
|
export declare function EmailsListCard(props: EmailsListCardProps): import("react").JSX.Element;
|
|
42
45
|
export declare namespace EmailsListCard {
|
|
@@ -98,17 +98,17 @@ const emailsDocsHelp = pluginDocsHelp('emailCampaigns', {
|
|
|
98
98
|
* ## Under a site, and over the organization
|
|
99
99
|
*
|
|
100
100
|
* Sends are the org's. Under a site this lists the ones sent as that site;
|
|
101
|
-
* on the
|
|
102
|
-
* on a row names the site that row is sent as โ the only
|
|
103
|
-
* duplicate it, discard it or open its template. Creating one
|
|
104
|
-
* asks which site it is sent as.
|
|
101
|
+
* on the organization's Emails page it lists every site's, with a Site column,
|
|
102
|
+
* and every action on a row names the site that row is sent as โ the only
|
|
103
|
+
* site that can duplicate it, discard it or open its template. Creating one
|
|
104
|
+
* there first asks which site it is sent as.
|
|
105
105
|
*/ export function EmailsListCard(props) {
|
|
106
106
|
const { hostId, basePath } = props;
|
|
107
107
|
const firestore = useFirestore();
|
|
108
108
|
const orgMount = useMarketingOrgMount();
|
|
109
109
|
const { orgId } = useMarketingOrgId(hostId);
|
|
110
110
|
// The sibling hub: a campaign's page belongs to the Marketing console โ
|
|
111
|
-
//
|
|
111
|
+
// over the org, the organization's own Marketing page the mount names.
|
|
112
112
|
const siteMarketingHub = useMarketingHubPath();
|
|
113
113
|
const marketingHub = orgMount ? orgMount.basePath : siteMarketingHub;
|
|
114
114
|
const router = useRouter();
|
|
@@ -139,10 +139,10 @@ const emailsDocsHelp = pluginDocsHelp('emailCampaigns', {
|
|
|
139
139
|
readEmails
|
|
140
140
|
]);
|
|
141
141
|
/*
|
|
142
|
-
* A message's own pages
|
|
143
|
-
*
|
|
144
|
-
* org
|
|
145
|
-
*/ const messagesPath =
|
|
142
|
+
* A message's own pages, beneath the Emails page this list is on โ the
|
|
143
|
+
* site's or the organization's. A template is a site's design, so over the
|
|
144
|
+
* org it opens on the site the row is sent as.
|
|
145
|
+
*/ const messagesPath = `${basePath}/messages`;
|
|
146
146
|
const emailHref = (email)=>`${messagesPath}/${email.$id}`;
|
|
147
147
|
const templatesHub = (email)=>orgMount ? orgSiteHubPath(orgMount, email == null ? void 0 : email.hostId, 'emails') : basePath;
|
|
148
148
|
/** The site a row is sent as, which every action on it must name. */ const rowHostId = useCallback((email)=>hostId != null ? hostId : (email == null ? void 0 : email.hostId) ? String(email.hostId) : null, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/emails-list-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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport {\n mdiBullhornOutline,\n mdiContentCopy,\n mdiDeleteOutline,\n mdiEyeOutline,\n mdiPaletteOutline,\n} from '@aglyn/shared-data-mdi'\nimport {\n AppLink,\n CardDisplay,\n MdiIcon,\n useConfirmationContext,\n} from '@aglyn/shared-ui-jsx'\nimport {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport type { RowActionsMenuItem } from '@aglyn/shared-ui-jsx/components/row-actions-menu.component'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { CreateArtifactDrawer } from '@aglyn/shared-ui-jsx-forms'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n ceilingedWindow,\n collectionCeiling,\n} from '@aglyn/tenant-feature-instance/hooks/host-collection-queries'\nimport {\n DUPLICATE_MENU_LABEL,\n useDuplicateResource,\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { Alert, Button, Chip, Stack, Typography } from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useRouter } from 'next/navigation'\nimport { useCallback, useMemo, useState } from 'react'\nimport {\n campaignPlacedOnHost,\n campaignSendDisplay,\n CAMPAIGN_SEND_CONTAINER_FIELD,\n type CampaignSendDisplayState,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-container'\nimport {\n emailListTimeMs,\n emailSendTimeMs,\n} from '@aglyn/shared-ui-email-campaigns/model/email-record'\nimport {\n useCampaignManageApi,\n useCampaignSendApi,\n} from './use-campaign-send-api'\nimport { useMarketingHubPath } from './use-marketing-hub-path'\nimport { campaignContainersQuery, campaignSendsQuery } from './campaign-queries'\nimport {\n orgSiteHubPath,\n orgSiteName,\n orgSiteOptions,\n useMarketingOrgId,\n useMarketingOrgMount,\n} from './marketing-org-mount'\n\n/** How many messages one read of this list covers. */\nconst EMAIL_CEILING = 30\n\n/** How many campaigns the create drawer offers to file a new email under. */\nconst CONTAINER_CEILING = 50\n\n/**\n * Why discard is refused, keyed by the state that refuses it.\n *\n * The KEYS are persisted status values written by the send path. Each line\n * says what to do instead, because \"you cannot\" on its own leaves a merchant\n * with an email they wanted rid of and no next step โ and for a scheduled one\n * the next step is a different act with a different consequence, so naming it\n * is the difference between withdrawing mail and losing the record of it.\n *\n * A state absent from here falls through to the generic refusal rather than\n * being flattened into one of these: a state this list cannot name is worth\n * seeing.\n */\nconst DISCARD_REFUSAL: Record<string, string> = {\n sent: 'This email has been sent. Its report and its unsubscribe links have to go on resolving.',\n scheduled: 'Cancel the send first โ cancelling takes it off the clock and keeps the email.',\n sending: 'This email is being sent right now.',\n canceled: 'A canceled email is kept as the record that it was withdrawn.',\n}\n\n/**\n * The chip color for one display state.\n *\n * `sending` is the one worth a color: an email part way through an audience\n * larger than one batch is doing something right now, and a merchant scanning\n * the list for what needs attention should find it without reading. The rest\n * are neutral, because a finished send and a draft are not events.\n */\nconst STATE_COLOR: Partial<\n Record<CampaignSendDisplayState, 'info' | 'warning'>\n> = {\n sending: 'info',\n stopped: 'warning',\n}\n\nconst emailsDocsHelp = pluginDocsHelp('emailCampaigns', {\n anchor: '#opens--clicks',\n excerpt:\n 'Every message this site has sent or has scheduled, each with its own ' +\n 'report: what was delivered, who opened it, and which links they followed.',\n})\n\nexport interface EmailsListCardProps {\n /** The site, or `null` on the org Marketing hub. */\n hostId: string | null\n /** The emails hub URL, so a row can link to the message's own page. */\n basePath: string\n}\n\n/**\n * EVERY MESSAGE, AS AGAINST EVERY CAMPAIGN.\n *\n * A campaign groups messages; this is the messages. The two are different\n * questions โ \"how did the spring promotion do\" and \"what went out on the\n * 14th, and to whom\" โ and they were previously the same list because a\n * campaign document WAS a single send.\n *\n * ## Ordered in the browser, deliberately\n *\n * No SEND date is on every message: a sent one carries `sentAt` and a\n * scheduled one carries `sendAtMs`, written by two different branches of the\n * send path, and a draft carries neither โ so `orderBy` on either would not\n * mis-sort this list, it would DROP half of it. `collectionCeiling` reads a\n * bounded window in document-id order and probes one past the ceiling, so the\n * rows are sorted here and the reader is told when there are more.\n *\n * Every writer stamps a `createdAtMs`, which is the field this list could be\n * ordered on in Firestore. Moving it there is a query change with the same\n * hazard as the two above โ `orderBy` drops a document missing the field โ\n * so it needs the corpus proven to carry one, not just the writers.\n *\n * The page is therefore a SLICE of a window this card already holds, not a\n * query: paging an id-ordered walk and re-sorting each page by date would run\n * in one order within a page and another across them.\n *\n * ## Under a site, and over the organization\n *\n * Sends are the org's. Under a site this lists the ones sent as that site;\n * on the org hub it lists every site's, with a Site column, and every action\n * on a row names the site that row is sent as โ the only site that can\n * duplicate it, discard it or open its template. Creating one there first\n * asks which site it is sent as.\n */\nexport function EmailsListCard(props: EmailsListCardProps) {\n const { hostId, basePath } = props\n const firestore = useFirestore()\n const orgMount = useMarketingOrgMount()\n const { orgId } = useMarketingOrgId(hostId)\n // The sibling hub: a campaign's page belongs to the Marketing console โ\n // which, on the org hub, is the page this list is already on.\n const siteMarketingHub = useMarketingHubPath()\n const marketingHub = orgMount ? orgMount.basePath : siteMarketingHub\n const router = useRouter()\n\n const { data: emailDocs } = useFirestoreCollection<any>(\n () => {\n const sends = campaignSendsQuery(firestore, orgId, hostId)\n return sends ? collectionCeiling(sends, EMAIL_CEILING) : null\n },\n [firestore, orgId, hostId],\n { idField: '$id' },\n )\n const { rows: readEmails, truncated } = ceilingedWindow<any>(\n emailDocs,\n EMAIL_CEILING,\n )\n /*\n * Newest first on the time each message SITS at โ its send time where it\n * has one, its creation where it does not.\n *\n * A draft has neither `sentAt` nor `sendAtMs`, so sorting on the send time\n * alone gave every draft the key 0 and filed the email a merchant is in the\n * middle of writing at the very bottom of the list, behind whatever paging\n * it has. `emailListTimeMs` is the same ordering with that one gap closed;\n * a SENT message still orders by when it went out, never by when it was\n * drafted.\n */\n const emails = useMemo(\n () =>\n [...readEmails].sort(\n (a: any, b: any) => emailListTimeMs(b) - emailListTimeMs(a),\n ),\n [readEmails],\n )\n\n /*\n * A message's own pages: the Emails console's under a site, the org hub's\n * Emails section over the org. A template is a site's design, so on the\n * org hub it opens on the site the row is sent as.\n */\n const messagesPath = orgMount\n ? `${orgMount.basePath}/emails`\n : `${basePath}/messages`\n const emailHref = (email: any) => `${messagesPath}/${email.$id}`\n const templatesHub = (email: any): string | null =>\n orgMount ? orgSiteHubPath(orgMount, email?.hostId, 'emails') : basePath\n /** The site a row is sent as, which every action on it must name. */\n const rowHostId = useCallback(\n (email: any): string | null =>\n hostId ?? (email?.hostId ? String(email.hostId) : null),\n [hostId],\n )\n const hostOfEmail = useMemo(\n () =>\n new Map<string, string | null>(\n readEmails.map((email: any) => [\n String(email.$id),\n email?.hostId ? String(email.hostId) : null,\n ]),\n ),\n [readEmails],\n )\n\n const { confirm } = useConfirmationContext()\n const { enqueueSnackbar } = useSnackbar()\n // Duplicate (AGL-2936): a new draft with the message and its design, and\n // nobody to send to until the person chooses โ through the manage door,\n // which is the plugin's own.\n const manageForCopy = useCampaignManageApi(hostId)\n const duplicate = useDuplicateResource({\n hostId: hostId ?? '',\n perform: async ({ sourceId, name, attemptKey }) => {\n const { response, payload } = await manageForCopy({\n action: 'duplicate',\n campaignId: sourceId,\n name,\n attemptKey,\n // The copy is made as the site the source is sent as.\n ...(hostId ? {} : { hostId: hostOfEmail.get(sourceId) ?? undefined }),\n })\n if (!response.ok) throw new Error(payload?.error ?? 'Duplicate failed')\n return {\n id: String(payload.emailId),\n versionId: null,\n name: String(payload.name ?? name),\n }\n },\n onDuplicated: (_kind, copy) =>\n enqueueSnackbar(`Duplicated as โ${copy.name}โ โ a draft with no audience yet`, {\n variant: 'success',\n }),\n })\n const manageApi = useCampaignManageApi(hostId)\n /** The email a discard is in flight for, so its row menu can say so. */\n const [discardingId, setDiscardingId] = useState('')\n\n /*==========================================\n * THROWING AWAY A DRAFT.\n *\n * The one removal this surface has, and it is deliberately the narrowest\n * one: an email that was never sent, whose record nobody outside the\n * console has ever seen. Everything else on this list is evidence โ a sent\n * message's report is what a merchant answers a complaint with, and its id\n * is inside the HMAC of every unsubscribe footer it delivered โ and a\n * scheduled one is withdrawn with Cancel, which keeps the record and takes\n * it off the clock.\n *\n * The menu already refuses anything but a draft, and so does the route.\n * That is not belt and braces: the state on screen is a snapshot that can\n * be seconds old, and the record can be claimed by `sendNow` in between.\n * The route's refusal is the one that decides, inside the transaction that\n * does the delete.\n *=========================================*/\n const handleDiscard = useCallback(\n async (email: any) => {\n if (discardingId) return\n const id = String(email?.$id ?? '')\n const name = String(email?.subject || email?.displayName || 'this draft')\n const agreed = await confirm({\n title: 'Discard this draft?',\n description:\n `${name} has not been sent to anybody, and discarding it removes ` +\n 'it for good โ the subject, the message and everything else ' +\n 'written on it. There is no undo.',\n confirmationText: 'Discard',\n })\n .then(() => true)\n .catch(() => false)\n if (!agreed) return\n setDiscardingId(id)\n try {\n const { response, payload } = await manageApi({\n action: 'discardEmail',\n campaignId: id,\n ...(hostId ? {} : { hostId: rowHostId(email) ?? undefined }),\n })\n if (!response.ok) {\n return void enqueueSnackbar(\n payload?.error ?? 'This draft could not be discarded',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n enqueueSnackbar('Draft discarded', {\n variant: 'success',\n persist: false,\n })\n } catch (error) {\n console.error(error)\n enqueueSnackbar('This draft could not be discarded', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setDiscardingId('')\n }\n },\n [confirm, discardingId, enqueueSnackbar, hostId, manageApi, rowHostId],\n )\n\n /**\n * What a message can be opened INTO, from the list.\n *\n * All three are places the message's own report already links to, moved one\n * screen earlier: the report itself, the campaign it belongs to, and the\n * template it was rendered from. A message need have neither of the last\n * two โ one sent before campaigns grouped anything names no container, and\n * one composed inline was built from no template โ so those entries are\n * shown DISABLED with the reason rather than hidden. A control that\n * disappears and a control that does not apply look identical, and only one\n * of them tells the reader which case they are in.\n *\n * DISCARD is the fourth entry and is offered on the same terms: a draft can\n * be thrown away, and nothing else can. It stays visible on a sent or\n * scheduled message carrying the reason it is refused, because that is the\n * honest answer to โhow do I get rid of thisโ โ and the route refuses it\n * too, so the menu is describing a rule rather than being one.\n */\n const rowActions = (email: any): RowActionsMenuItem[] => {\n const containerId = String(email?.[CAMPAIGN_SEND_CONTAINER_FIELD] ?? '')\n const templateScreenId = String(email?.templateScreenId ?? '')\n const state = String(email?.status ?? '')\n const templates = templatesHub(email)\n /** On the org hub, a send that names no site has nothing to act as. */\n const siteless = !rowHostId(email)\n const sitelessReason =\n 'This email does not record which site it was sent as. Manage it from ' +\n 'that siteโs own Emails page.'\n return [\n {\n key: 'details',\n label: 'Open report',\n icon: <MdiIcon path={mdiEyeOutline.path} size={0.8} />,\n href: emailHref(email),\n },\n {\n key: 'campaign',\n label: 'Open its campaign',\n icon: <MdiIcon path={mdiBullhornOutline.path} size={0.8} />,\n // The campaign's page belongs to the Marketing console, so this one\n // href is built from the sibling hub rather than this surface's own.\n href:\n containerId && marketingHub\n ? `${marketingHub}/campaigns/${containerId}`\n : undefined,\n disabled: !containerId || !marketingHub,\n disabledReason: containerId\n ? 'This siteโs console URL has not resolved yet'\n : 'Sent before campaigns grouped their emails, so it belongs to none',\n },\n {\n key: 'template',\n label: 'Open its template',\n icon: <MdiIcon path={mdiPaletteOutline.path} size={0.8} />,\n href:\n templateScreenId && templates\n ? `${templates}/templates/${templateScreenId}`\n : undefined,\n disabled: !templateScreenId || !templates,\n disabledReason: templateScreenId\n ? 'This siteโs console URL has not resolved yet'\n : 'This message was not built from a template',\n },\n {\n key: 'duplicate',\n label: DUPLICATE_MENU_LABEL,\n icon: <MdiIcon path={mdiContentCopy.path} size={0.8} />,\n disabled: siteless,\n disabledReason: sitelessReason,\n onClick: () =>\n duplicate.request('campaign', {\n id: String(email.$id),\n name: String(email?.displayName ?? email?.subject ?? ''),\n }),\n },\n {\n key: 'discard',\n label: 'Discard draft',\n icon: <MdiIcon path={mdiDeleteOutline.path} size={0.8} />,\n destructive: true,\n disabled: siteless || state !== 'draft' || Boolean(discardingId),\n disabledReason: siteless\n ? sitelessReason\n : (DISCARD_REFUSAL[state] ?? 'Only a draft can be discarded'),\n onClick: () => void handleDiscard(email),\n },\n ]\n }\n\n const [createOpen, setCreateOpen] = useState(false)\n const [creating, setCreating] = useState(false)\n const campaignSendApi = useCampaignSendApi(hostId)\n /*\n * The sites a new email can be sent as, on the org hub. One site answers\n * the question itself, so the field is asked only when there is a choice.\n */\n const orgSites = useMemo(\n () => (orgMount ? orgSiteOptions(orgMount) : []),\n [orgMount],\n )\n const askSite = !hostId && orgSites.length > 1\n\n /*\n * The campaigns a new email may be filed under, read only while the drawer\n * is OPEN.\n *\n * A null query opens no listener, so the list costs what it always did until\n * somebody asks to write something. Mounting this unconditionally would put\n * a second collection read on every reader who came to look at the table,\n * which is the cost the whole surface is routed to avoid.\n */\n const { data: campaignDocs } = useFirestoreCollection<any>(\n () => {\n const containers = createOpen\n ? campaignContainersQuery(firestore, orgId, hostId)\n : null\n return containers ? collectionCeiling(containers, CONTAINER_CEILING) : null\n },\n [firestore, orgId, hostId, createOpen],\n { idField: '$id' },\n )\n const campaignOptions = useMemo(\n () =>\n [...(campaignDocs ?? [])]\n .map((campaign: any) => ({\n value: String(campaign.$id),\n label: String(campaign.name || 'Untitled campaign'),\n }))\n .sort((a, b) => a.label.localeCompare(b.label)),\n [campaignDocs],\n )\n\n /*==========================================\n * CREATE, THEN GO TO THE EMAIL'S OWN PAGE.\n *\n * The drawer collects only what it takes to MINT the record โ the friendly\n * name, and the campaign it belongs to. Everything else about the email is\n * written on the email's own page, which is where a record is edited\n * throughout this console: a list page carries no form.\n *\n * The record is real from this moment: `/marketing/campaigns/{id}` resolves,\n * the row appears in the table below as a Draft, and the id it is created\n * under is the id it keeps when it is eventually sent. It costs nothing to\n * exist โ the route reserves no allowance and moves no meter for a draft,\n * and the scheduled processor only ever picks up `scheduled`.\n *=========================================*/\n const handleCreate = useCallback(\n async (values: Record<string, any>) => {\n if (creating) return\n const sendAs =\n hostId ?? (askSite ? String(values.hostId ?? '') : orgSites[0]?.value)\n if (!sendAs) {\n return void enqueueSnackbar('Choose the site this email is sent as', {\n variant: 'warning',\n allowDuplicate: true,\n })\n }\n /*\n * The organization hub offers every campaign, because the site is\n * chosen in the same form. An email can only join a campaign placed on\n * the site it is sent as โ the send route refuses anything else โ so\n * the mismatch is named here, where it can be fixed, rather than\n * arriving as the route's bare refusal. A site hub lists only the\n * campaigns placed on it, so there is nothing to check there.\n */\n const chosenCampaign =\n !hostId && values.emailCampaignId\n ? (campaignDocs ?? []).find(\n (campaign: any) =>\n String(campaign.$id) === String(values.emailCampaignId),\n )\n : null\n if (chosenCampaign && !campaignPlacedOnHost(chosenCampaign, sendAs)) {\n return void enqueueSnackbar(\n 'That campaign is not offered on the site this email is sent as. ' +\n 'Choose another, or add the site to the campaign first.',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n setCreating(true)\n try {\n const { response, payload } = await campaignSendApi({\n action: 'draft',\n ...(hostId ? {} : { hostId: sendAs }),\n displayName: String(values.displayName ?? '').trim(),\n ...(values.emailCampaignId\n ? { emailCampaignId: String(values.emailCampaignId) }\n : {}),\n })\n if (!response.ok || !payload?.campaignId) {\n return void enqueueSnackbar(\n payload?.error ?? 'This email could not be created',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n setCreateOpen(false)\n /*\n * Straight to where it is WRITTEN. The drawer collected the name and\n * the campaign; the record now exists and holds nothing else, so the\n * next thing to do with it is compose it โ and its own page is a\n * report of a send that has not happened.\n */\n router.push(`${messagesPath}/${payload.campaignId}/edit`)\n } catch (error) {\n console.error(error)\n enqueueSnackbar('This email could not be created', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setCreating(false)\n }\n },\n [\n askSite,\n campaignDocs,\n campaignSendApi,\n creating,\n enqueueSnackbar,\n hostId,\n messagesPath,\n orgSites,\n router,\n ],\n )\n\n /*\n * One row per message, in the order above; the whole window is in hand, so\n * the grid pages it. The subject is a link AND the row opens the report: a\n * click handler cannot be middle-clicked or opened in a new tab.\n */\n const columns: GridColDef[] = [\n {\n field: 'subject',\n headerName: 'Subject',\n flex: 1,\n minWidth: 220,\n valueGetter: (_value, row) => row.subject || 'Untitled email',\n renderCell: ({ row, value }) => (\n <AppLink\n href={emailHref(row)}\n // The row's own handler would fire too and push the same route\n // twice โ one history entry per back press.\n onClick={(event: { stopPropagation: () => void }) =>\n event.stopPropagation()\n }\n >\n {value}\n </AppLink>\n ),\n },\n // Which site each row is sent as, on the org hub only.\n ...(orgMount\n ? [\n {\n field: 'site',\n headerName: 'Site',\n width: 150,\n valueGetter: (_value: unknown, row: any) =>\n row?.hostId ? orgSiteName(orgMount, row.hostId) : 'โ',\n } satisfies GridColDef,\n ]\n : []),\n {\n /*\n * WHAT THIS EMAIL IS DOING, not what field it stores.\n *\n * An email delivering an audience larger than one batch is written back\n * as `scheduled` between runs, so a chip rendering the status said\n * \"Scheduled\" about a send that had already reached five hundred people.\n * The derivation reads the counters beside the status and says which of\n * the two it is.\n */\n field: 'state',\n headerName: 'State',\n width: 150,\n valueGetter: (_value, row) => campaignSendDisplay(row).label,\n renderCell: ({ row }) => {\n const display = campaignSendDisplay(row)\n return (\n <Chip\n size=\"small\"\n color={STATE_COLOR[display.state]}\n label={display.label}\n />\n )\n },\n },\n {\n field: 'when',\n headerName: 'When',\n width: 190,\n // Sorted on the time the list is ordered by, so a draft sorts by its\n // creation rather than as the oldest thing on the page.\n valueGetter: (_value, row) => emailListTimeMs(row),\n renderCell: ({ row }) => {\n const at = emailSendTimeMs(row)\n return at ? new Date(at).toLocaleString() : 'โ'\n },\n },\n ...(\n [\n ['recipients', 'Addressed'],\n ['opens', 'Opens'],\n ['clicks', 'Clicks'],\n ] as const\n ).map(\n ([stat, headerName]): GridColDef => ({\n field: stat,\n headerName,\n type: 'number',\n align: 'right',\n headerAlign: 'right',\n width: 110,\n valueGetter: (_value, row) => Number(row.stats?.[stat] ?? 0),\n valueFormatter: (value: number) => value.toLocaleString(),\n }),\n ),\n listActionsColumn(\n (row) => (\n <ListRowActions\n label={String(row.subject || 'Untitled email')}\n items={rowActions(row)}\n />\n ),\n { width: 72 },\n ),\n ]\n\n return (\n <CardDisplay\n header={'Messages'}\n help={emailsDocsHelp}\n HeaderProps={{\n action: (\n <Button\n size=\"small\"\n variant=\"contained\"\n onClick={() => setCreateOpen(true)}\n >\n {'New email'}\n </Button>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n {duplicate.dialog}\n <Stack spacing={2}>\n {emails.length === 0 ? (\n <Stack spacing={2} sx={{ alignItems: 'flex-start' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Nothing has been sent or scheduled yet. Write one here, or ' +\n 'from a campaign, and it appears in this list with its own ' +\n 'report.'}\n </Typography>\n <Button variant=\"contained\" onClick={() => setCreateOpen(true)}>\n {'New email'}\n </Button>\n </Stack>\n ) : (\n <ListTable\n aria-label=\"Messages\"\n rows={emails}\n columns={columns}\n rowHeight={TABLE_ROW_HEIGHT}\n onOpen={(_id, row) => router.push(emailHref(row))}\n />\n )}\n {truncated ? (\n <Alert severity=\"info\">\n {`Showing ${EMAIL_CEILING} messages. ${\n hostId ? 'This site' : 'This organization'\n } has sent or ` +\n 'scheduled more than that, and the rest are not in this list.'}\n </Alert>\n ) : null}\n </Stack>\n {/*\n AN EMAIL WRITTEN HERE BELONGS TO A CAMPAIGN, OR TO NO CAMPAIGN.\n\n The second is a real answer and not a gap in the model. A send with no\n container is what the product has always had โ every message that\n predates campaigns is one โ and `campaignListRows` adopts each of them\n as a campaign of one at read time, which is the \"Single send\" chip on\n the campaigns table. So composing from this list mints nothing, files\n nothing, and requires nobody to invent a campaign first: it leaves the\n container empty, and the send that results is presented the way every\n containerless send already is.\n\n Offering the campaigns anyway is what stops the opposite mistake โ a\n merchant who DOES have a spring campaign writing its third email into\n a single send that never joins the rollup.\n */}\n <CreateArtifactDrawer\n open={createOpen}\n onClose={() => setCreateOpen(false)}\n title=\"New email\"\n submitLabel={creating ? 'Creatingโฆ' : 'Start writing'}\n includeDescription={false}\n onSubmit={handleCreate}\n extraFields={[\n ...(askSite\n ? [\n {\n component: 'select',\n name: 'hostId',\n label: 'Send as',\n isRequired: true,\n initialValue: '',\n helperText:\n 'The site this email is sent from โ its sender, designs ' +\n 'and unsubscribe page',\n disableDefaultOption: true,\n options: orgSites,\n },\n ]\n : []),\n {\n component: 'select',\n name: 'emailCampaignId',\n label: 'Campaign',\n initialValue: '',\n helperText:\n 'Leave this as a single send unless the email belongs with ' +\n 'others',\n disableDefaultOption: true,\n options: [\n { value: '', label: 'Single send โ not part of a campaign' },\n ...campaignOptions,\n ],\n },\n ]}\n />\n </CardDisplay>\n )\n}\nEmailsListCard.displayName = 'EmailsListCard'\n\nexport default EmailsListCard\n"],"names":["pluginDocsHelp","mdiBullhornOutline","mdiContentCopy","mdiDeleteOutline","mdiEyeOutline","mdiPaletteOutline","AppLink","CardDisplay","MdiIcon","useConfirmationContext","ListRowActions","ListTable","listActionsColumn","TABLE_ROW_HEIGHT","CreateArtifactDrawer","useSnackbar","ceilingedWindow","collectionCeiling","DUPLICATE_MENU_LABEL","useDuplicateResource","useFirestore","useFirestoreCollection","Alert","Button","Chip","Stack","Typography","useRouter","useCallback","useMemo","useState","campaignPlacedOnHost","campaignSendDisplay","CAMPAIGN_SEND_CONTAINER_FIELD","emailListTimeMs","emailSendTimeMs","useCampaignManageApi","useCampaignSendApi","useMarketingHubPath","campaignContainersQuery","campaignSendsQuery","orgSiteHubPath","orgSiteName","orgSiteOptions","useMarketingOrgId","useMarketingOrgMount","EMAIL_CEILING","CONTAINER_CEILING","DISCARD_REFUSAL","sent","scheduled","sending","canceled","STATE_COLOR","stopped","emailsDocsHelp","anchor","excerpt","EmailsListCard","props","hostId","basePath","firestore","orgMount","orgId","siteMarketingHub","marketingHub","router","data","emailDocs","sends","idField","rows","readEmails","truncated","emails","sort","a","b","messagesPath","emailHref","email","$id","templatesHub","rowHostId","String","hostOfEmail","Map","map","confirm","enqueueSnackbar","manageForCopy","duplicate","perform","sourceId","name","attemptKey","payload","response","action","campaignId","get","undefined","ok","Error","error","id","emailId","versionId","onDuplicated","_kind","copy","variant","manageApi","discardingId","setDiscardingId","handleDiscard","subject","displayName","agreed","title","description","confirmationText","then","catch","allowDuplicate","persist","console","rowActions","containerId","templateScreenId","state","status","templates","siteless","sitelessReason","key","label","icon","path","size","href","disabled","disabledReason","onClick","request","destructive","Boolean","createOpen","setCreateOpen","creating","setCreating","campaignSendApi","orgSites","askSite","length","campaignDocs","containers","campaignOptions","campaign","value","localeCompare","handleCreate","values","sendAs","chosenCampaign","emailCampaignId","find","trim","push","columns","field","headerName","flex","minWidth","valueGetter","_value","row","renderCell","event","stopPropagation","width","display","color","at","Date","toLocaleString","stat","type","align","headerAlign","Number","stats","valueFormatter","items","header","help","HeaderProps","contentGutterX","contentGutterY","dialog","spacing","sx","alignItems","aria-label","rowHeight","onOpen","_id","severity","open","onClose","submitLabel","includeDescription","onSubmit","extraFields","component","isRequired","initialValue","helperText","disableDefaultOption","options"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SACEC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,QACZ,yBAAwB;AAC/B,SACEC,OAAO,EACPC,WAAW,EACXC,OAAO,EACPC,sBAAsB,QACjB,uBAAsB;AAC7B,SACEC,cAAc,EACdC,SAAS,EACTC,iBAAiB,QACZ,uDAAsD;AAE7D,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,eAAe,EACfC,iBAAiB,QACZ,+DAA8D;AACrE,SACEC,oBAAoB,EACpBC,oBAAoB,EACpBC,YAAY,EACZC,sBAAsB,QACjB,iCAAgC;AACvC,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AAEtE,SAASC,SAAS,QAAQ,kBAAiB;AAC3C,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACtD,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,6BAA6B,QAExB,4DAA2D;AAClE,SACEC,eAAe,EACfC,eAAe,QACV,sDAAqD;AAC5D,SACEC,oBAAoB,EACpBC,kBAAkB,QACb,6BAAyB;AAChC,SAASC,mBAAmB,QAAQ,8BAA0B;AAC9D,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ,wBAAoB;AAChF,SACEC,cAAc,EACdC,WAAW,EACXC,cAAc,EACdC,iBAAiB,EACjBC,oBAAoB,QACf,2BAAuB;AAE9B,oDAAoD,GACpD,MAAMC,gBAAgB;AAEtB,2EAA2E,GAC3E,MAAMC,oBAAoB;AAE1B;;;;;;;;;;;;CAYC,GACD,MAAMC,kBAA0C;IAC9CC,MA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AACjL;gCAAWsF,SAAQ;gCAAQuE,OAAM;0CAC/B,gEACC,+DACA;;0CAEJ,KAAChK;gCAAOyF,SAAQ;gCAAYgC,SAAS,IAAMK,cAAc;0CACtD;;;uCAIL,KAAC1I;wBACCiM,cAAW;wBACXpI,MAAMG;wBACN+F,SAASA;wBACTmC,WAAWhM;wBACXiM,QAAQ,CAACC,KAAK9B,MAAQ9G,OAAOsG,IAAI,CAACzF,UAAUiG;;oBAG/CvG,0BACC,KAACpD;wBAAM0L,UAAS;kCACb,CAAC,QAAQ,EAAElK,cAAc,WAAW,EACnCc,SAAS,cAAc,oBACxB,aAAa,CAAC,GACb;yBAEF;;;0BAkBN,KAAC9C;gBACCmM,MAAM7D;gBACN8D,SAAS,IAAM7D,cAAc;gBAC7B7B,OAAM;gBACN2F,aAAa7D,WAAW,cAAc;gBACtC8D,oBAAoB;gBACpBC,UAAUnD;gBACVoD,aAAa;uBACP5D,UACA;wBACE;4BACE6D,WAAW;4BACXxH,MAAM;4BACN0C,OAAO;4BACP+E,YAAY;4BACZC,cAAc;4BACdC,YACE,4DACA;4BACFC,sBAAsB;4BACtBC,SAASnE;wBACX;qBACD,GACD,EAAE;oBACN;wBACE8D,WAAW;wBACXxH,MAAM;wBACN0C,OAAO;wBACPgF,cAAc;wBACdC,YACE,+DACA;wBACFC,sBAAsB;wBACtBC,SAAS;4BACP;gCAAE5D,OAAO;gCAAIvB,OAAO;4BAAuC;+BACxDqB;yBACJ;oBACH;iBACD;;;;AAIT;AACApG,eAAe4D,WAAW,GAAG;AAE7B,eAAe5D,eAAc"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/emails-list-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 { pluginDocsHelp } from '@aglyn/aglyn'\nimport {\n mdiBullhornOutline,\n mdiContentCopy,\n mdiDeleteOutline,\n mdiEyeOutline,\n mdiPaletteOutline,\n} from '@aglyn/shared-data-mdi'\nimport {\n AppLink,\n CardDisplay,\n MdiIcon,\n useConfirmationContext,\n} from '@aglyn/shared-ui-jsx'\nimport {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport type { RowActionsMenuItem } from '@aglyn/shared-ui-jsx/components/row-actions-menu.component'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { CreateArtifactDrawer } from '@aglyn/shared-ui-jsx-forms'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n ceilingedWindow,\n collectionCeiling,\n} from '@aglyn/tenant-feature-instance/hooks/host-collection-queries'\nimport {\n DUPLICATE_MENU_LABEL,\n useDuplicateResource,\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { Alert, Button, Chip, Stack, Typography } from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useRouter } from 'next/navigation'\nimport { useCallback, useMemo, useState } from 'react'\nimport {\n campaignPlacedOnHost,\n campaignSendDisplay,\n CAMPAIGN_SEND_CONTAINER_FIELD,\n type CampaignSendDisplayState,\n} from '@aglyn/shared-ui-email-campaigns/model/campaign-container'\nimport {\n emailListTimeMs,\n emailSendTimeMs,\n} from '@aglyn/shared-ui-email-campaigns/model/email-record'\nimport {\n useCampaignManageApi,\n useCampaignSendApi,\n} from './use-campaign-send-api'\nimport { useMarketingHubPath } from './use-marketing-hub-path'\nimport { campaignContainersQuery, campaignSendsQuery } from './campaign-queries'\nimport {\n orgSiteHubPath,\n orgSiteName,\n orgSiteOptions,\n useMarketingOrgId,\n useMarketingOrgMount,\n} from './marketing-org-mount'\n\n/** How many messages one read of this list covers. */\nconst EMAIL_CEILING = 30\n\n/** How many campaigns the create drawer offers to file a new email under. */\nconst CONTAINER_CEILING = 50\n\n/**\n * Why discard is refused, keyed by the state that refuses it.\n *\n * The KEYS are persisted status values written by the send path. Each line\n * says what to do instead, because \"you cannot\" on its own leaves a merchant\n * with an email they wanted rid of and no next step โ and for a scheduled one\n * the next step is a different act with a different consequence, so naming it\n * is the difference between withdrawing mail and losing the record of it.\n *\n * A state absent from here falls through to the generic refusal rather than\n * being flattened into one of these: a state this list cannot name is worth\n * seeing.\n */\nconst DISCARD_REFUSAL: Record<string, string> = {\n sent: 'This email has been sent. Its report and its unsubscribe links have to go on resolving.',\n scheduled: 'Cancel the send first โ cancelling takes it off the clock and keeps the email.',\n sending: 'This email is being sent right now.',\n canceled: 'A canceled email is kept as the record that it was withdrawn.',\n}\n\n/**\n * The chip color for one display state.\n *\n * `sending` is the one worth a color: an email part way through an audience\n * larger than one batch is doing something right now, and a merchant scanning\n * the list for what needs attention should find it without reading. The rest\n * are neutral, because a finished send and a draft are not events.\n */\nconst STATE_COLOR: Partial<\n Record<CampaignSendDisplayState, 'info' | 'warning'>\n> = {\n sending: 'info',\n stopped: 'warning',\n}\n\nconst emailsDocsHelp = pluginDocsHelp('emailCampaigns', {\n anchor: '#opens--clicks',\n excerpt:\n 'Every message this site has sent or has scheduled, each with its own ' +\n 'report: what was delivered, who opened it, and which links they followed.',\n})\n\nexport interface EmailsListCardProps {\n /** The site, or `null` on the organization's Emails page. */\n hostId: string | null\n /**\n * The Emails page's own URL, under the site or the organization, so a row\n * can link to the message's own page beneath it.\n */\n basePath: string\n}\n\n/**\n * EVERY MESSAGE, AS AGAINST EVERY CAMPAIGN.\n *\n * A campaign groups messages; this is the messages. The two are different\n * questions โ \"how did the spring promotion do\" and \"what went out on the\n * 14th, and to whom\" โ and they were previously the same list because a\n * campaign document WAS a single send.\n *\n * ## Ordered in the browser, deliberately\n *\n * No SEND date is on every message: a sent one carries `sentAt` and a\n * scheduled one carries `sendAtMs`, written by two different branches of the\n * send path, and a draft carries neither โ so `orderBy` on either would not\n * mis-sort this list, it would DROP half of it. `collectionCeiling` reads a\n * bounded window in document-id order and probes one past the ceiling, so the\n * rows are sorted here and the reader is told when there are more.\n *\n * Every writer stamps a `createdAtMs`, which is the field this list could be\n * ordered on in Firestore. Moving it there is a query change with the same\n * hazard as the two above โ `orderBy` drops a document missing the field โ\n * so it needs the corpus proven to carry one, not just the writers.\n *\n * The page is therefore a SLICE of a window this card already holds, not a\n * query: paging an id-ordered walk and re-sorting each page by date would run\n * in one order within a page and another across them.\n *\n * ## Under a site, and over the organization\n *\n * Sends are the org's. Under a site this lists the ones sent as that site;\n * on the organization's Emails page it lists every site's, with a Site column,\n * and every action on a row names the site that row is sent as โ the only\n * site that can duplicate it, discard it or open its template. Creating one\n * there first asks which site it is sent as.\n */\nexport function EmailsListCard(props: EmailsListCardProps) {\n const { hostId, basePath } = props\n const firestore = useFirestore()\n const orgMount = useMarketingOrgMount()\n const { orgId } = useMarketingOrgId(hostId)\n // The sibling hub: a campaign's page belongs to the Marketing console โ\n // over the org, the organization's own Marketing page the mount names.\n const siteMarketingHub = useMarketingHubPath()\n const marketingHub = orgMount ? orgMount.basePath : siteMarketingHub\n const router = useRouter()\n\n const { data: emailDocs } = useFirestoreCollection<any>(\n () => {\n const sends = campaignSendsQuery(firestore, orgId, hostId)\n return sends ? collectionCeiling(sends, EMAIL_CEILING) : null\n },\n [firestore, orgId, hostId],\n { idField: '$id' },\n )\n const { rows: readEmails, truncated } = ceilingedWindow<any>(\n emailDocs,\n EMAIL_CEILING,\n )\n /*\n * Newest first on the time each message SITS at โ its send time where it\n * has one, its creation where it does not.\n *\n * A draft has neither `sentAt` nor `sendAtMs`, so sorting on the send time\n * alone gave every draft the key 0 and filed the email a merchant is in the\n * middle of writing at the very bottom of the list, behind whatever paging\n * it has. `emailListTimeMs` is the same ordering with that one gap closed;\n * a SENT message still orders by when it went out, never by when it was\n * drafted.\n */\n const emails = useMemo(\n () =>\n [...readEmails].sort(\n (a: any, b: any) => emailListTimeMs(b) - emailListTimeMs(a),\n ),\n [readEmails],\n )\n\n /*\n * A message's own pages, beneath the Emails page this list is on โ the\n * site's or the organization's. A template is a site's design, so over the\n * org it opens on the site the row is sent as.\n */\n const messagesPath = `${basePath}/messages`\n const emailHref = (email: any) => `${messagesPath}/${email.$id}`\n const templatesHub = (email: any): string | null =>\n orgMount ? orgSiteHubPath(orgMount, email?.hostId, 'emails') : basePath\n /** The site a row is sent as, which every action on it must name. */\n const rowHostId = useCallback(\n (email: any): string | null =>\n hostId ?? (email?.hostId ? String(email.hostId) : null),\n [hostId],\n )\n const hostOfEmail = useMemo(\n () =>\n new Map<string, string | null>(\n readEmails.map((email: any) => [\n String(email.$id),\n email?.hostId ? String(email.hostId) : null,\n ]),\n ),\n [readEmails],\n )\n\n const { confirm } = useConfirmationContext()\n const { enqueueSnackbar } = useSnackbar()\n // Duplicate (AGL-2936): a new draft with the message and its design, and\n // nobody to send to until the person chooses โ through the manage door,\n // which is the plugin's own.\n const manageForCopy = useCampaignManageApi(hostId)\n const duplicate = useDuplicateResource({\n hostId: hostId ?? '',\n perform: async ({ sourceId, name, attemptKey }) => {\n const { response, payload } = await manageForCopy({\n action: 'duplicate',\n campaignId: sourceId,\n name,\n attemptKey,\n // The copy is made as the site the source is sent as.\n ...(hostId ? {} : { hostId: hostOfEmail.get(sourceId) ?? undefined }),\n })\n if (!response.ok) throw new Error(payload?.error ?? 'Duplicate failed')\n return {\n id: String(payload.emailId),\n versionId: null,\n name: String(payload.name ?? name),\n }\n },\n onDuplicated: (_kind, copy) =>\n enqueueSnackbar(`Duplicated as โ${copy.name}โ โ a draft with no audience yet`, {\n variant: 'success',\n }),\n })\n const manageApi = useCampaignManageApi(hostId)\n /** The email a discard is in flight for, so its row menu can say so. */\n const [discardingId, setDiscardingId] = useState('')\n\n /*==========================================\n * THROWING AWAY A DRAFT.\n *\n * The one removal this surface has, and it is deliberately the narrowest\n * one: an email that was never sent, whose record nobody outside the\n * console has ever seen. Everything else on this list is evidence โ a sent\n * message's report is what a merchant answers a complaint with, and its id\n * is inside the HMAC of every unsubscribe footer it delivered โ and a\n * scheduled one is withdrawn with Cancel, which keeps the record and takes\n * it off the clock.\n *\n * The menu already refuses anything but a draft, and so does the route.\n * That is not belt and braces: the state on screen is a snapshot that can\n * be seconds old, and the record can be claimed by `sendNow` in between.\n * The route's refusal is the one that decides, inside the transaction that\n * does the delete.\n *=========================================*/\n const handleDiscard = useCallback(\n async (email: any) => {\n if (discardingId) return\n const id = String(email?.$id ?? '')\n const name = String(email?.subject || email?.displayName || 'this draft')\n const agreed = await confirm({\n title: 'Discard this draft?',\n description:\n `${name} has not been sent to anybody, and discarding it removes ` +\n 'it for good โ the subject, the message and everything else ' +\n 'written on it. There is no undo.',\n confirmationText: 'Discard',\n })\n .then(() => true)\n .catch(() => false)\n if (!agreed) return\n setDiscardingId(id)\n try {\n const { response, payload } = await manageApi({\n action: 'discardEmail',\n campaignId: id,\n ...(hostId ? {} : { hostId: rowHostId(email) ?? undefined }),\n })\n if (!response.ok) {\n return void enqueueSnackbar(\n payload?.error ?? 'This draft could not be discarded',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n enqueueSnackbar('Draft discarded', {\n variant: 'success',\n persist: false,\n })\n } catch (error) {\n console.error(error)\n enqueueSnackbar('This draft could not be discarded', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setDiscardingId('')\n }\n },\n [confirm, discardingId, enqueueSnackbar, hostId, manageApi, rowHostId],\n )\n\n /**\n * What a message can be opened INTO, from the list.\n *\n * All three are places the message's own report already links to, moved one\n * screen earlier: the report itself, the campaign it belongs to, and the\n * template it was rendered from. A message need have neither of the last\n * two โ one sent before campaigns grouped anything names no container, and\n * one composed inline was built from no template โ so those entries are\n * shown DISABLED with the reason rather than hidden. A control that\n * disappears and a control that does not apply look identical, and only one\n * of them tells the reader which case they are in.\n *\n * DISCARD is the fourth entry and is offered on the same terms: a draft can\n * be thrown away, and nothing else can. It stays visible on a sent or\n * scheduled message carrying the reason it is refused, because that is the\n * honest answer to โhow do I get rid of thisโ โ and the route refuses it\n * too, so the menu is describing a rule rather than being one.\n */\n const rowActions = (email: any): RowActionsMenuItem[] => {\n const containerId = String(email?.[CAMPAIGN_SEND_CONTAINER_FIELD] ?? '')\n const templateScreenId = String(email?.templateScreenId ?? '')\n const state = String(email?.status ?? '')\n const templates = templatesHub(email)\n /** On the org hub, a send that names no site has nothing to act as. */\n const siteless = !rowHostId(email)\n const sitelessReason =\n 'This email does not record which site it was sent as. Manage it from ' +\n 'that siteโs own Emails page.'\n return [\n {\n key: 'details',\n label: 'Open report',\n icon: <MdiIcon path={mdiEyeOutline.path} size={0.8} />,\n href: emailHref(email),\n },\n {\n key: 'campaign',\n label: 'Open its campaign',\n icon: <MdiIcon path={mdiBullhornOutline.path} size={0.8} />,\n // The campaign's page belongs to the Marketing console, so this one\n // href is built from the sibling hub rather than this surface's own.\n href:\n containerId && marketingHub\n ? `${marketingHub}/campaigns/${containerId}`\n : undefined,\n disabled: !containerId || !marketingHub,\n disabledReason: containerId\n ? 'This siteโs console URL has not resolved yet'\n : 'Sent before campaigns grouped their emails, so it belongs to none',\n },\n {\n key: 'template',\n label: 'Open its template',\n icon: <MdiIcon path={mdiPaletteOutline.path} size={0.8} />,\n href:\n templateScreenId && templates\n ? `${templates}/templates/${templateScreenId}`\n : undefined,\n disabled: !templateScreenId || !templates,\n disabledReason: templateScreenId\n ? 'This siteโs console URL has not resolved yet'\n : 'This message was not built from a template',\n },\n {\n key: 'duplicate',\n label: DUPLICATE_MENU_LABEL,\n icon: <MdiIcon path={mdiContentCopy.path} size={0.8} />,\n disabled: siteless,\n disabledReason: sitelessReason,\n onClick: () =>\n duplicate.request('campaign', {\n id: String(email.$id),\n name: String(email?.displayName ?? email?.subject ?? ''),\n }),\n },\n {\n key: 'discard',\n label: 'Discard draft',\n icon: <MdiIcon path={mdiDeleteOutline.path} size={0.8} />,\n destructive: true,\n disabled: siteless || state !== 'draft' || Boolean(discardingId),\n disabledReason: siteless\n ? sitelessReason\n : (DISCARD_REFUSAL[state] ?? 'Only a draft can be discarded'),\n onClick: () => void handleDiscard(email),\n },\n ]\n }\n\n const [createOpen, setCreateOpen] = useState(false)\n const [creating, setCreating] = useState(false)\n const campaignSendApi = useCampaignSendApi(hostId)\n /*\n * The sites a new email can be sent as, on the org hub. One site answers\n * the question itself, so the field is asked only when there is a choice.\n */\n const orgSites = useMemo(\n () => (orgMount ? orgSiteOptions(orgMount) : []),\n [orgMount],\n )\n const askSite = !hostId && orgSites.length > 1\n\n /*\n * The campaigns a new email may be filed under, read only while the drawer\n * is OPEN.\n *\n * A null query opens no listener, so the list costs what it always did until\n * somebody asks to write something. Mounting this unconditionally would put\n * a second collection read on every reader who came to look at the table,\n * which is the cost the whole surface is routed to avoid.\n */\n const { data: campaignDocs } = useFirestoreCollection<any>(\n () => {\n const containers = createOpen\n ? campaignContainersQuery(firestore, orgId, hostId)\n : null\n return containers ? collectionCeiling(containers, CONTAINER_CEILING) : null\n },\n [firestore, orgId, hostId, createOpen],\n { idField: '$id' },\n )\n const campaignOptions = useMemo(\n () =>\n [...(campaignDocs ?? [])]\n .map((campaign: any) => ({\n value: String(campaign.$id),\n label: String(campaign.name || 'Untitled campaign'),\n }))\n .sort((a, b) => a.label.localeCompare(b.label)),\n [campaignDocs],\n )\n\n /*==========================================\n * CREATE, THEN GO TO THE EMAIL'S OWN PAGE.\n *\n * The drawer collects only what it takes to MINT the record โ the friendly\n * name, and the campaign it belongs to. Everything else about the email is\n * written on the email's own page, which is where a record is edited\n * throughout this console: a list page carries no form.\n *\n * The record is real from this moment: `/marketing/campaigns/{id}` resolves,\n * the row appears in the table below as a Draft, and the id it is created\n * under is the id it keeps when it is eventually sent. It costs nothing to\n * exist โ the route reserves no allowance and moves no meter for a draft,\n * and the scheduled processor only ever picks up `scheduled`.\n *=========================================*/\n const handleCreate = useCallback(\n async (values: Record<string, any>) => {\n if (creating) return\n const sendAs =\n hostId ?? (askSite ? String(values.hostId ?? '') : orgSites[0]?.value)\n if (!sendAs) {\n return void enqueueSnackbar('Choose the site this email is sent as', {\n variant: 'warning',\n allowDuplicate: true,\n })\n }\n /*\n * The organization hub offers every campaign, because the site is\n * chosen in the same form. An email can only join a campaign placed on\n * the site it is sent as โ the send route refuses anything else โ so\n * the mismatch is named here, where it can be fixed, rather than\n * arriving as the route's bare refusal. A site hub lists only the\n * campaigns placed on it, so there is nothing to check there.\n */\n const chosenCampaign =\n !hostId && values.emailCampaignId\n ? (campaignDocs ?? []).find(\n (campaign: any) =>\n String(campaign.$id) === String(values.emailCampaignId),\n )\n : null\n if (chosenCampaign && !campaignPlacedOnHost(chosenCampaign, sendAs)) {\n return void enqueueSnackbar(\n 'That campaign is not offered on the site this email is sent as. ' +\n 'Choose another, or add the site to the campaign first.',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n setCreating(true)\n try {\n const { response, payload } = await campaignSendApi({\n action: 'draft',\n ...(hostId ? {} : { hostId: sendAs }),\n displayName: String(values.displayName ?? '').trim(),\n ...(values.emailCampaignId\n ? { emailCampaignId: String(values.emailCampaignId) }\n : {}),\n })\n if (!response.ok || !payload?.campaignId) {\n return void enqueueSnackbar(\n payload?.error ?? 'This email could not be created',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n setCreateOpen(false)\n /*\n * Straight to where it is WRITTEN. The drawer collected the name and\n * the campaign; the record now exists and holds nothing else, so the\n * next thing to do with it is compose it โ and its own page is a\n * report of a send that has not happened.\n */\n router.push(`${messagesPath}/${payload.campaignId}/edit`)\n } catch (error) {\n console.error(error)\n enqueueSnackbar('This email could not be created', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setCreating(false)\n }\n },\n [\n askSite,\n campaignDocs,\n campaignSendApi,\n creating,\n enqueueSnackbar,\n hostId,\n messagesPath,\n orgSites,\n router,\n ],\n )\n\n /*\n * One row per message, in the order above; the whole window is in hand, so\n * the grid pages it. The subject is a link AND the row opens the report: a\n * click handler cannot be middle-clicked or opened in a new tab.\n */\n const columns: GridColDef[] = [\n {\n field: 'subject',\n headerName: 'Subject',\n flex: 1,\n minWidth: 220,\n valueGetter: (_value, row) => row.subject || 'Untitled email',\n renderCell: ({ row, value }) => (\n <AppLink\n href={emailHref(row)}\n // The row's own handler would fire too and push the same route\n // twice โ one history entry per back press.\n onClick={(event: { stopPropagation: () => void }) =>\n event.stopPropagation()\n }\n >\n {value}\n </AppLink>\n ),\n },\n // Which site each row is sent as, on the org hub only.\n ...(orgMount\n ? [\n {\n field: 'site',\n headerName: 'Site',\n width: 150,\n valueGetter: (_value: unknown, row: any) =>\n row?.hostId ? orgSiteName(orgMount, row.hostId) : 'โ',\n } satisfies GridColDef,\n ]\n : []),\n {\n /*\n * WHAT THIS EMAIL IS DOING, not what field it stores.\n *\n * An email delivering an audience larger than one batch is written back\n * as `scheduled` between runs, so a chip rendering the status said\n * \"Scheduled\" about a send that had already reached five hundred people.\n * The derivation reads the counters beside the status and says which of\n * the two it is.\n */\n field: 'state',\n headerName: 'State',\n width: 150,\n valueGetter: (_value, row) => campaignSendDisplay(row).label,\n renderCell: ({ row }) => {\n const display = campaignSendDisplay(row)\n return (\n <Chip\n size=\"small\"\n color={STATE_COLOR[display.state]}\n label={display.label}\n />\n )\n },\n },\n {\n field: 'when',\n headerName: 'When',\n width: 190,\n // Sorted on the time the list is ordered by, so a draft sorts by its\n // creation rather than as the oldest thing on the page.\n valueGetter: (_value, row) => emailListTimeMs(row),\n renderCell: ({ row }) => {\n const at = emailSendTimeMs(row)\n return at ? new Date(at).toLocaleString() : 'โ'\n },\n },\n ...(\n [\n ['recipients', 'Addressed'],\n ['opens', 'Opens'],\n ['clicks', 'Clicks'],\n ] as const\n ).map(\n ([stat, headerName]): GridColDef => ({\n field: stat,\n headerName,\n type: 'number',\n align: 'right',\n headerAlign: 'right',\n width: 110,\n valueGetter: (_value, row) => Number(row.stats?.[stat] ?? 0),\n valueFormatter: (value: number) => value.toLocaleString(),\n }),\n ),\n listActionsColumn(\n (row) => (\n <ListRowActions\n label={String(row.subject || 'Untitled email')}\n items={rowActions(row)}\n />\n ),\n { width: 72 },\n ),\n ]\n\n return (\n <CardDisplay\n header={'Messages'}\n help={emailsDocsHelp}\n HeaderProps={{\n action: (\n <Button\n size=\"small\"\n variant=\"contained\"\n onClick={() => setCreateOpen(true)}\n >\n {'New email'}\n </Button>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n {duplicate.dialog}\n <Stack spacing={2}>\n {emails.length === 0 ? (\n <Stack spacing={2} sx={{ alignItems: 'flex-start' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Nothing has been sent or scheduled yet. Write one here, or ' +\n 'from a campaign, and it appears in this list with its own ' +\n 'report.'}\n </Typography>\n <Button variant=\"contained\" onClick={() => setCreateOpen(true)}>\n {'New email'}\n </Button>\n </Stack>\n ) : (\n <ListTable\n aria-label=\"Messages\"\n rows={emails}\n columns={columns}\n rowHeight={TABLE_ROW_HEIGHT}\n onOpen={(_id, row) => router.push(emailHref(row))}\n />\n )}\n {truncated ? (\n <Alert severity=\"info\">\n {`Showing ${EMAIL_CEILING} messages. ${\n hostId ? 'This site' : 'This organization'\n } has sent or ` +\n 'scheduled more than that, and the rest are not in this list.'}\n </Alert>\n ) : null}\n </Stack>\n {/*\n AN EMAIL WRITTEN HERE BELONGS TO A CAMPAIGN, OR TO NO CAMPAIGN.\n\n The second is a real answer and not a gap in the model. A send with no\n container is what the product has always had โ every message that\n predates campaigns is one โ and `campaignListRows` adopts each of them\n as a campaign of one at read time, which is the \"Single send\" chip on\n the campaigns table. So composing from this list mints nothing, files\n nothing, and requires nobody to invent a campaign first: it leaves the\n container empty, and the send that results is presented the way every\n containerless send already is.\n\n Offering the campaigns anyway is what stops the opposite mistake โ a\n merchant who DOES have a spring campaign writing its third email into\n a single send that never joins the rollup.\n */}\n <CreateArtifactDrawer\n open={createOpen}\n onClose={() => setCreateOpen(false)}\n title=\"New email\"\n submitLabel={creating ? 'Creatingโฆ' : 'Start writing'}\n includeDescription={false}\n onSubmit={handleCreate}\n extraFields={[\n ...(askSite\n ? [\n {\n component: 'select',\n name: 'hostId',\n label: 'Send as',\n isRequired: true,\n initialValue: '',\n helperText:\n 'The site this email is sent from โ its sender, designs ' +\n 'and unsubscribe page',\n disableDefaultOption: true,\n options: orgSites,\n },\n ]\n : []),\n {\n component: 'select',\n name: 'emailCampaignId',\n label: 'Campaign',\n initialValue: '',\n helperText:\n 'Leave this as a single send unless the email belongs with ' +\n 'others',\n disableDefaultOption: true,\n options: [\n { value: '', label: 'Single send โ not part of a campaign' },\n ...campaignOptions,\n ],\n },\n ]}\n />\n </CardDisplay>\n )\n}\nEmailsListCard.displayName = 'EmailsListCard'\n\nexport default EmailsListCard\n"],"names":["pluginDocsHelp","mdiBullhornOutline","mdiContentCopy","mdiDeleteOutline","mdiEyeOutline","mdiPaletteOutline","AppLink","CardDisplay","MdiIcon","useConfirmationContext","ListRowActions","ListTable","listActionsColumn","TABLE_ROW_HEIGHT","CreateArtifactDrawer","useSnackbar","ceilingedWindow","collectionCeiling","DUPLICATE_MENU_LABEL","useDuplicateResource","useFirestore","useFirestoreCollection","Alert","Button","Chip","Stack","Typography","useRouter","useCallback","useMemo","useState","campaignPlacedOnHost","campaignSendDisplay","CAMPAIGN_SEND_CONTAINER_FIELD","emailListTimeMs","emailSendTimeMs","useCampaignManageApi","useCampaignSendApi","useMarketingHubPath","campaignContainersQuery","campaignSendsQuery","orgSiteHubPath","orgSiteName","orgSiteOptions","useMarketingOrgId","useMarketingOrgMount","EMAIL_CEILING","CONTAINER_CEILING","DISCARD_REFUSAL","sent","scheduled","sending","canceled","STATE_COLOR","stopped","emailsDocsHelp","anchor","excerpt","EmailsListCard","props","hostId","basePath","firestore","orgMount","orgId","siteMarketingHub","marketingHub","router","data","emailDocs","sends","idField","rows","readEmails","truncated","emails","sort","a","b","messagesPath","emailHref","email","$id","templatesHub","rowHostId","String","hostOfEmail","Map","map","confirm","enqueueSnackbar","manageForCopy","duplicate","perform","sourceId","name","attemptKey","payload","response","action","campaignId","get","undefined","ok","Error","error","id","emailId","versionId","onDuplicated","_kind","copy","variant","manageApi","discardingId","setDiscardingId","handleDiscard","subject","displayName","agreed","title","description","confirmationText","then","catch","allowDuplicate","persist","console","rowActions","containerId","templateScreenId","state","status","templates","siteless","sitelessReason","key","label","icon","path","size","href","disabled","disabledReason","onClick","request","destructive","Boolean","createOpen","setCreateOpen","creating","setCreating","campaignSendApi","orgSites","askSite","length","campaignDocs","containers","campaignOptions","campaign","value","localeCompare","handleCreate","values","sendAs","chosenCampaign","emailCampaignId","find","trim","push","columns","field","headerName","flex","minWidth","valueGetter","_value","row","renderCell","event","stopPropagation","width","display","color","at","Date","toLocaleString","stat","type","align","headerAlign","Number","stats","valueFormatter","items","header","help","HeaderProps","contentGutterX","contentGutterY","dialog","spacing","sx","alignItems","aria-label","rowHeight","onOpen","_id","severity","open","onClose","submitLabel","includeDescription","onSubmit","extraFields","component","isRequired","initialValue","helperText","disableDefaultOption","options"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SACEC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,aAAa,EACbC,iBAAiB,QACZ,yBAAwB;AAC/B,SACEC,OAAO,EACPC,WAAW,EACXC,OAAO,EACPC,sBAAsB,QACjB,uBAAsB;AAC7B,SACEC,cAAc,EACdC,SAAS,EACTC,iBAAiB,QACZ,uDAAsD;AAE7D,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,oBAAoB,QAAQ,6BAA4B;AACjE,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,eAAe,EACfC,iBAAiB,QACZ,+DAA8D;AACrE,SACEC,oBAAoB,EACpBC,oBAAoB,E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,WAAW;4BACXxH,MAAM;4BACN0C,OAAO;4BACP+E,YAAY;4BACZC,cAAc;4BACdC,YACE,4DACA;4BACFC,sBAAsB;4BACtBC,SAASnE;wBACX;qBACD,GACD,EAAE;oBACN;wBACE8D,WAAW;wBACXxH,MAAM;wBACN0C,OAAO;wBACPgF,cAAc;wBACdC,YACE,+DACA;wBACFC,sBAAsB;wBACtBC,SAAS;4BACP;gCAAE5D,OAAO;gCAAIvB,OAAO;4BAAuC;+BACxDqB;yBACJ;oBACH;iBACD;;;;AAIT;AACApG,eAAe4D,WAAW,GAAG;AAE7B,eAAe5D,eAAc"}
|
|
@@ -4,6 +4,8 @@ export interface HostExperimentsCardProps {
|
|
|
4
4
|
/** Resolved entitlement source (AGL-395). */
|
|
5
5
|
org?: Partial<AglynOrgBilling>;
|
|
6
6
|
}
|
|
7
|
+
/** An experiment's status as a chip color, in every list of experiments. */
|
|
8
|
+
export declare const EXPERIMENT_STATUS_COLORS: Record<string, 'default' | 'success' | 'info' | 'warning'>;
|
|
7
9
|
/**
|
|
8
10
|
* Experiments manager (AGL-252): create screen/section/email A/B tests
|
|
9
11
|
* with weighted variants and a conversion goal; start/pause/finish them
|
|
@@ -18,7 +18,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
18
18
|
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
19
19
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
20
20
|
import { checkEntitlement, createResourceUid, HOST_EVENT_TYPES, pluginDocsHelp, SITE_EVENT_TYPES } from "@aglyn/aglyn";
|
|
21
|
-
import {
|
|
21
|
+
import { describeVariantComparison, experimentResultRows, validateExperiment } from "../model/index.js";
|
|
22
22
|
import { mdiChartBar, mdiDeleteOutline, mdiPause, mdiPencilOutline, mdiPlay } from "@aglyn/shared-data-mdi";
|
|
23
23
|
import { CardDisplay, MdiIcon, useConfirmationContext } from "@aglyn/shared-ui-jsx";
|
|
24
24
|
import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
|
|
@@ -32,7 +32,7 @@ import { collection, deleteDoc, doc, getDocs, limit, orderBy, query, setDoc } fr
|
|
|
32
32
|
import { useState } from "react";
|
|
33
33
|
import { useFirestore, useFirestoreCollection, useHostActivityLogger, usePagedCollection, writeGuardedBySeed } from "@aglyn/tenant-feature-instance";
|
|
34
34
|
import { ExperimentResultZone, ExperimentVariantsZone, marketingExperimentVariantDrafts } from "./experiment-zones.js";
|
|
35
|
-
const
|
|
35
|
+
/** An experiment's status as a chip color, in every list of experiments. */ export const EXPERIMENT_STATUS_COLORS = {
|
|
36
36
|
draft: 'default',
|
|
37
37
|
running: 'success',
|
|
38
38
|
paused: 'warning',
|
|
@@ -44,7 +44,7 @@ const STATUS_COLORS = {
|
|
|
44
44
|
* and read exposures/conversions per variant. Business tier
|
|
45
45
|
* (`ab-testing`).
|
|
46
46
|
*/ export function HostExperimentsCard(props) {
|
|
47
|
-
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _editor_$id, _editor_name, _editor_target, _ref6, _ref7,
|
|
47
|
+
var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _editor_$id, _editor_name, _editor_target, _ref6, _ref7, _results_experiment_$id, _results_experiment_$id1;
|
|
48
48
|
var _editor_goal, _editor_goal1, _results_experiment_name;
|
|
49
49
|
const { hostId } = props;
|
|
50
50
|
const firestore = useFirestore();
|
|
@@ -90,9 +90,17 @@ const STATUS_COLORS = {
|
|
|
90
90
|
* all. The rows are not re-sorted โ the server already ordered them, and
|
|
91
91
|
* re-sorting a page of a name-ordered walk is the lie the old code told.
|
|
92
92
|
*/ const experiments = experimentRows.filter((experiment)=>!experiment.deletedAt);
|
|
93
|
-
const
|
|
93
|
+
const [editor, setEditor] = useState(null);
|
|
94
|
+
/*
|
|
95
|
+
* The screens and their versions fill the EDITOR's pickers and nothing
|
|
96
|
+
* else on the card, so they are read while the editor is open and not
|
|
97
|
+
* before: a reader who came to see which tests are running pays for the
|
|
98
|
+
* experiments list alone, not for a hundred screens they never pick from.
|
|
99
|
+
*/ const editorOpen = editor !== null;
|
|
100
|
+
const { data: screenDocs } = useFirestoreCollection(()=>editorOpen ? query(collection(firestore, 'hosts', hostId, 'screens'), limit(100)) : null, [
|
|
94
101
|
firestore,
|
|
95
|
-
hostId
|
|
102
|
+
hostId,
|
|
103
|
+
editorOpen
|
|
96
104
|
], {
|
|
97
105
|
idField: '$id'
|
|
98
106
|
});
|
|
@@ -105,12 +113,8 @@ const STATUS_COLORS = {
|
|
|
105
113
|
name: (_ref = (_screen_displayName = screen.displayName) != null ? _screen_displayName : screen.name) != null ? _ref : screen.$id
|
|
106
114
|
};
|
|
107
115
|
}).sort((a, b)=>a.name.localeCompare(b.name));
|
|
108
|
-
const [editor, setEditor] = useState(null);
|
|
109
116
|
// Versions of the screen under test (AGL-253): variants pin one each.
|
|
110
|
-
const { data: versionDocs } = useFirestoreCollection(()=>
|
|
111
|
-
var _ref;
|
|
112
|
-
return query(collection(firestore, 'hosts', hostId, 'screens', (_ref = editor == null ? void 0 : editor.screenId) != null ? _ref : '-none-', 'versions'), limit(50));
|
|
113
|
-
}, [
|
|
117
|
+
const { data: versionDocs } = useFirestoreCollection(()=>(editor == null ? void 0 : editor.screenId) ? query(collection(firestore, 'hosts', hostId, 'screens', editor.screenId, 'versions'), limit(50)) : null, [
|
|
114
118
|
firestore,
|
|
115
119
|
hostId,
|
|
116
120
|
editor == null ? void 0 : editor.screenId
|
|
@@ -370,10 +374,10 @@ const STATUS_COLORS = {
|
|
|
370
374
|
headerName: 'Status',
|
|
371
375
|
width: 130,
|
|
372
376
|
renderCell: ({ row: experiment })=>{
|
|
373
|
-
var
|
|
377
|
+
var _EXPERIMENT_STATUS_COLORS_experiment_status;
|
|
374
378
|
return /*#__PURE__*/ _jsx(Chip, {
|
|
375
379
|
size: "small",
|
|
376
|
-
color: (
|
|
380
|
+
color: (_EXPERIMENT_STATUS_COLORS_experiment_status = EXPERIMENT_STATUS_COLORS[experiment.status]) != null ? _EXPERIMENT_STATUS_COLORS_experiment_status : 'default',
|
|
377
381
|
label: experiment.status
|
|
378
382
|
});
|
|
379
383
|
}
|
|
@@ -811,24 +815,15 @@ const STATUS_COLORS = {
|
|
|
811
815
|
})
|
|
812
816
|
}),
|
|
813
817
|
/*#__PURE__*/ _jsx(TableBody, {
|
|
814
|
-
children: (
|
|
815
|
-
var
|
|
816
|
-
const summary = summarizeVariantStats((_ref = results == null ? void 0 : results.stats[variant.id]) != null ? _ref : {});
|
|
817
|
-
// Lift + z-test confidence vs the first variant (AGL-265).
|
|
818
|
-
const control = results == null ? void 0 : results.experiment.variants[0];
|
|
819
|
-
const comparison = index > 0 && control ? compareVariants((_ref1 = results == null ? void 0 : results.stats[control.id]) != null ? _ref1 : {}, (_ref2 = results == null ? void 0 : results.stats[variant.id]) != null ? _ref2 : {}) : null;
|
|
820
|
-
const leader = summary.exposures > 0 && ((_ref3 = results == null ? void 0 : results.experiment.variants) != null ? _ref3 : []).every((other)=>{
|
|
821
|
-
var _ref;
|
|
822
|
-
const otherSummary = summarizeVariantStats((_ref = results == null ? void 0 : results.stats[other.id]) != null ? _ref : {});
|
|
823
|
-
return summary.rate >= otherSummary.rate;
|
|
824
|
-
});
|
|
818
|
+
children: (results ? experimentResultRows(results.experiment, results.stats) : []).map(({ variant, summary, comparison, leader, winner })=>{
|
|
819
|
+
var _variant_name;
|
|
825
820
|
return /*#__PURE__*/ _jsxs(TableRow, {
|
|
826
821
|
selected: leader,
|
|
827
822
|
children: [
|
|
828
823
|
/*#__PURE__*/ _jsxs(TableCell, {
|
|
829
824
|
children: [
|
|
830
825
|
(_variant_name = variant.name) != null ? _variant_name : variant.id.toUpperCase(),
|
|
831
|
-
|
|
826
|
+
winner ? ' ๐' : leader ? ' โฒ' : ''
|
|
832
827
|
]
|
|
833
828
|
}),
|
|
834
829
|
/*#__PURE__*/ _jsx(TableCell, {
|
|
@@ -841,7 +836,7 @@ const STATUS_COLORS = {
|
|
|
841
836
|
children: `${(summary.rate * 100).toFixed(1)}%`
|
|
842
837
|
}),
|
|
843
838
|
/*#__PURE__*/ _jsx(TableCell, {
|
|
844
|
-
children:
|
|
839
|
+
children: describeVariantComparison(comparison)
|
|
845
840
|
}),
|
|
846
841
|
/*#__PURE__*/ _jsx(TableCell, {
|
|
847
842
|
align: "right",
|