@aglyn/plugins-marketing 1.0.0-beta.143

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.
Files changed (183) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +7 -0
  3. package/package.json +56 -0
  4. package/src/index.d.ts +19 -0
  5. package/src/index.js +20 -0
  6. package/src/index.js.map +1 -0
  7. package/src/lib/components/announcement-bar-card.component.d.ts +20 -0
  8. package/src/lib/components/announcement-bar-card.component.js +292 -0
  9. package/src/lib/components/announcement-bar-card.component.js.map +1 -0
  10. package/src/lib/components/campaign-composer.d.ts +84 -0
  11. package/src/lib/components/campaign-composer.js +1643 -0
  12. package/src/lib/components/campaign-composer.js.map +1 -0
  13. package/src/lib/components/campaign-conversions-card.d.ts +22 -0
  14. package/src/lib/components/campaign-conversions-card.js +642 -0
  15. package/src/lib/components/campaign-conversions-card.js.map +1 -0
  16. package/src/lib/components/campaign-detail-card.d.ts +55 -0
  17. package/src/lib/components/campaign-detail-card.js +771 -0
  18. package/src/lib/components/campaign-detail-card.js.map +1 -0
  19. package/src/lib/components/campaign-edit-drawer.d.ts +60 -0
  20. package/src/lib/components/campaign-edit-drawer.js +252 -0
  21. package/src/lib/components/campaign-edit-drawer.js.map +1 -0
  22. package/src/lib/components/campaign-email-zones.d.ts +111 -0
  23. package/src/lib/components/campaign-email-zones.js +54 -0
  24. package/src/lib/components/campaign-email-zones.js.map +1 -0
  25. package/src/lib/components/campaign-glance-card.component.d.ts +18 -0
  26. package/src/lib/components/campaign-glance-card.component.js +151 -0
  27. package/src/lib/components/campaign-glance-card.component.js.map +1 -0
  28. package/src/lib/components/campaign-members-section.d.ts +87 -0
  29. package/src/lib/components/campaign-members-section.js +499 -0
  30. package/src/lib/components/campaign-members-section.js.map +1 -0
  31. package/src/lib/components/campaign-reach-sections.d.ts +137 -0
  32. package/src/lib/components/campaign-reach-sections.js +694 -0
  33. package/src/lib/components/campaign-reach-sections.js.map +1 -0
  34. package/src/lib/components/campaign-report-card.d.ts +91 -0
  35. package/src/lib/components/campaign-report-card.js +667 -0
  36. package/src/lib/components/campaign-report-card.js.map +1 -0
  37. package/src/lib/components/campaign-test-send-drawer.d.ts +45 -0
  38. package/src/lib/components/campaign-test-send-drawer.js +238 -0
  39. package/src/lib/components/campaign-test-send-drawer.js.map +1 -0
  40. package/src/lib/components/campaigns-card.d.ts +31 -0
  41. package/src/lib/components/campaigns-card.js +667 -0
  42. package/src/lib/components/campaigns-card.js.map +1 -0
  43. package/src/lib/components/conversion-attribution.component.d.ts +62 -0
  44. package/src/lib/components/conversion-attribution.component.js +127 -0
  45. package/src/lib/components/conversion-attribution.component.js.map +1 -0
  46. package/src/lib/components/email-compose-card.d.ts +12 -0
  47. package/src/lib/components/email-compose-card.js +157 -0
  48. package/src/lib/components/email-compose-card.js.map +1 -0
  49. package/src/lib/components/email-detail.d.ts +40 -0
  50. package/src/lib/components/email-detail.js +1180 -0
  51. package/src/lib/components/email-detail.js.map +1 -0
  52. package/src/lib/components/email-edit-drawer.d.ts +54 -0
  53. package/src/lib/components/email-edit-drawer.js +172 -0
  54. package/src/lib/components/email-edit-drawer.js.map +1 -0
  55. package/src/lib/components/email-messages-widget.d.ts +22 -0
  56. package/src/lib/components/email-messages-widget.js +49 -0
  57. package/src/lib/components/email-messages-widget.js.map +1 -0
  58. package/src/lib/components/email-recipients-card.d.ts +50 -0
  59. package/src/lib/components/email-recipients-card.js +338 -0
  60. package/src/lib/components/email-recipients-card.js.map +1 -0
  61. package/src/lib/components/emails-list-card.d.ts +36 -0
  62. package/src/lib/components/emails-list-card.js +544 -0
  63. package/src/lib/components/emails-list-card.js.map +1 -0
  64. package/src/lib/components/experiment-zones.d.ts +78 -0
  65. package/src/lib/components/experiment-zones.js +65 -0
  66. package/src/lib/components/experiment-zones.js.map +1 -0
  67. package/src/lib/components/host-experiments-card.component.d.ts +17 -0
  68. package/src/lib/components/host-experiments-card.component.js +887 -0
  69. package/src/lib/components/host-experiments-card.component.js.map +1 -0
  70. package/src/lib/components/host-marketing-summary-card.component.d.ts +15 -0
  71. package/src/lib/components/host-marketing-summary-card.component.js +161 -0
  72. package/src/lib/components/host-marketing-summary-card.component.js.map +1 -0
  73. package/src/lib/components/host-overlays-card.component.d.ts +19 -0
  74. package/src/lib/components/host-overlays-card.component.js +783 -0
  75. package/src/lib/components/host-overlays-card.component.js.map +1 -0
  76. package/src/lib/components/marketing-console-page.d.ts +28 -0
  77. package/src/lib/components/marketing-console-page.js +166 -0
  78. package/src/lib/components/marketing-console-page.js.map +1 -0
  79. package/src/lib/components/marketing-console-sections.d.ts +34 -0
  80. package/src/lib/components/marketing-console-sections.js +77 -0
  81. package/src/lib/components/marketing-console-sections.js.map +1 -0
  82. package/src/lib/components/overlay-stats-row.component.d.ts +15 -0
  83. package/src/lib/components/overlay-stats-row.component.js +78 -0
  84. package/src/lib/components/overlay-stats-row.component.js.map +1 -0
  85. package/src/lib/components/popup-card.component.d.ts +18 -0
  86. package/src/lib/components/popup-card.component.js +462 -0
  87. package/src/lib/components/popup-card.component.js.map +1 -0
  88. package/src/lib/components/record-attribution-widget.d.ts +35 -0
  89. package/src/lib/components/record-attribution-widget.js +33 -0
  90. package/src/lib/components/record-attribution-widget.js.map +1 -0
  91. package/src/lib/components/site-runtime.d.ts +9 -0
  92. package/src/lib/components/site-runtime.js +1081 -0
  93. package/src/lib/components/site-runtime.js.map +1 -0
  94. package/src/lib/components/use-campaign-send-api.d.ts +35 -0
  95. package/src/lib/components/use-campaign-send-api.js +99 -0
  96. package/src/lib/components/use-campaign-send-api.js.map +1 -0
  97. package/src/lib/components/use-campaign-topic-options.d.ts +20 -0
  98. package/src/lib/components/use-campaign-topic-options.js +44 -0
  99. package/src/lib/components/use-campaign-topic-options.js.map +1 -0
  100. package/src/lib/components/use-emails-hub-path.d.ts +39 -0
  101. package/src/lib/components/use-emails-hub-path.js +70 -0
  102. package/src/lib/components/use-emails-hub-path.js.map +1 -0
  103. package/src/lib/components/use-marketing-hub-path.d.ts +21 -0
  104. package/src/lib/components/use-marketing-hub-path.js +50 -0
  105. package/src/lib/components/use-marketing-hub-path.js.map +1 -0
  106. package/src/lib/components/use-overlay-copy-editor.d.ts +79 -0
  107. package/src/lib/components/use-overlay-copy-editor.js +110 -0
  108. package/src/lib/components/use-overlay-copy-editor.js.map +1 -0
  109. package/src/lib/constants/bundle-common.d.ts +8 -0
  110. package/src/lib/constants/bundle-common.js +9 -0
  111. package/src/lib/constants/bundle-common.js.map +1 -0
  112. package/src/lib/model/campaign-membership-figures.d.ts +109 -0
  113. package/src/lib/model/campaign-membership-figures.js +113 -0
  114. package/src/lib/model/campaign-membership-figures.js.map +1 -0
  115. package/src/lib/model/compile-client-automations.d.ts +65 -0
  116. package/src/lib/model/compile-client-automations.js +95 -0
  117. package/src/lib/model/compile-client-automations.js.map +1 -0
  118. package/src/lib/model/experiments.d.ts +130 -0
  119. package/src/lib/model/experiments.js +186 -0
  120. package/src/lib/model/experiments.js.map +1 -0
  121. package/src/lib/model/index.d.ts +26 -0
  122. package/src/lib/model/index.js +26 -0
  123. package/src/lib/model/index.js.map +1 -0
  124. package/src/lib/model/marketing-record-routes.d.ts +6 -0
  125. package/src/lib/model/marketing-record-routes.js +46 -0
  126. package/src/lib/model/marketing-record-routes.js.map +1 -0
  127. package/src/lib/model/overlay-copy.d.ts +62 -0
  128. package/src/lib/model/overlay-copy.js +78 -0
  129. package/src/lib/model/overlay-copy.js.map +1 -0
  130. package/src/lib/model/overlays.d.ts +113 -0
  131. package/src/lib/model/overlays.js +93 -0
  132. package/src/lib/model/overlays.js.map +1 -0
  133. package/src/lib/model/site-contract.d.ts +100 -0
  134. package/src/lib/model/site-contract.js +23 -0
  135. package/src/lib/model/site-contract.js.map +1 -0
  136. package/src/lib/plugin.d.ts +27 -0
  137. package/src/lib/plugin.js +168 -0
  138. package/src/lib/plugin.js.map +1 -0
  139. package/src/lib/preview-props.d.ts +31 -0
  140. package/src/lib/preview-props.js +54 -0
  141. package/src/lib/preview-props.js.map +1 -0
  142. package/src/lib/server/campaign-manage.d.ts +62 -0
  143. package/src/lib/server/campaign-manage.js +829 -0
  144. package/src/lib/server/campaign-manage.js.map +1 -0
  145. package/src/lib/server/campaign-process-scheduled.d.ts +26 -0
  146. package/src/lib/server/campaign-process-scheduled.js +198 -0
  147. package/src/lib/server/campaign-process-scheduled.js.map +1 -0
  148. package/src/lib/server/campaign-recipients.d.ts +55 -0
  149. package/src/lib/server/campaign-recipients.js +219 -0
  150. package/src/lib/server/campaign-recipients.js.map +1 -0
  151. package/src/lib/server/campaign-send.d.ts +487 -0
  152. package/src/lib/server/campaign-send.js +3157 -0
  153. package/src/lib/server/campaign-send.js.map +1 -0
  154. package/src/lib/server/email-campaign-reach.d.ts +174 -0
  155. package/src/lib/server/email-campaign-reach.js +254 -0
  156. package/src/lib/server/email-campaign-reach.js.map +1 -0
  157. package/src/lib/server/email-events.d.ts +27 -0
  158. package/src/lib/server/email-events.js +714 -0
  159. package/src/lib/server/email-events.js.map +1 -0
  160. package/src/lib/server/get-client-automations.d.ts +60 -0
  161. package/src/lib/server/get-client-automations.js +87 -0
  162. package/src/lib/server/get-client-automations.js.map +1 -0
  163. package/src/lib/server/get-overlays.d.ts +28 -0
  164. package/src/lib/server/get-overlays.js +65 -0
  165. package/src/lib/server/get-overlays.js.map +1 -0
  166. package/src/lib/server/get-screen-experiments.d.ts +42 -0
  167. package/src/lib/server/get-screen-experiments.js +82 -0
  168. package/src/lib/server/get-screen-experiments.js.map +1 -0
  169. package/src/lib/server/lists-materialize.d.ts +18 -0
  170. package/src/lib/server/lists-materialize.js +130 -0
  171. package/src/lib/server/lists-materialize.js.map +1 -0
  172. package/src/lib/server/marketing-figures.d.ts +37 -0
  173. package/src/lib/server/marketing-figures.js +248 -0
  174. package/src/lib/server/marketing-figures.js.map +1 -0
  175. package/src/lib/server/site-page-enricher.d.ts +26 -0
  176. package/src/lib/server/site-page-enricher.js +210 -0
  177. package/src/lib/server/site-page-enricher.js.map +1 -0
  178. package/src/lib/server.d.ts +20 -0
  179. package/src/lib/server.js +152 -0
  180. package/src/lib/server.js.map +1 -0
  181. package/src/lib/site.d.ts +22 -0
  182. package/src/lib/site.js +48 -0
  183. package/src/lib/site.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketing/src/lib/components/campaign-detail-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 {\n mdiDeleteOutline,\n mdiEyeOutline,\n mdiPaletteOutline,\n mdiPencilOutline,\n} from '@aglyn/shared-data-mdi'\nimport {\n AppLink,\n CardDisplay,\n MdiIcon,\n useConfirmationContext,\n} from '@aglyn/shared-ui-jsx'\nimport {\n Figure,\n RateRow,\n Section,\n} from '@aglyn/shared-ui-email-campaigns/components/report-figures'\nimport {\n ListRowActions,\n ListTable,\n listActionsColumn,\n} from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport RowActionsMenu, {\n type RowActionsMenuItem,\n} from '@aglyn/shared-ui-jsx/components/row-actions-menu.component'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { ceilingedWindow } from '@aglyn/tenant-feature-instance/hooks/host-collection-queries'\nimport { PageHeaderRecord, pluginDocsHelp } from '@aglyn/aglyn'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Divider,\n Stack,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport {\n collection,\n deleteField,\n doc,\n documentId,\n limit,\n orderBy,\n query,\n updateDoc,\n where,\n} from 'firebase/firestore'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useRouter } from 'next/navigation'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n useFirestore,\n useFirestoreCollection,\n useFirestoreDoc,\n useOrgDataScope,\n} from '@aglyn/tenant-feature-instance'\nimport {\n campaignRollup,\n campaignSendDisplay,\n campaignWindowState,\n emailListTimeMs,\n type CampaignAggregate,\n type CampaignSend,\n type EmailCampaign,\n} from '@aglyn/shared-ui-email-campaigns/model'\nimport CampaignComposer from './campaign-composer'\nimport CampaignEditDrawer, {\n type CampaignEditValues,\n} from './campaign-edit-drawer'\nimport {\n CampaignConversionsSection,\n CampaignDestinationsSection,\n CampaignRevenueSection,\n} from './campaign-reach-sections'\nimport CampaignMembersSection from './campaign-members-section'\nimport CampaignReportCard from './campaign-report-card'\nimport { useCampaignManageApi } from './use-campaign-send-api'\nimport { useEmailsHubPath } from './use-emails-hub-path'\nimport { useCampaignTopicOptions } from './use-campaign-topic-options'\n\n/** How many of a campaign's emails the detail page enumerates. */\nconst CAMPAIGN_EMAIL_CEILING = 50\n\nconst detailDocsHelp = pluginDocsHelp('emailCampaigns', {\n anchor: '#the-campaign-report',\n excerpt:\n 'A campaign groups the emails sent to its lists. The figures here are ' +\n 'the sum across those emails, and each one keeps its own report.',\n})\n\n/**\n * A rolled-up figure, in the shared `Figure`'s shape.\n *\n * The note is where an aggregate differs from a single send's count: a total\n * measured over fewer emails than the campaign holds says which part of the\n * campaign it describes, rather than presenting a partial sum as a complete\n * one. `null` still renders as an em dash and says \"not recorded\", which is\n * the property the shared component already owns.\n */\nconst rolled = (\n value: CampaignAggregate,\n): { value: number | null; note: string } => ({\n value: value.value,\n note:\n value.value !== null && value.recorded < value.sends\n ? `across ${value.recorded} of ${value.sends} emails`\n : `across ${value.sends} email${value.sends === 1 ? '' : 's'}`,\n})\n\nexport interface CampaignDetailCardProps {\n hostId: string\n /** A campaign container id, or a send id from before containers existed. */\n campaignId: string\n /** The marketing hub URL, for the way back to the campaigns list. */\n basePath: string\n}\n\n/**\n * ONE CAMPAIGN: its lists, what it caused, what it earned, where it sent\n * people, and the emails it did all of that with.\n *\n * ## Why the emails are a section rather than the page\n *\n * A campaign reaches people by email, which is not the same as a campaign\n * BEING a list of emails. It runs over a window, against a set of audiences,\n * and the pages its links land on, the money credited to it and the\n * conversions credited to it are facts about the campaign that no single\n * message in it holds. So the body is sectioned — what it caused, what it\n * earned, where it sent people, then the mail's own figures, then its emails\n * — and each section names the population it describes.\n *\n * The ORDER is the part that says which of those the page is about. Delivery,\n * engagement and rates are mechanics of a message; a page that met the reader\n * with them and reached the outcomes only after scrolling was a mail report\n * whatever its headings claimed. `campaign-report-card.tsx` — the page a\n * campaign of one email gets — carries the same two outcome headings first,\n * for the same reason and in the same words.\n *\n * The three middle sections live in `campaign-reach-sections.tsx`, which is\n * also where the reason a campaign cannot simply DECLARE the screens and\n * forms it runs across is written down: no such edge is stored, attribution\n * is the mechanism, and all three sections join on this campaign's send ids.\n *\n * ## Why this resolves two kinds of id\n *\n * The id in `campaigns/{id}` may name a campaign CONTAINER or a single SEND,\n * and which it is is answered by reading: a container at `emailCampaigns/{id}`\n * renders this page, and anything else falls through to that send's own\n * report.\n *\n * Not every send belongs to a container. One written before campaigns grouped\n * their emails names none, its own id is the only id the URL can carry, and\n * that id is also inside the HMAC of every unsubscribe footer already\n * delivered — so a send id has to go on addressing a page rather than a 404.\n * The fall-through is what makes the container additive: no send document is\n * rewritten and no id is reassigned.\n *\n * The extra read is one document, and it buys the guarantee that a pasted\n * report link resolves whichever kind of id it carries.\n */\nexport function CampaignDetailCard(props: CampaignDetailCardProps) {\n const { hostId, campaignId, basePath } = props\n const firestore = useFirestore()\n // The sibling hub, for the two records this page links to but does not own:\n // each message's report and the template it was built from.\n const emailsHub = useEmailsHubPath()\n const router = useRouter()\n const { scope: dataScope } = useOrgDataScope({ hostId })\n const { confirm } = useConfirmationContext()\n const { enqueueSnackbar } = useSnackbar()\n const manageApi = useCampaignManageApi(hostId)\n const [composing, setComposing] = useState(false)\n const [editing, setEditing] = useState(false)\n const [saving, setSaving] = useState(false)\n const [saveError, setSaveError] = useState<string | null>(null)\n const [deleting, setDeleting] = useState(false)\n\n const { data: campaign, status } = useFirestoreDoc<EmailCampaign>(\n () => doc(firestore, 'hosts', hostId, 'emailCampaigns', campaignId),\n [firestore, hostId, campaignId],\n )\n\n /*\n * ONLY WHEN THE ID NAMES A CAMPAIGN.\n *\n * Both queries below are gated on the container having been found, because\n * the other half of this component is the single-send report — and that\n * screen's whole design is that it reads two documents whatever the size of\n * the audience. Listening unconditionally would add two collection reads to\n * every legacy report URL, which is the cost the report route was split out\n * to avoid. Not listening is what a null builder means.\n *\n * The campaign's emails come back by the field each send carries: equality\n * on one field ordered by DOCUMENT NAME, which Firestore's automatic\n * single-field index serves without a composite one. Ordering on a date\n * would need that index AND would drop every send missing that particular\n * date — a sent send carries `sentAt`, a scheduled one `sendAtMs`, and\n * neither is on both. Sorted by date below, over a window this page holds\n * whole.\n *\n * One document past the ceiling, so \"this campaign has more emails than are\n * listed\" is a fact rather than a guess.\n */\n const { data: sendDocs } = useFirestoreCollection<any>(\n () =>\n campaign\n ? query(\n collection(firestore, 'hosts', hostId, 'campaigns'),\n where('emailCampaignId', '==', campaignId),\n orderBy(documentId()),\n limit(CAMPAIGN_EMAIL_CEILING + 1),\n )\n : null,\n [firestore, hostId, campaignId, Boolean(campaign)],\n { idField: '$id' },\n )\n\n const { data: listDocs } = useFirestoreCollection<any>(\n () =>\n campaign && dataScope\n ? query(\n collection(firestore, dataScope[0], dataScope[1], 'lists'),\n limit(50),\n )\n : null,\n [firestore, dataScope, Boolean(campaign)],\n { idField: '$id' },\n )\n\n /*\n * The org's topic catalog, read only while the EDIT DRAWER is open.\n *\n * It fills one picker in that drawer and is drawn nowhere else on this\n * page, so reading it on mount would charge every reader who came for the\n * campaign's numbers for a field they are not looking at. The composer\n * carries its own read of the same catalog, behind its own button, for the\n * same reason.\n */\n const { topics, source: topicSource } = useCampaignTopicOptions(hostId, {\n enabled: editing,\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 { rows: readSends, truncated: sendsTruncated } = ceilingedWindow<any>(\n sendDocs,\n CAMPAIGN_EMAIL_CEILING,\n )\n /*\n * Newest first on the time each email SITS at — its send time where it has\n * one, its creation where it does not. A draft has neither `sentAt` nor\n * `sendAtMs`, so ordering on the send time alone gave every draft the key 0\n * and filed the email a merchant is in the middle of writing below mail\n * sent years ago.\n */\n const sends = useMemo(\n () =>\n [...(readSends as CampaignSend[])].sort(\n (a, b) => emailListTimeMs(b) - emailListTimeMs(a),\n ),\n [readSends],\n )\n const rollup = useMemo(() => campaignRollup(sends), [sends])\n // The ids the two sections beneath the figures join on. Derived from the\n // window this card already holds, so neither of them reads the send list\n // again to find out which emails the campaign has.\n const sendIds = useMemo(\n () => sends.map((send) => String(send.$id)).filter(Boolean),\n [sends],\n )\n\n /*==========================================\n * SAVING THE CONTAINER, WITH THE CLIENT SDK.\n *\n * The same door the create drawer already uses. `emailCampaigns` is\n * deliberately outside the security rules' server-only exclusion list — a\n * container holds no counter, no consent record and no entitlement input,\n * so an editor who writes one cannot buy themselves a send — and giving the\n * edit a route of its own would be a second writer to keep in step with the\n * create.\n *\n * `updateDoc` rather than a merge-set, because this is an edit of a\n * document that exists: a set would CREATE a campaign at this id for\n * somebody who deleted it in another tab, which is the shape the delivery\n * webhook is careful about on the send collection for the same reason.\n *\n * A cleared date is written as `null` — the absence the model already\n * spells — and a cleared topic REMOVES the field, because the model has no\n * null topic and `campaignTopicId` is handed to the composer as one.\n *=========================================*/\n const handleSave = useCallback(\n async (values: CampaignEditValues) => {\n if (saving) return\n setSaving(true)\n setSaveError(null)\n try {\n await updateDoc(\n doc(firestore, 'hosts', hostId, 'emailCampaigns', campaignId),\n {\n name: values.name,\n startAtMs: values.startAtMs,\n endAtMs: values.endAtMs,\n listIds: values.listIds,\n topicId: values.topicId ? values.topicId : deleteField(),\n },\n )\n setEditing(false)\n enqueueSnackbar('Campaign updated', {\n variant: 'success',\n persist: false,\n })\n } catch (error) {\n console.error(error)\n setSaveError('The campaign could not be saved')\n } finally {\n setSaving(false)\n }\n },\n [campaignId, enqueueSnackbar, firestore, hostId, saving],\n )\n\n /*==========================================\n * DELETING THE CONTAINER, WHICH IS NOT DELETING ITS MAIL.\n *\n * The route detaches every email first and then removes the campaign, so\n * what a merchant is agreeing to is the grouping going away — the emails\n * stay, keep their ids, keep their reports, and read afterwards as single\n * sends. Their unsubscribe links carry those ids inside an HMAC and go on\n * working, which is why the container can never take them with it.\n *\n * The confirmation says the count and says what a delete does NOT do. A\n * scheduled email inside the campaign still goes out at its time — stopping\n * somebody's mail is `cancel`, on that email's own page — and a merchant\n * who reads \"delete campaign\" as \"stop the campaign\" has to be told\n * otherwise before they press it, not after.\n *=========================================*/\n const handleDelete = useCallback(async () => {\n if (deleting) return\n /*\n * Emails with mail still to go: the ones waiting for their time AND the\n * ones part way through an audience larger than one batch. Both are what\n * a merchant needs warning about, and counting only `scheduled` would\n * miss the case that needs it most — a campaign that is delivering right\n * now is stored as `scheduled` too, but `rollup.scheduled` is the\n * narrower reading that excludes it.\n */\n const unfinished = rollup.scheduled + rollup.sending\n const agreed = await confirm({\n title: 'Delete this campaign?',\n description:\n (sends.length\n ? `The ${sends.length.toLocaleString()} ` +\n `${sends.length === 1 ? 'email' : 'emails'} in it are kept — ` +\n 'each keeps its own report and its unsubscribe links, and they ' +\n 'appear in the campaigns 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 screens, 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 setDeleting(true)\n try {\n const { response, payload } = await manageApi({\n action: 'deleteCampaign',\n campaignId,\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', { variant: 'success', persist: false })\n router.push(`${basePath}/campaigns`)\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 setDeleting(false)\n }\n }, [\n basePath,\n campaignId,\n confirm,\n deleting,\n enqueueSnackbar,\n manageApi,\n rollup.scheduled,\n rollup.sending,\n router,\n sends.length,\n ])\n\n // Still settling. Falling through to the send report here would flash \"this\n // campaign could not be loaded\" on every open of a campaign that exists.\n if (!campaign && status === 'loading') return null\n\n /*\n * NOT A CONTAINER — so it is a send id, and the send's own report is what\n * this URL has always meant.\n */\n if (!campaign) {\n return (\n <CampaignReportCard\n hostId={hostId}\n campaignId={campaignId}\n basePath={basePath}\n />\n )\n }\n\n const listIds = campaign.listIds ?? []\n const names = new Map<string, string>(\n (listDocs ?? []).map((list: any) => [\n String(list.$id),\n String(list.name ?? list.$id),\n ]),\n )\n /*==========================================\n * ONE EMAIL'S PAGE — the same one every other route to that record opens.\n *\n * The Emails hub's `emails/{sendId}`, which is where the messages list and\n * a template's messages table also send a reader. One record has one page:\n * a link that resolved somewhere else depending on which list it was\n * clicked in would give the same message two pages, and the reader would\n * have no way to tell which one they were on.\n *\n * `campaigns/{sendId}` on THIS hub goes on resolving as well, through the\n * fall-through at the top of this file. That is not a convenience — every\n * unsubscribe footer already delivered carries `cid={sendId}`, those\n * messages sit in inboxes forever, and merchants paste report URLs into\n * their own mail. Which link the console GENERATES and which URLs ANSWER\n * are two separate questions, and only the first is decided here.\n *\n * Nor is a redirect the answer to the second. A redirect would be another\n * thing to be wrong about an id that is inside an HMAC; a page that keeps\n * working has nothing to get wrong, and it costs nothing to leave standing.\n *=========================================*/\n const sendHref = (send: CampaignSend) =>\n emailsHub ? `${emailsHub}/messages/${send.$id}` : undefined\n\n /**\n * What one of this campaign's emails can be opened into.\n *\n * The same two the Emails hub offers, less the campaign — this page IS the\n * campaign. Both destinations are records the Emails console owns, so they\n * are built from {@link useEmailsHubPath} rather than from this surface's\n * own `basePath`.\n *\n * A message composed inline was built from no template, so that entry is\n * shown DISABLED with the reason rather than hidden: an absent control and\n * an inapplicable one look identical, and only one is honest.\n */\n const sendActions = (send: CampaignSend): RowActionsMenuItem[] => {\n const templateScreenId = String((send as any).templateScreenId ?? '')\n return [\n {\n key: 'details',\n label: 'Open report',\n icon: <MdiIcon path={mdiEyeOutline.path} size={0.8} />,\n href: sendHref(send),\n disabled: !sendHref(send),\n disabledReason: 'This site’s console URL has not resolved yet',\n },\n {\n key: 'template',\n label: 'Open its template',\n icon: <MdiIcon path={mdiPaletteOutline.path} size={0.8} />,\n href:\n templateScreenId && emailsHub\n ? `${emailsHub}/templates/${templateScreenId}`\n : undefined,\n disabled: !templateScreenId || !emailsHub,\n disabledReason: templateScreenId\n ? 'This site’s console URL has not resolved yet'\n : 'This message was not built from a template',\n },\n ]\n }\n\n /*\n * The campaign's emails, on the surface's own row grammar: the row opens\n * the email's report, its subject is also a real link so it can be\n * middle-clicked and copied, and the trailing cluster holds the actions.\n * The window is one the card already holds, so the grid pages it.\n */\n const sendColumns: GridColDef<CampaignSend>[] = [\n {\n field: 'subject',\n headerName: 'Subject',\n flex: 1,\n minWidth: 220,\n valueGetter: (_value, send) => send.subject || send.$id,\n /*\n Plain text until the Emails hub resolves: a link with no destination\n is worse than none, and this cell is the message's subject either way.\n */\n renderCell: ({ row: send, value }) => {\n const href = sendHref(send)\n return href ? (\n <AppLink\n href={href}\n // The row's own handler would fire too and push the same route\n // twice — one history entry per back press.\n onClick={(event: { stopPropagation: () => void }) =>\n event.stopPropagation()\n }\n >\n {value}\n </AppLink>\n ) : (\n value\n )\n },\n },\n {\n /*\n WHAT THE EMAIL IS DOING, not the field it stores.\n\n This branched on the status, which reads \"Scheduled\" about an email\n that has delivered five hundred messages and is between batches — the\n stored state the processor claims to resume it. The derivation reads\n the counters beside the status; the due date is appended only where\n there is genuinely nothing delivered yet, which is the one case a time\n answers.\n */\n field: 'state',\n headerName: 'State',\n width: 220,\n valueGetter: (_value, send) => {\n const display = campaignSendDisplay(send)\n return display.state === 'pending' && send.sendAtMs\n ? `${display.label} · ${new Date(send.sendAtMs).toLocaleString()}`\n : display.label\n },\n renderCell: ({ row: send, value }) => {\n const state = campaignSendDisplay(send).state\n return (\n <Chip\n size=\"small\"\n color={\n state === 'sending' ? 'info' : state === 'stopped' ? 'warning' : undefined\n }\n label={value}\n />\n )\n },\n },\n {\n /*\n Sent over addressed, on one line: the two figures only mean anything\n beside each other, and the gap between them is the suppression list\n doing its work.\n */\n field: 'sent',\n headerName: 'Sent',\n type: 'number',\n align: 'right',\n headerAlign: 'right',\n width: 110,\n valueGetter: (_value, send) => Number(send.stats?.sent ?? 0),\n renderCell: ({ row: send }) =>\n `${send.stats?.sent ?? 0}/${send.stats?.recipients ?? 0}`,\n },\n {\n field: 'opens',\n headerName: 'Opens',\n type: 'number',\n align: 'right',\n headerAlign: 'right',\n width: 100,\n valueGetter: (_value, send) => Number(send.stats?.opens ?? 0),\n valueFormatter: (value: number) => value.toLocaleString(),\n },\n {\n field: 'clicks',\n headerName: 'Clicks',\n type: 'number',\n align: 'right',\n headerAlign: 'right',\n width: 100,\n valueGetter: (_value, send) => Number(send.stats?.clicks ?? 0),\n valueFormatter: (value: number) => value.toLocaleString(),\n },\n listActionsColumn(\n (send: CampaignSend) => (\n <ListRowActions\n label={String(send.subject || send.$id)}\n items={sendActions(send)}\n />\n ),\n { width: 72 },\n ),\n ]\n\n const windowState = campaignWindowState(campaign, Date.now())\n const start = campaign.startAtMs\n ? new Date(campaign.startAtMs).toLocaleDateString()\n : ''\n const end = campaign.endAtMs\n ? new Date(campaign.endAtMs).toLocaleDateString()\n : ''\n\n /* The card, named so the page chrome above it is a plain list of\n what this surface publishes upward. */\n const card = (\n <CardDisplay\n header={'Campaign'}\n subheader={\n start || end\n ? `${start || 'Open'} – ${end || 'open-ended'}`\n : 'No campaign dates'\n }\n help={detailDocsHelp}\n HeaderProps={{\n /*\n NAVIGATION, THEN THE OVERFLOW.\n\n Editing and deleting a campaign live here rather than on the\n campaigns table, because a record is edited on its own page in this\n console. `RowActionsMenu` is named for table rows and its rendering\n is not — a kebab and a menu whose items carry `destructive` and\n `disabled` — so reusing it is what keeps this overflow behaving like\n every other one on the surface, including the email page's.\n */\n action: (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Button\n component={AppLink as any}\n {...({ componentVariant: 'naked', nativeButton: false } as any)}\n href={`${basePath}/campaigns`}\n size=\"small\"\n color=\"primary\"\n >\n {'All campaigns'}\n </Button>\n <RowActionsMenu\n label={campaign.name || 'Campaign'}\n items={[\n {\n key: 'edit',\n label: 'Edit campaign',\n icon: <MdiIcon path={mdiPencilOutline.path} size={0.8} />,\n onClick: () => {\n setSaveError(null)\n setEditing(true)\n },\n },\n {\n key: 'delete',\n label: 'Delete campaign',\n icon: <MdiIcon path={mdiDeleteOutline.path} size={0.8} />,\n destructive: true,\n disabled: deleting,\n disabledReason: 'This campaign is being deleted',\n onClick: () => void handleDelete(),\n },\n ]}\n />\n </Stack>\n ),\n }}\n contentGutterX\n contentGutterY\n >\n <Stack spacing={2}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Chip size=\"small\" label={windowState} />\n {listIds.length ? (\n listIds.map((id) => (\n <Chip\n key={id}\n size=\"small\"\n variant=\"outlined\"\n label={names.get(id) ?? id}\n />\n ))\n ) : (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'No lists assigned — its emails pick their own audience'}\n </Typography>\n )}\n </Stack>\n\n <Divider />\n {/*\n A CAMPAIGN IS NOT ONLY ITS MAIL, and it leads with the part that\n is not.\n\n What the campaign CAUSED and where it SENT people are facts about the\n campaign; delivery, engagement and rates are mechanics of the\n messages it used, and the list of those messages is one section among\n several rather than the page. Ordering the mail first said the\n opposite in the only way a page can — by what a reader meets before\n they scroll — and a campaign of ONE email says it loudest, which is\n why `campaign-report-card.tsx` carries these two headings in this\n order too.\n\n All three sections join on the campaign's own send ids, which is the\n only handle the attribution, revenue and click-report collections\n offer — see `campaign-reach-sections.tsx` for why no other join\n exists, and why the web channel is named there rather than quietly\n omitted.\n */}\n <CampaignConversionsSection\n hostId={hostId}\n sendIds={sendIds}\n truncated={sendsTruncated}\n basePath={basePath}\n />\n\n <Divider />\n {/*\n WHAT IT EARNED, between what it caused and where it sent people —\n the order `campaign-report-card.tsx` puts these three in, so a\n campaign of one email and a campaign of ten answer the merchant's\n questions in the same sequence.\n\n How many messages a container holds is not a fact about whether its\n revenue is knowable, so the money question is answered here whatever\n the count. Reading it costs one record per email, so it asks first —\n see `campaign-reach-sections.tsx` for that bargain, and for why the\n currencies are reported apart and never totalled.\n */}\n <CampaignRevenueSection\n hostId={hostId}\n sendIds={sendIds}\n truncated={sendsTruncated}\n />\n\n <Divider />\n <CampaignDestinationsSection\n hostId={hostId}\n sendIds={sendIds}\n truncated={sendsTruncated}\n />\n\n <Divider />\n {/*\n WHAT THE MERCHANT SAID BELONGS HERE, under what the visitors did.\n\n Everything above this line is measured — the conversions, the money\n and the pages the mail's own links pointed at, all joined on this\n campaign's send ids. This section is the only one on the page that\n reports a DECLARATION: a screen or a form carrying this campaign's\n id in its own document because somebody put it there.\n\n It sits after the evidence deliberately. A reader who met the\n assigned list first would take it for the campaign's reach, and the\n two are not the same list — a landing page can be assigned to a\n campaign no email ever linked to, and a campaign's mail can drive\n traffic to a page assigned to nothing.\n\n The dates go with it. A form's counters are lifetime, so a campaign\n with a window has to be able to confine them to its own months; a\n campaign without one is told so, and says its figures are lifetime\n rather than implying they are its own.\n */}\n <CampaignMembersSection\n hostId={hostId}\n campaignId={campaignId}\n startAtMs={campaign.startAtMs}\n endAtMs={campaign.endAtMs}\n />\n\n <Divider />\n {/*\n THE MAIL'S OWN FIGURES, under the outcomes rather than over them.\n\n The sum over the campaign's emails, not a second set of counters.\n Nothing is stored per campaign: a rollup document would have to be\n kept true against every delivery event of every email in it, and the\n numbers it duplicates are already on the sends this page reads.\n\n Drawn by the shared figures so a campaign's rate and a single\n message's read the same way — denominator named on the line, and an\n em dash rather than a zero where nothing was recorded.\n */}\n <Section title=\"The mail, across this campaign\">\n <Stack direction=\"row\" spacing={3} sx={{ flexWrap: 'wrap' }}>\n <Figure label=\"Addressed\" {...rolled(rollup.addressed)} />\n <Figure label=\"Sent\" {...rolled(rollup.sent)} />\n <Figure label=\"Delivered\" {...rolled(rollup.delivered)} />\n <Figure label=\"Opens\" {...rolled(rollup.opens)} />\n <Figure label=\"Clicks\" {...rolled(rollup.clicks)} />\n <Figure label=\"Unsubscribed\" {...rolled(rollup.unsubscribes)} />\n </Stack>\n </Section>\n <Stack spacing={0.5}>\n <RateRow label=\"Open rate\" rate={rollup.openRate} />\n <RateRow label=\"Click rate\" rate={rollup.clickRate} />\n <RateRow label=\"Unsubscribe rate\" rate={rollup.unsubscribeRate} />\n </Stack>\n\n <Divider />\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', justifyContent: 'space-between' }}\n >\n {/*\n The section rail's own heading style, so this reads as one section\n among the others rather than as the page's subject.\n */}\n <Typography variant=\"overline\" color=\"text.secondary\">\n {`Emails (${sends.length})`}\n </Typography>\n <Button\n size=\"small\"\n variant={composing ? 'text' : 'contained'}\n onClick={() => setComposing((open) => !open)}\n >\n {composing ? 'Close composer' : 'Write an email'}\n </Button>\n </Stack>\n {sends.length ? (\n <Stack spacing={0.5}>\n <ListTable\n aria-label=\"The campaign's emails\"\n rows={sends}\n columns={sendColumns}\n rowHeight={TABLE_ROW_HEIGHT}\n onOpen={(_id, send) => {\n const href = sendHref(send)\n if (href) router.push(href)\n }}\n />\n {sendsTruncated ? (\n <Alert severity=\"info\">\n {`Showing ${CAMPAIGN_EMAIL_CEILING} of this campaign's ` +\n 'emails. It has sent more — the ones listed are not ' +\n 'necessarily the most recent, because a send carries no ' +\n 'date field that every writer stamps, and the figures above ' +\n 'cover the emails listed.'}\n </Alert>\n ) : null}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No emails in this campaign yet.'}\n </Typography>\n )}\n\n {/*\n THE COMPOSER, ON DEMAND.\n\n It opens listens of its own — the site's email designs, the org's\n lists and segments, the running experiments — and this page is also\n where somebody arrives to read numbers. Mounting it unasked would\n make every reader pay for a composer they did not open, which is the\n same cost the campaign report was split onto its own route to avoid.\n */}\n {composing ? (\n <Box>\n <Divider sx={{ mb: 2 }} />\n <CampaignComposer\n hostId={hostId}\n emailCampaignId={campaignId}\n campaignListIds={listIds}\n campaignTopicId={campaign.topicId}\n onSent={() => setComposing(false)}\n />\n </Box>\n ) : null}\n </Stack>\n {/*\n THE EDIT DRAWER, on the campaign's own page.\n\n Its list picker reads the same `listDocs` the chips above already\n cost, so opening it adds one read — the topic catalog — and only\n while it is open.\n */}\n {/* Draws nothing: the zone the topic catalog's owner answers through. */}\n {topicSource}\n <CampaignEditDrawer\n open={editing}\n onClose={() => setEditing(false)}\n campaign={campaign}\n lists={(listDocs ?? []).map((list: any) => ({\n value: String(list.$id),\n label: String(list.name ?? list.$id),\n }))}\n topics={topicOptions}\n busy={saving}\n error={saveError}\n onSubmit={(values) => void handleSave(values)}\n />\n </CardDisplay>\n )\n\n return (\n <>\n {/* The page heading and the trail name the campaign; this card is\n then free to say what it holds rather than repeating the title. */}\n <PageHeaderRecord title={campaign.name || campaignId} />\n {card}\n </>\n )\n}\nCampaignDetailCard.displayName = 'CampaignDetailCard'\n\nexport default CampaignDetailCard\n"],"names":["mdiDeleteOutline","mdiEyeOutline","mdiPaletteOutline","mdiPencilOutline","AppLink","CardDisplay","MdiIcon","useConfirmationContext","Figure","RateRow","Section","ListRowActions","ListTable","listActionsColumn","RowActionsMenu","TABLE_ROW_HEIGHT","ceilingedWindow","PageHeaderRecord","pluginDocsHelp","Alert","Box","Button","Chip","Divider","Stack","Typography","collection","deleteField","doc","documentId","limit","orderBy","query","updateDoc","where","useCallback","useMemo","useState","useRouter","useSnackbar","useFirestore","useFirestoreCollection","useFirestoreDoc","useOrgDataScope","campaignRollup","campaignSendDisplay","campaignWindowState","emailListTimeMs","CampaignComposer","CampaignEditDrawer","CampaignConversionsSection","CampaignDestinationsSection","CampaignRevenueSection","CampaignMembersSection","CampaignReportCard","useCampaignManageApi","useEmailsHubPath","useCampaignTopicOptions","CAMPAIGN_EMAIL_CEILING","detailDocsHelp","anchor","excerpt","rolled","value","note","recorded","sends","CampaignDetailCard","props","campaign","hostId","campaignId","basePath","firestore","emailsHub","router","scope","dataScope","confirm","enqueueSnackbar","manageApi","composing","setComposing","editing","setEditing","saving","setSaving","saveError","setSaveError","deleting","setDeleting","data","status","sendDocs","Boolean","idField","listDocs","topics","source","topicSource","enabled","topicOptions","map","topic","id","label","name","rows","readSends","truncated","sendsTruncated","sort","a","b","rollup","sendIds","send","String","$id","filter","handleSave","values","startAtMs","endAtMs","listIds","topicId","variant","persist","error","console","handleDelete","unfinished","scheduled","sending","agreed","title","description","length","toLocaleString","confirmationText","then","catch","response","payload","action","ok","allowDuplicate","push","names","Map","list","sendHref","undefined","sendActions","templateScreenId","key","icon","path","size","href","disabled","disabledReason","sendColumns","field","headerName","flex","minWidth","valueGetter","_value","subject","renderCell","row","onClick","event","stopPropagation","width","display","state","sendAtMs","Date","color","type","align","headerAlign","Number","stats","sent","recipients","opens","valueFormatter","clicks","items","windowState","now","start","toLocaleDateString","end","card","header","subheader","help","HeaderProps","direction","spacing","sx","alignItems","component","componentVariant","nativeButton","destructive","contentGutterX","contentGutterY","get","flexWrap","addressed","delivered","unsubscribes","rate","openRate","clickRate","unsubscribeRate","justifyContent","open","aria-label","columns","rowHeight","onOpen","_id","severity","mb","emailCampaignId","campaignListIds","campaignTopicId","onS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CACb,CAAC,QAAQ,EAAE1K,uBAAuB,oBAAoB,CAAC,GACtD,wDACA,4DACA,gEACA;iCAEF;;uCAGN,KAACjC;wBAAWqG,SAAQ;wBAAQsD,OAAM;kCAC/B;;oBAaJnG,0BACC,MAAC7D;;0CACC,KAACG;gCAAQqL,IAAI;oCAAEyB,IAAI;gCAAE;;0CACrB,KAACrL;gCACCsB,QAAQA;gCACRgK,iBAAiB/J;gCACjBgK,iBAAiB3G;gCACjB4G,iBAAiBnK,SAASwD,OAAO;gCACjC4G,QAAQ,IAAMvJ,aAAa;;;yBAG7B;;;YAULiB;0BACD,KAAClD;gBACC6K,MAAM3I;gBACNuJ,SAAS,IAAMtJ,WAAW;gBAC1Bf,UAAUA;gBACVsK,OAAO,CAAC3I,mBAAAA,WAAY,EAAE,EAAEM,GAAG,CAAC,CAACgD;wBAEbA;2BAF4B;wBAC1CvF,OAAOsD,OAAOiC,KAAKhC,GAAG;wBACtBb,OAAOY,QAAOiC,aAAAA,KAAK5C,IAAI,YAAT4C,aAAaA,KAAKhC,GAAG;oBACrC;;gBACArB,QAAQI;gBACRuI,MAAMvJ;gBACN2C,OAAOzC;gBACPsJ,UAAU,CAACpH,SAAW,KAAKD,WAAWC;;;;IAK5C,qBACE;;0BAGE,KAACxG;gBAAiBsH,OAAOlE,SAASqC,IAAI,IAAInC;;YACzC8H;;;AAGP;AACAlI,mBAAmB2K,WAAW,GAAG;AAEjC,eAAe3K,mBAAkB"}
@@ -0,0 +1,60 @@
1
+ /** One option in the list or topic picker. */
2
+ export interface CampaignEditOption {
3
+ value: string;
4
+ label: string;
5
+ }
6
+ /** What the drawer collects — the container's whole editable surface. */
7
+ export interface CampaignEditValues {
8
+ name: string;
9
+ startAtMs: number | null;
10
+ endAtMs: number | null;
11
+ listIds: string[];
12
+ topicId: string;
13
+ }
14
+ export interface CampaignEditDrawerProps {
15
+ open: boolean;
16
+ onClose: () => void;
17
+ /** The campaign as stored, for the fields to open on. */
18
+ campaign: {
19
+ name?: string;
20
+ startAtMs?: number | null;
21
+ endAtMs?: number | null;
22
+ listIds?: string[];
23
+ topicId?: string;
24
+ } | null;
25
+ /** The org's email lists, which this campaign may be aimed at. */
26
+ lists: CampaignEditOption[];
27
+ /** The org's active topics — the stream its emails open on. */
28
+ topics: CampaignEditOption[];
29
+ busy?: boolean;
30
+ /** A refusal from the write, shown where the form still is. */
31
+ error?: string | null;
32
+ onSubmit: (values: CampaignEditValues) => void;
33
+ }
34
+ /**
35
+ * EDITING ONE CAMPAIGN, IN A DRAWER ON THE CAMPAIGN'S OWN PAGE.
36
+ *
37
+ * A drawer and not a form above the campaigns table: a record is edited on
38
+ * its own surface in this console, and a list with a form on top of it is
39
+ * the shape the whole surface was routed to stop.
40
+ *
41
+ * ## Everything a container holds is editable, and that is the whole point
42
+ *
43
+ * A campaign is a name, a window, the lists it is aimed at and the stream its
44
+ * emails open on. None of it describes mail that has already been delivered —
45
+ * that lives on the SENDS, which record their own subject, audience and topic
46
+ * at send time and are never rewritten. So unlike an email, where only the
47
+ * console-only display name stays editable after it goes out, a campaign has
48
+ * no field that could come to disagree with somebody's inbox.
49
+ *
50
+ * Changing the topic is the one that reads as though it might. It does not:
51
+ * the topic here is what the composer's picker OPENS ON, and each send
52
+ * records the topic it actually went out under. Re-pointing a campaign
53
+ * changes the default for the next email written in it and nothing about the
54
+ * ones already sent.
55
+ */
56
+ export declare function CampaignEditDrawer(props: CampaignEditDrawerProps): import("react").JSX.Element;
57
+ export declare namespace CampaignEditDrawer {
58
+ var displayName: string;
59
+ }
60
+ export default CampaignEditDrawer;
@@ -0,0 +1,252 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
18
+ import { ICON_VARIANT_CLOSE } from "@aglyn/shared-data-enums";
19
+ import { Container, MdiIcon, SrOnly } from "@aglyn/shared-ui-jsx";
20
+ import { NavigationDrawerComponent } from "@aglyn/shared-ui-jsx/components/navigation-drawer.component";
21
+ import { Alert, Button, Chip, IconButton, MenuItem, Stack, TextField, Typography } from "@mui/material";
22
+ import { useEffect, useState } from "react";
23
+ /**
24
+ * The `YYYY-MM-DD` a `date` input wants, from epoch ms.
25
+ *
26
+ * UTC, matching the writer: the create drawer stores `Date.parse('2026-03-01')`,
27
+ * which is UTC midnight, so reading it back in local time shows the previous
28
+ * day to everyone west of Greenwich — a campaign that changed its own start
29
+ * date by being opened.
30
+ */ function dayInputValue(ms) {
31
+ if (typeof ms !== 'number' || !Number.isFinite(ms)) return '';
32
+ const at = new Date(ms);
33
+ return Number.isNaN(at.getTime()) ? '' : at.toISOString().slice(0, 10);
34
+ }
35
+ /** Epoch ms for a `YYYY-MM-DD` a `date` input produced, or null for empty. */ function dayInputMs(value) {
36
+ if (!value) return null;
37
+ const parsed = Date.parse(value);
38
+ return Number.isFinite(parsed) ? parsed : null;
39
+ }
40
+ /**
41
+ * EDITING ONE CAMPAIGN, IN A DRAWER ON THE CAMPAIGN'S OWN PAGE.
42
+ *
43
+ * A drawer and not a form above the campaigns table: a record is edited on
44
+ * its own surface in this console, and a list with a form on top of it is
45
+ * the shape the whole surface was routed to stop.
46
+ *
47
+ * ## Everything a container holds is editable, and that is the whole point
48
+ *
49
+ * A campaign is a name, a window, the lists it is aimed at and the stream its
50
+ * emails open on. None of it describes mail that has already been delivered —
51
+ * that lives on the SENDS, which record their own subject, audience and topic
52
+ * at send time and are never rewritten. So unlike an email, where only the
53
+ * console-only display name stays editable after it goes out, a campaign has
54
+ * no field that could come to disagree with somebody's inbox.
55
+ *
56
+ * Changing the topic is the one that reads as though it might. It does not:
57
+ * the topic here is what the composer's picker OPENS ON, and each send
58
+ * records the topic it actually went out under. Re-pointing a campaign
59
+ * changes the default for the next email written in it and nothing about the
60
+ * ones already sent.
61
+ */ export function CampaignEditDrawer(props) {
62
+ const { open, onClose, campaign, lists, topics, busy, error, onSubmit } = props;
63
+ const [name, setName] = useState('');
64
+ const [startAt, setStartAt] = useState('');
65
+ const [endAt, setEndAt] = useState('');
66
+ const [listIds, setListIds] = useState([]);
67
+ const [topicId, setTopicId] = useState('');
68
+ /*
69
+ * Re-seeded whenever the drawer opens rather than held from the last time.
70
+ * The campaign arrives asynchronously and can change under a closed drawer,
71
+ * so seeding once at mount would open it on a stale name.
72
+ */ useEffect(()=>{
73
+ var _ref, _ref1, _ref2;
74
+ if (!open) return;
75
+ setName(String((_ref = campaign == null ? void 0 : campaign.name) != null ? _ref : ''));
76
+ setStartAt(dayInputValue(campaign == null ? void 0 : campaign.startAtMs));
77
+ setEndAt(dayInputValue(campaign == null ? void 0 : campaign.endAtMs));
78
+ setListIds(((_ref1 = campaign == null ? void 0 : campaign.listIds) != null ? _ref1 : []).map(String));
79
+ setTopicId(String((_ref2 = campaign == null ? void 0 : campaign.topicId) != null ? _ref2 : ''));
80
+ }, [
81
+ open,
82
+ campaign
83
+ ]);
84
+ const startAtMs = dayInputMs(startAt);
85
+ const endAtMs = dayInputMs(endAt);
86
+ /*
87
+ * Refused in the form rather than stored and rendered, exactly as the
88
+ * create drawer refuses it: a campaign that ends before it starts is a
89
+ * window no state in `campaignWindowState` describes, so it would draw as
90
+ * "Ended" from the day it was made.
91
+ */ const backwards = startAtMs !== null && endAtMs !== null && endAtMs < startAtMs;
92
+ const submittable = name.trim().length > 0 && !backwards && !busy;
93
+ return /*#__PURE__*/ _jsx(NavigationDrawerComponent, {
94
+ open: open,
95
+ anchor: "right",
96
+ variant: "temporary",
97
+ onClose: onClose,
98
+ AppBarProps: {
99
+ color: 'surface'
100
+ },
101
+ appBarLeft: /*#__PURE__*/ _jsxs(_Fragment, {
102
+ children: [
103
+ /*#__PURE__*/ _jsxs(IconButton, {
104
+ color: "inherit",
105
+ edge: "start",
106
+ onClick: onClose,
107
+ sx: {
108
+ mr: 2
109
+ },
110
+ children: [
111
+ /*#__PURE__*/ _jsx(MdiIcon, {
112
+ path: ICON_VARIANT_CLOSE.path
113
+ }),
114
+ /*#__PURE__*/ _jsx(SrOnly, {
115
+ children: "close drawer"
116
+ })
117
+ ]
118
+ }),
119
+ /*#__PURE__*/ _jsx(Typography, {
120
+ variant: "h6",
121
+ component: "div",
122
+ children: 'Edit campaign'
123
+ })
124
+ ]
125
+ }),
126
+ appBarRight: /*#__PURE__*/ _jsx(Button, {
127
+ variant: "outlined",
128
+ color: "inherit",
129
+ onClick: onClose,
130
+ children: 'Cancel'
131
+ }),
132
+ children: /*#__PURE__*/ _jsx(Container, {
133
+ gutterY: true,
134
+ children: /*#__PURE__*/ _jsxs(Stack, {
135
+ spacing: 2,
136
+ children: [
137
+ /*#__PURE__*/ _jsx(TextField, {
138
+ label: "Name",
139
+ value: name,
140
+ onChange: (event)=>setName(event.target.value),
141
+ helperText: "What you call this campaign in the console",
142
+ fullWidth: true
143
+ }),
144
+ /*#__PURE__*/ _jsx(TextField, {
145
+ type: "date",
146
+ label: "Starts",
147
+ value: startAt,
148
+ onChange: (event)=>setStartAt(event.target.value),
149
+ helperText: "When the campaign window opens",
150
+ slotProps: {
151
+ inputLabel: {
152
+ shrink: true
153
+ }
154
+ },
155
+ fullWidth: true
156
+ }),
157
+ /*#__PURE__*/ _jsx(TextField, {
158
+ type: "date",
159
+ label: "Ends",
160
+ value: endAt,
161
+ onChange: (event)=>setEndAt(event.target.value),
162
+ helperText: "Leave empty for an open-ended campaign",
163
+ slotProps: {
164
+ inputLabel: {
165
+ shrink: true
166
+ }
167
+ },
168
+ fullWidth: true
169
+ }),
170
+ /*#__PURE__*/ _jsx(TextField, {
171
+ select: true,
172
+ label: "Lists",
173
+ value: listIds,
174
+ onChange: (event)=>setListIds(// A multiple select hands back an array; the typing on the
175
+ // change event does not know that.
176
+ event.target.value.map(String)),
177
+ // A campaign with no list is legitimate: its emails can go to
178
+ // leads, to site members, or to a segment.
179
+ helperText: "The lists this campaign is aimed at",
180
+ slotProps: {
181
+ select: {
182
+ multiple: true,
183
+ renderValue: (selected)=>/*#__PURE__*/ _jsx(Stack, {
184
+ direction: "row",
185
+ spacing: 0.5,
186
+ sx: {
187
+ flexWrap: 'wrap'
188
+ },
189
+ children: selected.map((id)=>{
190
+ var _ref;
191
+ var _lists_find;
192
+ return /*#__PURE__*/ _jsx(Chip, {
193
+ size: "small",
194
+ label: (_ref = (_lists_find = lists.find((list)=>list.value === id)) == null ? void 0 : _lists_find.label) != null ? _ref : id
195
+ }, id);
196
+ })
197
+ })
198
+ }
199
+ },
200
+ fullWidth: true,
201
+ children: lists.map((list)=>/*#__PURE__*/ _jsx(MenuItem, {
202
+ value: list.value,
203
+ children: list.label
204
+ }, list.value))
205
+ }),
206
+ /*#__PURE__*/ _jsxs(TextField, {
207
+ select: true,
208
+ label: "Topic",
209
+ value: topicId,
210
+ onChange: (event)=>setTopicId(event.target.value),
211
+ helperText: "The stream its emails open on — each one can change it",
212
+ fullWidth: true,
213
+ children: [
214
+ /*#__PURE__*/ _jsx(MenuItem, {
215
+ value: "",
216
+ children: 'No default — each email chooses'
217
+ }),
218
+ topics.map((topic)=>/*#__PURE__*/ _jsx(MenuItem, {
219
+ value: topic.value,
220
+ children: topic.label
221
+ }, topic.value))
222
+ ]
223
+ }),
224
+ backwards ? /*#__PURE__*/ _jsx(Alert, {
225
+ severity: "warning",
226
+ children: 'The end date is before the start date.'
227
+ }) : null,
228
+ error ? /*#__PURE__*/ _jsx(Alert, {
229
+ severity: "error",
230
+ children: error
231
+ }) : null,
232
+ /*#__PURE__*/ _jsx(Button, {
233
+ variant: "contained",
234
+ disabled: !submittable,
235
+ onClick: ()=>onSubmit({
236
+ name: name.trim(),
237
+ startAtMs,
238
+ endAtMs,
239
+ listIds,
240
+ topicId
241
+ }),
242
+ children: busy ? 'Saving…' : 'Save campaign'
243
+ })
244
+ ]
245
+ })
246
+ })
247
+ });
248
+ }
249
+ CampaignEditDrawer.displayName = 'CampaignEditDrawer';
250
+ export default CampaignEditDrawer;
251
+
252
+ //# sourceMappingURL=campaign-edit-drawer.js.map
@@ -0,0 +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 {\n Alert,\n Button,\n Chip,\n IconButton,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState } from 'react'\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}\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 } | 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 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 { open, onClose, campaign, lists, topics, busy, error, 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\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 }, [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 = name.trim().length > 0 && !backwards && !busy\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 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 {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 })\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","Alert","Button","Chip","IconButton","MenuItem","Stack","TextField","Typography","useEffect","useState","dayInputValue","ms","Number","isFinite","at","Date","isNaN","getTime","toISOString","slice","dayInputMs","value","parsed","parse","CampaignEditDrawer","props","open","onClose","campaign","lists","topics","busy","error","onSubmit","name","setName","startAt","setStartAt","endAt","setEndAt","listIds","setListIds","topicId","setTopicId","String","startAtMs","endAtMs","map","backwards","submittable","trim","length","anchor","variant","AppBarProps","color","appBarLeft","edge","onClick","sx","mr","path","component","appBarRight","gutterY","spacing","label","onChange","event","target","helperText","fullWidth","type","slotProps","inputLabel","shrink","select","multiple","renderValue","selected","direction","flexWrap","id","size","find","list","topic","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,SACEC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AAsC3C;;;;;;;CAOC,GACD,SAASC,cAAcC,EAA6B;IAClD,IAAI,OAAOA,OAAO,YAAY,CAACC,OAAOC,QAAQ,CAACF,KAAK,OAAO;IAC3D,MAAMG,KAAK,IAAIC,KAAKJ;IACpB,OAAOC,OAAOI,KAAK,CAACF,GAAGG,OAAO,MAAM,KAAKH,GAAGI,WAAW,GAAGC,KAAK,CAAC,GAAG;AACrE;AAEA,4EAA4E,GAC5E,SAASC,WAAWC,KAAa;IAC/B,IAAI,CAACA,OAAO,OAAO;IACnB,MAAMC,SAASP,KAAKQ,KAAK,CAACF;IAC1B,OAAOT,OAAOC,QAAQ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CAAEsB,UAAU;wCAAO;kDACzD,AAACF,SAAsBhC,GAAG,CAAC,CAACmC;;gDAKvBrD;iEAJJ,KAAC3B;gDAECiF,MAAK;gDACLjB,KAAK,WACHrC,cAAAA,MAAMuD,IAAI,CAAC,CAACC,OAASA,KAAKhE,KAAK,KAAK6D,wBAApCrD,YAAyCqC,KAAK,mBAAIgB;+CAH/CA;;;4BASf;wBACF;wBACAX,SAAS;kCAER1C,MAAMkB,GAAG,CAAC,CAACsC,qBACV,KAACjF;gCAA0BiB,OAAOgE,KAAKhE,KAAK;0CACzCgE,KAAKnB,KAAK;+BADEmB,KAAKhE,KAAK;;kCAK7B,MAACf;wBACCsE,MAAM;wBACNV,OAAM;wBACN7C,OAAOqB;wBACPyB,UAAU,CAACC,QAAUzB,WAAWyB,MAAMC,MAAM,CAAChD,KAAK;wBAClDiD,YAAW;wBACXC,SAAS;;0CAQT,KAACnE;gCAASiB,OAAM;0CAAI;;4BACnBS,OAAOiB,GAAG,CAAC,CAACuC,sBACX,KAAClF;oCAA2BiB,OAAOiE,MAAMjE,KAAK;8CAC3CiE,MAAMpB,KAAK;mCADCoB,MAAMjE,KAAK;;;oBAK7B2B,0BACC,KAAChD;wBAAMuF,UAAS;kCACb;yBAED;oBACHvD,sBAAQ,KAAChC;wBAAMuF,UAAS;kCAASvD;yBAAiB;kCACnD,KAAC/B;wBACCoD,SAAQ;wBACRmC,UAAU,CAACvC;wBACXS,SAAS,IACPzB,SAAS;gCACPC,MAAMA,KAAKgB,IAAI;gCACfL;gCACAC;gCACAN;gCACAE;4BACF;kCAGDX,OAAO,YAAY;;;;;;AAMhC;AACAP,mBAAmBiE,WAAW,GAAG;AAEjC,eAAejE,mBAAkB"}
@@ -0,0 +1,111 @@
1
+ import type { SendingIdentityView } from '@aglyn/tenant-feature-instance/hooks/use-sending-identity-api';
2
+ import { type ReactElement } from 'react';
3
+ /**
4
+ * WHAT A CAMPAIGN EMAIL ASKS OF WHICHEVER PLUGIN KEEPS THE MAIL ITSELF.
5
+ *
6
+ * A campaign is this plugin's: who it goes to, when, under which container,
7
+ * and what came of it. The mail it rides on is not. The catalog of streams a
8
+ * recipient can leave, the identities a site may send as, the design document
9
+ * a message is built from and the renderer that turns one into what an inbox
10
+ * receives all belong to the plugin that keeps email, and a composer that
11
+ * imported them would make this package uninstallable without that one.
12
+ *
13
+ * So each is a zone this plugin hosts. It hands over what it holds — the
14
+ * site, the value, a callback — and draws whatever a widget there draws. A
15
+ * widget never writes a campaign: it reports a choice through the callback
16
+ * and the composer does the write, because the record is this plugin's.
17
+ *
18
+ * Outside a console shell, and in a workspace with no plugin filling a zone,
19
+ * each of these draws nothing.
20
+ */
21
+ /** The stream this email belongs to, chosen before it is sent. */
22
+ export interface CampaignTopicSelectZoneProps {
23
+ hostId: string;
24
+ /** The chosen topic id; empty until the widget settles it on a real one. */
25
+ value: string;
26
+ onChange: (topicId: string) => void;
27
+ disabled?: boolean;
28
+ }
29
+ export declare const CAMPAIGN_TOPIC_SELECT_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<CampaignTopicSelectZoneProps>;
30
+ /** One stream a campaign can open on. */
31
+ export interface CampaignTopicOption {
32
+ id: string;
33
+ name: string;
34
+ }
35
+ /**
36
+ * The streams a campaign can open on, REPORTED rather than drawn.
37
+ *
38
+ * The two drawers that collect a campaign's topic are generic forms whose
39
+ * select takes a list of options, so what they need from the catalog's owner
40
+ * is the list. A widget here draws nothing: it reads the catalog while
41
+ * `enabled` and answers through `onTopics`. `enabled` is the read gate —
42
+ * the catalog is the section's largest read and only an open drawer needs it.
43
+ */
44
+ export interface CampaignTopicOptionsZoneProps {
45
+ hostId: string;
46
+ enabled: boolean;
47
+ onTopics: (topics: readonly CampaignTopicOption[]) => void;
48
+ }
49
+ export declare const CAMPAIGN_TOPIC_OPTIONS_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<CampaignTopicOptionsZoneProps>;
50
+ /**
51
+ * Adding a sender without leaving the email being written. The widget is the
52
+ * editor, opened in its ADD mode; `onSaved` names the sender it created so
53
+ * the composer can select it once its own read shows the row.
54
+ */
55
+ export interface CampaignSenderEditorZoneProps {
56
+ hostId: string;
57
+ view: SendingIdentityView | null;
58
+ onClose: () => void;
59
+ onSaved: (senderId?: string) => void;
60
+ }
61
+ export declare const CAMPAIGN_SENDER_EDITOR_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<CampaignSenderEditorZoneProps>;
62
+ /**
63
+ * A design document of this email's own. The widget is the control that mints
64
+ * one; `onCreated` names it, and the composer records the choice on the
65
+ * campaign and opens the editor.
66
+ */
67
+ export interface CampaignDesignCreateZoneProps {
68
+ hostId: string;
69
+ /** What to call the design, so the picker does not list "Untitled email". */
70
+ name?: string;
71
+ onCreated: (design: {
72
+ screenId: string;
73
+ versionId: string;
74
+ }) => void;
75
+ onError: (error: unknown) => void;
76
+ }
77
+ export declare const CAMPAIGN_DESIGN_CREATE_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<CampaignDesignCreateZoneProps>;
78
+ /** The message as an inbox receives it, on the message's own page. */
79
+ export interface CampaignDesignPreviewZoneProps {
80
+ hostId: string;
81
+ /** The version document's raw `nodes` field, in any of its stored forms. */
82
+ nodes: unknown;
83
+ /** The plain-text body, for a message composed without a design. */
84
+ text?: string;
85
+ loading?: boolean;
86
+ subject?: string;
87
+ preheader?: string;
88
+ emptyMessage: string;
89
+ note?: string;
90
+ }
91
+ export declare const CAMPAIGN_DESIGN_PREVIEW_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<CampaignDesignPreviewZoneProps>;
92
+ export declare const CampaignTopicSelect: {
93
+ (props: CampaignTopicSelectZoneProps): ReactElement | null;
94
+ displayName: string;
95
+ };
96
+ export declare const CampaignTopicOptions: {
97
+ (props: CampaignTopicOptionsZoneProps): ReactElement | null;
98
+ displayName: string;
99
+ };
100
+ export declare const CampaignSenderEditor: {
101
+ (props: CampaignSenderEditorZoneProps): ReactElement | null;
102
+ displayName: string;
103
+ };
104
+ export declare const CampaignDesignCreate: {
105
+ (props: CampaignDesignCreateZoneProps): ReactElement | null;
106
+ displayName: string;
107
+ };
108
+ export declare const CampaignDesignPreview: {
109
+ (props: CampaignDesignPreviewZoneProps): ReactElement | null;
110
+ displayName: string;
111
+ };
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ 'use client';
17
+ import { _ as _extends } from "@swc/helpers/_/_extends";
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ import { useConsoleWidgetSlot } from "@aglyn/aglyn/app-utils/console-widget-slot-context";
20
+ import { definePluginZone } from "@aglyn/aglyn/plugin-manager/plugin-zones";
21
+ import { Suspense } from "react";
22
+ export const CAMPAIGN_TOPIC_SELECT_ZONE = definePluginZone('campaignTopicSelect');
23
+ export const CAMPAIGN_TOPIC_OPTIONS_ZONE = definePluginZone('campaignTopicOptions');
24
+ export const CAMPAIGN_SENDER_EDITOR_ZONE = definePluginZone('campaignSenderEditor');
25
+ export const CAMPAIGN_DESIGN_CREATE_ZONE = definePluginZone('campaignDesignCreate');
26
+ export const CAMPAIGN_DESIGN_PREVIEW_ZONE = definePluginZone('campaignDesignPreview');
27
+ /**
28
+ * Draws one of the zones above where the shell provides a renderer.
29
+ *
30
+ * Under its own \`Suspense\`, with nothing as the fallback. A widget is a lazy
31
+ * chunk, and several of these mount in answer to a click — the sender editor,
32
+ * the topics behind an opening drawer. Without a boundary here the suspension
33
+ * would climb to the page's, and the form being filled in would be swapped
34
+ * for a loading state while one drawer's code arrives.
35
+ */ function zoneHost(zone, name) {
36
+ function Host(props) {
37
+ const Zone = useConsoleWidgetSlot();
38
+ return Zone ? /*#__PURE__*/ _jsx(Suspense, {
39
+ fallback: null,
40
+ children: /*#__PURE__*/ _jsx(Zone, _extends({
41
+ slot: zone.id
42
+ }, props))
43
+ }) : null;
44
+ }
45
+ Host.displayName = name;
46
+ return Host;
47
+ }
48
+ export const CampaignTopicSelect = zoneHost(CAMPAIGN_TOPIC_SELECT_ZONE, 'CampaignTopicSelect');
49
+ export const CampaignTopicOptions = zoneHost(CAMPAIGN_TOPIC_OPTIONS_ZONE, 'CampaignTopicOptions');
50
+ export const CampaignSenderEditor = zoneHost(CAMPAIGN_SENDER_EDITOR_ZONE, 'CampaignSenderEditor');
51
+ export const CampaignDesignCreate = zoneHost(CAMPAIGN_DESIGN_CREATE_ZONE, 'CampaignDesignCreate');
52
+ export const CampaignDesignPreview = zoneHost(CAMPAIGN_DESIGN_PREVIEW_ZONE, 'CampaignDesignPreview');
53
+
54
+ //# sourceMappingURL=campaign-email-zones.js.map