@aglyn/plugins-marketing 1.20.1 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-marketing",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,21 +25,21 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.20.1",
29
- "@aglyn/shared-data-enums": "1.20.1",
30
- "@aglyn/shared-data-mdi": "1.20.1",
31
- "@aglyn/shared-ui-email-campaigns": "1.20.1",
32
- "@aglyn/shared-ui-jsx": "1.20.1",
33
- "@aglyn/shared-ui-jsx-forms": "1.20.1",
34
- "@aglyn/shared-ui-next": "1.20.1",
35
- "@aglyn/shared-ui-snackstack": "1.20.1",
36
- "@aglyn/shared-util-email": "1.20.1",
37
- "@aglyn/shared-util-http": "1.20.1",
38
- "@aglyn/shared-util-timestamp": "1.20.1",
39
- "@aglyn/shared-util-tools": "1.20.1",
40
- "@aglyn/tenant-data-admin": "1.20.1",
41
- "@aglyn/tenant-feature-instance": "1.20.1",
42
- "@aglyn/tenant-runtime": "1.20.1",
28
+ "@aglyn/aglyn": "1.20.2",
29
+ "@aglyn/shared-data-enums": "1.20.2",
30
+ "@aglyn/shared-data-mdi": "1.20.2",
31
+ "@aglyn/shared-ui-email-campaigns": "1.20.2",
32
+ "@aglyn/shared-ui-jsx": "1.20.2",
33
+ "@aglyn/shared-ui-jsx-forms": "1.20.2",
34
+ "@aglyn/shared-ui-next": "1.20.2",
35
+ "@aglyn/shared-ui-snackstack": "1.20.2",
36
+ "@aglyn/shared-util-email": "1.20.2",
37
+ "@aglyn/shared-util-http": "1.20.2",
38
+ "@aglyn/shared-util-timestamp": "1.20.2",
39
+ "@aglyn/shared-util-tools": "1.20.2",
40
+ "@aglyn/tenant-data-admin": "1.20.2",
41
+ "@aglyn/tenant-feature-instance": "1.20.2",
42
+ "@aglyn/tenant-runtime": "1.20.2",
43
43
  "@swc/helpers": "0.5.23"
44
44
  },
45
45
  "peerDependencies": {
@@ -116,11 +116,26 @@ import { campaignListUnsubscribe, campaignSharingChoice, campaignSharingKey, cam
116
116
  setTopicId(String((_ref2 = campaign == null ? void 0 : campaign.topicId) != null ? _ref2 : ''));
117
117
  setListUnsubscribe(campaignListUnsubscribe(campaign));
118
118
  setUtmLabels(campaignUtmLabels(campaign == null ? void 0 : campaign.utmCampaigns).join(', '));
119
- setSharing(campaignSharingChoice(campaign));
120
119
  }, [
121
120
  open,
122
121
  campaign
123
122
  ]);
123
+ /*
124
+ * The sharing is seeded on its own: when the drawer opens and when the
125
+ * STORED sharing moves, not on every snapshot of the campaign (AGL-4047).
126
+ * A save writes the other fields before the route answers for the sharing,
127
+ * so a refused sharing change still brings a fresh campaign, and seeding
128
+ * from it put the choice back on the stored one beside the refusal; the
129
+ * choice being refused is the one to keep.
130
+ */ const storedSharingKey = campaignSharingKey(campaignSharingChoice(campaign));
131
+ useEffect(()=>{
132
+ if (!open) return;
133
+ setSharing(campaignSharingChoice(campaign));
134
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- `campaign` is read through its stored sharing
135
+ }, [
136
+ open,
137
+ storedSharingKey
138
+ ]);
124
139
  const startAtMs = dayInputMs(startAt);
125
140
  const endAtMs = dayInputMs(endAt);
126
141
  /*
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-edit-drawer.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 { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport { Container, MdiIcon, SrOnly } from '@aglyn/shared-ui-jsx'\nimport { NavigationDrawerComponent } from '@aglyn/shared-ui-jsx/components/navigation-drawer.component'\nimport { SiteSharingField } from '@aglyn/shared-ui-jsx/components/site-sharing-field.component'\nimport type { ScopeSharingChoice } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport {\n Alert,\n Button,\n Chip,\n FormControlLabel,\n IconButton,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useMemo, useState } from 'react'\nimport {\n campaignListUnsubscribe,\n campaignSharingChoice,\n campaignSharingKey,\n campaignSharingWrite,\n campaignUtmLabels,\n} from '../model/campaign-container'\n\n/** One option in the list or topic picker. */\nexport interface CampaignEditOption {\n value: string\n label: string\n}\n\n/** What the drawer collects — the container's whole editable surface. */\nexport interface CampaignEditValues {\n name: string\n startAtMs: number | null\n endAtMs: number | null\n listIds: string[]\n topicId: string\n /** Whether its emails carry the mail-client unsubscribe button (AGL-3307). */\n listUnsubscribe: boolean\n /**\n * The `utm_campaign` labels that mean this campaign (AGL-3461), as typed —\n * the save normalizes them with `campaignUtmLabels`.\n */\n utmCampaigns: string[]\n /**\n * Who it is shared with: all sites, the sites chosen, or all sites except\n * some (AGL-4047). Present only when the drawer was handed `sites`, which\n * only the org hub does (a site hub never moves a campaign's placement), and\n * only when the choice was changed. The manage route writes it, never the\n * client: a marker is the server's alone.\n */\n sharing?: ScopeSharingChoice\n}\n\nexport interface CampaignEditDrawerProps {\n open: boolean\n onClose: () => void\n /** The campaign as stored, for the fields to open on. */\n campaign: {\n name?: string\n startAtMs?: number | null\n endAtMs?: number | null\n listIds?: string[]\n topicId?: string\n visibleTo?: string[]\n scopeMode?: string | null\n scopeExcept?: string[] | null\n listUnsubscribe?: boolean\n utmCampaigns?: string[]\n } | null\n /** The org's email lists, which this campaign may be aimed at. */\n lists: CampaignEditOption[]\n /** The org's active topics — the stream its emails open on. */\n topics: CampaignEditOption[]\n /**\n * The org's sites, which turns on the placement field. Passed by the org\n * hub alone: moving a campaign between sites is an org-wide decision, and\n * the rules refuse it from anyone narrower.\n */\n sites?: CampaignEditOption[]\n /** False while `sites` is still being read. */\n sitesReady?: boolean\n busy?: boolean\n /** A refusal from the write, shown where the form still is. */\n error?: string | null\n onSubmit: (values: CampaignEditValues) => void\n}\n\n/**\n * The `YYYY-MM-DD` a `date` input wants, from epoch ms.\n *\n * UTC, matching the writer: the create drawer stores `Date.parse('2026-03-01')`,\n * which is UTC midnight, so reading it back in local time shows the previous\n * day to everyone west of Greenwich — a campaign that changed its own start\n * date by being opened.\n */\nfunction dayInputValue(ms: number | null | undefined): string {\n if (typeof ms !== 'number' || !Number.isFinite(ms)) return ''\n const at = new Date(ms)\n return Number.isNaN(at.getTime()) ? '' : at.toISOString().slice(0, 10)\n}\n\n/** Epoch ms for a `YYYY-MM-DD` a `date` input produced, or null for empty. */\nfunction dayInputMs(value: string): number | null {\n if (!value) return null\n const parsed = Date.parse(value)\n return Number.isFinite(parsed) ? parsed : null\n}\n\n/**\n * EDITING ONE CAMPAIGN, IN A DRAWER ON THE CAMPAIGN'S OWN PAGE.\n *\n * A drawer and not a form above the campaigns table: a record is edited on\n * its own surface in this console, and a list with a form on top of it is\n * the shape the whole surface was routed to stop.\n *\n * ## Everything a container holds is editable, and that is the whole point\n *\n * A campaign is a name, a window, the lists it is aimed at and the stream its\n * emails open on. None of it describes mail that has already been delivered —\n * that lives on the SENDS, which record their own subject, audience and topic\n * at send time and are never rewritten. So unlike an email, where only the\n * console-only display name stays editable after it goes out, a campaign has\n * no field that could come to disagree with somebody's inbox.\n *\n * Changing the topic is the one that reads as though it might. It does not:\n * the topic here is what the composer's picker OPENS ON, and each send\n * records the topic it actually went out under. Re-pointing a campaign\n * changes the default for the next email written in it and nothing about the\n * ones already sent.\n */\nexport function CampaignEditDrawer(props: CampaignEditDrawerProps) {\n const {\n open,\n onClose,\n campaign,\n lists,\n topics,\n sites,\n sitesReady = true,\n busy,\n error,\n onSubmit,\n } = props\n\n const [name, setName] = useState('')\n const [startAt, setStartAt] = useState('')\n const [endAt, setEndAt] = useState('')\n const [listIds, setListIds] = useState<string[]>([])\n const [topicId, setTopicId] = useState('')\n const [listUnsubscribe, setListUnsubscribe] = useState(true)\n /** The utm_campaign labels, as the field holds them: one per line or comma. */\n const [utmLabels, setUtmLabels] = useState('')\n /*\n * Who it is shared with, as edited here: null while it stores none (an\n * absent `visibleTo`, which no reader matches), so no choice shows as picked\n * until someone picks one. Only a CHANGED choice is submitted, so saving a\n * name cannot rewrite where a campaign is offered.\n */\n const [sharing, setSharing] = useState<ScopeSharingChoice | null>(null)\n const sharingSites = useMemo(\n () => (sites ?? []).map((site) => ({ id: site.value, name: site.label })),\n [sites],\n )\n const sharingChanged =\n Boolean(sites) &&\n sharing !== null &&\n campaignSharingKey(sharing) !== campaignSharingKey(campaignSharingChoice(campaign))\n /*\n * Why the choice cannot be saved, the same answer the manage route gives\n * from the sites it reads itself. The sites a choice leaves out stay known\n * here even where this list cannot name them, so they aren't taken for sites\n * that are gone. Nothing to say about leaving sites out until they are read.\n */\n const sharingProblem = useMemo(() => {\n if (!sharingChanged || !sharing) return null\n if (sharing.mode === 'allExcept' && !sitesReady) return null\n const leftOut = sharing.mode === 'allExcept' ? sharing.exceptHostIds : []\n return campaignSharingWrite(sharing, [\n ...sharingSites.map((site) => site.id),\n ...leftOut,\n ]).problem\n }, [sharing, sharingChanged, sharingSites, sitesReady])\n\n /*\n * Re-seeded whenever the drawer opens rather than held from the last time.\n * The campaign arrives asynchronously and can change under a closed drawer,\n * so seeding once at mount would open it on a stale name.\n */\n useEffect(() => {\n if (!open) return\n setName(String(campaign?.name ?? ''))\n setStartAt(dayInputValue(campaign?.startAtMs))\n setEndAt(dayInputValue(campaign?.endAtMs))\n setListIds((campaign?.listIds ?? []).map(String))\n setTopicId(String(campaign?.topicId ?? ''))\n setListUnsubscribe(campaignListUnsubscribe(campaign))\n setUtmLabels(campaignUtmLabels(campaign?.utmCampaigns).join(', '))\n setSharing(campaignSharingChoice(campaign))\n }, [open, campaign])\n\n const startAtMs = dayInputMs(startAt)\n const endAtMs = dayInputMs(endAt)\n /*\n * Refused in the form rather than stored and rendered, exactly as the\n * create drawer refuses it: a campaign that ends before it starts is a\n * window no state in `campaignWindowState` describes, so it would draw as\n * \"Ended\" from the day it was made.\n */\n const backwards = startAtMs !== null && endAtMs !== null && endAtMs < startAtMs\n const submittable =\n name.trim().length > 0 &&\n !backwards &&\n !busy &&\n !sharingProblem &&\n !(sharingChanged && sharing?.mode === 'allExcept' && !sitesReady)\n\n return (\n <NavigationDrawerComponent\n open={open}\n anchor=\"right\"\n variant=\"temporary\"\n onClose={onClose}\n AppBarProps={{ color: 'surface' }}\n appBarLeft={\n <>\n <IconButton\n color=\"inherit\"\n edge=\"start\"\n onClick={onClose}\n sx={{ mr: 2 }}\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n <SrOnly>close drawer</SrOnly>\n </IconButton>\n <Typography variant=\"h6\" component=\"div\">\n {'Edit campaign'}\n </Typography>\n </>\n }\n appBarRight={\n <Button variant=\"outlined\" color=\"inherit\" onClick={onClose}>\n {'Cancel'}\n </Button>\n }\n >\n <Container gutterY>\n <Stack spacing={2}>\n <TextField\n label=\"Name\"\n value={name}\n onChange={(event) => setName(event.target.value)}\n helperText=\"What you call this campaign in the console\"\n fullWidth\n />\n <TextField\n type=\"date\"\n label=\"Starts\"\n value={startAt}\n onChange={(event) => setStartAt(event.target.value)}\n helperText=\"When the campaign window opens\"\n slotProps={{ inputLabel: { shrink: true } }}\n fullWidth\n />\n <TextField\n type=\"date\"\n label=\"Ends\"\n value={endAt}\n onChange={(event) => setEndAt(event.target.value)}\n helperText=\"Leave empty for an open-ended campaign\"\n slotProps={{ inputLabel: { shrink: true } }}\n fullWidth\n />\n <TextField\n select\n label=\"Lists\"\n value={listIds}\n onChange={(event) =>\n setListIds(\n // A multiple select hands back an array; the typing on the\n // change event does not know that.\n (event.target.value as unknown as string[]).map(String),\n )\n }\n // A campaign with no list is legitimate: its emails can go to\n // leads, to site members, or to a segment.\n helperText=\"The lists this campaign is aimed at\"\n slotProps={{\n select: {\n multiple: true,\n renderValue: (selected: unknown) => (\n <Stack useFlexGap direction=\"row\" spacing={0.5} sx={{ flexWrap: 'wrap' }}>\n {(selected as string[]).map((id) => (\n <Chip\n key={id}\n size=\"small\"\n label={\n lists.find((list) => list.value === id)?.label ?? id\n }\n />\n ))}\n </Stack>\n ),\n },\n }}\n fullWidth\n >\n {lists.map((list) => (\n <MenuItem key={list.value} value={list.value}>\n {list.label}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n select\n label=\"Topic\"\n value={topicId}\n onChange={(event) => setTopicId(event.target.value)}\n helperText=\"The stream its emails open on — each one can change it\"\n fullWidth\n >\n {/*\n An explicit \"no default\" option rather than only the topics.\n A campaign is allowed to carry none — the send resolves the\n org's default when the composer names nothing — and a select\n with no way back to empty makes the first choice permanent.\n */}\n <MenuItem value=\"\">{'No default — each email chooses'}</MenuItem>\n {topics.map((topic) => (\n <MenuItem key={topic.value} value={topic.value}>\n {topic.label}\n </MenuItem>\n ))}\n </TextField>\n {/*\n THE LABELS THAT MEAN THIS CAMPAIGN (AGL-3461). An ad or a social\n post carries `utm_campaign=…`; a label named here credits this\n campaign the way a page filed under it does. Lowercased and\n deduped on save, which is how the lookup matches them.\n */}\n <TextField\n label=\"utm_campaign labels\"\n value={utmLabels}\n onChange={(event) => setUtmLabels(event.target.value)}\n helperText={\n 'Links carrying one of these utm_campaign values credit this ' +\n 'campaign. Separate them with commas. A label two campaigns ' +\n 'both list credits neither.'\n }\n placeholder=\"spring-launch, spring-retargeting\"\n fullWidth\n />\n {/*\n The mail-client unsubscribe button (AGL-3307), the setting a\n sequence carries too with the same label. ON for a campaign,\n because campaigns are bulk mail. Off warns, and the send path\n turns it back on for any email that would make the organization\n a bulk sender — the page says so when it does.\n */}\n <Stack spacing={0}>\n <FormControlLabel\n control={\n <Switch\n checked={listUnsubscribe}\n onChange={(event) => setListUnsubscribe(event.target.checked)}\n />\n }\n label=\"Add a mail-client unsubscribe button\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n Adds the List-Unsubscribe header, so the recipient’s mail app\n shows its own Unsubscribe button. It’s the easiest way out for\n them, and Gmail and Yahoo require it from bulk senders. The\n unsubscribe link in the footer is always there, either way.\n </Typography>\n </Stack>\n {!listUnsubscribe ? (\n <Alert severity=\"warning\">\n {'Without it, Gmail and Yahoo can reject or spam-folder these ' +\n 'emails once your organization sends in bulk, and more ' +\n 'people mark you as spam when their mail app offers no ' +\n 'unsubscribe button. It is turned back on automatically for ' +\n 'any email that would make your organization a bulk sender, ' +\n 'and the campaign page says so when it is.'}\n </Alert>\n ) : null}\n {sites ? (\n <Stack spacing={0.5}>\n <SiteSharingField\n label=\"Shared with\"\n value={sharing}\n onChange={setSharing}\n sites={sharingSites}\n sitesReady={sitesReady}\n problem={sharingProblem}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'The sites this campaign is offered on.'}\n </Typography>\n </Stack>\n ) : null}\n {backwards ? (\n <Alert severity=\"warning\">\n {'The end date is before the start date.'}\n </Alert>\n ) : null}\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n <Button\n variant=\"contained\"\n disabled={!submittable}\n onClick={() =>\n onSubmit({\n name: name.trim(),\n startAtMs,\n endAtMs,\n listIds,\n topicId,\n listUnsubscribe,\n utmCampaigns: campaignUtmLabels(utmLabels),\n ...(sharingChanged && sharing ? { sharing } : {}),\n })\n }\n >\n {busy ? 'Saving…' : 'Save campaign'}\n </Button>\n </Stack>\n </Container>\n </NavigationDrawerComponent>\n )\n}\nCampaignEditDrawer.displayName = 'CampaignEditDrawer'\n\nexport default CampaignEditDrawer\n"],"names":["ICON_VARIANT_CLOSE","Container","MdiIcon","SrOnly","NavigationDrawerComponent","SiteSharingField","Alert","Button","Chip","FormControlLabel","IconButton","MenuItem","Stack","Switch","TextField","Typography","useEffect","useMemo","useState","campaignListUnsubscribe","campaignSharingChoice","campaignSharingKey","campaignSharingWrite","campaignUtmLabels","dayInputValue","ms","Number","isFinite","at","Date","isNaN","getTime","toISOString","slice","dayInputMs","value","parsed","parse","CampaignEditDrawer","props","open","onClose","campaign","lists","topics","sites","sitesReady","busy","error","onSubmit","name","setName","startAt","setStartAt","endAt","setEndAt","listIds","setListIds","topicId","setTopicId","listUnsubscribe","setListUnsubscribe","utmLabels","setUtmLabels","sharing","setSharing","sharingSites","map","site","id","label","sharingChanged","Boolean","sharingProblem","mode","leftOut","exceptHostIds","problem","String","startAtMs","endAtMs","utmCampaigns","join","backwards","submittable","trim","length","anchor","variant","AppBarProps","color","appBarLeft","edge","onClick","sx","mr","path","component","appBarRight","gutterY","spacing","onChange","event","target","helperText","fullWidth","type","slotProps","inputLabel","shrink","select","multiple","renderValue","selected","useFlexGap","direction","flexWrap","size","find","list","topic","placeholder","control","checked","severity","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,kBAAkB,QAAQ,2BAA0B;AAC7D,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,uBAAsB;AACjE,SAASC,yBAAyB,QAAQ,8DAA6D;AACvG,SAASC,gBAAgB,QAAQ,+DAA8D;AAE/F,SACEC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACpD,SACEC,uBAAuB,EACvBC,qBAAqB,EACrBC,kBAAkB,EAClBC,oBAAoB,EACpBC,iBAAiB,QACZ,iCAA6B;AAkE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AAC7G;oCACC8G,SAAS/D;oCACTyC,UAAU,CAACC,QAAUzC,mBAAmByC,MAAMC,MAAM,CAACoB,OAAO;;gCAGhErD,OAAM;;0CAER,KAACvD;gCAAWyE,SAAQ;gCAAUE,OAAM;0CAAiB;;;;oBAOtD,CAAC9B,gCACA,KAACtD;wBAAMsH,UAAS;kCACb,iEACC,2DACA,2DACA,gEACA,gEACA;yBAEF;oBACH/E,sBACC,MAACjC;wBAAMwF,SAAS;;0CACd,KAAC/F;gCACCiE,OAAM;gCACNnC,OAAO6B;gCACPqC,UAAUpC;gCACVpB,OAAOqB;gCACPpB,YAAYA;gCACZ+B,SAASJ;;0CAEX,KAAC1D;gCAAWyE,SAAQ;gCAAUE,OAAM;0CACjC;;;yBAGH;oBACHP,0BACC,KAAC7E;wBAAMsH,UAAS;kCACb;yBAED;oBACH5E,sBAAQ,KAAC1C;wBAAMsH,UAAS;kCAAS5E;yBAAiB;kCACnD,KAACzC;wBACCiF,SAAQ;wBACRqC,UAAU,CAACzC;wBACXS,SAAS,IACP5C,SAAS;gCACPC,MAAMA,KAAKmC,IAAI;gCACfN;gCACAC;gCACAxB;gCACAE;gCACAE;gCACAqB,cAAc1D,kBAAkBuC;+BAC5BS,kBAAkBP,UAAU;gCAAEA;4BAAQ,IAAI,CAAC;kCAIlDjB,OAAO,YAAY;;;;;;AAMhC;AACAT,mBAAmBwF,WAAW,GAAG;AAEjC,eAAexF,mBAAkB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-edit-drawer.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 { ICON_VARIANT_CLOSE } from '@aglyn/shared-data-enums'\nimport { Container, MdiIcon, SrOnly } from '@aglyn/shared-ui-jsx'\nimport { NavigationDrawerComponent } from '@aglyn/shared-ui-jsx/components/navigation-drawer.component'\nimport { SiteSharingField } from '@aglyn/shared-ui-jsx/components/site-sharing-field.component'\nimport type { ScopeSharingChoice } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport {\n Alert,\n Button,\n Chip,\n FormControlLabel,\n IconButton,\n MenuItem,\n Stack,\n Switch,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useMemo, useState } from 'react'\nimport {\n campaignListUnsubscribe,\n campaignSharingChoice,\n campaignSharingKey,\n campaignSharingWrite,\n campaignUtmLabels,\n} from '../model/campaign-container'\n\n/** One option in the list or topic picker. */\nexport interface CampaignEditOption {\n value: string\n label: string\n}\n\n/** What the drawer collects — the container's whole editable surface. */\nexport interface CampaignEditValues {\n name: string\n startAtMs: number | null\n endAtMs: number | null\n listIds: string[]\n topicId: string\n /** Whether its emails carry the mail-client unsubscribe button (AGL-3307). */\n listUnsubscribe: boolean\n /**\n * The `utm_campaign` labels that mean this campaign (AGL-3461), as typed —\n * the save normalizes them with `campaignUtmLabels`.\n */\n utmCampaigns: string[]\n /**\n * Who it is shared with: all sites, the sites chosen, or all sites except\n * some (AGL-4047). Present only when the drawer was handed `sites`, which\n * only the org hub does (a site hub never moves a campaign's placement), and\n * only when the choice was changed. The manage route writes it, never the\n * client: a marker is the server's alone.\n */\n sharing?: ScopeSharingChoice\n}\n\nexport interface CampaignEditDrawerProps {\n open: boolean\n onClose: () => void\n /** The campaign as stored, for the fields to open on. */\n campaign: {\n name?: string\n startAtMs?: number | null\n endAtMs?: number | null\n listIds?: string[]\n topicId?: string\n visibleTo?: string[]\n scopeMode?: string | null\n scopeExcept?: string[] | null\n listUnsubscribe?: boolean\n utmCampaigns?: string[]\n } | null\n /** The org's email lists, which this campaign may be aimed at. */\n lists: CampaignEditOption[]\n /** The org's active topics — the stream its emails open on. */\n topics: CampaignEditOption[]\n /**\n * The org's sites, which turns on the placement field. Passed by the org\n * hub alone: moving a campaign between sites is an org-wide decision, and\n * the rules refuse it from anyone narrower.\n */\n sites?: CampaignEditOption[]\n /** False while `sites` is still being read. */\n sitesReady?: boolean\n busy?: boolean\n /** A refusal from the write, shown where the form still is. */\n error?: string | null\n onSubmit: (values: CampaignEditValues) => void\n}\n\n/**\n * The `YYYY-MM-DD` a `date` input wants, from epoch ms.\n *\n * UTC, matching the writer: the create drawer stores `Date.parse('2026-03-01')`,\n * which is UTC midnight, so reading it back in local time shows the previous\n * day to everyone west of Greenwich — a campaign that changed its own start\n * date by being opened.\n */\nfunction dayInputValue(ms: number | null | undefined): string {\n if (typeof ms !== 'number' || !Number.isFinite(ms)) return ''\n const at = new Date(ms)\n return Number.isNaN(at.getTime()) ? '' : at.toISOString().slice(0, 10)\n}\n\n/** Epoch ms for a `YYYY-MM-DD` a `date` input produced, or null for empty. */\nfunction dayInputMs(value: string): number | null {\n if (!value) return null\n const parsed = Date.parse(value)\n return Number.isFinite(parsed) ? parsed : null\n}\n\n/**\n * EDITING ONE CAMPAIGN, IN A DRAWER ON THE CAMPAIGN'S OWN PAGE.\n *\n * A drawer and not a form above the campaigns table: a record is edited on\n * its own surface in this console, and a list with a form on top of it is\n * the shape the whole surface was routed to stop.\n *\n * ## Everything a container holds is editable, and that is the whole point\n *\n * A campaign is a name, a window, the lists it is aimed at and the stream its\n * emails open on. None of it describes mail that has already been delivered —\n * that lives on the SENDS, which record their own subject, audience and topic\n * at send time and are never rewritten. So unlike an email, where only the\n * console-only display name stays editable after it goes out, a campaign has\n * no field that could come to disagree with somebody's inbox.\n *\n * Changing the topic is the one that reads as though it might. It does not:\n * the topic here is what the composer's picker OPENS ON, and each send\n * records the topic it actually went out under. Re-pointing a campaign\n * changes the default for the next email written in it and nothing about the\n * ones already sent.\n */\nexport function CampaignEditDrawer(props: CampaignEditDrawerProps) {\n const {\n open,\n onClose,\n campaign,\n lists,\n topics,\n sites,\n sitesReady = true,\n busy,\n error,\n onSubmit,\n } = props\n\n const [name, setName] = useState('')\n const [startAt, setStartAt] = useState('')\n const [endAt, setEndAt] = useState('')\n const [listIds, setListIds] = useState<string[]>([])\n const [topicId, setTopicId] = useState('')\n const [listUnsubscribe, setListUnsubscribe] = useState(true)\n /** The utm_campaign labels, as the field holds them: one per line or comma. */\n const [utmLabels, setUtmLabels] = useState('')\n /*\n * Who it is shared with, as edited here: null while it stores none (an\n * absent `visibleTo`, which no reader matches), so no choice shows as picked\n * until someone picks one. Only a CHANGED choice is submitted, so saving a\n * name cannot rewrite where a campaign is offered.\n */\n const [sharing, setSharing] = useState<ScopeSharingChoice | null>(null)\n const sharingSites = useMemo(\n () => (sites ?? []).map((site) => ({ id: site.value, name: site.label })),\n [sites],\n )\n const sharingChanged =\n Boolean(sites) &&\n sharing !== null &&\n campaignSharingKey(sharing) !== campaignSharingKey(campaignSharingChoice(campaign))\n /*\n * Why the choice cannot be saved, the same answer the manage route gives\n * from the sites it reads itself. The sites a choice leaves out stay known\n * here even where this list cannot name them, so they aren't taken for sites\n * that are gone. Nothing to say about leaving sites out until they are read.\n */\n const sharingProblem = useMemo(() => {\n if (!sharingChanged || !sharing) return null\n if (sharing.mode === 'allExcept' && !sitesReady) return null\n const leftOut = sharing.mode === 'allExcept' ? sharing.exceptHostIds : []\n return campaignSharingWrite(sharing, [\n ...sharingSites.map((site) => site.id),\n ...leftOut,\n ]).problem\n }, [sharing, sharingChanged, sharingSites, sitesReady])\n\n /*\n * Re-seeded whenever the drawer opens rather than held from the last time.\n * The campaign arrives asynchronously and can change under a closed drawer,\n * so seeding once at mount would open it on a stale name.\n */\n useEffect(() => {\n if (!open) return\n setName(String(campaign?.name ?? ''))\n setStartAt(dayInputValue(campaign?.startAtMs))\n setEndAt(dayInputValue(campaign?.endAtMs))\n setListIds((campaign?.listIds ?? []).map(String))\n setTopicId(String(campaign?.topicId ?? ''))\n setListUnsubscribe(campaignListUnsubscribe(campaign))\n setUtmLabels(campaignUtmLabels(campaign?.utmCampaigns).join(', '))\n }, [open, campaign])\n /*\n * The sharing is seeded on its own: when the drawer opens and when the\n * STORED sharing moves, not on every snapshot of the campaign (AGL-4047).\n * A save writes the other fields before the route answers for the sharing,\n * so a refused sharing change still brings a fresh campaign, and seeding\n * from it put the choice back on the stored one beside the refusal; the\n * choice being refused is the one to keep.\n */\n const storedSharingKey = campaignSharingKey(campaignSharingChoice(campaign))\n useEffect(() => {\n if (!open) return\n setSharing(campaignSharingChoice(campaign))\n // eslint-disable-next-line react-hooks/exhaustive-deps -- `campaign` is read through its stored sharing\n }, [open, storedSharingKey])\n\n const startAtMs = dayInputMs(startAt)\n const endAtMs = dayInputMs(endAt)\n /*\n * Refused in the form rather than stored and rendered, exactly as the\n * create drawer refuses it: a campaign that ends before it starts is a\n * window no state in `campaignWindowState` describes, so it would draw as\n * \"Ended\" from the day it was made.\n */\n const backwards = startAtMs !== null && endAtMs !== null && endAtMs < startAtMs\n const submittable =\n name.trim().length > 0 &&\n !backwards &&\n !busy &&\n !sharingProblem &&\n !(sharingChanged && sharing?.mode === 'allExcept' && !sitesReady)\n\n return (\n <NavigationDrawerComponent\n open={open}\n anchor=\"right\"\n variant=\"temporary\"\n onClose={onClose}\n AppBarProps={{ color: 'surface' }}\n appBarLeft={\n <>\n <IconButton\n color=\"inherit\"\n edge=\"start\"\n onClick={onClose}\n sx={{ mr: 2 }}\n >\n <MdiIcon path={ICON_VARIANT_CLOSE.path} />\n <SrOnly>close drawer</SrOnly>\n </IconButton>\n <Typography variant=\"h6\" component=\"div\">\n {'Edit campaign'}\n </Typography>\n </>\n }\n appBarRight={\n <Button variant=\"outlined\" color=\"inherit\" onClick={onClose}>\n {'Cancel'}\n </Button>\n }\n >\n <Container gutterY>\n <Stack spacing={2}>\n <TextField\n label=\"Name\"\n value={name}\n onChange={(event) => setName(event.target.value)}\n helperText=\"What you call this campaign in the console\"\n fullWidth\n />\n <TextField\n type=\"date\"\n label=\"Starts\"\n value={startAt}\n onChange={(event) => setStartAt(event.target.value)}\n helperText=\"When the campaign window opens\"\n slotProps={{ inputLabel: { shrink: true } }}\n fullWidth\n />\n <TextField\n type=\"date\"\n label=\"Ends\"\n value={endAt}\n onChange={(event) => setEndAt(event.target.value)}\n helperText=\"Leave empty for an open-ended campaign\"\n slotProps={{ inputLabel: { shrink: true } }}\n fullWidth\n />\n <TextField\n select\n label=\"Lists\"\n value={listIds}\n onChange={(event) =>\n setListIds(\n // A multiple select hands back an array; the typing on the\n // change event does not know that.\n (event.target.value as unknown as string[]).map(String),\n )\n }\n // A campaign with no list is legitimate: its emails can go to\n // leads, to site members, or to a segment.\n helperText=\"The lists this campaign is aimed at\"\n slotProps={{\n select: {\n multiple: true,\n renderValue: (selected: unknown) => (\n <Stack useFlexGap direction=\"row\" spacing={0.5} sx={{ flexWrap: 'wrap' }}>\n {(selected as string[]).map((id) => (\n <Chip\n key={id}\n size=\"small\"\n label={\n lists.find((list) => list.value === id)?.label ?? id\n }\n />\n ))}\n </Stack>\n ),\n },\n }}\n fullWidth\n >\n {lists.map((list) => (\n <MenuItem key={list.value} value={list.value}>\n {list.label}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n select\n label=\"Topic\"\n value={topicId}\n onChange={(event) => setTopicId(event.target.value)}\n helperText=\"The stream its emails open on — each one can change it\"\n fullWidth\n >\n {/*\n An explicit \"no default\" option rather than only the topics.\n A campaign is allowed to carry none — the send resolves the\n org's default when the composer names nothing — and a select\n with no way back to empty makes the first choice permanent.\n */}\n <MenuItem value=\"\">{'No default — each email chooses'}</MenuItem>\n {topics.map((topic) => (\n <MenuItem key={topic.value} value={topic.value}>\n {topic.label}\n </MenuItem>\n ))}\n </TextField>\n {/*\n THE LABELS THAT MEAN THIS CAMPAIGN (AGL-3461). An ad or a social\n post carries `utm_campaign=…`; a label named here credits this\n campaign the way a page filed under it does. Lowercased and\n deduped on save, which is how the lookup matches them.\n */}\n <TextField\n label=\"utm_campaign labels\"\n value={utmLabels}\n onChange={(event) => setUtmLabels(event.target.value)}\n helperText={\n 'Links carrying one of these utm_campaign values credit this ' +\n 'campaign. Separate them with commas. A label two campaigns ' +\n 'both list credits neither.'\n }\n placeholder=\"spring-launch, spring-retargeting\"\n fullWidth\n />\n {/*\n The mail-client unsubscribe button (AGL-3307), the setting a\n sequence carries too with the same label. ON for a campaign,\n because campaigns are bulk mail. Off warns, and the send path\n turns it back on for any email that would make the organization\n a bulk sender — the page says so when it does.\n */}\n <Stack spacing={0}>\n <FormControlLabel\n control={\n <Switch\n checked={listUnsubscribe}\n onChange={(event) => setListUnsubscribe(event.target.checked)}\n />\n }\n label=\"Add a mail-client unsubscribe button\"\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n Adds the List-Unsubscribe header, so the recipient’s mail app\n shows its own Unsubscribe button. It’s the easiest way out for\n them, and Gmail and Yahoo require it from bulk senders. The\n unsubscribe link in the footer is always there, either way.\n </Typography>\n </Stack>\n {!listUnsubscribe ? (\n <Alert severity=\"warning\">\n {'Without it, Gmail and Yahoo can reject or spam-folder these ' +\n 'emails once your organization sends in bulk, and more ' +\n 'people mark you as spam when their mail app offers no ' +\n 'unsubscribe button. It is turned back on automatically for ' +\n 'any email that would make your organization a bulk sender, ' +\n 'and the campaign page says so when it is.'}\n </Alert>\n ) : null}\n {sites ? (\n <Stack spacing={0.5}>\n <SiteSharingField\n label=\"Shared with\"\n value={sharing}\n onChange={setSharing}\n sites={sharingSites}\n sitesReady={sitesReady}\n problem={sharingProblem}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'The sites this campaign is offered on.'}\n </Typography>\n </Stack>\n ) : null}\n {backwards ? (\n <Alert severity=\"warning\">\n {'The end date is before the start date.'}\n </Alert>\n ) : null}\n {error ? <Alert severity=\"error\">{error}</Alert> : null}\n <Button\n variant=\"contained\"\n disabled={!submittable}\n onClick={() =>\n onSubmit({\n name: name.trim(),\n startAtMs,\n endAtMs,\n listIds,\n topicId,\n listUnsubscribe,\n utmCampaigns: campaignUtmLabels(utmLabels),\n ...(sharingChanged && sharing ? { sharing } : {}),\n })\n }\n >\n {busy ? 'Saving…' : 'Save campaign'}\n </Button>\n </Stack>\n </Container>\n </NavigationDrawerComponent>\n )\n}\nCampaignEditDrawer.displayName = 'CampaignEditDrawer'\n\nexport default CampaignEditDrawer\n"],"names":["ICON_VARIANT_CLOSE","Container","MdiIcon","SrOnly","NavigationDrawerComponent","SiteSharingField","Alert","Button","Chip","FormControlLabel","IconButton","MenuItem","Stack","Switch","TextField","Typography","useEffect","useMemo","useState","campaignListUnsubscribe","campaignSharingChoice","campaignSharingKey","campaignSharingWrite","campaignUtmLabels","dayInputValue","ms","Number","isFinite","at","Date","isNaN","getTime","toISOString","slice","dayInputMs","value","parsed","parse","CampaignEditDrawer","props","open","onClose","campaign","lists","topics","sites","sitesReady","busy","error","onSubmit","name","setName","startAt","setStartAt","endAt","setEndAt","listIds","setListIds","topicId","setTopicId","listUnsubscribe","setListUnsubscribe","utmLabels","setUtmLabels","sharing","setSharing","sharingSites","map","site","id","label","sharingChanged","Boolean","sharingProblem","mode","leftOut","exceptHostIds","problem","String","startAtMs","endAtMs","utmCampaigns","join","storedSharingKey","backwards","submittable","trim","length","anchor","variant","AppBarProps","color","appBarLeft","edge","onClick","sx","mr","path","component","appBarRight","gutterY","spacing","onChange","event","target","helperText","fullWidth","type","slotProps","inputLabel","shrink","select","multiple","renderValue","selected","useFlexGap","direction","flexWrap","size","find","list","topic","placeholder","control","checked","severity","disabled","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,kBAAkB,QAAQ,2BAA0B;AAC7D,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,uBAAsB;AACjE,SAASC,yBAAyB,QAAQ,8DAA6D;AACvG,SAASC,gBAAgB,QAAQ,+DAA8D;AAE/F,SACEC,KAAK,EACLC,MAAM,EACNC,I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AAO,YAAY;;;;;;AAMhC;AACAT,mBAAmByF,WAAW,GAAG;AAEjC,eAAezF,mBAAkB"}
@@ -29,7 +29,7 @@ import { campaignSharingWrite } from "../model/campaign-container.js";
29
29
  * whether it can be, is `campaignSharingWrite`, asked here to say why before
30
30
  * the create, and again by the create itself and by the manage route.
31
31
  */ export function CampaignSharingFormField(props) {
32
- const { input, sites, sitesReady, label, helperText } = useFieldApi(props);
32
+ const { input, meta, sites, sitesReady, label, helperText } = useFieldApi(props);
33
33
  const value = input.value ? input.value : null;
34
34
  const named = useMemo(()=>sites != null ? sites : [], [
35
35
  sites
@@ -44,6 +44,12 @@ import { campaignSharingWrite } from "../model/campaign-container.js";
44
44
  named,
45
45
  ready
46
46
  ]);
47
+ /*
48
+ * Why the create refused this choice, said beside it (AGL-4047): the drawer
49
+ * keeps the choice, and the reason goes once the choice changes. The live
50
+ * answer above comes first; the create's own answer covers what only it
51
+ * knows, such as the sites not having been read yet.
52
+ */ const refusal = typeof (meta == null ? void 0 : meta.submitError) === 'string' && !meta.dirtySinceLastSubmit ? meta.submitError : null;
47
53
  return /*#__PURE__*/ _jsxs(FormFieldGrid, {
48
54
  children: [
49
55
  /*#__PURE__*/ _jsx(SiteSharingField, {
@@ -52,7 +58,7 @@ import { campaignSharingWrite } from "../model/campaign-container.js";
52
58
  onChange: input.onChange,
53
59
  sites: named,
54
60
  sitesReady: ready,
55
- problem: problem
61
+ problem: problem != null ? problem : refusal
56
62
  }),
57
63
  helperText ? /*#__PURE__*/ _jsx(Typography, {
58
64
  variant: "caption",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-sharing-form-field.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 { ScopeSharingChoice } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport {\n SiteSharingField,\n type SiteSharingSite,\n} from '@aglyn/shared-ui-jsx/components/site-sharing-field.component'\nimport { FormFieldGrid } from '@aglyn/shared-ui-jsx-forms/mapper/form-field-grid'\nimport { useFieldApi } from '@aglyn/shared-ui-jsx-forms/vendor/data-driven-forms'\nimport { Typography } from '@mui/material'\nimport { useMemo } from 'react'\nimport { campaignSharingWrite } from '../model/campaign-container'\n\n/** The `component` name the create drawer's sharing field asks for. */\nexport const CAMPAIGN_SHARING_FIELD = 'campaign-site-sharing'\n\n/**\n * Who a new campaign is shared with, in the console's create drawer\n * (AGL-4047): the shared `SiteSharingField`, radios and a visible list of\n * sites, never a dropdown. It holds the choice; what the choice writes, and\n * whether it can be, is `campaignSharingWrite`, asked here to say why before\n * the create, and again by the create itself and by the manage route.\n */\nexport function CampaignSharingFormField(props: Record<string, unknown>) {\n const { input, sites, sitesReady, label, helperText } = useFieldApi(props as never) as unknown as {\n input: { value: ScopeSharingChoice | ''; onChange: (next: ScopeSharingChoice) => void }\n sites?: readonly SiteSharingSite[]\n sitesReady?: boolean\n label?: string\n helperText?: string\n }\n const value = input.value ? input.value : null\n const named = useMemo(() => sites ?? [], [sites])\n const ready = sitesReady !== false\n // Nothing to say about leaving sites out until the sites have been read.\n const problem = useMemo(() => {\n if (!value || (value.mode === 'allExcept' && !ready)) return null\n return campaignSharingWrite(\n value,\n named.map((site) => site.id),\n ).problem\n }, [value, named, ready])\n return (\n <FormFieldGrid>\n <SiteSharingField\n label={label ?? 'Shared with'}\n value={value}\n onChange={input.onChange}\n sites={named}\n sitesReady={ready}\n problem={problem}\n />\n {helperText ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {helperText}\n </Typography>\n ) : null}\n </FormFieldGrid>\n )\n}\nCampaignSharingFormField.displayName = 'CampaignSharingFormField'\n\nexport default CampaignSharingFormField\n"],"names":["SiteSharingField","FormFieldGrid","useFieldApi","Typography","useMemo","campaignSharingWrite","CAMPAIGN_SHARING_FIELD","CampaignSharingFormField","props","input","sites","sitesReady","label","helperText","value","named","ready","problem","mode","map","site","id","onChange","variant","color","component","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SACEA,gBAAgB,QAEX,+DAA8D;AACrE,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,WAAW,QAAQ,sDAAqD;AACjF,SAASC,UAAU,QAAQ,gBAAe;AAC1C,SAASC,OAAO,QAAQ,QAAO;AAC/B,SAASC,oBAAoB,QAAQ,iCAA6B;AAElE,qEAAqE,GACrE,OAAO,MAAMC,yBAAyB,wBAAuB;AAE7D;;;;;;CAMC,GACD,OAAO,SAASC,yBAAyBC,KAA8B;IACrE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGX,YAAYM;IAOpE,MAAMM,QAAQL,MAAMK,KAAK,GAAGL,MAAMK,KAAK,GAAG;IAC1C,MAAMC,QAAQX,QAAQ,IAAMM,gBAAAA,QAAS,EAAE,EAAE;QAACA;KAAM;IAChD,MAAMM,QAAQL,eAAe;IAC7B,yEAAyE;IACzE,MAAMM,UAAUb,QAAQ;QACtB,IAAI,CAACU,SAAUA,MAAMI,IAAI,KAAK,eAAe,CAACF,OAAQ,OAAO;QAC7D,OAAOX,qBACLS,OACAC,MAAMI,GAAG,CAAC,CAACC,OAASA,KAAKC,EAAE,GAC3BJ,OAAO;IACX,GAAG;QAACH;QAAOC;QAAOC;KAAM;IACxB,qBACE,MAACf;;0BACC,KAACD;gBACCY,KAAK,EAAEA,gBAAAA,QAAS;gBAChBE,OAAOA;gBACPQ,UAAUb,MAAMa,QAAQ;gBACxBZ,OAAOK;gBACPJ,YAAYK;gBACZC,SAASA;;YAEVJ,2BACC,KAACV;gBAAWoB,SAAQ;gBAAUC,OAAM;gBAAiBC,WAAU;0BAC5DZ;iBAED;;;AAGV;AACAN,yBAAyBmB,WAAW,GAAG;AAEvC,eAAenB,yBAAwB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-sharing-form-field.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 { ScopeSharingChoice } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport {\n SiteSharingField,\n type SiteSharingSite,\n} from '@aglyn/shared-ui-jsx/components/site-sharing-field.component'\nimport { FormFieldGrid } from '@aglyn/shared-ui-jsx-forms/mapper/form-field-grid'\nimport { useFieldApi } from '@aglyn/shared-ui-jsx-forms/vendor/data-driven-forms'\nimport { Typography } from '@mui/material'\nimport { useMemo } from 'react'\nimport { campaignSharingWrite } from '../model/campaign-container'\n\n/** The `component` name the create drawer's sharing field asks for. */\nexport const CAMPAIGN_SHARING_FIELD = 'campaign-site-sharing'\n\n/**\n * Who a new campaign is shared with, in the console's create drawer\n * (AGL-4047): the shared `SiteSharingField`, radios and a visible list of\n * sites, never a dropdown. It holds the choice; what the choice writes, and\n * whether it can be, is `campaignSharingWrite`, asked here to say why before\n * the create, and again by the create itself and by the manage route.\n */\nexport function CampaignSharingFormField(props: Record<string, unknown>) {\n const { input, meta, sites, sitesReady, label, helperText } = useFieldApi(props as never) as unknown as {\n input: { value: ScopeSharingChoice | ''; onChange: (next: ScopeSharingChoice) => void }\n meta: { submitError?: unknown; dirtySinceLastSubmit?: boolean }\n sites?: readonly SiteSharingSite[]\n sitesReady?: boolean\n label?: string\n helperText?: string\n }\n const value = input.value ? input.value : null\n const named = useMemo(() => sites ?? [], [sites])\n const ready = sitesReady !== false\n // Nothing to say about leaving sites out until the sites have been read.\n const problem = useMemo(() => {\n if (!value || (value.mode === 'allExcept' && !ready)) return null\n return campaignSharingWrite(\n value,\n named.map((site) => site.id),\n ).problem\n }, [value, named, ready])\n /*\n * Why the create refused this choice, said beside it (AGL-4047): the drawer\n * keeps the choice, and the reason goes once the choice changes. The live\n * answer above comes first; the create's own answer covers what only it\n * knows, such as the sites not having been read yet.\n */\n const refusal =\n typeof meta?.submitError === 'string' && !meta.dirtySinceLastSubmit ? meta.submitError : null\n return (\n <FormFieldGrid>\n <SiteSharingField\n label={label ?? 'Shared with'}\n value={value}\n onChange={input.onChange}\n sites={named}\n sitesReady={ready}\n problem={problem ?? refusal}\n />\n {helperText ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\">\n {helperText}\n </Typography>\n ) : null}\n </FormFieldGrid>\n )\n}\nCampaignSharingFormField.displayName = 'CampaignSharingFormField'\n\nexport default CampaignSharingFormField\n"],"names":["SiteSharingField","FormFieldGrid","useFieldApi","Typography","useMemo","campaignSharingWrite","CAMPAIGN_SHARING_FIELD","CampaignSharingFormField","props","input","meta","sites","sitesReady","label","helperText","value","named","ready","problem","mode","map","site","id","refusal","submitError","dirtySinceLastSubmit","onChange","variant","color","component","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SACEA,gBAAgB,QAEX,+DAA8D;AACrE,SAASC,aAAa,QAAQ,oDAAmD;AACjF,SAASC,WAAW,QAAQ,sDAAqD;AACjF,SAASC,UAAU,QAAQ,gBAAe;AAC1C,SAASC,OAAO,QAAQ,QAAO;AAC/B,SAASC,oBAAoB,QAAQ,iCAA6B;AAElE,qEAAqE,GACrE,OAAO,MAAMC,yBAAyB,wBAAuB;AAE7D;;;;;;CAMC,GACD,OAAO,SAASC,yBAAyBC,KAA8B;IACrE,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,KAAK,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAE,GAAGZ,YAAYM;IAQ1E,MAAMO,QAAQN,MAAMM,KAAK,GAAGN,MAAMM,KAAK,GAAG;IAC1C,MAAMC,QAAQZ,QAAQ,IAAMO,gBAAAA,QAAS,EAAE,EAAE;QAACA;KAAM;IAChD,MAAMM,QAAQL,eAAe;IAC7B,yEAAyE;IACzE,MAAMM,UAAUd,QAAQ;QACtB,IAAI,CAACW,SAAUA,MAAMI,IAAI,KAAK,eAAe,CAACF,OAAQ,OAAO;QAC7D,OAAOZ,qBACLU,OACAC,MAAMI,GAAG,CAAC,CAACC,OAASA,KAAKC,EAAE,GAC3BJ,OAAO;IACX,GAAG;QAACH;QAAOC;QAAOC;KAAM;IACxB;;;;;GAKC,GACD,MAAMM,UACJ,QAAOb,wBAAAA,KAAMc,WAAW,MAAK,YAAY,CAACd,KAAKe,oBAAoB,GAAGf,KAAKc,WAAW,GAAG;IAC3F,qBACE,MAACvB;;0BACC,KAACD;gBACCa,KAAK,EAAEA,gBAAAA,QAAS;gBAChBE,OAAOA;gBACPW,UAAUjB,MAAMiB,QAAQ;gBACxBf,OAAOK;gBACPJ,YAAYK;gBACZC,OAAO,EAAEA,kBAAAA,UAAWK;;YAErBT,2BACC,KAACX;gBAAWwB,SAAQ;gBAAUC,OAAM;gBAAiBC,WAAU;0BAC5Df;iBAED;;;AAGV;AACAP,yBAAyBuB,WAAW,GAAG;AAEvC,eAAevB,yBAAwB"}
@@ -470,15 +470,27 @@ const NO_CLAUSES = {
470
470
  * marked by the manage route, the one writer of the marker: the rules
471
471
  * refuse it on a client create. Until the route answers it is exactly
472
472
  * a campaign on those sites, never on a site that was left out.
473
+ *
474
+ * A refused choice is handed back to the sharing field, which says why
475
+ * beside itself and stops once the choice changes; the drawer keeps
476
+ * exactly what was chosen (production check 11/10).
473
477
  */ const sharing = hostId ? null : (_values_sharing = values.sharing) != null ? _values_sharing : {
474
478
  mode: 'all'
475
479
  };
476
480
  const orgHostIds = ((_ref = orgMount == null ? void 0 : orgMount.hosts) != null ? _ref : []).map((site)=>site.id);
477
481
  const placed = sharing ? campaignSharingWrite(sharing, orgHostIds) : null;
478
482
  if (sharing && sharing.mode !== 'all' && !(orgMount == null ? void 0 : orgMount.hostsReady)) {
479
- return setCreateError('This workspace’s sites are still loading — try again');
483
+ setCreateError(null);
484
+ return {
485
+ sharing: 'This workspace’s sites are still loading — try again'
486
+ };
487
+ }
488
+ if (placed && !placed.fields) {
489
+ setCreateError(null);
490
+ return {
491
+ sharing: placed.problem
492
+ };
480
493
  }
481
- if (placed && !placed.fields) return setCreateError(placed.problem);
482
494
  const visibleTo = hostId ? campaignSiteVisibleTo(hostId) : (_ref1 = placed == null ? void 0 : (_placed_fields = placed.fields) == null ? void 0 : _placed_fields.visibleTo) != null ? _ref1 : [];
483
495
  setCreating(true);
484
496
  setCreateError(null);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaigns-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 { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { MARKETING_CAMPAIGNS_REFUSAL } from '../model/marketing-permissions'\nimport { useCampaignListAccess } from './use-campaign-containers-blocked'\nimport { buildRoute, createResourceUid, pluginDocsHelp, Route } from '@aglyn/aglyn'\n/*\n * The MODULE, not the barrel, for the two PURE helpers — a spec that mocks\n * `@aglyn/tenant-feature-instance` wholesale to stage its Firestore hooks\n * would otherwise lose them, and neither is a hook.\n */\nimport {\n ceilingedWindow,\n collectionCeiling,\n} from '@aglyn/tenant-feature-instance/hooks/host-collection-queries'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\nimport { mdiDeleteOutline, mdiPageNextOutline } from '@aglyn/shared-data-mdi'\nimport {\n AppLink,\n CardDisplay,\n MdiIcon,\n useConfirmationContext,\n} from '@aglyn/shared-ui-jsx'\nimport ListFilterChips from '@aglyn/shared-ui-jsx/components/list-filter-chips.component'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport ListQueryNotices, {\n listQueryRefusals,\n} from '@aglyn/shared-ui-jsx/components/list-query-notices.component'\nimport {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { hiddenFilterVisibility } from '@aglyn/shared-ui-jsx/const/list-filter'\nimport {\n type ListFilterClause,\n listFilterGridColumns,\n} from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\nimport { useListColumnSort } from '@aglyn/shared-ui-jsx/hooks/use-list-column-sort'\nimport type { ListQuerySort } from '@aglyn/shared-ui-jsx/const/list-query-plan'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Alert,\n Button,\n Chip,\n Stack,\n ToggleButton,\n ToggleButtonGroup,\n Typography,\n} from '@mui/material'\nimport { collection, limit, query, setDoc, where } from 'firebase/firestore'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useRouter } from 'next/navigation'\nimport {\n useConsoleHostRoute,\n useFirestore,\n useFirestoreCollection,\n useUser,\n} from '@aglyn/tenant-feature-instance'\nimport {\n campaignAllExceptLabel,\n campaignListRows,\n campaignSharingWrite,\n campaignSiteIds,\n campaignSiteVisibleTo,\n type CampaignAggregate,\n type CampaignListRow,\n type CampaignSend,\n type EmailCampaign,\n} from '../model/campaign-container'\nimport { CreateArtifactDrawer } from '@aglyn/shared-ui-jsx-forms'\nimport {\n CAMPAIGN_SITE_SEARCH_NOTICE,\n SINGLE_SENDS_BASE,\n campaignContainerSearchFields,\n campaignContainersListQuery,\n campaignContainersScope,\n campaignSendsScope,\n campaignSingleSendsListQuery,\n campaignSiteSearchClause,\n} from '../model/campaign-list-query'\nimport {\n campaignContainerDoc,\n campaignContainersCollection,\n campaignSendsCollection,\n} from './campaign-queries'\nimport {\n orgSiteName,\n orgSiteOptions,\n topicCatalogHostId,\n useMarketingOrgId,\n useMarketingOrgMount,\n type MarketingOrgMount,\n} from './marketing-org-mount'\nimport { useCampaignManageApi } from './use-campaign-send-api'\nimport { CAMPAIGN_SHARING_FIELD, CampaignSharingFormField } from './campaign-sharing-form-field'\nimport type { ScopeSharingChoice } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport { HostCampaignsZone } from './campaign-list-zones'\nimport { useCampaignTopicOptions } from './use-campaign-topic-options'\n\n/**\n * How many emails one read of a page's campaigns covers, for their figures.\n *\n * A ceiling on the ROLLUP read, not on the list: the list is paged by its\n * own query, and this reads the emails of the campaigns on the page on\n * screen, thirty campaigns to a read (`in` takes thirty ids), so the largest\n * page is two reads of this many. Past it, the figures say so.\n */\nconst ROLLUP_CEILING = 50\n\n/** Firestore's cap on an `in` clause's values. */\nconst IN_LIMIT = 30\n\n/** Which kind of row the table shows: the two are separate queries. */\ntype CampaignListKind = 'campaign' | 'single'\n\nconst formatDay = (ms: number | null): string =>\n ms === null ? '' : new Date(ms).toLocaleDateString()\n\n/** A rolled-up figure, or an em dash where nothing recorded one. */\nconst figure = (value: CampaignAggregate): string =>\n value.value === null ? '—' : value.value.toLocaleString()\n\n/*\n * EVERY HEADER SORTS (AGL-3680). A campaign's name and a single send's\n * subject order the kind's query (`declaration.sorts`); what a row is drawn\n * from — its sites, its window, its lists, and its figures (a campaign's\n * summed from its emails for the page, a send's counters absent until\n * something is counted) — sorts the page.\n */\nconst CAMPAIGN_PAGE_SORT_HEADERS = {\n sitesLabel: 'Sites',\n windowState: 'Window',\n listIds: 'Lists',\n emails: 'Emails',\n sent: 'Mail sent',\n opens: 'Mail opens',\n clicks: 'Mail clicks',\n}\n\nconst WINDOW_LABEL: Record<CampaignListRow['windowState'], string> = {\n undated: 'No dates',\n upcoming: 'Upcoming',\n running: 'Running',\n ended: 'Ended',\n}\n\n/*\n * What the campaigns grid's Filters panel offers, each clause and the search\n * on the list's Firestore query (AGL-3321, `campaignContainersListQuery` and\n * `campaignSingleSendsListQuery`). The Window column is derived from a\n * campaign's dates against the clock, which no query can ask, so it is not\n * offered; the one date range is Created, the list's own order.\n */\nconst CAMPAIGN_FILTER_HEADERS: Record<CampaignListKind, Readonly<Record<string, string>>> = {\n campaign: {\n name: 'Campaign',\n listIds: 'Lists',\n sitesLabel: 'Sites',\n createdAtMs: 'Created',\n },\n // A single send has no container; its `name` field filters by the subject.\n single: {\n name: 'Subject',\n sitesLabel: 'Sites',\n createdAtMs: 'Created',\n },\n}\nconst NO_CLAUSES: Record<CampaignListKind, ListFilterClause[]> = {\n campaign: [],\n single: [],\n}\n\n/**\n * THE CAMPAIGNS LIST.\n *\n * A campaign is a container — a name, a window, the lists it is aimed at, and\n * the emails sent inside it — so this is a table of campaigns and not of\n * messages. Composing is not here: a message belongs to a campaign, and the\n * campaign's own page is where one is written.\n *\n * The rows come from two collections. `emailCampaigns` holds the\n * containers. `campaigns` holds every send, including thousands written\n * before containers existed; those carry no container (`emailCampaignId`\n * null), and `campaignListRows` presents each as a campaign of one rather\n * than dropping it. The two are two queries, so the table lists one kind at a\n * time — Campaigns or Single sends — each paged by its own query (AGL-3321).\n * No send is re-filed, so no unsubscribe link and no pasted report URL stops\n * resolving.\n *\n * ## At two levels\n *\n * Both collections are the organization's. Under a site the card lists the\n * campaigns PLACED on that site and the sends sent AS it (see\n * `campaign-queries.ts` for why those filters are what make the read legal);\n * on the org hub, with `hostId` null, it lists every campaign with the sites\n * each one is placed on, and a new campaign is placed where its creator says.\n */\nexport function HostCampaignsCard(props: {\n /** The site, or `null` on the org Marketing hub. */\n hostId: string | null\n /**\n * The marketing hub URL, when the caller already has it.\n *\n * Resolved from the host route when it does not: the inbox console page\n * embeds this card on a tab of its own, and its `basePath` names the INBOX\n * hub. Deriving one hub's URL from another's by string surgery is the kind\n * of link that breaks silently when a surface moves.\n */\n basePath?: string\n}) {\n const { hostId, basePath } = props\n const firestore = useFirestore()\n const router = useRouter()\n const { orgSlug, subdomain } = useConsoleHostRoute(hostId)\n const hubPath =\n basePath ??\n (orgSlug && subdomain\n ? buildRoute(Route.HOST_PLUGIN, {\n orgSlug,\n host: subdomain,\n pluginSlug: 'marketing',\n })\n : null)\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n const orgMount = useMarketingOrgMount()\n const { orgId } = useMarketingOrgId(hostId)\n // \"Run email campaigns\" (AGL-4047): the container's create is client-direct,\n // so the rule asks it, and the button says so before the save does. Created\n // here it is placed on this site, so the site's verdict counts. A row's Delete\n // answers the manage route, which the same hook reads.\n const {\n createBlocked: containersBlocked,\n deleteBlocked,\n deleteReachRefusal,\n } = useCampaignListAccess(orgId, hostId)\n // A container is the org's, so deleting one from the org hub names the org.\n const manageApi = useCampaignManageApi(hostId, orgId)\n\n /*==========================================\n * TWO KINDS OF ROW, EACH ITS OWN QUERY (AGL-3321).\n *\n * A campaign is a CONTAINER (`emailCampaigns`); a single send is an email\n * filed under none (`campaigns` where `emailCampaignId == null`). The two\n * live in different collections, and one Firestore query reads one\n * collection — so a table that merged them could page neither, and every\n * filter would be matched over whatever window of each it happened to\n * hold. The toggle above the table picks the kind, and the table shows a\n * page of that kind's query: newest first on `createdAtMs`, every clause\n * and the search word on the query, paged by it. Same table, same\n * columns; a single send still reads as a campaign of one.\n *\n * Each kind keeps its own clauses (their Sites values differ: a campaign\n * is asked by scope token, a send by the site it was sent as); the search\n * words are the reader's and carry across.\n *=========================================*/\n const [kind, setKind] = useState<CampaignListKind>('campaign')\n // The header order asked of the kind on screen; a new kind starts unsorted.\n const [askedSort, setAskedSort] = useState<ListQuerySort | null>(null)\n const [clausesByKind, setClausesByKind] = useState(NO_CLAUSES)\n const [searchWords, setSearchWords] = useState<string[]>([])\n const setKindClauses = useCallback(\n (next: ListFilterClause[]) =>\n setClausesByKind((current) => ({ ...current, [kind]: next })),\n [kind],\n )\n const gridFilter = useListGridFilter({\n clauses: clausesByKind[kind],\n onChange: setKindClauses,\n selectFields: ['listIds', 'sitesLabel'],\n search: { words: searchWords, onChange: setSearchWords },\n })\n const containerDeclaration = campaignContainersListQuery(!hostId)\n const singleDeclaration = campaignSingleSendsListQuery(!hostId)\n const declaration = kind === 'campaign' ? containerDeclaration : singleDeclaration\n const filterHeaders = CAMPAIGN_FILTER_HEADERS[kind]\n /*\n * A site's campaigns are searched by the START of the name: a range beside\n * the site's scope clause, the one array clause the rules can prove for a\n * site collaborator (see `campaign-list-query.ts`). The org hub keeps the\n * word search.\n */\n const siteSearch =\n hostId && kind === 'campaign' ? campaignSiteSearchClause(gridFilter.searchWords) : null\n const containerPage = useListQuery<any>({\n collection:\n kind === 'campaign' ? campaignContainersCollection(firestore, orgId) : null,\n declaration: containerDeclaration,\n request: {\n clauses:\n kind === 'campaign'\n ? siteSearch\n ? [siteSearch, ...gridFilter.clauses]\n : gridFilter.clauses\n : [],\n search: hostId ? [] : gridFilter.searchWords,\n base: campaignContainersScope(hostId),\n sort: kind === 'campaign' ? askedSort : null,\n },\n deps: [firestore, orgId, hostId, kind],\n idField: '$id',\n })\n const singlePage = useListQuery<any>({\n collection: kind === 'single' ? campaignSendsCollection(firestore, orgId) : null,\n declaration: singleDeclaration,\n request: {\n clauses: kind === 'single' ? gridFilter.clauses : [],\n search: gridFilter.searchWords,\n base: [SINGLE_SENDS_BASE, ...campaignSendsScope(hostId)],\n sort: kind === 'single' ? askedSort : null,\n },\n deps: [firestore, orgId, hostId, kind],\n idField: '$id',\n })\n const page = kind === 'campaign' ? containerPage : singlePage\n const filtering =\n gridFilter.clauses.length > 0 ||\n gridFilter.searchWords.some((word) => word.trim())\n\n /*\n * THE FIGURES OF THE CAMPAIGNS ON THE PAGE ON SCREEN.\n *\n * A container stores no counters; its row sums the emails filed under it.\n * Those are read for the page's campaigns only — `emailCampaignId in` the\n * ids on screen, thirty to a read, and under a site the ones sent as it —\n * and never used to filter: the page is already the query's answer. Past\n * `ROLLUP_CEILING` emails a read stops, and the table says the figures\n * are partial.\n */\n const pageIds = useMemo(\n () =>\n kind === 'campaign'\n ? containerPage.rows.map((row: any) => String(row.$id))\n : [],\n [kind, containerPage.rows],\n )\n const rollupRead = (ids: string[]) => () => {\n const sends = campaignSendsCollection(firestore, orgId)\n if (!sends || !ids.length) return null\n return collectionCeiling(\n query(\n sends,\n where('emailCampaignId', 'in', ids),\n ...(hostId ? [where('hostId', '==', hostId)] : []),\n ),\n ROLLUP_CEILING,\n )\n }\n const firstIds = pageIds.slice(0, IN_LIMIT)\n const restIds = pageIds.slice(IN_LIMIT, IN_LIMIT * 2)\n const { data: firstSendDocs } = useFirestoreCollection<any>(\n rollupRead(firstIds),\n [firestore, orgId, hostId, firstIds.join(',')],\n { idField: '$id' },\n )\n const { data: restSendDocs } = useFirestoreCollection<any>(\n rollupRead(restIds),\n [firestore, orgId, hostId, restIds.join(',')],\n { idField: '$id' },\n )\n const firstSends = ceilingedWindow<any>(firstSendDocs, ROLLUP_CEILING)\n const restSends = ceilingedWindow<any>(restSendDocs, ROLLUP_CEILING)\n const rollupTruncated = firstSends.truncated || restSends.truncated\n\n // Org email lists, so a row can name what it is aimed at rather than\n // showing ids.\n const { data: listDocs } = useFirestoreCollection<any>(\n () =>\n orgId\n ? query(collection(firestore, 'orgs', orgId, 'lists'), limit(50))\n : null,\n [firestore, orgId],\n { idField: '$id' },\n )\n const [createOpen, setCreateOpen] = useState(false)\n /*\n * The org's topic catalog, read only while the CREATE DRAWER is open.\n *\n * It fills one picker in that drawer and is drawn nowhere in the table, so\n * a reader who came to look at their campaigns must not pay for it — the\n * same rule the emails list already applies to the campaigns it offers its\n * own drawer, and the one the audiences section applies to a list's\n * members. It is the largest read on this section at 200 documents, and it\n * is the only one nothing on screen needs.\n */\n const { topics, source: topicSource } = useCampaignTopicOptions(\n topicCatalogHostId(hostId, orgMount),\n { enabled: createOpen },\n )\n const topicOptions = useMemo(\n () =>\n topics.map((topic) => ({\n value: topic.id,\n label: topic.name,\n })),\n [topics],\n )\n\n const listNames = useMemo(() => {\n const names = new Map<string, string>()\n for (const list of listDocs ?? []) {\n names.set(String(list.$id), String(list.name ?? list.$id))\n }\n return names\n }, [listDocs])\n\n const listOptions = useMemo(\n () =>\n (listDocs ?? []).map((list: any) => ({\n value: String(list.$id),\n label: String(list.name ?? list.$id),\n })),\n [listDocs],\n )\n\n /*\n * The page's rows, in the QUERY's order. `campaignListRows` builds each\n * row — a container with its emails summed, or a single send as a\n * campaign of one — and sorts by date, which is not this list's order, so\n * the page is put back in the order the query returned it.\n */\n const rows = useMemo(() => {\n const read = page.rows as any[]\n const order = new Map(read.map((row, at) => [String(row.$id), at]))\n const built =\n kind === 'campaign'\n ? campaignListRows(\n read as EmailCampaign[],\n [...firstSends.rows, ...restSends.rows] as CampaignSend[],\n Date.now(),\n )\n : campaignListRows([], read as CampaignSend[], Date.now())\n const byId = new Map(read.map((row) => [String(row.$id), row]))\n return built\n .filter((row) => order.has(row.id))\n .sort((a, b) => (order.get(a.id) ?? 0) - (order.get(b.id) ?? 0))\n .map((row) => ({\n ...row,\n $id: row.id,\n sitesLabel: orgMount\n ? campaignSitesLabel(orgMount, row, byId.get(row.id))\n : '',\n /*\n * Why the site's own door would refuse this row's delete past the\n * key: a campaign on other sites too, or shared with all sites except\n * some, asks for access to every site (AGL-4047). Read off the row\n * already loaded, so it costs nothing.\n */\n deleteReach: row.legacy ? null : deleteReachRefusal(byId.get(row.id)),\n }))\n }, [kind, page.rows, firstSends.rows, restSends.rows, orgMount, deleteReachRefusal])\n\n const pageSorts = useMemo(\n () => ({\n sitesLabel: (row: any) => row.sitesLabel || null,\n windowState: (row: any) => row.startAtMs ?? row.endAtMs ?? null,\n listIds: (row: any) =>\n (row.listIds as string[]).map((id) => listNames.get(id) ?? id).join(', ') || null,\n emails: (row: any) => row.rollup.sends,\n sent: (row: any) => row.rollup.sent.value,\n opens: (row: any) => row.rollup.opens.value,\n clicks: (row: any) => row.rollup.clicks.value,\n }),\n [listNames],\n )\n const columnSort = useListColumnSort<any>({\n sorts: declaration.sorts,\n sort: askedSort,\n onSortChange: setAskedSort,\n orderBy: page.plan.orderBy,\n rows,\n pageSorts,\n headers: CAMPAIGN_PAGE_SORT_HEADERS,\n })\n\n /*\n * The choices the picked fields offer. A campaign's Sites are asked by\n * scope token — `org` is placed on every site — and a single send's by\n * the site it was sent as.\n */\n const filterOptions = useMemo(() => {\n if (!orgMount) return {}\n const sites = orgSiteOptions(orgMount)\n return kind === 'campaign'\n ? {\n listIds: listOptions,\n sitesLabel: [\n { value: 'org', label: 'Every site' },\n ...sites.map((site) => ({\n value: `host:${site.value}`,\n label: site.label,\n })),\n ],\n }\n : { sitesLabel: sites }\n }, [kind, listOptions, orgMount])\n\n const [createError, setCreateError] = useState<string | null>(null)\n const [creating, setCreating] = useState(false)\n /** The campaign a delete is in flight for, so its row menu can say so. */\n const [deletingId, setDeletingId] = useState('')\n\n const openCampaign = useCallback(\n (id: string) => {\n if (hubPath) void router.push(`${hubPath}/campaigns/${id}`)\n },\n [hubPath, router],\n )\n\n const handleCreate = useCallback(\n async (values: Record<string, any>) => {\n if (creating) return\n /*\n * `displayName` is the shared drawer's own field, and every artifact\n * create in the console collects a name under that key. The campaign\n * stores it as `name` — the container has one name and no second\n * internal label — so the mapping happens here rather than by giving\n * this one drawer a field the others do not have.\n */\n const name = String(values.displayName ?? '').trim()\n if (!name) return\n const startAtMs = values.startAt ? Date.parse(String(values.startAt)) : null\n const endAtMs = values.endAt ? Date.parse(String(values.endAt)) : null\n // Refused here rather than stored and rendered as a campaign that ends\n // before it starts, which no window state describes.\n if (startAtMs !== null && endAtMs !== null && endAtMs < startAtMs) {\n return setCreateError('The end date is before the start date')\n }\n /*\n * Held until the org is known. A container has one home, and a write\n * that raced the site's org lookup would have nowhere to go.\n */\n if (!orgId) {\n return setCreateError('This workspace is still loading — try again')\n }\n /*\n * Where it is placed. From a site's hub, that site — the creator is\n * standing on it, and a campaign that appeared on every sibling site\n * would be a decision nobody made. From the org hub, who it is shared\n * with, as the sharing field chose (AGL-4047): a choice that cannot be\n * stored is refused with the reason, never cut short — more than thirty\n * chosen sites used to keep the first thirty and say nothing.\n *\n * \"All sites except…\" is created on the sites it reaches today and then\n * marked by the manage route, the one writer of the marker: the rules\n * refuse it on a client create. Until the route answers it is exactly\n * a campaign on those sites, never on a site that was left out.\n */\n const sharing = hostId\n ? null\n : ((values.sharing as ScopeSharingChoice | undefined) ?? { mode: 'all' as const })\n const orgHostIds = (orgMount?.hosts ?? []).map((site) => site.id)\n const placed = sharing ? campaignSharingWrite(sharing, orgHostIds) : null\n if (sharing && sharing.mode !== 'all' && !orgMount?.hostsReady) {\n return setCreateError('This workspace’s sites are still loading — try again')\n }\n if (placed && !placed.fields) return setCreateError(placed.problem)\n const visibleTo = hostId\n ? campaignSiteVisibleTo(hostId)\n : (placed?.fields?.visibleTo ?? [])\n setCreating(true)\n setCreateError(null)\n const id = createResourceUid()\n try {\n await setDoc(campaignContainerDoc(firestore, orgId, id), {\n name,\n // What the list's search reads (AGL-3321), from the name.\n ...campaignContainerSearchFields(name),\n ...(Number.isFinite(startAtMs) && startAtMs !== null\n ? { startAtMs }\n : {}),\n ...(Number.isFinite(endAtMs) && endAtMs !== null ? { endAtMs } : {}),\n listIds: Array.isArray(values.listIds)\n ? values.listIds.map(String)\n : [],\n ...(values.topicId ? { topicId: String(values.topicId) } : {}),\n visibleTo,\n createdAtMs: Date.now(),\n createdBy: String((user as any)?.uid ?? ''),\n })\n if (sharing?.mode === 'allExcept') {\n // The campaign exists either way, so a refusal here is said, never\n // reported as a create that failed.\n const refusal = await manageApi({\n action: 'setSharing',\n campaignId: id,\n choice: sharing,\n })\n .then(({ response, payload }) =>\n response.ok ? null : String(payload?.error ?? 'the sharing was refused'),\n )\n .catch(() => 'the sharing could not be saved')\n if (refusal) {\n enqueueSnackbar(\n 'The campaign was created on the sites it reaches today, but a ' +\n `new site will not get it: ${refusal}`,\n { variant: 'warning', allowDuplicate: true },\n )\n }\n }\n setCreateOpen(false)\n openCampaign(id)\n } catch (error) {\n console.error(error)\n setCreateError('The campaign could not be created')\n enqueueSnackbar('Could not create the campaign', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setCreating(false)\n }\n },\n [creating, firestore, hostId, orgId, orgMount, user, enqueueSnackbar, manageApi, openCampaign],\n )\n\n const campaignHref = useCallback(\n (id: string) => (hubPath ? `${hubPath}/campaigns/${id}` : null),\n [hubPath],\n )\n\n /*==========================================\n * DELETING A CAMPAIGN FROM ITS ROW.\n *\n * The container goes and its emails stay — the route detaches them first,\n * so each one keeps its id, its report and its unsubscribe links, and\n * reappears in this very table as a \"Single send\". That is not a\n * convenience: a send id is inside the HMAC of every unsubscribe footer\n * already delivered, so a delete that took the sends with it would break\n * opt-outs that must go on working.\n *\n * The confirmation names the count and says what the delete does NOT do.\n * Deleting a campaign cancels nothing — a scheduled email inside it still\n * goes out — and a merchant who reads the button as \"stop this campaign\"\n * has to be told before they press it.\n *\n * EDITING is deliberately not offered here. A record is edited on its own\n * page in this console; the campaign's page carries the edit drawer, and\n * this row's first entry is the way to it.\n *=========================================*/\n const handleDelete = useCallback(\n async (row: CampaignListRow) => {\n if (deletingId) return\n const emails = row.sends.length\n /*\n * Emails with mail still to go: waiting for their time, AND part way\n * through an audience larger than one batch. Counting only `scheduled`\n * would miss the case that needs the warning most — an email delivering\n * right now is stored as `scheduled` too, and `rollup.scheduled` is the\n * narrower reading that leaves it out.\n */\n const unfinished = row.rollup.scheduled + row.rollup.sending\n const agreed = await confirm({\n title: `Delete ${row.name}?`,\n description:\n (emails\n ? `The ${emails.toLocaleString()} ` +\n `${emails === 1 ? 'email' : 'emails'} in it are kept — each ` +\n 'keeps its own report and its unsubscribe links, and they stay ' +\n 'in this list as single sends. '\n : 'It holds no emails. ') +\n (unfinished\n ? `${unfinished.toLocaleString()} of them ${\n unfinished === 1 ? 'is' : 'are'\n } still going out or still due, and deleting the campaign does ` +\n 'not stop that — the sender picks each one up from its own ' +\n 'record. Stop a send from its own page. '\n : '') +\n 'Any pages, forms and contacts assigned to it come out of it and ' +\n 'are otherwise untouched. Only the campaign itself goes.',\n confirmationText: 'Delete campaign',\n })\n .then(() => true)\n .catch(() => false)\n if (!agreed) return\n setDeletingId(row.id)\n try {\n const { response, payload } = await manageApi({\n action: 'deleteCampaign',\n campaignId: row.id,\n })\n if (!response.ok) {\n return void enqueueSnackbar(\n payload?.error ?? 'The campaign could not be deleted',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n enqueueSnackbar('Campaign deleted', {\n variant: 'success',\n persist: false,\n })\n } catch (error) {\n console.error(error)\n enqueueSnackbar('The campaign could not be deleted', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setDeletingId('')\n }\n },\n [confirm, deletingId, enqueueSnackbar, manageApi],\n )\n\n const columns = useMemo(\n () => [\n {\n field: 'name',\n headerName: filterHeaders.name,\n flex: 1,\n minWidth: 180,\n renderCell: ({ row }: any) => (\n <Stack\n direction=\"row\"\n spacing={1}\n /*\n `minWidth: 0` on the row AND on the name: a flex child will not\n shrink below its content without it, so the chip beside it is\n what gets clipped instead of the name being ellipsed.\n */\n sx={{ alignItems: 'center', minWidth: 0, width: 1 }}\n >\n {/*\n The name is a real anchor as well as the row being clickable, so\n a campaign can be middle-clicked into a tab or copied out of the\n context menu — affordances a row handler cannot offer. The grid's\n own row click fires too, so the link stops the event rather than\n pushing the same route twice.\n */}\n {campaignHref(row.id) ? (\n <AppLink\n href={campaignHref(row.id) as string}\n onClick={(event: { stopPropagation: () => void }) =>\n event.stopPropagation()\n }\n style={{ minWidth: 0 }}\n >\n <Typography variant=\"body2\" noWrap>\n {row.name}\n </Typography>\n </AppLink>\n ) : (\n <Typography variant=\"body2\" noWrap sx={{ minWidth: 0 }}>\n {row.name}\n </Typography>\n )}\n {row.legacy ? (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label=\"Single send\"\n // A label that reads \"Single sen\" is worse than a shorter name.\n sx={{ flexShrink: 0 }}\n title={\n 'Sent before campaigns grouped their emails. Its report ' +\n 'and its unsubscribe links are unchanged.'\n }\n />\n ) : null}\n </Stack>\n ),\n },\n /*\n WHERE IT IS PLACED, on the org hub only. Under a site every row is on\n that site by construction, so the column would say one thing thirty\n times.\n */\n ...(orgMount\n ? [\n {\n field: 'sitesLabel',\n headerName: 'Sites',\n width: 170,\n sortable: false,\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\" noWrap>\n {row.sitesLabel}\n </Typography>\n ),\n },\n ]\n : []),\n {\n field: 'windowState',\n headerName: 'Window',\n width: 170,\n renderCell: ({ row }: any) => {\n const start = formatDay(row.startAtMs)\n const end = formatDay(row.endAtMs)\n const range =\n start && end && start !== end\n ? `${start} – ${end}`\n : start || end || ''\n return (\n <Stack sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {WINDOW_LABEL[row.windowState as CampaignListRow['windowState']]}\n </Typography>\n {range ? (\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {range}\n </Typography>\n ) : null}\n </Stack>\n )\n },\n },\n {\n field: 'listIds',\n headerName: 'Lists',\n width: 140,\n sortable: false,\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\" noWrap>\n {row.listIds.length\n ? row.listIds\n .map((id: string) => listNames.get(id) ?? id)\n .join(', ')\n : '—'}\n </Typography>\n ),\n },\n /*\n THE FOUR COUNTS, RIGHT-ALIGNED HEAD AND BODY.\n A figure is read by its last digit, so a column of them lines up on\n the right or it does not line up at all. `headerAlign` has to be said\n as well as `align`: a grid column defaults its header to the column\n type's alignment rather than to the cell's, which is how these came to\n sit with left headers over figures nobody could compare down the page.\n\n EVERY ONE OF THEM MEASURES THE MAIL, and the headings say so. What a\n campaign CAUSED — the submissions, leads, contacts and bookings\n credited to it — is not a column here, because there is no figure to\n read: a container has no conversion counter of its own, so a column\n would be an aggregation per row for a campaign and a subcollection\n document per row for a single send, on a list that costs two queries\n however many campaigns it holds. Headings that named the campaign over\n figures that all described its mail were the cheaper mistake, so the\n headings name the mail and the note under the table says where the\n outcome figures are.\n */\n {\n field: 'emails',\n headerName: 'Emails',\n width: 128,\n align: 'right',\n headerAlign: 'right',\n /*\n THE COUNT, AND WHAT IS STILL HAPPENING TO IT.\n\n `sending` is called out apart from `scheduled` because the two are\n opposite readings of the same stored status: an email delivering an\n audience larger than one batch sits as `scheduled` between runs, and\n rolling it in with the ones that have mailed nobody reports a\n campaign that is half delivered as a campaign that has not started.\n\n The note sits UNDER the figure rather than beside it — the column\n would otherwise have to be wide enough for the longest sentence, and\n the figure is what the column is read for.\n */\n renderCell: ({ row }: any) => {\n const { sends, sending, scheduled } = row.rollup\n const note = [\n sending ? `${sending} sending` : '',\n scheduled ? `${scheduled} scheduled` : '',\n ]\n .filter(Boolean)\n .join(', ')\n return (\n <Stack sx={{ alignItems: 'flex-end', minWidth: 0, width: 1 }}>\n <Typography variant=\"body2\">{String(sends)}</Typography>\n {note ? (\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {note}\n </Typography>\n ) : null}\n </Stack>\n )\n },\n },\n {\n field: 'sent',\n headerName: 'Mail sent',\n width: 112,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\">{figure(row.rollup.sent)}</Typography>\n ),\n },\n {\n field: 'opens',\n headerName: 'Mail opens',\n width: 112,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\">{figure(row.rollup.opens)}</Typography>\n ),\n },\n {\n field: 'clicks',\n headerName: 'Mail clicks',\n width: 112,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\">{figure(row.rollup.clicks)}</Typography>\n ),\n },\n /*\n THE TRAILING CLUSTER, through the grid's own actions column.\n `listActionsColumn` is what every other grid list in the console\n renders, so the reader cannot tell which family of table they are\n standing in — the hand-rolled tables on this surface reach the same\n `RowActionsMenu` from the other direction.\n\n Opening the campaign is restated here even though the row click does\n the same thing, for the reason the screens table restates its own: the\n menu is where a row's actions are NAMED, and an action absent from it\n reads as an action the row does not have.\n\n A \"Single send\" row is a SEND with no container — the table adopts it\n so a merchant's history is not missing — and there is no container\n under it to delete. Its entry is shown disabled with that reason\n rather than hidden, because a control that vanishes and one that does\n not apply look identical from the outside.\n */\n listActionsColumn(\n (row: any) => (\n <ListRowActions\n label={String(row.name ?? row.id)}\n items={[\n {\n key: 'details',\n label: 'Open campaign',\n icon: <MdiIcon path={mdiPageNextOutline.path} size={0.8} />,\n href: campaignHref(row.id) ?? undefined,\n disabled: !campaignHref(row.id),\n disabledReason: campaignHref(row.id)\n ? undefined\n : 'This site’s console URL has not resolved yet',\n },\n {\n key: 'delete',\n label: 'Delete campaign',\n icon: <MdiIcon path={mdiDeleteOutline.path} size={0.8} />,\n destructive: true,\n disabled:\n row.legacy || deleteBlocked || Boolean(row.deleteReach) || Boolean(deletingId),\n disabledReason: row.legacy\n ? 'This is a single send, not a campaign. Open it to ' +\n 'manage the email itself.'\n : deleteBlocked\n ? MARKETING_CAMPAIGNS_REFUSAL\n : row.deleteReach\n ? String(row.deleteReach)\n : 'A campaign is being deleted',\n onClick: () => void handleDelete(row as CampaignListRow),\n },\n ]}\n />\n ),\n { width: 72 },\n ),\n ],\n [listNames, campaignHref, deletingId, deleteBlocked, handleDelete, orgMount, filterHeaders],\n )\n\n /** Nothing of this kind stored at all — not a filter that matched nothing. */\n const none =\n page.status !== 'loading' && !rows.length && !filtering && page.page === 0\n\n /*\n * Other ways to start a campaign, from plugins (AGL-3603): the\n * `hostCampaigns` zone this plugin declares, drawn through the shell's own\n * gated slot. On the organization's hub it is handed the sites a campaign\n * could be placed on, since there is no one site to take.\n */\n const campaignsZone = (\n <HostCampaignsZone\n hostId={hostId}\n orgId={orgId}\n sites={\n hostId\n ? []\n : (orgMount?.hosts ?? []).map((host) => ({ id: host.id, name: host.name }))\n }\n />\n )\n\n return (\n <CardDisplay\n header={'Campaigns'}\n help={pluginDocsHelp('emailCampaigns', {\n anchor: '#campaigns-group-emails',\n excerpt:\n 'A campaign groups the emails you send to a set of lists over a ' +\n 'window of dates. Open one to write and send an email inside it.',\n })}\n HeaderProps={{\n action: (\n <Stack direction=\"row\" spacing={1}>\n {campaignsZone}\n <BlockedControl blocked={containersBlocked} reason={MARKETING_CAMPAIGNS_REFUSAL}>\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={creating}\n onClick={() => {\n setCreateError(null)\n setCreateOpen(true)\n }}\n >\n {creating ? 'Creating…' : 'Create campaign'}\n </Button>\n </BlockedControl>\n </Stack>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1.5}>\n <ToggleButtonGroup\n exclusive\n size=\"small\"\n value={kind}\n onChange={(_event, next: CampaignListKind | null) => {\n if (next) {\n setKind(next)\n setAskedSort(null)\n }\n }}\n aria-label=\"Which rows the table lists\"\n sx={{ alignSelf: 'flex-start' }}\n >\n <ToggleButton value=\"campaign\">{'Campaigns'}</ToggleButton>\n <ToggleButton value=\"single\">{'Single sends'}</ToggleButton>\n </ToggleButtonGroup>\n <ListFilterChips\n fields={declaration.fields}\n headers={filterHeaders}\n clauses={gridFilter.clauses}\n onChange={gridFilter.setClauses}\n options={filterOptions}\n />\n <ListQueryNotices\n refused={listQueryRefusals(page.plan.refused, {\n fields: declaration.fields,\n headers: filterHeaders,\n options: filterOptions,\n })}\n notices={[\n ...(siteSearch ? [CAMPAIGN_SITE_SEARCH_NOTICE] : []),\n ...page.plan.notices,\n ...columnSort.notices,\n ]}\n />\n <ListTable\n rows={columnSort.rows}\n columns={listFilterGridColumns(\n columns as any,\n declaration.fields,\n filterOptions,\n filterHeaders,\n )}\n onOpen={(id) => openCampaign(id)}\n loading={page.status === 'loading'}\n /*\n * The panel and the search are the grid's; every clause and the\n * search word are on the list's query (AGL-3321), and the grid\n * neither filters nor sorts the page it is handed: a stored\n * column's header orders the query, a drawn one the page\n * (AGL-3680).\n */\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n columnSort={columnSort}\n hideFooter\n initialState={{\n columns: {\n columnVisibilityModel: hiddenFilterVisibility(\n declaration.fields,\n (columns as Array<{ field: string }>).map((column) => column.field),\n ),\n },\n }}\n noRowsLabel={\n none\n ? kind === 'campaign'\n ? 'No campaigns yet'\n : 'No single sends'\n : kind === 'campaign'\n ? 'No campaigns match these filters'\n : 'No single sends match these filters'\n }\n noRowsDescription={\n none\n ? kind === 'campaign'\n ? 'A campaign groups the emails you send to a set of lists.'\n : 'An email filed under no campaign is listed here.'\n : undefined\n }\n noRowsAction={\n none && kind === 'campaign' ? (\n <Stack direction=\"row\" spacing={1}>\n {/* Other ways to start a campaign, the header's zone again. */}\n {campaignsZone}\n <BlockedControl blocked={containersBlocked} reason={MARKETING_CAMPAIGNS_REFUSAL}>\n <Button variant=\"contained\" onClick={() => setCreateOpen(true)}>\n {'Create campaign'}\n </Button>\n </BlockedControl>\n </Stack>\n ) : undefined\n }\n />\n <ListPagination\n page={page.page}\n pageSize={page.pageSize}\n rowCount={rows.length}\n hasMore={page.hasMore}\n onPageChange={page.setPage}\n onPageSizeChange={page.setPageSize}\n />\n {/*\n WHAT THIS TABLE MEASURES, said rather than inferred from the column\n names. Every figure in it is a fact about the campaign's mail, and a\n reader comparing rows is comparing mailings — the conversions and the\n destinations credited to a campaign are on the campaign's own page,\n because counting them for every row is a read per row on a list whose\n whole cost is two queries.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'These figures measure each campaign’s mail. What a campaign ' +\n 'caused — the form submissions, leads, contacts and bookings ' +\n 'credited to it — and the pages it sent people to are on the ' +\n 'campaign’s own page.'}\n </Typography>\n {rollupTruncated ? (\n <Alert severity=\"info\">\n {`The campaigns on this page hold more than ${ROLLUP_CEILING} ` +\n 'emails between them, so their figures count the first ' +\n `${ROLLUP_CEILING} read.`}\n </Alert>\n ) : null}\n </Stack>\n {/*\n The console's own create drawer, from the shared library rather than a\n second one that looks like it. What a campaign collects beyond a name\n is its window, the lists it is aimed at and the stream its emails open\n on; the description box is left off because the container stores none,\n and a field the writer discards is worse than one never offered.\n */}\n {/* Draws nothing: the zone the topic catalog's owner answers through. */}\n {topicSource}\n <CreateArtifactDrawer\n open={createOpen}\n onClose={() => setCreateOpen(false)}\n title=\"Create campaign\"\n submitLabel=\"Create campaign\"\n includeDescription={false}\n onSubmit={handleCreate}\n extraFields={campaignFields(\n listOptions,\n topicOptions,\n orgMount\n ? {\n sites: orgSiteOptions(orgMount).map((site) => ({\n id: site.value,\n name: site.label,\n })),\n ready: orgMount.hostsReady,\n }\n : null,\n )}\n componentMapper={CAMPAIGN_FORM_COMPONENTS}\n errorSlot={\n createError ? (\n <Alert severity=\"error\" sx={{ mt: 2, mb: 1 }}>\n {createError}\n </Alert>\n ) : null\n }\n />\n </CardDisplay>\n )\n}\n/** The create drawer's one field the shared form library has no component for. */\nconst CAMPAIGN_FORM_COMPONENTS = { [CAMPAIGN_SHARING_FIELD]: CampaignSharingFormField }\n\n/**\n * What a campaign collects beyond its name.\n *\n * Data-driven-forms field descriptors, built from the org's own lists and\n * topics so the drawer offers what this workspace actually has. Dates are\n * plain `date` inputs: a campaign window is a day at each end, and a time of\n * day would be a precision the model does not carry.\n */\nfunction campaignFields(\n lists: Array<{ value: string; label: string }>,\n topics: Array<{ value: string; label: string }>,\n /** The org's sites, on the org hub only — a site hub places on itself. */\n sites: { sites: Array<{ id: string; name: string }>; ready: boolean } | null,\n): any[] {\n return [\n /*\n * Who it is shared with (AGL-4047): radios and a visible list of sites,\n * never a dropdown, starting on All sites as the empty selection it\n * replaces did.\n */\n ...(sites\n ? [\n {\n component: CAMPAIGN_SHARING_FIELD,\n name: 'sharing',\n label: 'Shared with',\n initialValue: { mode: 'all' },\n helperText: 'The sites this campaign is offered on.',\n sites: sites.sites,\n sitesReady: sites.ready,\n },\n ]\n : []),\n {\n component: 'text-field',\n name: 'startAt',\n label: 'Starts',\n type: 'date',\n helperText: 'When the campaign window opens',\n },\n {\n component: 'text-field',\n name: 'endAt',\n label: 'Ends',\n type: 'date',\n helperText: 'Leave empty for an open-ended campaign',\n InputLabelProps: { shrink: true },\n },\n {\n component: 'select',\n name: 'listIds',\n label: 'Lists',\n multiple: true,\n initialValue: [],\n // A campaign with no list is legitimate: its emails can go to leads, to\n // site members, or to a segment. The lists are what it is AIMED at.\n helperText: 'The lists this campaign is aimed at',\n disableDefaultOption: true,\n options: lists,\n },\n {\n component: 'select',\n name: 'topicId',\n label: 'Topic',\n helperText: 'The stream its emails open on — each one can change it',\n disableDefaultOption: true,\n options: topics,\n },\n ]\n}\n\n/**\n * The Sites cell: where a campaign is offered.\n *\n * A container reads its `visibleTo`; a single send, which has no container,\n * is on the one site it was sent as. An empty placement is said rather than\n * left blank, because a blank cell reads as \"every site\" and it means none.\n */\nfunction campaignSitesLabel(\n mount: MarketingOrgMount,\n row: CampaignListRow,\n container: EmailCampaign | undefined,\n): string {\n if (row.legacy) return orgSiteName(mount, row.sends[0]?.hostId) || '—'\n // Shared with all sites except some: the sites it leaves out (AGL-4047).\n const allExcept = campaignAllExceptLabel(\n container,\n Object.fromEntries(orgSiteOptions(mount).map((site) => [site.value, site.label])),\n )\n if (allExcept) return allExcept\n const ids = campaignSiteIds(container)\n if (ids === null) return 'Every site'\n if (!ids.length) return 'No site'\n return ids.map((id) => orgSiteName(mount, id)).join(', ')\n}\n\nHostCampaignsCard.displayName = 'HostCampaignsCard'\n\nexport default HostCampaignsCard\n"],"names":["BlockedControl","MARKETING_CAMPAIGNS_REFUSAL","useCampaignListAccess","buildRoute","createResourceUid","pluginDocsHelp","Route","ceilingedWindow","collectionCeiling","useListQuery","mdiDeleteOutline","mdiPageNextOutline","AppLink","CardDisplay","MdiIcon","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","hiddenFilterVisibility","listFilterGridColumns","useListGridFilter","useListColumnSort","useSnackbar","Alert","Button","Chip","Stack","ToggleButton","ToggleButtonGroup","Typography","collection","limit","query","setDoc","where","useCallback","useMemo","useState","useRouter","useConsoleHostRoute","useFirestore","useFirestoreCollection","useUser","campaignAllExceptLabel","campaignListRows","campaignSharingWrite","campaignSiteIds","campaignSiteVisibleTo","CreateArtifactDrawer","CAMPAIGN_SITE_SEARCH_NOTICE","SINGLE_SENDS_BASE","campaignContainerSearchFields","campaignContainersListQuery","campaignContainersScope","campaignSendsScope","campaignSingleSendsListQuery","campaignSiteSearchClause","campaignContainerDoc","campaignContainersCollection","campaignSendsCollection","orgSiteName","orgSiteOptions","topicCatalogHostId","useMarketingOrgId","useMarketingOrgMount","useCampaignManageApi","CAMPAIGN_SHARING_FIELD","CampaignSharingFormField","HostCampaignsZone","useCampaignTopicOptions","ROLLUP_CEILING","IN_LIMIT","formatDay","ms","Date","toLocaleDateString","figure","value","toLocaleString","CAMPAIGN_PAGE_SORT_HEADERS","sitesLabel","windowState","listIds","emails","sent","opens","clicks","WINDOW_LABEL","undated","upcoming","running","ended","CAMPAIGN_FILTER_HEADERS","campaign","name","createdAtMs","single","NO_CLAUSES","HostCampaignsCard","props","hostId","basePath","firestore","router","orgSlug","subdomain","hubPath","HOST_PLUGIN","host","pluginSlug","data","user","enqueueSnackbar","confirm","orgMount","orgId","createBlocked","containersBlocked","deleteBlocked","deleteReachRefusal","manageApi","kind","setKind","askedSort","setAskedSort","clausesByKind","setClausesByKind","searchWords","setSearchWords","setKindClauses","next","current","gridFilter","clauses","onChange","selectFields","search","words","containerDeclaration","singleDeclaration","declaration","filterHeaders","siteSearch","containerPage","request","base","sort","deps","idField","singlePage","page","filtering","length","some","word","trim","pageIds","rows","map","row","String","$id","rollupRead","ids","sends","firstIds","slice","restIds","firstSendDocs","join","restSendDocs","firstSends","restSends","rollupTruncated","truncated","listDocs","createOpen","setCreateOpen","topics","source","topicSource","enabled","topicOptions","topic","id","label","listNames","names","Map","list","set","listOptions","read","order","at","built","now","byId","filter","has","a","b","get","campaignSitesLabel","deleteReach","legacy","pageSorts","startAtMs","endAtMs","rollup","columnSort","sorts","onSortChange","orderBy","plan","headers","filterOptions","sites","site","createError","setCreateError","creating","setCreating","deletingId","setDeletingId","openCampaign","push","handleCreate","values","placed","displayName","startAt","parse","endAt","sharing","mode","orgHostIds","hosts","hostsReady","fields","problem","visibleTo","Number","isFinite","Array","isArray","topicId","createdBy","uid","refusal","action","campaignId","choice","then","response","payload","ok","error","catch","variant","allowDuplicate","console","campaignHref","handleDelete","unfinished","scheduled","sending","agreed","title","description","confirmationText","persist","columns","field","headerName","flex","minWidth","renderCell","direction","spacing","sx","alignItems","width","href","onClick","event","stopPropagation","style","noWrap","size","flexShrink","sortable","start","end","range","color","align","headerAlign","note","Boolean","items","key","icon","path","undefined","disabled","disabledReason","destructive","none","status","campaignsZone","header","help","anchor","excerpt","HeaderProps","blocked","reason","contentGutterX","contentGutterY","exclusive","_event","aria-label","alignSelf","setClauses","options","refused","notices","onOpen","loading","filterMode","filterModel","onFilterModelChange","quickFilter","hideFooter","initialState","columnVisibilityModel","column","noRowsLabel","noRowsDescription","noRowsAction","pageSize","rowCount","hasMore","onPageChange","setPage","onPageSizeChange","setPageSize","severity","open","onClose","submitLabel","includeDescription","onSubmit","extraFields","campaignFields","ready","componentMapper","CAMPAIGN_FORM_COMPONENTS","errorSlot","mt","mb","lists","component","initialValue","helperText","sitesReady","type","InputLabelProps","shrink","multiple","disableDefaultOption","mount","container","allExcept","Object","fromEntries"],"mappings":"A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ACzE,MAAMkR,YAAY3U,uBAChB0U,WACAE,OAAOC,WAAW,CAAC3T,eAAeuT,OAAOtN,GAAG,CAAC,CAAC4D,OAAS;YAACA,KAAK7I,KAAK;YAAE6I,KAAKjC,KAAK;SAAC;IAEjF,IAAI6L,WAAW,OAAOA;IACtB,MAAMnN,MAAMrH,gBAAgBuU;IAC5B,IAAIlN,QAAQ,MAAM,OAAO;IACzB,IAAI,CAACA,IAAIX,MAAM,EAAE,OAAO;IACxB,OAAOW,IAAIL,GAAG,CAAC,CAAC0B,KAAO5H,YAAYwT,OAAO5L,KAAKf,IAAI,CAAC;AACtD;AAEAvE,kBAAkBoI,WAAW,GAAG;AAEhC,eAAepI,kBAAiB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaigns-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 { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { MARKETING_CAMPAIGNS_REFUSAL } from '../model/marketing-permissions'\nimport { useCampaignListAccess } from './use-campaign-containers-blocked'\nimport { buildRoute, createResourceUid, pluginDocsHelp, Route } from '@aglyn/aglyn'\n/*\n * The MODULE, not the barrel, for the two PURE helpers — a spec that mocks\n * `@aglyn/tenant-feature-instance` wholesale to stage its Firestore hooks\n * would otherwise lose them, and neither is a hook.\n */\nimport {\n ceilingedWindow,\n collectionCeiling,\n} from '@aglyn/tenant-feature-instance/hooks/host-collection-queries'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\nimport { mdiDeleteOutline, mdiPageNextOutline } from '@aglyn/shared-data-mdi'\nimport {\n AppLink,\n CardDisplay,\n MdiIcon,\n useConfirmationContext,\n} from '@aglyn/shared-ui-jsx'\nimport ListFilterChips from '@aglyn/shared-ui-jsx/components/list-filter-chips.component'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport ListQueryNotices, {\n listQueryRefusals,\n} from '@aglyn/shared-ui-jsx/components/list-query-notices.component'\nimport {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { hiddenFilterVisibility } from '@aglyn/shared-ui-jsx/const/list-filter'\nimport {\n type ListFilterClause,\n listFilterGridColumns,\n} from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\nimport { useListColumnSort } from '@aglyn/shared-ui-jsx/hooks/use-list-column-sort'\nimport type { ListQuerySort } from '@aglyn/shared-ui-jsx/const/list-query-plan'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n Alert,\n Button,\n Chip,\n Stack,\n ToggleButton,\n ToggleButtonGroup,\n Typography,\n} from '@mui/material'\nimport { collection, limit, query, setDoc, where } from 'firebase/firestore'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useRouter } from 'next/navigation'\nimport {\n useConsoleHostRoute,\n useFirestore,\n useFirestoreCollection,\n useUser,\n} from '@aglyn/tenant-feature-instance'\nimport {\n campaignAllExceptLabel,\n campaignListRows,\n campaignSharingWrite,\n campaignSiteIds,\n campaignSiteVisibleTo,\n type CampaignAggregate,\n type CampaignListRow,\n type CampaignSend,\n type EmailCampaign,\n} from '../model/campaign-container'\nimport { CreateArtifactDrawer } from '@aglyn/shared-ui-jsx-forms'\nimport {\n CAMPAIGN_SITE_SEARCH_NOTICE,\n SINGLE_SENDS_BASE,\n campaignContainerSearchFields,\n campaignContainersListQuery,\n campaignContainersScope,\n campaignSendsScope,\n campaignSingleSendsListQuery,\n campaignSiteSearchClause,\n} from '../model/campaign-list-query'\nimport {\n campaignContainerDoc,\n campaignContainersCollection,\n campaignSendsCollection,\n} from './campaign-queries'\nimport {\n orgSiteName,\n orgSiteOptions,\n topicCatalogHostId,\n useMarketingOrgId,\n useMarketingOrgMount,\n type MarketingOrgMount,\n} from './marketing-org-mount'\nimport { useCampaignManageApi } from './use-campaign-send-api'\nimport { CAMPAIGN_SHARING_FIELD, CampaignSharingFormField } from './campaign-sharing-form-field'\nimport type { ScopeSharingChoice } from '@aglyn/aglyn/app-utils/scope-tokens'\nimport { HostCampaignsZone } from './campaign-list-zones'\nimport { useCampaignTopicOptions } from './use-campaign-topic-options'\n\n/**\n * How many emails one read of a page's campaigns covers, for their figures.\n *\n * A ceiling on the ROLLUP read, not on the list: the list is paged by its\n * own query, and this reads the emails of the campaigns on the page on\n * screen, thirty campaigns to a read (`in` takes thirty ids), so the largest\n * page is two reads of this many. Past it, the figures say so.\n */\nconst ROLLUP_CEILING = 50\n\n/** Firestore's cap on an `in` clause's values. */\nconst IN_LIMIT = 30\n\n/** Which kind of row the table shows: the two are separate queries. */\ntype CampaignListKind = 'campaign' | 'single'\n\nconst formatDay = (ms: number | null): string =>\n ms === null ? '' : new Date(ms).toLocaleDateString()\n\n/** A rolled-up figure, or an em dash where nothing recorded one. */\nconst figure = (value: CampaignAggregate): string =>\n value.value === null ? '—' : value.value.toLocaleString()\n\n/*\n * EVERY HEADER SORTS (AGL-3680). A campaign's name and a single send's\n * subject order the kind's query (`declaration.sorts`); what a row is drawn\n * from — its sites, its window, its lists, and its figures (a campaign's\n * summed from its emails for the page, a send's counters absent until\n * something is counted) — sorts the page.\n */\nconst CAMPAIGN_PAGE_SORT_HEADERS = {\n sitesLabel: 'Sites',\n windowState: 'Window',\n listIds: 'Lists',\n emails: 'Emails',\n sent: 'Mail sent',\n opens: 'Mail opens',\n clicks: 'Mail clicks',\n}\n\nconst WINDOW_LABEL: Record<CampaignListRow['windowState'], string> = {\n undated: 'No dates',\n upcoming: 'Upcoming',\n running: 'Running',\n ended: 'Ended',\n}\n\n/*\n * What the campaigns grid's Filters panel offers, each clause and the search\n * on the list's Firestore query (AGL-3321, `campaignContainersListQuery` and\n * `campaignSingleSendsListQuery`). The Window column is derived from a\n * campaign's dates against the clock, which no query can ask, so it is not\n * offered; the one date range is Created, the list's own order.\n */\nconst CAMPAIGN_FILTER_HEADERS: Record<CampaignListKind, Readonly<Record<string, string>>> = {\n campaign: {\n name: 'Campaign',\n listIds: 'Lists',\n sitesLabel: 'Sites',\n createdAtMs: 'Created',\n },\n // A single send has no container; its `name` field filters by the subject.\n single: {\n name: 'Subject',\n sitesLabel: 'Sites',\n createdAtMs: 'Created',\n },\n}\nconst NO_CLAUSES: Record<CampaignListKind, ListFilterClause[]> = {\n campaign: [],\n single: [],\n}\n\n/**\n * THE CAMPAIGNS LIST.\n *\n * A campaign is a container — a name, a window, the lists it is aimed at, and\n * the emails sent inside it — so this is a table of campaigns and not of\n * messages. Composing is not here: a message belongs to a campaign, and the\n * campaign's own page is where one is written.\n *\n * The rows come from two collections. `emailCampaigns` holds the\n * containers. `campaigns` holds every send, including thousands written\n * before containers existed; those carry no container (`emailCampaignId`\n * null), and `campaignListRows` presents each as a campaign of one rather\n * than dropping it. The two are two queries, so the table lists one kind at a\n * time — Campaigns or Single sends — each paged by its own query (AGL-3321).\n * No send is re-filed, so no unsubscribe link and no pasted report URL stops\n * resolving.\n *\n * ## At two levels\n *\n * Both collections are the organization's. Under a site the card lists the\n * campaigns PLACED on that site and the sends sent AS it (see\n * `campaign-queries.ts` for why those filters are what make the read legal);\n * on the org hub, with `hostId` null, it lists every campaign with the sites\n * each one is placed on, and a new campaign is placed where its creator says.\n */\nexport function HostCampaignsCard(props: {\n /** The site, or `null` on the org Marketing hub. */\n hostId: string | null\n /**\n * The marketing hub URL, when the caller already has it.\n *\n * Resolved from the host route when it does not: the inbox console page\n * embeds this card on a tab of its own, and its `basePath` names the INBOX\n * hub. Deriving one hub's URL from another's by string surgery is the kind\n * of link that breaks silently when a surface moves.\n */\n basePath?: string\n}) {\n const { hostId, basePath } = props\n const firestore = useFirestore()\n const router = useRouter()\n const { orgSlug, subdomain } = useConsoleHostRoute(hostId)\n const hubPath =\n basePath ??\n (orgSlug && subdomain\n ? buildRoute(Route.HOST_PLUGIN, {\n orgSlug,\n host: subdomain,\n pluginSlug: 'marketing',\n })\n : null)\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { confirm } = useConfirmationContext()\n const orgMount = useMarketingOrgMount()\n const { orgId } = useMarketingOrgId(hostId)\n // \"Run email campaigns\" (AGL-4047): the container's create is client-direct,\n // so the rule asks it, and the button says so before the save does. Created\n // here it is placed on this site, so the site's verdict counts. A row's Delete\n // answers the manage route, which the same hook reads.\n const {\n createBlocked: containersBlocked,\n deleteBlocked,\n deleteReachRefusal,\n } = useCampaignListAccess(orgId, hostId)\n // A container is the org's, so deleting one from the org hub names the org.\n const manageApi = useCampaignManageApi(hostId, orgId)\n\n /*==========================================\n * TWO KINDS OF ROW, EACH ITS OWN QUERY (AGL-3321).\n *\n * A campaign is a CONTAINER (`emailCampaigns`); a single send is an email\n * filed under none (`campaigns` where `emailCampaignId == null`). The two\n * live in different collections, and one Firestore query reads one\n * collection — so a table that merged them could page neither, and every\n * filter would be matched over whatever window of each it happened to\n * hold. The toggle above the table picks the kind, and the table shows a\n * page of that kind's query: newest first on `createdAtMs`, every clause\n * and the search word on the query, paged by it. Same table, same\n * columns; a single send still reads as a campaign of one.\n *\n * Each kind keeps its own clauses (their Sites values differ: a campaign\n * is asked by scope token, a send by the site it was sent as); the search\n * words are the reader's and carry across.\n *=========================================*/\n const [kind, setKind] = useState<CampaignListKind>('campaign')\n // The header order asked of the kind on screen; a new kind starts unsorted.\n const [askedSort, setAskedSort] = useState<ListQuerySort | null>(null)\n const [clausesByKind, setClausesByKind] = useState(NO_CLAUSES)\n const [searchWords, setSearchWords] = useState<string[]>([])\n const setKindClauses = useCallback(\n (next: ListFilterClause[]) =>\n setClausesByKind((current) => ({ ...current, [kind]: next })),\n [kind],\n )\n const gridFilter = useListGridFilter({\n clauses: clausesByKind[kind],\n onChange: setKindClauses,\n selectFields: ['listIds', 'sitesLabel'],\n search: { words: searchWords, onChange: setSearchWords },\n })\n const containerDeclaration = campaignContainersListQuery(!hostId)\n const singleDeclaration = campaignSingleSendsListQuery(!hostId)\n const declaration = kind === 'campaign' ? containerDeclaration : singleDeclaration\n const filterHeaders = CAMPAIGN_FILTER_HEADERS[kind]\n /*\n * A site's campaigns are searched by the START of the name: a range beside\n * the site's scope clause, the one array clause the rules can prove for a\n * site collaborator (see `campaign-list-query.ts`). The org hub keeps the\n * word search.\n */\n const siteSearch =\n hostId && kind === 'campaign' ? campaignSiteSearchClause(gridFilter.searchWords) : null\n const containerPage = useListQuery<any>({\n collection:\n kind === 'campaign' ? campaignContainersCollection(firestore, orgId) : null,\n declaration: containerDeclaration,\n request: {\n clauses:\n kind === 'campaign'\n ? siteSearch\n ? [siteSearch, ...gridFilter.clauses]\n : gridFilter.clauses\n : [],\n search: hostId ? [] : gridFilter.searchWords,\n base: campaignContainersScope(hostId),\n sort: kind === 'campaign' ? askedSort : null,\n },\n deps: [firestore, orgId, hostId, kind],\n idField: '$id',\n })\n const singlePage = useListQuery<any>({\n collection: kind === 'single' ? campaignSendsCollection(firestore, orgId) : null,\n declaration: singleDeclaration,\n request: {\n clauses: kind === 'single' ? gridFilter.clauses : [],\n search: gridFilter.searchWords,\n base: [SINGLE_SENDS_BASE, ...campaignSendsScope(hostId)],\n sort: kind === 'single' ? askedSort : null,\n },\n deps: [firestore, orgId, hostId, kind],\n idField: '$id',\n })\n const page = kind === 'campaign' ? containerPage : singlePage\n const filtering =\n gridFilter.clauses.length > 0 ||\n gridFilter.searchWords.some((word) => word.trim())\n\n /*\n * THE FIGURES OF THE CAMPAIGNS ON THE PAGE ON SCREEN.\n *\n * A container stores no counters; its row sums the emails filed under it.\n * Those are read for the page's campaigns only — `emailCampaignId in` the\n * ids on screen, thirty to a read, and under a site the ones sent as it —\n * and never used to filter: the page is already the query's answer. Past\n * `ROLLUP_CEILING` emails a read stops, and the table says the figures\n * are partial.\n */\n const pageIds = useMemo(\n () =>\n kind === 'campaign'\n ? containerPage.rows.map((row: any) => String(row.$id))\n : [],\n [kind, containerPage.rows],\n )\n const rollupRead = (ids: string[]) => () => {\n const sends = campaignSendsCollection(firestore, orgId)\n if (!sends || !ids.length) return null\n return collectionCeiling(\n query(\n sends,\n where('emailCampaignId', 'in', ids),\n ...(hostId ? [where('hostId', '==', hostId)] : []),\n ),\n ROLLUP_CEILING,\n )\n }\n const firstIds = pageIds.slice(0, IN_LIMIT)\n const restIds = pageIds.slice(IN_LIMIT, IN_LIMIT * 2)\n const { data: firstSendDocs } = useFirestoreCollection<any>(\n rollupRead(firstIds),\n [firestore, orgId, hostId, firstIds.join(',')],\n { idField: '$id' },\n )\n const { data: restSendDocs } = useFirestoreCollection<any>(\n rollupRead(restIds),\n [firestore, orgId, hostId, restIds.join(',')],\n { idField: '$id' },\n )\n const firstSends = ceilingedWindow<any>(firstSendDocs, ROLLUP_CEILING)\n const restSends = ceilingedWindow<any>(restSendDocs, ROLLUP_CEILING)\n const rollupTruncated = firstSends.truncated || restSends.truncated\n\n // Org email lists, so a row can name what it is aimed at rather than\n // showing ids.\n const { data: listDocs } = useFirestoreCollection<any>(\n () =>\n orgId\n ? query(collection(firestore, 'orgs', orgId, 'lists'), limit(50))\n : null,\n [firestore, orgId],\n { idField: '$id' },\n )\n const [createOpen, setCreateOpen] = useState(false)\n /*\n * The org's topic catalog, read only while the CREATE DRAWER is open.\n *\n * It fills one picker in that drawer and is drawn nowhere in the table, so\n * a reader who came to look at their campaigns must not pay for it — the\n * same rule the emails list already applies to the campaigns it offers its\n * own drawer, and the one the audiences section applies to a list's\n * members. It is the largest read on this section at 200 documents, and it\n * is the only one nothing on screen needs.\n */\n const { topics, source: topicSource } = useCampaignTopicOptions(\n topicCatalogHostId(hostId, orgMount),\n { enabled: createOpen },\n )\n const topicOptions = useMemo(\n () =>\n topics.map((topic) => ({\n value: topic.id,\n label: topic.name,\n })),\n [topics],\n )\n\n const listNames = useMemo(() => {\n const names = new Map<string, string>()\n for (const list of listDocs ?? []) {\n names.set(String(list.$id), String(list.name ?? list.$id))\n }\n return names\n }, [listDocs])\n\n const listOptions = useMemo(\n () =>\n (listDocs ?? []).map((list: any) => ({\n value: String(list.$id),\n label: String(list.name ?? list.$id),\n })),\n [listDocs],\n )\n\n /*\n * The page's rows, in the QUERY's order. `campaignListRows` builds each\n * row — a container with its emails summed, or a single send as a\n * campaign of one — and sorts by date, which is not this list's order, so\n * the page is put back in the order the query returned it.\n */\n const rows = useMemo(() => {\n const read = page.rows as any[]\n const order = new Map(read.map((row, at) => [String(row.$id), at]))\n const built =\n kind === 'campaign'\n ? campaignListRows(\n read as EmailCampaign[],\n [...firstSends.rows, ...restSends.rows] as CampaignSend[],\n Date.now(),\n )\n : campaignListRows([], read as CampaignSend[], Date.now())\n const byId = new Map(read.map((row) => [String(row.$id), row]))\n return built\n .filter((row) => order.has(row.id))\n .sort((a, b) => (order.get(a.id) ?? 0) - (order.get(b.id) ?? 0))\n .map((row) => ({\n ...row,\n $id: row.id,\n sitesLabel: orgMount\n ? campaignSitesLabel(orgMount, row, byId.get(row.id))\n : '',\n /*\n * Why the site's own door would refuse this row's delete past the\n * key: a campaign on other sites too, or shared with all sites except\n * some, asks for access to every site (AGL-4047). Read off the row\n * already loaded, so it costs nothing.\n */\n deleteReach: row.legacy ? null : deleteReachRefusal(byId.get(row.id)),\n }))\n }, [kind, page.rows, firstSends.rows, restSends.rows, orgMount, deleteReachRefusal])\n\n const pageSorts = useMemo(\n () => ({\n sitesLabel: (row: any) => row.sitesLabel || null,\n windowState: (row: any) => row.startAtMs ?? row.endAtMs ?? null,\n listIds: (row: any) =>\n (row.listIds as string[]).map((id) => listNames.get(id) ?? id).join(', ') || null,\n emails: (row: any) => row.rollup.sends,\n sent: (row: any) => row.rollup.sent.value,\n opens: (row: any) => row.rollup.opens.value,\n clicks: (row: any) => row.rollup.clicks.value,\n }),\n [listNames],\n )\n const columnSort = useListColumnSort<any>({\n sorts: declaration.sorts,\n sort: askedSort,\n onSortChange: setAskedSort,\n orderBy: page.plan.orderBy,\n rows,\n pageSorts,\n headers: CAMPAIGN_PAGE_SORT_HEADERS,\n })\n\n /*\n * The choices the picked fields offer. A campaign's Sites are asked by\n * scope token — `org` is placed on every site — and a single send's by\n * the site it was sent as.\n */\n const filterOptions = useMemo(() => {\n if (!orgMount) return {}\n const sites = orgSiteOptions(orgMount)\n return kind === 'campaign'\n ? {\n listIds: listOptions,\n sitesLabel: [\n { value: 'org', label: 'Every site' },\n ...sites.map((site) => ({\n value: `host:${site.value}`,\n label: site.label,\n })),\n ],\n }\n : { sitesLabel: sites }\n }, [kind, listOptions, orgMount])\n\n const [createError, setCreateError] = useState<string | null>(null)\n const [creating, setCreating] = useState(false)\n /** The campaign a delete is in flight for, so its row menu can say so. */\n const [deletingId, setDeletingId] = useState('')\n\n const openCampaign = useCallback(\n (id: string) => {\n if (hubPath) void router.push(`${hubPath}/campaigns/${id}`)\n },\n [hubPath, router],\n )\n\n const handleCreate = useCallback(\n async (values: Record<string, any>) => {\n if (creating) return\n /*\n * `displayName` is the shared drawer's own field, and every artifact\n * create in the console collects a name under that key. The campaign\n * stores it as `name` — the container has one name and no second\n * internal label — so the mapping happens here rather than by giving\n * this one drawer a field the others do not have.\n */\n const name = String(values.displayName ?? '').trim()\n if (!name) return\n const startAtMs = values.startAt ? Date.parse(String(values.startAt)) : null\n const endAtMs = values.endAt ? Date.parse(String(values.endAt)) : null\n // Refused here rather than stored and rendered as a campaign that ends\n // before it starts, which no window state describes.\n if (startAtMs !== null && endAtMs !== null && endAtMs < startAtMs) {\n return setCreateError('The end date is before the start date')\n }\n /*\n * Held until the org is known. A container has one home, and a write\n * that raced the site's org lookup would have nowhere to go.\n */\n if (!orgId) {\n return setCreateError('This workspace is still loading — try again')\n }\n /*\n * Where it is placed. From a site's hub, that site — the creator is\n * standing on it, and a campaign that appeared on every sibling site\n * would be a decision nobody made. From the org hub, who it is shared\n * with, as the sharing field chose (AGL-4047): a choice that cannot be\n * stored is refused with the reason, never cut short — more than thirty\n * chosen sites used to keep the first thirty and say nothing.\n *\n * \"All sites except…\" is created on the sites it reaches today and then\n * marked by the manage route, the one writer of the marker: the rules\n * refuse it on a client create. Until the route answers it is exactly\n * a campaign on those sites, never on a site that was left out.\n *\n * A refused choice is handed back to the sharing field, which says why\n * beside itself and stops once the choice changes; the drawer keeps\n * exactly what was chosen (production check 11/10).\n */\n const sharing = hostId\n ? null\n : ((values.sharing as ScopeSharingChoice | undefined) ?? { mode: 'all' as const })\n const orgHostIds = (orgMount?.hosts ?? []).map((site) => site.id)\n const placed = sharing ? campaignSharingWrite(sharing, orgHostIds) : null\n if (sharing && sharing.mode !== 'all' && !orgMount?.hostsReady) {\n setCreateError(null)\n return { sharing: 'This workspace’s sites are still loading — try again' }\n }\n if (placed && !placed.fields) {\n setCreateError(null)\n return { sharing: placed.problem }\n }\n const visibleTo = hostId\n ? campaignSiteVisibleTo(hostId)\n : (placed?.fields?.visibleTo ?? [])\n setCreating(true)\n setCreateError(null)\n const id = createResourceUid()\n try {\n await setDoc(campaignContainerDoc(firestore, orgId, id), {\n name,\n // What the list's search reads (AGL-3321), from the name.\n ...campaignContainerSearchFields(name),\n ...(Number.isFinite(startAtMs) && startAtMs !== null\n ? { startAtMs }\n : {}),\n ...(Number.isFinite(endAtMs) && endAtMs !== null ? { endAtMs } : {}),\n listIds: Array.isArray(values.listIds)\n ? values.listIds.map(String)\n : [],\n ...(values.topicId ? { topicId: String(values.topicId) } : {}),\n visibleTo,\n createdAtMs: Date.now(),\n createdBy: String((user as any)?.uid ?? ''),\n })\n if (sharing?.mode === 'allExcept') {\n // The campaign exists either way, so a refusal here is said, never\n // reported as a create that failed.\n const refusal = await manageApi({\n action: 'setSharing',\n campaignId: id,\n choice: sharing,\n })\n .then(({ response, payload }) =>\n response.ok ? null : String(payload?.error ?? 'the sharing was refused'),\n )\n .catch(() => 'the sharing could not be saved')\n if (refusal) {\n enqueueSnackbar(\n 'The campaign was created on the sites it reaches today, but a ' +\n `new site will not get it: ${refusal}`,\n { variant: 'warning', allowDuplicate: true },\n )\n }\n }\n setCreateOpen(false)\n openCampaign(id)\n } catch (error) {\n console.error(error)\n setCreateError('The campaign could not be created')\n enqueueSnackbar('Could not create the campaign', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setCreating(false)\n }\n },\n [creating, firestore, hostId, orgId, orgMount, user, enqueueSnackbar, manageApi, openCampaign],\n )\n\n const campaignHref = useCallback(\n (id: string) => (hubPath ? `${hubPath}/campaigns/${id}` : null),\n [hubPath],\n )\n\n /*==========================================\n * DELETING A CAMPAIGN FROM ITS ROW.\n *\n * The container goes and its emails stay — the route detaches them first,\n * so each one keeps its id, its report and its unsubscribe links, and\n * reappears in this very table as a \"Single send\". That is not a\n * convenience: a send id is inside the HMAC of every unsubscribe footer\n * already delivered, so a delete that took the sends with it would break\n * opt-outs that must go on working.\n *\n * The confirmation names the count and says what the delete does NOT do.\n * Deleting a campaign cancels nothing — a scheduled email inside it still\n * goes out — and a merchant who reads the button as \"stop this campaign\"\n * has to be told before they press it.\n *\n * EDITING is deliberately not offered here. A record is edited on its own\n * page in this console; the campaign's page carries the edit drawer, and\n * this row's first entry is the way to it.\n *=========================================*/\n const handleDelete = useCallback(\n async (row: CampaignListRow) => {\n if (deletingId) return\n const emails = row.sends.length\n /*\n * Emails with mail still to go: waiting for their time, AND part way\n * through an audience larger than one batch. Counting only `scheduled`\n * would miss the case that needs the warning most — an email delivering\n * right now is stored as `scheduled` too, and `rollup.scheduled` is the\n * narrower reading that leaves it out.\n */\n const unfinished = row.rollup.scheduled + row.rollup.sending\n const agreed = await confirm({\n title: `Delete ${row.name}?`,\n description:\n (emails\n ? `The ${emails.toLocaleString()} ` +\n `${emails === 1 ? 'email' : 'emails'} in it are kept — each ` +\n 'keeps its own report and its unsubscribe links, and they stay ' +\n 'in this list as single sends. '\n : 'It holds no emails. ') +\n (unfinished\n ? `${unfinished.toLocaleString()} of them ${\n unfinished === 1 ? 'is' : 'are'\n } still going out or still due, and deleting the campaign does ` +\n 'not stop that — the sender picks each one up from its own ' +\n 'record. Stop a send from its own page. '\n : '') +\n 'Any pages, forms and contacts assigned to it come out of it and ' +\n 'are otherwise untouched. Only the campaign itself goes.',\n confirmationText: 'Delete campaign',\n })\n .then(() => true)\n .catch(() => false)\n if (!agreed) return\n setDeletingId(row.id)\n try {\n const { response, payload } = await manageApi({\n action: 'deleteCampaign',\n campaignId: row.id,\n })\n if (!response.ok) {\n return void enqueueSnackbar(\n payload?.error ?? 'The campaign could not be deleted',\n { variant: 'warning', allowDuplicate: true },\n )\n }\n enqueueSnackbar('Campaign deleted', {\n variant: 'success',\n persist: false,\n })\n } catch (error) {\n console.error(error)\n enqueueSnackbar('The campaign could not be deleted', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setDeletingId('')\n }\n },\n [confirm, deletingId, enqueueSnackbar, manageApi],\n )\n\n const columns = useMemo(\n () => [\n {\n field: 'name',\n headerName: filterHeaders.name,\n flex: 1,\n minWidth: 180,\n renderCell: ({ row }: any) => (\n <Stack\n direction=\"row\"\n spacing={1}\n /*\n `minWidth: 0` on the row AND on the name: a flex child will not\n shrink below its content without it, so the chip beside it is\n what gets clipped instead of the name being ellipsed.\n */\n sx={{ alignItems: 'center', minWidth: 0, width: 1 }}\n >\n {/*\n The name is a real anchor as well as the row being clickable, so\n a campaign can be middle-clicked into a tab or copied out of the\n context menu — affordances a row handler cannot offer. The grid's\n own row click fires too, so the link stops the event rather than\n pushing the same route twice.\n */}\n {campaignHref(row.id) ? (\n <AppLink\n href={campaignHref(row.id) as string}\n onClick={(event: { stopPropagation: () => void }) =>\n event.stopPropagation()\n }\n style={{ minWidth: 0 }}\n >\n <Typography variant=\"body2\" noWrap>\n {row.name}\n </Typography>\n </AppLink>\n ) : (\n <Typography variant=\"body2\" noWrap sx={{ minWidth: 0 }}>\n {row.name}\n </Typography>\n )}\n {row.legacy ? (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label=\"Single send\"\n // A label that reads \"Single sen\" is worse than a shorter name.\n sx={{ flexShrink: 0 }}\n title={\n 'Sent before campaigns grouped their emails. Its report ' +\n 'and its unsubscribe links are unchanged.'\n }\n />\n ) : null}\n </Stack>\n ),\n },\n /*\n WHERE IT IS PLACED, on the org hub only. Under a site every row is on\n that site by construction, so the column would say one thing thirty\n times.\n */\n ...(orgMount\n ? [\n {\n field: 'sitesLabel',\n headerName: 'Sites',\n width: 170,\n sortable: false,\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\" noWrap>\n {row.sitesLabel}\n </Typography>\n ),\n },\n ]\n : []),\n {\n field: 'windowState',\n headerName: 'Window',\n width: 170,\n renderCell: ({ row }: any) => {\n const start = formatDay(row.startAtMs)\n const end = formatDay(row.endAtMs)\n const range =\n start && end && start !== end\n ? `${start} – ${end}`\n : start || end || ''\n return (\n <Stack sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {WINDOW_LABEL[row.windowState as CampaignListRow['windowState']]}\n </Typography>\n {range ? (\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {range}\n </Typography>\n ) : null}\n </Stack>\n )\n },\n },\n {\n field: 'listIds',\n headerName: 'Lists',\n width: 140,\n sortable: false,\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\" noWrap>\n {row.listIds.length\n ? row.listIds\n .map((id: string) => listNames.get(id) ?? id)\n .join(', ')\n : '—'}\n </Typography>\n ),\n },\n /*\n THE FOUR COUNTS, RIGHT-ALIGNED HEAD AND BODY.\n A figure is read by its last digit, so a column of them lines up on\n the right or it does not line up at all. `headerAlign` has to be said\n as well as `align`: a grid column defaults its header to the column\n type's alignment rather than to the cell's, which is how these came to\n sit with left headers over figures nobody could compare down the page.\n\n EVERY ONE OF THEM MEASURES THE MAIL, and the headings say so. What a\n campaign CAUSED — the submissions, leads, contacts and bookings\n credited to it — is not a column here, because there is no figure to\n read: a container has no conversion counter of its own, so a column\n would be an aggregation per row for a campaign and a subcollection\n document per row for a single send, on a list that costs two queries\n however many campaigns it holds. Headings that named the campaign over\n figures that all described its mail were the cheaper mistake, so the\n headings name the mail and the note under the table says where the\n outcome figures are.\n */\n {\n field: 'emails',\n headerName: 'Emails',\n width: 128,\n align: 'right',\n headerAlign: 'right',\n /*\n THE COUNT, AND WHAT IS STILL HAPPENING TO IT.\n\n `sending` is called out apart from `scheduled` because the two are\n opposite readings of the same stored status: an email delivering an\n audience larger than one batch sits as `scheduled` between runs, and\n rolling it in with the ones that have mailed nobody reports a\n campaign that is half delivered as a campaign that has not started.\n\n The note sits UNDER the figure rather than beside it — the column\n would otherwise have to be wide enough for the longest sentence, and\n the figure is what the column is read for.\n */\n renderCell: ({ row }: any) => {\n const { sends, sending, scheduled } = row.rollup\n const note = [\n sending ? `${sending} sending` : '',\n scheduled ? `${scheduled} scheduled` : '',\n ]\n .filter(Boolean)\n .join(', ')\n return (\n <Stack sx={{ alignItems: 'flex-end', minWidth: 0, width: 1 }}>\n <Typography variant=\"body2\">{String(sends)}</Typography>\n {note ? (\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {note}\n </Typography>\n ) : null}\n </Stack>\n )\n },\n },\n {\n field: 'sent',\n headerName: 'Mail sent',\n width: 112,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\">{figure(row.rollup.sent)}</Typography>\n ),\n },\n {\n field: 'opens',\n headerName: 'Mail opens',\n width: 112,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\">{figure(row.rollup.opens)}</Typography>\n ),\n },\n {\n field: 'clicks',\n headerName: 'Mail clicks',\n width: 112,\n align: 'right',\n headerAlign: 'right',\n renderCell: ({ row }: any) => (\n <Typography variant=\"body2\">{figure(row.rollup.clicks)}</Typography>\n ),\n },\n /*\n THE TRAILING CLUSTER, through the grid's own actions column.\n `listActionsColumn` is what every other grid list in the console\n renders, so the reader cannot tell which family of table they are\n standing in — the hand-rolled tables on this surface reach the same\n `RowActionsMenu` from the other direction.\n\n Opening the campaign is restated here even though the row click does\n the same thing, for the reason the screens table restates its own: the\n menu is where a row's actions are NAMED, and an action absent from it\n reads as an action the row does not have.\n\n A \"Single send\" row is a SEND with no container — the table adopts it\n so a merchant's history is not missing — and there is no container\n under it to delete. Its entry is shown disabled with that reason\n rather than hidden, because a control that vanishes and one that does\n not apply look identical from the outside.\n */\n listActionsColumn(\n (row: any) => (\n <ListRowActions\n label={String(row.name ?? row.id)}\n items={[\n {\n key: 'details',\n label: 'Open campaign',\n icon: <MdiIcon path={mdiPageNextOutline.path} size={0.8} />,\n href: campaignHref(row.id) ?? undefined,\n disabled: !campaignHref(row.id),\n disabledReason: campaignHref(row.id)\n ? undefined\n : 'This site’s console URL has not resolved yet',\n },\n {\n key: 'delete',\n label: 'Delete campaign',\n icon: <MdiIcon path={mdiDeleteOutline.path} size={0.8} />,\n destructive: true,\n disabled:\n row.legacy || deleteBlocked || Boolean(row.deleteReach) || Boolean(deletingId),\n disabledReason: row.legacy\n ? 'This is a single send, not a campaign. Open it to ' +\n 'manage the email itself.'\n : deleteBlocked\n ? MARKETING_CAMPAIGNS_REFUSAL\n : row.deleteReach\n ? String(row.deleteReach)\n : 'A campaign is being deleted',\n onClick: () => void handleDelete(row as CampaignListRow),\n },\n ]}\n />\n ),\n { width: 72 },\n ),\n ],\n [listNames, campaignHref, deletingId, deleteBlocked, handleDelete, orgMount, filterHeaders],\n )\n\n /** Nothing of this kind stored at all — not a filter that matched nothing. */\n const none =\n page.status !== 'loading' && !rows.length && !filtering && page.page === 0\n\n /*\n * Other ways to start a campaign, from plugins (AGL-3603): the\n * `hostCampaigns` zone this plugin declares, drawn through the shell's own\n * gated slot. On the organization's hub it is handed the sites a campaign\n * could be placed on, since there is no one site to take.\n */\n const campaignsZone = (\n <HostCampaignsZone\n hostId={hostId}\n orgId={orgId}\n sites={\n hostId\n ? []\n : (orgMount?.hosts ?? []).map((host) => ({ id: host.id, name: host.name }))\n }\n />\n )\n\n return (\n <CardDisplay\n header={'Campaigns'}\n help={pluginDocsHelp('emailCampaigns', {\n anchor: '#campaigns-group-emails',\n excerpt:\n 'A campaign groups the emails you send to a set of lists over a ' +\n 'window of dates. Open one to write and send an email inside it.',\n })}\n HeaderProps={{\n action: (\n <Stack direction=\"row\" spacing={1}>\n {campaignsZone}\n <BlockedControl blocked={containersBlocked} reason={MARKETING_CAMPAIGNS_REFUSAL}>\n <Button\n size=\"small\"\n variant=\"contained\"\n disabled={creating}\n onClick={() => {\n setCreateError(null)\n setCreateOpen(true)\n }}\n >\n {creating ? 'Creating…' : 'Create campaign'}\n </Button>\n </BlockedControl>\n </Stack>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={1.5}>\n <ToggleButtonGroup\n exclusive\n size=\"small\"\n value={kind}\n onChange={(_event, next: CampaignListKind | null) => {\n if (next) {\n setKind(next)\n setAskedSort(null)\n }\n }}\n aria-label=\"Which rows the table lists\"\n sx={{ alignSelf: 'flex-start' }}\n >\n <ToggleButton value=\"campaign\">{'Campaigns'}</ToggleButton>\n <ToggleButton value=\"single\">{'Single sends'}</ToggleButton>\n </ToggleButtonGroup>\n <ListFilterChips\n fields={declaration.fields}\n headers={filterHeaders}\n clauses={gridFilter.clauses}\n onChange={gridFilter.setClauses}\n options={filterOptions}\n />\n <ListQueryNotices\n refused={listQueryRefusals(page.plan.refused, {\n fields: declaration.fields,\n headers: filterHeaders,\n options: filterOptions,\n })}\n notices={[\n ...(siteSearch ? [CAMPAIGN_SITE_SEARCH_NOTICE] : []),\n ...page.plan.notices,\n ...columnSort.notices,\n ]}\n />\n <ListTable\n rows={columnSort.rows}\n columns={listFilterGridColumns(\n columns as any,\n declaration.fields,\n filterOptions,\n filterHeaders,\n )}\n onOpen={(id) => openCampaign(id)}\n loading={page.status === 'loading'}\n /*\n * The panel and the search are the grid's; every clause and the\n * search word are on the list's query (AGL-3321), and the grid\n * neither filters nor sorts the page it is handed: a stored\n * column's header orders the query, a drawn one the page\n * (AGL-3680).\n */\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n columnSort={columnSort}\n hideFooter\n initialState={{\n columns: {\n columnVisibilityModel: hiddenFilterVisibility(\n declaration.fields,\n (columns as Array<{ field: string }>).map((column) => column.field),\n ),\n },\n }}\n noRowsLabel={\n none\n ? kind === 'campaign'\n ? 'No campaigns yet'\n : 'No single sends'\n : kind === 'campaign'\n ? 'No campaigns match these filters'\n : 'No single sends match these filters'\n }\n noRowsDescription={\n none\n ? kind === 'campaign'\n ? 'A campaign groups the emails you send to a set of lists.'\n : 'An email filed under no campaign is listed here.'\n : undefined\n }\n noRowsAction={\n none && kind === 'campaign' ? (\n <Stack direction=\"row\" spacing={1}>\n {/* Other ways to start a campaign, the header's zone again. */}\n {campaignsZone}\n <BlockedControl blocked={containersBlocked} reason={MARKETING_CAMPAIGNS_REFUSAL}>\n <Button variant=\"contained\" onClick={() => setCreateOpen(true)}>\n {'Create campaign'}\n </Button>\n </BlockedControl>\n </Stack>\n ) : undefined\n }\n />\n <ListPagination\n page={page.page}\n pageSize={page.pageSize}\n rowCount={rows.length}\n hasMore={page.hasMore}\n onPageChange={page.setPage}\n onPageSizeChange={page.setPageSize}\n />\n {/*\n WHAT THIS TABLE MEASURES, said rather than inferred from the column\n names. Every figure in it is a fact about the campaign's mail, and a\n reader comparing rows is comparing mailings — the conversions and the\n destinations credited to a campaign are on the campaign's own page,\n because counting them for every row is a read per row on a list whose\n whole cost is two queries.\n */}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'These figures measure each campaign’s mail. What a campaign ' +\n 'caused — the form submissions, leads, contacts and bookings ' +\n 'credited to it — and the pages it sent people to are on the ' +\n 'campaign’s own page.'}\n </Typography>\n {rollupTruncated ? (\n <Alert severity=\"info\">\n {`The campaigns on this page hold more than ${ROLLUP_CEILING} ` +\n 'emails between them, so their figures count the first ' +\n `${ROLLUP_CEILING} read.`}\n </Alert>\n ) : null}\n </Stack>\n {/*\n The console's own create drawer, from the shared library rather than a\n second one that looks like it. What a campaign collects beyond a name\n is its window, the lists it is aimed at and the stream its emails open\n on; the description box is left off because the container stores none,\n and a field the writer discards is worse than one never offered.\n */}\n {/* Draws nothing: the zone the topic catalog's owner answers through. */}\n {topicSource}\n <CreateArtifactDrawer\n open={createOpen}\n onClose={() => setCreateOpen(false)}\n title=\"Create campaign\"\n submitLabel=\"Create campaign\"\n includeDescription={false}\n onSubmit={handleCreate}\n extraFields={campaignFields(\n listOptions,\n topicOptions,\n orgMount\n ? {\n sites: orgSiteOptions(orgMount).map((site) => ({\n id: site.value,\n name: site.label,\n })),\n ready: orgMount.hostsReady,\n }\n : null,\n )}\n componentMapper={CAMPAIGN_FORM_COMPONENTS}\n errorSlot={\n createError ? (\n <Alert severity=\"error\" sx={{ mt: 2, mb: 1 }}>\n {createError}\n </Alert>\n ) : null\n }\n />\n </CardDisplay>\n )\n}\n/** The create drawer's one field the shared form library has no component for. */\nconst CAMPAIGN_FORM_COMPONENTS = { [CAMPAIGN_SHARING_FIELD]: CampaignSharingFormField }\n\n/**\n * What a campaign collects beyond its name.\n *\n * Data-driven-forms field descriptors, built from the org's own lists and\n * topics so the drawer offers what this workspace actually has. Dates are\n * plain `date` inputs: a campaign window is a day at each end, and a time of\n * day would be a precision the model does not carry.\n */\nfunction campaignFields(\n lists: Array<{ value: string; label: string }>,\n topics: Array<{ value: string; label: string }>,\n /** The org's sites, on the org hub only — a site hub places on itself. */\n sites: { sites: Array<{ id: string; name: string }>; ready: boolean } | null,\n): any[] {\n return [\n /*\n * Who it is shared with (AGL-4047): radios and a visible list of sites,\n * never a dropdown, starting on All sites as the empty selection it\n * replaces did.\n */\n ...(sites\n ? [\n {\n component: CAMPAIGN_SHARING_FIELD,\n name: 'sharing',\n label: 'Shared with',\n initialValue: { mode: 'all' },\n helperText: 'The sites this campaign is offered on.',\n sites: sites.sites,\n sitesReady: sites.ready,\n },\n ]\n : []),\n {\n component: 'text-field',\n name: 'startAt',\n label: 'Starts',\n type: 'date',\n helperText: 'When the campaign window opens',\n },\n {\n component: 'text-field',\n name: 'endAt',\n label: 'Ends',\n type: 'date',\n helperText: 'Leave empty for an open-ended campaign',\n InputLabelProps: { shrink: true },\n },\n {\n component: 'select',\n name: 'listIds',\n label: 'Lists',\n multiple: true,\n initialValue: [],\n // A campaign with no list is legitimate: its emails can go to leads, to\n // site members, or to a segment. The lists are what it is AIMED at.\n helperText: 'The lists this campaign is aimed at',\n disableDefaultOption: true,\n options: lists,\n },\n {\n component: 'select',\n name: 'topicId',\n label: 'Topic',\n helperText: 'The stream its emails open on — each one can change it',\n disableDefaultOption: true,\n options: topics,\n },\n ]\n}\n\n/**\n * The Sites cell: where a campaign is offered.\n *\n * A container reads its `visibleTo`; a single send, which has no container,\n * is on the one site it was sent as. An empty placement is said rather than\n * left blank, because a blank cell reads as \"every site\" and it means none.\n */\nfunction campaignSitesLabel(\n mount: MarketingOrgMount,\n row: CampaignListRow,\n container: EmailCampaign | undefined,\n): string {\n if (row.legacy) return orgSiteName(mount, row.sends[0]?.hostId) || '—'\n // Shared with all sites except some: the sites it leaves out (AGL-4047).\n const allExcept = campaignAllExceptLabel(\n container,\n Object.fromEntries(orgSiteOptions(mount).map((site) => [site.value, site.label])),\n )\n if (allExcept) return allExcept\n const ids = campaignSiteIds(container)\n if (ids === null) return 'Every site'\n if (!ids.length) return 'No site'\n return ids.map((id) => orgSiteName(mount, id)).join(', ')\n}\n\nHostCampaignsCard.displayName = 'HostCampaignsCard'\n\nexport default HostCampaignsCard\n"],"names":["BlockedControl","MARKETING_CAMPAIGNS_REFUSAL","useCampaignListAccess","buildRoute","createResourceUid","pluginDocsHelp","Route","ceilingedWindow","collectionCeiling","useListQuery","mdiDeleteOutline","mdiPageNextOutline","AppLink","CardDisplay","MdiIcon","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","hiddenFilterVisibility","listFilterGridColumns","useListGridFilter","useListColumnSort","useSnackbar","Alert","Button","Chip","Stack","ToggleButton","ToggleButtonGroup","Typography","collection","limit","query","setDoc","where","useCallback","useMemo","useState","useRouter","useConsoleHostRoute","useFirestore","useFirestoreCollection","useUser","campaignAllExceptLabel","campaignListRows","campaignSharingWrite","campaignSiteIds","campaignSiteVisibleTo","CreateArtifactDrawer","CAMPAIGN_SITE_SEARCH_NOTICE","SINGLE_SENDS_BASE","campaignContainerSearchFields","campaignContainersListQuery","campaignContainersScope","campaignSendsScope","campaignSingleSendsListQuery","campaignSiteSearchClause","campaignContainerDoc","campaignContainersCollection","campaignSendsCollection","orgSiteName","orgSiteOptions","topicCatalogHostId","useMarketingOrgId","useMarketingOrgMount","useCampaignManageApi","CAMPAIGN_SHARING_FIELD","CampaignSharingFormField","HostCampaignsZone","useCampaignTopicOptions","ROLLUP_CEILING","IN_LIMIT","formatDay","ms","Date","toLocaleDateString","figure","value","toLocaleString","CAMPAIGN_PAGE_SORT_HEADERS","sitesLabel","windowState","listIds","emails","sent","opens","clicks","WINDOW_LABEL","undated","upcoming","running","ended","CAMPAIGN_FILTER_HEADERS","campaign","name","createdAtMs","single","NO_CLAUSES","HostCampaignsCard","props","hostId","basePath","firestore","router","orgSlug","subdomain","hubPath","HOST_PLUGIN","host","pluginSlug","data","user","enqueueSnackbar","confirm","orgMount","orgId","createBlocked","containersBlocked","deleteBlocked","deleteReachRefusal","manageApi","kind","setKind","askedSort","setAskedSort","clausesByKind","setClausesByKind","searchWords","setSearchWords","setKindClauses","next","current","gridFilter","clauses","onChange","selectFields","search","words","containerDeclaration","singleDeclaration","declaration","filterHeaders","siteSearch","containerPage","request","base","sort","deps","idField","singlePage","page","filtering","length","some","word","trim","pageIds","rows","map","row","String","$id","rollupRead","ids","sends","firstIds","slice","restIds","firstSendDocs","join","restSendDocs","firstSends","restSends","rollupTruncated","truncated","listDocs","createOpen","setCreateOpen","topics","source","topicSource","enabled","topicOptions","topic","id","label","listNames","names","Map","list","set","listOptions","read","order","at","built","now","byId","filter","has","a","b","get","campaignSitesLabel","deleteReach","legacy","pageSorts","startAtMs","endAtMs","rollup","columnSort","sorts","onSortChange","orderBy","plan","headers","filterOptions","sites","site","createError","setCreateError","creating","setCreating","deletingId","setDeletingId","openCampaign","push","handleCreate","values","placed","displayName","startAt","parse","endAt","sharing","mode","orgHostIds","hosts","hostsReady","fields","problem","visibleTo","Number","isFinite","Array","isArray","topicId","createdBy","uid","refusal","action","campaignId","choice","then","response","payload","ok","error","catch","variant","allowDuplicate","console","campaignHref","handleDelete","unfinished","scheduled","sending","agreed","title","description","confirmationText","persist","columns","field","headerName","flex","minWidth","renderCell","direction","spacing","sx","alignItems","width","href","onClick","event","stopPropagation","style","noWrap","size","flexShrink","sortable","start","end","range","color","align","headerAlign","note","Boolean","items","key","icon","path","undefined","disabled","disabledReason","destructive","none","status","campaignsZone","header","help","anchor","excerpt","HeaderProps","blocked","reason","contentGutterX","contentGutterY","exclusive","_event","aria-label","alignSelf","setClauses","options","refused","notices","onOpen","loading","filterMode","filterModel","onFilterModelChange","quickFilter","hideFooter","initialState","columnVisibilityModel","column","noRowsLabel","noRowsDescription","noRowsAction","pageSize","rowCount","hasMore","onPageChange","setPage","onPageSizeChange","setPageSize","severity","open","onClose","submitLabel","includeDescription","onSubmit","extraFields","campaignFields","ready","componentMapper","CAMPAIGN_FORM_COMPONENTS","errorSlot","mt","mb","lists","component","initialValue","helperText","sitesReady","type","InputLabelProps","shrink","multiple","disableDefaultOption","mount","container","allExcept","Object","fromEntries"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,2BAA2B,QAAQ,oCAAgC;AAC5E,SAASC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