@aglyn/plugins-inbox 1.0.0-beta.290 → 1.0.0-beta.291

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,6 +33,8 @@ The Inbox is console-only. Submissions, members and leads live in Firestore and
33
33
  - An "Inbox" glance widget in the `hostDashboard` slot.
34
34
  - A "Submissions" widget in the `formSubmissions` slot, a zone the forms plugin hosts on a form's page. It is the Inbox's own table narrowed to that form.
35
35
  - Two zones the Inbox hosts for other plugins: the body of its Campaigns section, and a "where this came from" attribution area on a lead or submission. The plugin that owns campaigns draws in both.
36
+ - A third, `inboxSubmissionActions` (AGL-4098): an action on an open submission, among its buttons. Commerce draws "Start a quote" there for a quote request.
37
+ - An open submission's files, downloaded through the forms plugin's `/api/forms/submission-file`, and a "Quote request" chip on a request. Deleting a submission asks that route to release its files.
36
38
 
37
39
  ### On the server
38
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/plugins-inbox",
3
- "version": "1.0.0-beta.290",
3
+ "version": "1.0.0-beta.291",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,16 +25,16 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.0.0-beta.290",
29
- "@aglyn/shared-data-mdi": "1.0.0-beta.290",
30
- "@aglyn/shared-ui-jsx": "1.0.0-beta.290",
31
- "@aglyn/shared-ui-next": "1.0.0-beta.290",
32
- "@aglyn/shared-ui-snackstack": "1.0.0-beta.290",
33
- "@aglyn/shared-util-email": "1.0.0-beta.290",
34
- "@aglyn/shared-util-http": "1.0.0-beta.290",
35
- "@aglyn/shared-util-tools": "1.0.0-beta.290",
36
- "@aglyn/tenant-data-admin": "1.0.0-beta.290",
37
- "@aglyn/tenant-feature-instance": "1.0.0-beta.290",
28
+ "@aglyn/aglyn": "1.0.0-beta.291",
29
+ "@aglyn/shared-data-mdi": "1.0.0-beta.291",
30
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.291",
31
+ "@aglyn/shared-ui-next": "1.0.0-beta.291",
32
+ "@aglyn/shared-ui-snackstack": "1.0.0-beta.291",
33
+ "@aglyn/shared-util-email": "1.0.0-beta.291",
34
+ "@aglyn/shared-util-http": "1.0.0-beta.291",
35
+ "@aglyn/shared-util-tools": "1.0.0-beta.291",
36
+ "@aglyn/tenant-data-admin": "1.0.0-beta.291",
37
+ "@aglyn/tenant-feature-instance": "1.0.0-beta.291",
38
38
  "@swc/helpers": "0.5.23"
39
39
  },
40
40
  "peerDependencies": {
@@ -0,0 +1,43 @@
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
+ */
17
+ /**
18
+ * Something to DO with an open submission, drawn by the plugin that does it
19
+ * (AGL-4098): "Start a quote" on a quote request, from the plugin that makes
20
+ * quotes. The Inbox lists what arrived and may not import that plugin, so it
21
+ * hosts this zone among the open submission's actions and hands it what the
22
+ * submission is; a widget decides for itself whether it has anything to offer
23
+ * (a quote for a `quote` request, nothing for an ordinary message).
24
+ *
25
+ * The widget reads anything more it needs through the forms plugin's facts
26
+ * reader on the server, under its own permission, and writes nothing through
27
+ * the Inbox.
28
+ */
29
+ export interface InboxSubmissionActionsZoneProps {
30
+ /** The site the submission was sent on. */
31
+ hostId: string;
32
+ submissionId: string;
33
+ /** What the submission asks for (`quote`), or null for an ordinary message. */
34
+ requestKind: string | null;
35
+ /** The form it was sent to, as it was called when it arrived. */
36
+ formName: string;
37
+ }
38
+ export declare const INBOX_SUBMISSION_ACTIONS_ZONE: import("@aglyn/aglyn/plugin-manager/plugin-zones").PluginZone<InboxSubmissionActionsZoneProps>;
39
+ /** One control among the open submission's actions: the zone is `bare`. */
40
+ export declare function InboxSubmissionActionsZone(props: InboxSubmissionActionsZoneProps): import("react").JSX.Element;
41
+ export declare namespace InboxSubmissionActionsZone {
42
+ var displayName: string;
43
+ }
@@ -0,0 +1,31 @@
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
+ export const INBOX_SUBMISSION_ACTIONS_ZONE = definePluginZone('inboxSubmissionActions');
22
+ /** One control among the open submission's actions: the zone is `bare`. */ export function InboxSubmissionActionsZone(props) {
23
+ const Slot = useConsoleWidgetSlot();
24
+ if (!Slot) return null;
25
+ return /*#__PURE__*/ _jsx(Slot, _extends({
26
+ slot: INBOX_SUBMISSION_ACTIONS_ZONE.id
27
+ }, props));
28
+ }
29
+ InboxSubmissionActionsZone.displayName = 'InboxSubmissionActionsZone';
30
+
31
+ //# sourceMappingURL=inbox-submission-actions-zone.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/inbox/src/lib/components/inbox-submission-actions-zone.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\n'use client'\n\nimport { useConsoleWidgetSlot } from '@aglyn/aglyn/app-utils/console-widget-slot-context'\nimport { definePluginZone } from '@aglyn/aglyn/plugin-manager/plugin-zones'\n\n/**\n * Something to DO with an open submission, drawn by the plugin that does it\n * (AGL-4098): \"Start a quote\" on a quote request, from the plugin that makes\n * quotes. The Inbox lists what arrived and may not import that plugin, so it\n * hosts this zone among the open submission's actions and hands it what the\n * submission is; a widget decides for itself whether it has anything to offer\n * (a quote for a `quote` request, nothing for an ordinary message).\n *\n * The widget reads anything more it needs through the forms plugin's facts\n * reader on the server, under its own permission, and writes nothing through\n * the Inbox.\n */\nexport interface InboxSubmissionActionsZoneProps {\n /** The site the submission was sent on. */\n hostId: string\n submissionId: string\n /** What the submission asks for (`quote`), or null for an ordinary message. */\n requestKind: string | null\n /** The form it was sent to, as it was called when it arrived. */\n formName: string\n}\n\nexport const INBOX_SUBMISSION_ACTIONS_ZONE =\n definePluginZone<InboxSubmissionActionsZoneProps>('inboxSubmissionActions')\n\n/** One control among the open submission's actions: the zone is `bare`. */\nexport function InboxSubmissionActionsZone(props: InboxSubmissionActionsZoneProps) {\n const Slot = useConsoleWidgetSlot()\n if (!Slot) return null\n return <Slot slot={INBOX_SUBMISSION_ACTIONS_ZONE.id} {...props} />\n}\nInboxSubmissionActionsZone.displayName = 'InboxSubmissionActionsZone'\n"],"names":["useConsoleWidgetSlot","definePluginZone","INBOX_SUBMISSION_ACTIONS_ZONE","InboxSubmissionActionsZone","props","Slot","slot","id","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,oBAAoB,QAAQ,qDAAoD;AACzF,SAASC,gBAAgB,QAAQ,2CAA0C;AAwB3E,OAAO,MAAMC,gCACXD,iBAAkD,0BAAyB;AAE7E,yEAAyE,GACzE,OAAO,SAASE,2BAA2BC,KAAsC;IAC/E,MAAMC,OAAOL;IACb,IAAI,CAACK,MAAM,OAAO;IAClB,qBAAO,KAACA;QAAKC,MAAMJ,8BAA8BK,EAAE;OAAMH;AAC3D;AACAD,2BAA2BK,WAAW,GAAG"}
@@ -0,0 +1,38 @@
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
+ */
17
+ import { type SubmissionFile } from '../model/submission-presenter';
18
+ /**
19
+ * The forms plugin's route for a submission's files (AGL-4098), by address:
20
+ * this plugin shows the files and may not import the plugin that keeps them.
21
+ */
22
+ export declare const FORM_SUBMISSION_FILE_API_PATH = "/api/forms/submission-file";
23
+ export interface SubmissionFilesProps {
24
+ hostId: string;
25
+ submissionId: string;
26
+ files: readonly SubmissionFile[];
27
+ }
28
+ /**
29
+ * The files an open submission carries (AGL-4098): each by name and size,
30
+ * downloaded when pressed through the forms plugin's member-gated route, with
31
+ * the member's own token. Nothing is shown inside the console: every file,
32
+ * a picture included, is saved to the reader's computer.
33
+ */
34
+ export declare function SubmissionFiles(props: SubmissionFilesProps): import("react").JSX.Element;
35
+ export declare namespace SubmissionFiles {
36
+ var displayName: string;
37
+ }
38
+ export default SubmissionFiles;
@@ -0,0 +1,116 @@
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 } from "react/jsx-runtime";
18
+ import { useSnackbar } from "@aglyn/shared-ui-snackstack";
19
+ import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
20
+ import { useUser } from "@aglyn/tenant-feature-instance";
21
+ import { Chip, Stack, Typography } from "@mui/material";
22
+ import { useCallback, useState } from "react";
23
+ import { submissionFileSize } from "../model/submission-presenter.js";
24
+ /**
25
+ * The forms plugin's route for a submission's files (AGL-4098), by address:
26
+ * this plugin shows the files and may not import the plugin that keeps them.
27
+ */ export const FORM_SUBMISSION_FILE_API_PATH = '/api/forms/submission-file';
28
+ /**
29
+ * The files an open submission carries (AGL-4098): each by name and size,
30
+ * downloaded when pressed through the forms plugin's member-gated route, with
31
+ * the member's own token. Nothing is shown inside the console: every file,
32
+ * a picture included, is saved to the reader's computer.
33
+ */ export function SubmissionFiles(props) {
34
+ const { hostId, submissionId, files } = props;
35
+ const { data: user } = useUser();
36
+ const { enqueueSnackbar } = useSnackbar();
37
+ const [busy, setBusy] = useState(null);
38
+ const download = useCallback(async (file)=>{
39
+ setBusy(file.id);
40
+ try {
41
+ const response = await authorizedFetch(user, FORM_SUBMISSION_FILE_API_PATH, {
42
+ method: 'POST',
43
+ headers: {
44
+ 'Content-Type': 'application/json'
45
+ },
46
+ body: JSON.stringify({
47
+ action: 'download',
48
+ hostId,
49
+ submissionId,
50
+ fileId: file.id
51
+ })
52
+ });
53
+ if (!response.ok) {
54
+ var _ref;
55
+ const payload = await response.json().catch(()=>({}));
56
+ enqueueSnackbar((_ref = payload == null ? void 0 : payload.error) != null ? _ref : `${file.name} could not be downloaded`, {
57
+ variant: 'error',
58
+ allowDuplicate: true
59
+ });
60
+ return;
61
+ }
62
+ const url = URL.createObjectURL(await response.blob());
63
+ const link = document.createElement('a');
64
+ link.href = url;
65
+ link.download = file.name;
66
+ link.click();
67
+ setTimeout(()=>URL.revokeObjectURL(url), 0);
68
+ } catch (unused) {
69
+ enqueueSnackbar(`${file.name} could not be downloaded`, {
70
+ variant: 'error',
71
+ allowDuplicate: true
72
+ });
73
+ } finally{
74
+ setBusy(null);
75
+ }
76
+ }, [
77
+ user,
78
+ hostId,
79
+ submissionId,
80
+ enqueueSnackbar
81
+ ]);
82
+ if (!files.length) return null;
83
+ return /*#__PURE__*/ _jsxs(Stack, {
84
+ spacing: 0.75,
85
+ sx: {
86
+ mt: 1.5
87
+ },
88
+ children: [
89
+ /*#__PURE__*/ _jsx(Typography, {
90
+ variant: "caption",
91
+ color: "text.secondary",
92
+ children: files.length === 1 ? 'File' : `Files (${files.length})`
93
+ }),
94
+ /*#__PURE__*/ _jsx(Stack, {
95
+ direction: "row",
96
+ spacing: 1,
97
+ useFlexGap: true,
98
+ sx: {
99
+ flexWrap: 'wrap'
100
+ },
101
+ children: files.map((file)=>/*#__PURE__*/ _jsx(Chip, {
102
+ size: "small",
103
+ variant: "outlined",
104
+ label: `${file.name} · ${submissionFileSize(file.size)}`,
105
+ onClick: ()=>void download(file),
106
+ disabled: busy === file.id,
107
+ title: `Download ${file.name}`
108
+ }, file.id))
109
+ })
110
+ ]
111
+ });
112
+ }
113
+ SubmissionFiles.displayName = 'SubmissionFiles';
114
+ export default SubmissionFiles;
115
+
116
+ //# sourceMappingURL=submission-files.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/inbox/src/lib/components/submission-files.component.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\n'use client'\n\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport { Chip, Stack, Typography } from '@mui/material'\nimport { useCallback, useState } from 'react'\nimport { submissionFileSize, type SubmissionFile } from '../model/submission-presenter'\n\n/**\n * The forms plugin's route for a submission's files (AGL-4098), by address:\n * this plugin shows the files and may not import the plugin that keeps them.\n */\nexport const FORM_SUBMISSION_FILE_API_PATH = '/api/forms/submission-file'\n\nexport interface SubmissionFilesProps {\n hostId: string\n submissionId: string\n files: readonly SubmissionFile[]\n}\n\n/**\n * The files an open submission carries (AGL-4098): each by name and size,\n * downloaded when pressed through the forms plugin's member-gated route, with\n * the member's own token. Nothing is shown inside the console: every file,\n * a picture included, is saved to the reader's computer.\n */\nexport function SubmissionFiles(props: SubmissionFilesProps) {\n const { hostId, submissionId, files } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [busy, setBusy] = useState<string | null>(null)\n\n const download = useCallback(\n async (file: SubmissionFile) => {\n setBusy(file.id)\n try {\n const response = await authorizedFetch(user, FORM_SUBMISSION_FILE_API_PATH, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action: 'download', hostId, submissionId, fileId: file.id }),\n })\n if (!response.ok) {\n const payload = await response.json().catch(() => ({}))\n enqueueSnackbar(payload?.error ?? `${file.name} could not be downloaded`, {\n variant: 'error',\n allowDuplicate: true,\n })\n return\n }\n const url = URL.createObjectURL(await response.blob())\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 0)\n } catch {\n enqueueSnackbar(`${file.name} could not be downloaded`, { variant: 'error', allowDuplicate: true })\n } finally {\n setBusy(null)\n }\n },\n [user, hostId, submissionId, enqueueSnackbar],\n )\n\n if (!files.length) return null\n return (\n <Stack spacing={0.75} sx={{ mt: 1.5 }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {files.length === 1 ? 'File' : `Files (${files.length})`}\n </Typography>\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {files.map((file) => (\n <Chip\n key={file.id}\n size=\"small\"\n variant=\"outlined\"\n label={`${file.name} · ${submissionFileSize(file.size)}`}\n onClick={() => void download(file)}\n disabled={busy === file.id}\n title={`Download ${file.name}`}\n />\n ))}\n </Stack>\n </Stack>\n )\n}\nSubmissionFiles.displayName = 'SubmissionFiles'\n\nexport default SubmissionFiles\n"],"names":["useSnackbar","authorizedFetch","useUser","Chip","Stack","Typography","useCallback","useState","submissionFileSize","FORM_SUBMISSION_FILE_API_PATH","SubmissionFiles","props","hostId","submissionId","files","data","user","enqueueSnackbar","busy","setBusy","download","file","id","response","method","headers","body","JSON","stringify","action","fileId","ok","payload","json","catch","error","name","variant","allowDuplicate","url","URL","createObjectURL","blob","link","document","createElement","href","click","setTimeout","revokeObjectURL","length","spacing","sx","mt","color","direction","useFlexGap","flexWrap","map","size","label","onClick","disabled","title","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,SAASA,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SAASC,IAAI,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACvD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AwB,CAAC,EAAE;gBAAEC,SAAS;gBAASC,gBAAgB;YAAK;QACnG,SAAU;YACRnB,QAAQ;QACV;IACF,GACA;QAACH;QAAMJ;QAAQC;QAAcI;KAAgB;IAG/C,IAAI,CAACH,MAAMoC,MAAM,EAAE,OAAO;IAC1B,qBACE,MAAC9C;QAAM+C,SAAS;QAAMC,IAAI;YAAEC,IAAI;QAAI;;0BAClC,KAAChD;gBAAWgC,SAAQ;gBAAUiB,OAAM;0BACjCxC,MAAMoC,MAAM,KAAK,IAAI,SAAS,CAAC,OAAO,EAAEpC,MAAMoC,MAAM,CAAC,CAAC,CAAC;;0BAE1D,KAAC9C;gBAAMmD,WAAU;gBAAMJ,SAAS;gBAAGK,UAAU;gBAACJ,IAAI;oBAAEK,UAAU;gBAAO;0BAClE3C,MAAM4C,GAAG,CAAC,CAACrC,qBACV,KAAClB;wBAECwD,MAAK;wBACLtB,SAAQ;wBACRuB,OAAO,GAAGvC,KAAKe,IAAI,CAAC,GAAG,EAAE5B,mBAAmBa,KAAKsC,IAAI,GAAG;wBACxDE,SAAS,IAAM,KAAKzC,SAASC;wBAC7ByC,UAAU5C,SAASG,KAAKC,EAAE;wBAC1ByC,OAAO,CAAC,SAAS,EAAE1C,KAAKe,IAAI,EAAE;uBANzBf,KAAKC,EAAE;;;;AAYxB;AACAZ,gBAAgBsD,WAAW,GAAG;AAE9B,eAAetD,gBAAe"}
@@ -49,7 +49,9 @@ import { collection, deleteDoc, getDoc, limit, orderBy, query, updateDoc } from
49
49
  import { pluginRecordListDoc, pluginRecordListWalk } from "@aglyn/aglyn/plugin-manager/plugin-record-lists";
50
50
  import { useSearchParams } from "next/navigation";
51
51
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
52
- import { relativeTime, routingChips, senderHue, submissionSender } from "../model/submission-presenter.js";
52
+ import { relativeTime, routingChips, senderHue, submissionFiles, submissionRequestKind, submissionRequestLabel, submissionSender } from "../model/submission-presenter.js";
53
+ import { InboxSubmissionActionsZone } from "./inbox-submission-actions-zone.js";
54
+ import SubmissionFiles, { FORM_SUBMISSION_FILE_API_PATH } from "./submission-files.component.js";
53
55
  import { FORM_SCOPED_SUBMISSION_LIST_QUERY, ORG_SUBMISSION_LIST_QUERY, SUBMISSION_FILTER_HEADERS, SUBMISSION_LIST_QUERY, SUBMISSION_READ_OPTIONS, formSubmissionBase, orgSubmissionBase } from "../constants/list-queries.js";
54
56
  import { orgSiteName } from "./inbox-org-sites.js";
55
57
  import SubmissionListAssignment from "./submission-list-assignment.component.js";
@@ -79,7 +81,7 @@ const messageTextOf = (submission)=>{
79
81
  return Object.entries((_ref = submission == null ? void 0 : submission.fields) != null ? _ref : {}).map(([key, value])=>`${key}: ${value}`).join(' · ');
80
82
  };
81
83
  export function SubmissionsCard({ hostId, formId, orgMount }) {
82
- var _ref, _ref1, _ref2, _ref3, _ref4, _hostPublicOrigin, _ref5, _ref6, _ref7;
84
+ var _ref, _ref1, _ref2, _ref3, _ref4, _hostPublicOrigin, _ref5, _ref6, _ref7, _reader_formName;
83
85
  var _reader_createdAt_toDate, _reader_createdAt, _orgMount_hosts_find;
84
86
  const firestore = useFirestore();
85
87
  const { enqueueSnackbar } = useSnackbar();
@@ -376,6 +378,17 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
376
378
  persist: false
377
379
  });
378
380
  /*
381
+ * Its files go with it (AGL-4098). They are in private storage, which
382
+ * the browser cannot reach, so the forms plugin deletes them once the
383
+ * submission is gone. Best effort: the delete has happened either way.
384
+ */ if (submissionFiles(submission.files).length) {
385
+ void postPluginApi(FORM_SUBMISSION_FILE_API_PATH, {
386
+ action: 'release',
387
+ hostId: site,
388
+ submissionId: submission.$id
389
+ });
390
+ }
391
+ /*
379
392
  * The form counted this submission when it arrived (AGL-3330), and an
380
393
  * increment cannot see a delete: the forms plugin recounts the form
381
394
  * from the rows that are left. Best effort — the delete has happened
@@ -499,11 +512,27 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
499
512
  noWrap: true,
500
513
  children: sender.label
501
514
  }),
502
- /*#__PURE__*/ _jsx(Typography, {
503
- variant: "caption",
504
- color: "text.secondary",
505
- noWrap: true,
506
- children: (_submission_formName = submission.formName) != null ? _submission_formName : 'Form'
515
+ /*#__PURE__*/ _jsxs(Stack, {
516
+ direction: "row",
517
+ spacing: 0.5,
518
+ sx: {
519
+ alignItems: 'center',
520
+ minWidth: 0
521
+ },
522
+ children: [
523
+ /*#__PURE__*/ _jsx(Typography, {
524
+ variant: "caption",
525
+ color: "text.secondary",
526
+ noWrap: true,
527
+ children: (_submission_formName = submission.formName) != null ? _submission_formName : 'Form'
528
+ }),
529
+ submissionRequestLabel(submission.request) ? /*#__PURE__*/ _jsx(Chip, {
530
+ size: "small",
531
+ color: "info",
532
+ variant: "outlined",
533
+ label: submissionRequestLabel(submission.request)
534
+ }) : null
535
+ ]
507
536
  })
508
537
  ]
509
538
  })
@@ -694,7 +723,24 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
694
723
  fullWidth: true,
695
724
  children: [
696
725
  /*#__PURE__*/ _jsx(DialogTitle, {
697
- children: (_ref3 = reader == null ? void 0 : reader.formName) != null ? _ref3 : 'Form submission'
726
+ children: /*#__PURE__*/ _jsxs(Stack, {
727
+ direction: "row",
728
+ spacing: 1,
729
+ sx: {
730
+ alignItems: 'center'
731
+ },
732
+ children: [
733
+ /*#__PURE__*/ _jsx("span", {
734
+ children: (_ref3 = reader == null ? void 0 : reader.formName) != null ? _ref3 : 'Form submission'
735
+ }),
736
+ submissionRequestLabel(reader == null ? void 0 : reader.request) ? /*#__PURE__*/ _jsx(Chip, {
737
+ size: "small",
738
+ color: "info",
739
+ variant: "outlined",
740
+ label: submissionRequestLabel(reader == null ? void 0 : reader.request)
741
+ }) : null
742
+ ]
743
+ })
698
744
  }),
699
745
  /*#__PURE__*/ _jsxs(DialogContent, {
700
746
  children: [
@@ -770,6 +816,11 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
770
816
  ]
771
817
  }, key))
772
818
  }),
819
+ (reader == null ? void 0 : reader.$id) && readerSite && submissionFiles(reader.files).length ? /*#__PURE__*/ _jsx(SubmissionFiles, {
820
+ hostId: readerSite,
821
+ submissionId: String(reader.$id),
822
+ files: submissionFiles(reader.files)
823
+ }) : null,
773
824
  /*#__PURE__*/ _jsx(Stack, {
774
825
  useFlexGap: true,
775
826
  direction: "row",
@@ -809,6 +860,12 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
809
860
  }),
810
861
  /*#__PURE__*/ _jsxs(DialogActions, {
811
862
  children: [
863
+ (reader == null ? void 0 : reader.$id) && readerSite ? /*#__PURE__*/ _jsx(InboxSubmissionActionsZone, {
864
+ hostId: readerSite,
865
+ submissionId: String(reader.$id),
866
+ requestKind: submissionRequestKind(reader.request),
867
+ formName: String((_reader_formName = reader.formName) != null ? _reader_formName : 'Form')
868
+ }) : null,
812
869
  /*#__PURE__*/ _jsx(Button, {
813
870
  color: "error",
814
871
  onClick: async ()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/inbox/src/lib/components/submissions-card.component.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 FORMS_MAX_PER_HOST,\n pluginDocsHelp,\n type ConsolePluginOrgMount,\n} from '@aglyn/aglyn'\nimport { INBOX_SUBMISSION_PARAM } from '../model/inbox-record-routes'\nimport { hostPublicOrigin } from '@aglyn/aglyn/app-utils/host-naming'\nimport { submissionFiledUnder, submissionLinks } from '../model/submission-links'\n\n/** The forms plugin's record kind this card reads (AGL-3080). */\nconst FORM_SUBMISSION_KIND = 'formSubmission'\n// A deep import, NOT the plugin barrel (AGL-1151): the barrel is the entry\n// point the tenant's loader dynamically imports to activate the marketing\n// plugin's SITE half, so a console card named there ships to every published\n// page. The component path reaches the same module without crossing it.\nimport { InboxRecordAttributionZone } from './inbox-attribution-zone'\n// The CRM's route builder by its leaf path, for the reason above: the barrel\n// is the plugin's site entry point.\nimport {\n pluginRecordByEmailHref,\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport {\n mdiAccountArrowRight,\n mdiDeleteOutline,\n mdiEmailOpenOutline,\n mdiEmailOutline,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, CardDisplay, MdiIcon, useConfirmationContext } 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 type { RowActionsMenuItem } from '@aglyn/shared-ui-jsx/components/row-actions-menu.component'\nimport {\n type ListFilterOption,\n listFilterGridColumns,\n} from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport type { ListQueryDeclaration } from '@aglyn/shared-ui-jsx/const/list-query-plan'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n useFirestore,\n useFirestoreCollection,\n usePluginApiPost,\n} from '@aglyn/tenant-feature-instance'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\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 {\n Avatar,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Divider,\n Stack,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport {\n collection,\n deleteDoc,\n getDoc,\n limit,\n orderBy,\n query,\n updateDoc,\n} from 'firebase/firestore'\n// The submissions are the forms plugin's records, walked and opened through\n// the list source it publishes (AGL-3080).\nimport {\n pluginRecordListDoc,\n pluginRecordListWalk,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-lists'\nimport { useSearchParams } from 'next/navigation'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n relativeTime,\n routingChips,\n senderHue,\n submissionSender,\n} from '../model/submission-presenter'\nimport {\n FORM_SCOPED_SUBMISSION_LIST_QUERY,\n ORG_SUBMISSION_LIST_QUERY,\n SUBMISSION_FILTER_HEADERS,\n SUBMISSION_LIST_QUERY,\n SUBMISSION_READ_OPTIONS,\n formSubmissionBase,\n orgSubmissionBase,\n} from '../constants/list-queries'\nimport { orgSiteName } from './inbox-org-sites'\nimport SubmissionListAssignment from './submission-list-assignment.component'\nimport SubmissionReply from './submission-reply.component'\nimport { useRecordRouteContext } from './use-record-route-context'\n\n\n/**\n * The forms plugin's recount route (AGL-3330), by address: this plugin\n * shows the submissions a form counts and may not import the plugin that\n * keeps the counts.\n */\nconst FORM_STATS_API_PATH = '/api/forms/stats'\n/** Read, Form and Site are picked, so the panel shows selects. */\nconst SUBMISSION_SELECT_FIELDS = ['read', 'formId', 'hostId']\nconst SUBMISSION_HIDDEN_COLUMNS = { read: false, formId: false }\n\n/** Every field of a message, as one line — what the Message column draws. */\n/** The page-sorted headers, for their notice (AGL-3680). */\nconst SUBMISSION_PAGE_SORT_HEADERS = { from: 'From', hostId: 'Site', message: 'Message' }\n\nconst messageTextOf = (submission: any): string =>\n Object.entries(submission?.fields ?? {})\n .map(([key, value]) => `${key}: ${value}`)\n .join(' · ')\n\n/**\n * The Submissions section of the Inbox (AGL-77/104/109 → AGL-395): the form\n * messages a site collected, newest first, and the reader that opens one.\n *\n * Its own component since AGL-2501, when the Inbox's tabs became routes. The\n * split is what makes \"mount only the section being read\" structural: hooks\n * cannot be conditional, so a page holding every section's reads pays for all\n * of them whichever one the URL names.\n */\nexport interface SubmissionsCardProps {\n /**\n * The site whose submissions are listed, or `null` on the organization's\n * Inbox, where the card lists every site's at once (AGL-3303) and each row\n * is acted on as the site it was sent to.\n */\n hostId: string | null\n /** The organization and its sites — present exactly when `hostId` is `null`. */\n orgMount?: ConsolePluginOrgMount\n /**\n * Narrow this card to ONE form, permanently.\n *\n * What the forms plugin's detail surface renders instead of a second\n * submissions table. The reader has already chosen the subject by being on\n * that page, so scoping here does three things a copy would have had to\n * re-derive: the form picker is not rendered (there is nothing to pick),\n * the site's `forms` collection is not read at all (the picker was its only\n * consumer), and the empty state names the form rather than the site.\n *\n * Everything else — the paged walk, the reader dialog, read/unread,\n * delete, reply, list assignment, attribution — is the same code answering\n * a narrower query. That is the reason this is a prop rather than a second\n * component: a per-form table written separately would be a second reader\n * to keep in step, and it would have been the one to reintroduce the\n * unordered `limit()` this card's own comment exists to warn about.\n */\n formId?: string\n}\n\nexport function SubmissionsCard({\n hostId,\n formId,\n orgMount,\n}: SubmissionsCardProps) {\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n const postPluginApi = usePluginApiPost()\n const { confirm } = useConfirmationContext()\n /** Scoped to one form: the subject is fixed and nothing may widen it. */\n const scoped = Boolean(formId)\n /** Every site of this organization at once, when no site is named. */\n const orgId = hostId == null ? (orgMount?.orgId ?? null) : null\n /*\n * The site a row lives on, which is where every act on it is addressed:\n * this card's own site, or — across every site — the `hostId` the submit\n * route stamps on the row. That stamp is frozen against a client update and\n * written from the row's own path, so it names the document's real parent;\n * the rules check the host role on that site either way.\n */\n const siteOf = useCallback(\n (submission: any): string | null =>\n hostId ??\n (typeof submission?.hostId === 'string' && submission.hostId\n ? submission.hostId\n : null),\n [hostId],\n )\n /*\n * Where the sender's CONTACT is (AGL-2612). A submission that carried an\n * address updated a contact in the CRM at stage Lead; the row links to\n * it by that address, and the Contacts list — which holds the id nothing\n * here does — opens the record. The same hub path the Members & leads\n * rows use to open a lead.\n */\n const routeContext = useRecordRouteContext()\n\n /*\n * The site's forms, for the Submissions filter.\n *\n * `FORMS_MAX_PER_HOST` is a read WINDOW, not a cap on the collection — how\n * many forms a site may hold is `formsPerHost`, enforced at the create in\n * `/api/hosts/resources`, and a staff-set per-org override can raise it\n * past this window. So the window can be smaller than the catalog, and one\n * more document than fits is read on purpose: a filter that quietly listed\n * the first N would report \"this form does not exist\" and \"this form is\n * past the window\" as the same empty answer.\n *\n * Ordered by `__name__`. `displayName` would be the nicer order and is the\n * wrong instrument: `orderBy` on a data field DROPS every document missing\n * it, invisibly, so a form saved without a name would vanish from its own\n * filter. The list is sorted for display below, where a missing name is\n * merely ugly.\n */\n const { data: formDocs } = useFirestoreCollection<any>(\n () =>\n // Forms are one site's catalog. Across every site there is no single\n // catalog to filter by, and picking a site is how a reader gets one.\n scoped || !hostId\n ? null\n : query(\n collection(firestore, 'hosts', hostId, 'forms'),\n orderBy('__name__'),\n limit(FORMS_MAX_PER_HOST + 1),\n ),\n [firestore, hostId, scoped],\n { idField: '$id' },\n )\n /** More forms exist than the window shows; the filter has to say so. */\n const formsTruncated = (formDocs?.length ?? 0) > FORMS_MAX_PER_HOST\n const forms = useMemo(\n () =>\n [...(formDocs ?? [])]\n .slice(0, FORMS_MAX_PER_HOST)\n .sort((left: any, right: any) =>\n String(left.displayName ?? left.$id).localeCompare(\n String(right.displayName ?? right.$id),\n ),\n ),\n [formDocs],\n )\n /** Form is offered where the site's catalog is read. */\n const offersForm = !scoped && Boolean(hostId) && forms.length > 0\n /*\n * WHAT THIS CARD'S LIST CAN BE ASKED (AGL-3321) — every clause and the\n * search on the query, see `SUBMISSION_LIST_QUERY`:\n *\n * - a site's Inbox: From, Read and — where the site has forms — Form;\n * - a card scoped to one form: that form is the list's own scope, and\n * Form has nothing left to pick, so it is not offered. The scope wins\n * over any clause: it is the base, and no clause can reach it;\n * - every site's, on the organization's Inbox: From, Read and Site,\n * under the `orgId` clause the rules require of the group read.\n */\n const declaration = useMemo<ListQueryDeclaration>(() => {\n if (scoped) return FORM_SCOPED_SUBMISSION_LIST_QUERY\n if (hostId == null) return ORG_SUBMISSION_LIST_QUERY\n return offersForm\n ? SUBMISSION_LIST_QUERY\n : {\n ...SUBMISSION_LIST_QUERY,\n fields: SUBMISSION_LIST_QUERY.fields.filter((field) => field.column !== 'formId'),\n }\n }, [scoped, hostId, offersForm])\n const base = useMemo(\n () =>\n formId ? formSubmissionBase(formId) : hostId == null && orgId ? orgSubmissionBase(orgId) : [],\n [formId, hostId, orgId],\n )\n const gridFilter = useListGridFilter({ selectFields: SUBMISSION_SELECT_FIELDS })\n /*\n * EVERY HEADER SORTS (AGL-3680). Received and Read order the QUERY (see\n * `SUBMISSION_LIST_QUERY`); From, Site and Message are drawn from the\n * message, so they sort the page on screen and say so. Null is newest\n * first, the inbox's own order.\n */\n const [askedSort, setAskedSort] = useState<ListQuerySort | null>(null)\n\n /*\n * The inbox WALKS its submissions instead of sampling them (AGL-2501,\n * AGL-2292), and every filter and search word is a predicate on the walk\n * (AGL-3321), so a page is a page of the matches.\n *\n * `limit(200)` carried no `orderBy`, so Firestore answered it in\n * DOCUMENT-ID order over ids `add()` generates — an arbitrary two hundred\n * of the site's messages, which the client sort then arranged newest-first\n * so the result looked like a feed. A site past two hundred submissions\n * could not reach the rest, and the messages missing left no gap: the row\n * dates on screen simply skipped, which reads as a quiet week rather than\n * as an unreachable inbox.\n *\n * `createdAt` is safe to order on, checked against the writer rather than\n * assumed: `libs/plugins/forms/src/lib/server/form-submit.ts` is the only path\n * that creates one and stamps `createdAt: serverTimestamp()` on every add,\n * the v1 API only ever reads and deletes, and `formSubmissions` is absent\n * from `IMPORTABLE_FIELDS`, so no restore path can make one without it.\n *\n * EVERY SITE'S SUBMISSIONS IN ONE QUERY on the organization's Inbox\n * (AGL-3303), not a listener per site: the collection group, newest first.\n * The `orgId` clause is not a filter this card could drop. The rules admit\n * a group read only when it is narrowed to an org the reader spans, so an\n * unfiltered group query is refused outright. Every submission carries\n * `orgId`: the submit route stamps it, and the rows written before it did\n * were stamped once (AGL-3303). A row without one would be in no\n * organization's list, though its own site's Inbox lists it either way.\n */\n const {\n rows: submissions,\n hasMore: hasMoreSubmissions,\n page: submissionPage,\n setPage: setSubmissionPage,\n pageSize: submissionPageSize,\n setPageSize: setSubmissionPageSize,\n plan,\n } = useListQuery<any>({\n collection: pluginRecordListWalk(FORM_SUBMISSION_KIND, firestore, { hostId, orgId }),\n declaration,\n request: {\n clauses: gridFilter.clauses,\n search: gridFilter.searchWords,\n sort: askedSort,\n base,\n },\n deps: [firestore, hostId, orgId],\n idField: '$id',\n })\n const submissionOptions = useMemo<Readonly<Record<string, readonly ListFilterOption[]>>>(\n () => ({\n read: SUBMISSION_READ_OPTIONS,\n ...(offersForm\n ? {\n formId: forms.map((form: any) => ({\n value: String(form.$id),\n label: String(form.displayName || form.$id),\n })),\n }\n : {}),\n ...(hostId == null\n ? {\n hostId: (orgMount?.hosts ?? []).map((host) => ({\n value: host.id,\n label: host.name || host.id,\n })),\n }\n : {}),\n }),\n [offersForm, forms, hostId, orgMount],\n )\n const refusals = useMemo(\n () =>\n listQueryRefusals(plan.refused, {\n fields: declaration.fields,\n headers: SUBMISSION_FILTER_HEADERS,\n options: submissionOptions,\n }),\n [plan.refused, declaration, submissionOptions],\n )\n const submissionPageSorts = useMemo(\n () => ({\n from: (submission: any) => submissionSender(submission.fields).label,\n hostId: (submission: any) => orgSiteName(orgMount, submission.hostId),\n message: (submission: any) => messageTextOf(submission),\n }),\n [orgMount],\n )\n const columnSort = useListColumnSort<any>({\n sorts: declaration.sorts,\n defaultSort: declaration.sorts[0],\n sort: askedSort,\n onSortChange: setAskedSort,\n orderBy: plan.orderBy,\n rows: submissions,\n pageSorts: submissionPageSorts,\n headers: SUBMISSION_PAGE_SORT_HEADERS,\n })\n const searching = gridFilter.searchWords.some((word) => word.trim())\n const filtering = gridFilter.clauses.length > 0 || searching\n /** Narrowed by nothing but a Form clause. */\n const onlyForm =\n !searching &&\n gridFilter.clauses.length > 0 &&\n gridFilter.clauses.every((clause) => clause.field === 'formId')\n\n // Mail reader (AGL-104): opening a submission shows the full message and\n // marks it read.\n const [reader, setReader] = useState<any | null>(null)\n const handleOpenReader = useCallback(\n (submission: any) => () => {\n setReader(submission)\n const site = siteOf(submission)\n const submissionDoc = site\n ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, { hostId: site, id: submission.$id })\n : null\n if (!submission.read && submissionDoc) {\n void updateDoc(submissionDoc, { read: true })\n }\n },\n [firestore, siteOf],\n )\n\n const handleToggleRead = useCallback(\n (submission: any) => () => {\n const site = siteOf(submission)\n const submissionDoc = site\n ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, { hostId: site, id: submission.$id })\n : null\n if (!submissionDoc) return\n void updateDoc(submissionDoc, { read: !submission.read })\n },\n [firestore, siteOf],\n )\n\n /*\n * A submission named in the URL opens in the reader on arrival (AGL-2622).\n *\n * A contact's timeline names the submission that captured the person, and\n * the address it links to is this tab with `?submission={id}`. The\n * document is read once, by id, rather than looked for in the paged\n * window: the window is the newest page of a walk that may not reach a\n * submission from months back, and one document read is what the URL\n * asked for. Opening it marks it read, as a click on the row would. A\n * submission that is gone says so, because a reader that silently stays\n * shut reads as the link having done nothing.\n *\n * Once per id: the ref keeps a re-render — and the same URL re-settling —\n * from reopening a reader the person has since closed. The landing read\n * is judged against that ref rather than an effect cleanup: a listener\n * settling while the read is in flight re-renders this card, and a\n * cleanup keyed on any dep would cancel the answer to the question the\n * URL just asked.\n */\n const searchParams = useSearchParams()\n const seededSubmissionId = searchParams?.get(INBOX_SUBMISSION_PARAM) ?? null\n const seededOpened = useRef<string | null>(null)\n useEffect(() => {\n // A submission link names one site's Inbox; the org's has no site to read\n // the id under.\n if (!hostId) return\n if (!seededSubmissionId || seededOpened.current === seededSubmissionId) return\n seededOpened.current = seededSubmissionId\n const seededDoc = pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, {\n hostId,\n id: seededSubmissionId,\n })\n if (!seededDoc) return\n void getDoc(seededDoc)\n .then((snapshot) => {\n if (seededOpened.current !== snapshot.id) return\n if (!snapshot.exists()) {\n enqueueSnackbar('That submission is no longer in the Inbox.', {\n variant: 'warning',\n persist: false,\n })\n return\n }\n handleOpenReader({ ...snapshot.data(), $id: snapshot.id })()\n })\n .catch(() => undefined)\n }, [seededSubmissionId, firestore, hostId, handleOpenReader, enqueueSnackbar])\n\n const handleDelete = useCallback(\n (submission: any) => async () => {\n const site = siteOf(submission)\n const submissionDoc = site\n ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, { hostId: site, id: submission.$id })\n : null\n if (!site || !submissionDoc) return\n const confirmed = await confirm({\n title: 'Delete this submission?',\n description: 'The submission is removed permanently.',\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await deleteDoc(submissionDoc)\n enqueueSnackbar('Submission deleted', {\n variant: 'success',\n persist: false,\n })\n /*\n * The form counted this submission when it arrived (AGL-3330), and an\n * increment cannot see a delete: the forms plugin recounts the form\n * from the rows that are left. Best effort — the delete has happened\n * either way, and the recount script catches a follow-up that failed.\n */\n if (typeof submission.formId === 'string' && submission.formId) {\n void postPluginApi(FORM_STATS_API_PATH, { hostId: site, formIds: [submission.formId] })\n }\n },\n [confirm, firestore, siteOf, enqueueSnackbar, postPluginApi],\n )\n\n /*\n * One row per submission, newest first: who sent it, what it said and how\n * long ago. The row opens the reader, which also marks it read.\n */\n const submissionActions = (submission: any): RowActionsMenuItem[] => {\n const senderEmail = submissionSender(submission.fields).email\n // Where the sender's contact is read, asked of whichever plugin keeps\n // people; with none loaded there is no such page, and no menu item.\n const contactsHref = routeContext\n ? pluginRecordListHref('contact', routeContext)\n : null\n return [\n ...(routeContext && contactsHref\n ? [\n {\n key: 'crm',\n label: 'Open contact in CRM',\n icon: <MdiIcon path={mdiAccountArrowRight.path} size={0.8} />,\n ...(senderEmail\n ? {\n href:\n pluginRecordByEmailHref(\n 'contact',\n routeContext,\n senderEmail,\n ) ?? contactsHref,\n }\n : {\n disabled: true,\n disabledReason:\n 'This submission carried no email address, so no contact was updated.',\n }),\n },\n ]\n : []),\n {\n key: 'read',\n label: submission.read ? 'Mark unread' : 'Mark read',\n icon: (\n <MdiIcon\n path={submission.read ? mdiEmailOutline.path : mdiEmailOpenOutline.path}\n size={0.8}\n />\n ),\n onClick: handleToggleRead(submission),\n },\n {\n key: 'delete',\n label: 'Delete',\n icon: <MdiIcon path={mdiDeleteOutline.path} size={0.8} />,\n destructive: true,\n onClick: handleDelete(submission),\n },\n ]\n }\n const submissionColumns: GridColDef[] = [\n {\n /*\n The mockup's list is people, not forms (AGL-2168): an initials avatar,\n the sender, and the form name beneath it. The unread DOT replaces the\n `New` chip — the row is already bold, and a chip that says \"New\" beside\n bold text is the same fact twice.\n */\n field: 'from',\n headerName: 'From',\n flex: 1,\n minWidth: 220,\n valueGetter: (_value, submission) => submissionSender(submission.fields).label,\n renderCell: ({ row: submission }) => {\n const sender = submissionSender(submission.fields)\n const hue = senderHue(sender.label)\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', minWidth: 0 }}>\n {!submission.read ? (\n <Box\n aria-label=\"Unread\"\n sx={{\n width: 8,\n height: 8,\n borderRadius: '50%',\n bgcolor: 'primary.main',\n flexShrink: 0,\n }}\n />\n ) : (\n <Box sx={{ width: 8, flexShrink: 0 }} />\n )}\n <Avatar\n sx={{\n width: 28,\n height: 28,\n fontSize: 13,\n bgcolor: `hsl(${hue} 55% 45%)`,\n }}\n >\n {sender.initials}\n </Avatar>\n <Stack sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {sender.label}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {submission.formName ?? 'Form'}\n </Typography>\n </Stack>\n </Stack>\n )\n },\n },\n /*\n Which site it was sent to, on the organization's Inbox only — under a\n site every row is that site's, and a column saying so would be noise.\n */\n ...(hostId == null\n ? [\n {\n field: 'hostId',\n headerName: 'Site',\n flex: 1,\n minWidth: 140,\n // Sorted and drawn by name; the filter matches the id.\n valueGetter: (_value: unknown, submission: any) =>\n orgSiteName(orgMount, submission.hostId),\n renderCell: ({ row: submission }: { row: any }) =>\n orgSiteName(orgMount, submission.hostId),\n } satisfies GridColDef,\n ]\n : []),\n {\n field: 'message',\n headerName: 'Message',\n flex: 2,\n minWidth: 260,\n valueGetter: (_value, submission) => messageTextOf(submission),\n renderCell: ({ value }) => (\n <Typography variant=\"body2\" noWrap>\n {value}\n </Typography>\n ),\n },\n {\n /*\n Relative, as the mockup shows it — an inbox is scanned for recency and a\n locale timestamp makes the reader do the subtraction. The absolute time\n stays on the detail dialog, where it is the fact you actually want.\n */\n field: 'createdAt',\n headerName: 'Received',\n width: 130,\n valueGetter: (_value, submission) =>\n submission.createdAt?.toDate?.()?.getTime?.() ?? 0,\n renderCell: ({ row: submission }) => (\n <Tooltip title={submission.createdAt?.toDate?.().toLocaleString() ?? ''}>\n <span>{relativeTime(submission.createdAt?.toDate?.().getTime())}</span>\n </Tooltip>\n ),\n },\n /*\n READ, as the panel picks it — never drawn: the unread dot and the bold\n row already say it. A boolean field has no hidden column of its own (the\n grid's boolean operators are not the select's), so it is declared here,\n kept hidden and out of Manage columns.\n */\n {\n field: 'read',\n headerName: 'Read',\n hideable: false,\n valueGetter: (_value, submission) => String(Boolean(submission.read)),\n },\n /*\n One overflow menu, as the Members & leads rows have: two inline buttons\n had no room for a third, and the contact link is the one a reader\n reaches for after reading. Present but disabled for a submission with no\n address, with the reason — a row that simply lacked the item would read\n as the contact not existing.\n */\n listActionsColumn(\n (submission) => (\n <ListRowActions\n label={String(submissionSender(submission.fields).email ?? submission.$id)}\n items={submissionActions(submission)}\n />\n ),\n { width: 72 },\n ),\n ]\n\n /** The site the open submission was sent to, which its reader acts as. */\n const readerSite = reader ? siteOf(reader) : null\n\n return (\n <>\n <CardDisplay\n header={scoped ? 'Submissions to this form' : 'Form Submissions'}\n help={pluginDocsHelp(\n 'forms',\n // Scoped to one form, this is the form page's own \"Submissions to\n // this form\" card, opened in place — the same card, the same link.\n scoped\n ? { anchor: '#form-submissions' }\n : hostId == null\n ? {\n anchor: '#every-sites-inbox-at-once',\n excerpt:\n 'Every site’s form messages in one list, newest first, ' +\n 'each under the site it was sent to.',\n }\n : {\n anchor: '#the-inbox',\n excerpt:\n 'Messages your forms collected, newest first, showing who ' +\n 'sent each one and where it was routed.',\n },\n )}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n >\n {/*\n * The Inbox stays the site-wide answer to \"who is waiting for a\n * reply\" — that question does not decompose by form. The panel's\n * Form filter narrows it on request; it does not turn the page into\n * a per-form view. It is offered only when the site HAS forms, and\n * never on a card already scoped to one.\n */}\n {offersForm && formsTruncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" sx={{ mb: 1 }}>\n {`The Form filter offers the first ${FORMS_MAX_PER_HOST.toLocaleString()} ` +\n 'forms. Narrow by form is incomplete; with no Form filter the ' +\n 'list still covers every submission.'}\n </Typography>\n ) : null}\n {hostId == null ? (\n <Typography\n variant=\"body2\"\n color=\"text.secondary\"\n sx={{ mb: submissions.length ? 2 : 1 }}\n >\n {'Every site’s submissions, newest first. Choose a site to ' +\n 'narrow them by form.'}\n </Typography>\n ) : null}\n {submissions.length === 0 && !hasMoreSubmissions && !filtering ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {scoped\n ? 'No submissions carry this form’s id yet. Messages this ' +\n 'form’s design collected before it became a form entity are ' +\n 'in the Inbox, filed under the name they were sent with.'\n : hostId == null\n ? 'No form submissions on any site yet.'\n : 'No form submissions yet. Add a Contact Form element to a ' +\n 'page — visitor messages arrive here.'}\n </Typography>\n ) : (\n <>\n <ListFilterChips\n fields={declaration.fields}\n headers={SUBMISSION_FILTER_HEADERS}\n clauses={gridFilter.clauses}\n onChange={gridFilter.setClauses}\n options={submissionOptions}\n />\n <ListQueryNotices\n refused={refusals}\n notices={[...plan.notices, ...columnSort.notices]}\n />\n <ListTable\n aria-label={scoped ? 'Submissions to this form' : 'Form submissions'}\n rows={columnSort.rows}\n columnSort={columnSort}\n columns={listFilterGridColumns(\n submissionColumns,\n declaration.fields,\n submissionOptions,\n SUBMISSION_FILTER_HEADERS,\n )}\n initialState={{ columns: { columnVisibilityModel: SUBMISSION_HIDDEN_COLUMNS } }}\n noRowsLabel={\n onlyForm\n ? 'No submissions for this form yet. Submissions sent before ' +\n 'the form was created are listed with no Form filter.'\n : 'No submissions match these filters'\n }\n rowHeight={TABLE_ROW_HEIGHT}\n onOpen={(_id, submission) => handleOpenReader(submission)()}\n // An unread submission reads bold across its row, which is why\n // the list needs no `New` chip.\n getRowClassName={({ row }) => (row.read ? '' : 'submission-unread')}\n sx={{\n '& .submission-unread .MuiDataGrid-cell, & .submission-unread .MuiTypography-root':\n { fontWeight: 'fontWeightBold' },\n }}\n // Paged by the footer below, so the grid must not also slice.\n hideFooter\n // The panel, the search and the headers go to the query (From,\n // Site and Message sort the page, and say so).\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n />\n <ListPagination\n page={submissionPage}\n pageSize={submissionPageSize}\n rowCount={submissions.length}\n hasMore={hasMoreSubmissions}\n onPageChange={setSubmissionPage}\n onPageSizeChange={setSubmissionPageSize}\n />\n </>\n )}\n </CardDisplay>\n <Dialog\n open={Boolean(reader)}\n onClose={() => setReader(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>{reader?.formName ?? 'Form submission'}</DialogTitle>\n <DialogContent>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Received ${reader?.createdAt?.toDate?.().toLocaleString() ?? ''}` +\n // The site it was sent to, where the list spans every site.\n (hostId == null && readerSite\n ? ` · ${orgSiteName(orgMount, readerSite)}`\n : '')}\n </Typography>\n {/*\n WHERE IT CAME IN, AND WHAT IT MADE (AGL-3461) — the form, the page\n it was on, and the lead or contact it filed, each a link to its\n own page. The page is also the field the marketing console's\n landing-page grouping joins on, so a reader can check one row\n against that grouping. Each link is asked of the plugin that owns\n the record, and is text where no plugin answers.\n */}\n {reader ? (\n <Stack spacing={0.5} sx={{ mt: 1 }}>\n {submissionLinks({\n submission: reader,\n hrefOf: (kind, id) =>\n routeContext ? pluginRecordHref(kind, routeContext, id) : null,\n siteOrigin:\n hostPublicOrigin({\n subdomain:\n (hostId != null ? routeContext?.host : null) ??\n orgMount?.hosts.find((site) => site.id === readerSite)?.subdomain ??\n null,\n }) ?? null,\n }).map((link) => (\n <Stack key={link.key} direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ minWidth: 72 }}>\n {link.label}\n </Typography>\n {link.href ? (\n <AppLink\n href={link.href}\n {...(link.external ? { target: '_blank', rel: 'noopener' } : {})}\n >\n {link.text}\n </AppLink>\n ) : (\n <Typography variant=\"body2\">{link.text}</Typography>\n )}\n </Stack>\n ))}\n </Stack>\n ) : null}\n <Divider sx={{ my: 1.5 }} />\n <Stack spacing={1.5}>\n {Object.entries(reader?.fields ?? {}).map(([key, value]) => (\n <Stack key={key} spacing={0.25}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {key}\n </Typography>\n <Typography\n variant=\"body2\"\n sx={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}\n >\n {String(value)}\n </Typography>\n </Stack>\n ))}\n </Stack>\n {/*\n What happened to this submission (AGL-2168). The mockup puts\n these under the fields: `Saved to Inbox` and `Added to \"Leads\"\n dataset`. The second is stamped by the submit route only when a\n record was really appended — a form bound to a deleted dataset,\n or one whose record quota is full, shows no chip rather than a\n chip for a row that does not exist. Both are failures the route\n already swallows silently, and a chip that lied about them\n would be worse than the silence.\n */}\n <Stack\n useFlexGap\n direction=\"row\"\n spacing={1}\n sx={{ mt: 2, flexWrap: 'wrap', rowGap: 1 }}\n >\n {routingChips(reader?.routing).map((chip) => (\n <Chip\n key={chip.label}\n size=\"small\"\n label={chip.label}\n color={chip.color}\n variant=\"outlined\"\n />\n ))}\n </Stack>\n {/*\n WHERE THIS SUBMISSION CAME FROM.\n\n One keyed document read — the attribution's id is `form:{id}` and\n the submission's id is that `{id}` — paid when a merchant opens a\n submission rather than once per row of the list. A submission that\n was credited to nobody renders the sentence saying so; it never\n renders a campaign with a zero beside it.\n */}\n {reader?.$id && readerSite ? (\n <Box sx={{ mt: 2 }}>\n <InboxRecordAttributionZone\n hostId={readerSite}\n recordKind=\"form\"\n recordId={String(reader.$id)}\n filedUnder={submissionFiledUnder(reader)}\n />\n </Box>\n ) : null}\n {/*\n Answering the person is the act the Inbox exists for, and it is\n inside the reader rather than on the row because a reply written\n without the message in front of you is the reply that answers the\n wrong question. Mounted with the dialog, so its reads — the site\n name and the replies already sent — are paid when a merchant opens\n a submission and not once per visit to this page.\n */}\n {reader && readerSite ? (\n <SubmissionReply hostId={readerSite} submission={reader} />\n ) : null}\n {/*\n Enrolling the sender in a marketing list — a SEPARATE act from\n answering them, and a separate card, because the person asked to\n be answered and did not ask to be marketed to. Its reads are paid\n only when a merchant presses its own button, so opening a\n submission to read it costs nothing extra.\n */}\n {reader && readerSite ? (\n <SubmissionListAssignment hostId={readerSite} submission={reader} />\n ) : null}\n </DialogContent>\n <DialogActions>\n <Button\n color=\"error\"\n onClick={async () => {\n const target = reader\n setReader(null)\n if (target) await handleDelete(target)()\n }}\n >\n {'Delete'}\n </Button>\n <Button\n onClick={() => {\n if (reader) void handleToggleRead({ ...reader, read: true })()\n setReader(null)\n }}\n >\n {'Mark unread'}\n </Button>\n <Button variant=\"contained\" onClick={() => setReader(null)}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n </>\n )\n}\nSubmissionsCard.displayName = 'SubmissionsCard'\n\nexport default SubmissionsCard\n"],"names":["FORMS_MAX_PER_HOST","pluginDocsHelp","INBOX_SUBMISSION_PARAM","hostPublicOrigin","submissionFiledUnder","submissionLinks","FORM_SUBMISSION_KIND","InboxRecordAttributionZone","pluginRecordByEmailHref","pluginRecordHref","pluginRecordListHref","mdiAccountArrowRight","mdiDeleteOutline","mdiEmailOpenOutline","mdiEmailOutline","AppLink","CardDisplay","MdiIcon","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","listFilterGridColumns","TABLE_ROW_HEIGHT","useListGridFilter","useSnackbar","useFirestore","useFirestoreCollection","usePluginApiPost","useListQuery","useListColumnSort","Avatar","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Divider","Stack","Tooltip","Typography","collection","deleteDoc","getDoc","limit","orderBy","query","updateDoc","pluginRecordListDoc","pluginRecordListWalk","useSearchParams","useCallback","useEffect","useMemo","useRef","useState","relativeTime","routingChips","senderHue","submissionSender","FORM_SCOPED_SUBMISSION_LIST_QUERY","ORG_SUBMISSION_LIST_QUERY","SUBMISSION_FILTER_HEADERS","SUBMISSION_LIST_QUERY","SUBMISSION_READ_OPTIONS","formSubmissionBase","orgSubmissionBase","orgSiteName","SubmissionListAssignment","SubmissionReply","useRecordRouteContext","FORM_STATS_API_PATH","SUBMISSION_SELECT_FIELDS","SUBMISSION_HIDDEN_COLUMNS","read","formId","SUBMISSION_PAGE_SORT_HEADERS","from","hostId","message","messageTextOf","submission","Object","entries","fields","map","key","value","join","SubmissionsCard","orgMount","reader","firestore","enqueueSnackbar","postPluginApi","confirm","scoped","Boolean","orgId","siteOf","routeContext","data","formDocs","idField","formsTruncated","length","forms","slice","sort","left","right","String","displayName","$id","localeCompare","offersForm","declaration","filter","field","column","base","gridFilter","selectFields","askedSort","setAskedSort","rows","submissions","hasMore","hasMoreSubmissions","page","submissionPage","setPage","setSubmissionPage","pageSize","submissionPageSize","setPageSize","setSubmissionPageSize","plan","request","clauses","search","searchWords","deps","submissionOptions","form","label","hosts","host","id","name","refusals","refused","headers","options","submissionPageSorts","columnSort","sorts","defaultSort","onSortChange","pageSorts","searching","some","word","trim","filtering","onlyForm","every","clause","setReader","handleOpenReader","site","submissionDoc","handleToggleRead","searchParams","seededSubmissionId","get","seededOpened","current","seededDoc","then","snapshot","exists","variant","persist","catch","undefined","handleDelete","confirmed","title","description","confirmationText","confirmationButtonProps","color","formIds","submissionActions","senderEmail","email","contactsHref","icon","path","size","href","disabled","disabledReason","onClick","destructive","submissionColumns","headerName","flex","minWidth","valueGetter","_value","renderCell","row","sender","hue","direction","spacing","sx","alignItems","aria-label","width","height","borderRadius","bgcolor","flexShrink","fontSize","initials","noWrap","formName","createdAt","toDate","getTime","toLocaleString","span","hideable","items","readerSite","header","help","anchor","excerpt","contentGutterX","contentGutterY","contentBordered","component","mb","onChange","setClauses","notices","columns","initialState","columnVisibilityModel","noRowsLabel","rowHeight","onOpen","_id","getRowClassName","fontWeight","hideFooter","filterMode","filterModel","onFilterModelChange","quickFilter","rowCount","onPageChange","onPageSizeChange","open","onClose","maxWidth","fullWidth","mt","hrefOf","kind","siteOrigin","subdomain","find","link","external","target","rel","text","my","whiteSpace","wordBreak","useFlexGap","flexWrap","rowGap","routing","chip","recordKind","recordId","filedUnder"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,kBAAkB,EAClBC,cAAc,QAET,eAAc;AACrB,SAASC,sBAAsB,QAAQ,kCAA8B;AACrE,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,+BAA2B;AAEjF,+DAA+D,GAC/D,MAAMC,uBAAuB;AAC7B,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,SAASC,0BAA0B,QAAQ,8BAA0B;AACrE,6EAA6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f6E,UAAU;oCACV,IAAI+G,QAAQ,MAAM7F,aAAa6F;gCACjC;0CAEC;;0CAEH,KAACxP;gCACC6K,SAAS;oCACP,IAAIjH,QAAQ,KAAKiF,iBAAiB,aAAKjF;wCAAQjB,MAAM;;oCACrD8F,UAAU;gCACZ;0CAEC;;0CAEH,KAACzI;gCAAOuJ,SAAQ;gCAAYsB,SAAS,IAAMpC,UAAU;0CAClD;;;;;;;;AAMb;AACA/E,gBAAgBuB,WAAW,GAAG;AAE9B,eAAevB,gBAAe"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/inbox/src/lib/components/submissions-card.component.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 FORMS_MAX_PER_HOST,\n pluginDocsHelp,\n type ConsolePluginOrgMount,\n} from '@aglyn/aglyn'\nimport { INBOX_SUBMISSION_PARAM } from '../model/inbox-record-routes'\nimport { hostPublicOrigin } from '@aglyn/aglyn/app-utils/host-naming'\nimport { submissionFiledUnder, submissionLinks } from '../model/submission-links'\n\n/** The forms plugin's record kind this card reads (AGL-3080). */\nconst FORM_SUBMISSION_KIND = 'formSubmission'\n// A deep import, NOT the plugin barrel (AGL-1151): the barrel is the entry\n// point the tenant's loader dynamically imports to activate the marketing\n// plugin's SITE half, so a console card named there ships to every published\n// page. The component path reaches the same module without crossing it.\nimport { InboxRecordAttributionZone } from './inbox-attribution-zone'\n// The CRM's route builder by its leaf path, for the reason above: the barrel\n// is the plugin's site entry point.\nimport {\n pluginRecordByEmailHref,\n pluginRecordHref,\n pluginRecordListHref,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport {\n mdiAccountArrowRight,\n mdiDeleteOutline,\n mdiEmailOpenOutline,\n mdiEmailOutline,\n} from '@aglyn/shared-data-mdi'\nimport { AppLink, CardDisplay, MdiIcon, useConfirmationContext } 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 type { RowActionsMenuItem } from '@aglyn/shared-ui-jsx/components/row-actions-menu.component'\nimport {\n type ListFilterOption,\n listFilterGridColumns,\n} from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport type { ListQueryDeclaration } from '@aglyn/shared-ui-jsx/const/list-query-plan'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\nimport { useListGridFilter } from '@aglyn/shared-ui-jsx/hooks/use-list-grid-filter'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport {\n useFirestore,\n useFirestoreCollection,\n usePluginApiPost,\n} from '@aglyn/tenant-feature-instance'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\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 {\n Avatar,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Divider,\n Stack,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport {\n collection,\n deleteDoc,\n getDoc,\n limit,\n orderBy,\n query,\n updateDoc,\n} from 'firebase/firestore'\n// The submissions are the forms plugin's records, walked and opened through\n// the list source it publishes (AGL-3080).\nimport {\n pluginRecordListDoc,\n pluginRecordListWalk,\n} from '@aglyn/aglyn/plugin-manager/plugin-record-lists'\nimport { useSearchParams } from 'next/navigation'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n relativeTime,\n routingChips,\n senderHue,\n submissionFiles,\n submissionRequestKind,\n submissionRequestLabel,\n submissionSender,\n} from '../model/submission-presenter'\nimport { InboxSubmissionActionsZone } from './inbox-submission-actions-zone'\nimport SubmissionFiles, { FORM_SUBMISSION_FILE_API_PATH } from './submission-files.component'\nimport {\n FORM_SCOPED_SUBMISSION_LIST_QUERY,\n ORG_SUBMISSION_LIST_QUERY,\n SUBMISSION_FILTER_HEADERS,\n SUBMISSION_LIST_QUERY,\n SUBMISSION_READ_OPTIONS,\n formSubmissionBase,\n orgSubmissionBase,\n} from '../constants/list-queries'\nimport { orgSiteName } from './inbox-org-sites'\nimport SubmissionListAssignment from './submission-list-assignment.component'\nimport SubmissionReply from './submission-reply.component'\nimport { useRecordRouteContext } from './use-record-route-context'\n\n\n/**\n * The forms plugin's recount route (AGL-3330), by address: this plugin\n * shows the submissions a form counts and may not import the plugin that\n * keeps the counts.\n */\nconst FORM_STATS_API_PATH = '/api/forms/stats'\n/** Read, Form and Site are picked, so the panel shows selects. */\nconst SUBMISSION_SELECT_FIELDS = ['read', 'formId', 'hostId']\nconst SUBMISSION_HIDDEN_COLUMNS = { read: false, formId: false }\n\n/** Every field of a message, as one line — what the Message column draws. */\n/** The page-sorted headers, for their notice (AGL-3680). */\nconst SUBMISSION_PAGE_SORT_HEADERS = { from: 'From', hostId: 'Site', message: 'Message' }\n\nconst messageTextOf = (submission: any): string =>\n Object.entries(submission?.fields ?? {})\n .map(([key, value]) => `${key}: ${value}`)\n .join(' · ')\n\n/**\n * The Submissions section of the Inbox (AGL-77/104/109 → AGL-395): the form\n * messages a site collected, newest first, and the reader that opens one.\n *\n * Its own component since AGL-2501, when the Inbox's tabs became routes. The\n * split is what makes \"mount only the section being read\" structural: hooks\n * cannot be conditional, so a page holding every section's reads pays for all\n * of them whichever one the URL names.\n */\nexport interface SubmissionsCardProps {\n /**\n * The site whose submissions are listed, or `null` on the organization's\n * Inbox, where the card lists every site's at once (AGL-3303) and each row\n * is acted on as the site it was sent to.\n */\n hostId: string | null\n /** The organization and its sites — present exactly when `hostId` is `null`. */\n orgMount?: ConsolePluginOrgMount\n /**\n * Narrow this card to ONE form, permanently.\n *\n * What the forms plugin's detail surface renders instead of a second\n * submissions table. The reader has already chosen the subject by being on\n * that page, so scoping here does three things a copy would have had to\n * re-derive: the form picker is not rendered (there is nothing to pick),\n * the site's `forms` collection is not read at all (the picker was its only\n * consumer), and the empty state names the form rather than the site.\n *\n * Everything else — the paged walk, the reader dialog, read/unread,\n * delete, reply, list assignment, attribution — is the same code answering\n * a narrower query. That is the reason this is a prop rather than a second\n * component: a per-form table written separately would be a second reader\n * to keep in step, and it would have been the one to reintroduce the\n * unordered `limit()` this card's own comment exists to warn about.\n */\n formId?: string\n}\n\nexport function SubmissionsCard({\n hostId,\n formId,\n orgMount,\n}: SubmissionsCardProps) {\n const firestore = useFirestore()\n const { enqueueSnackbar } = useSnackbar()\n const postPluginApi = usePluginApiPost()\n const { confirm } = useConfirmationContext()\n /** Scoped to one form: the subject is fixed and nothing may widen it. */\n const scoped = Boolean(formId)\n /** Every site of this organization at once, when no site is named. */\n const orgId = hostId == null ? (orgMount?.orgId ?? null) : null\n /*\n * The site a row lives on, which is where every act on it is addressed:\n * this card's own site, or — across every site — the `hostId` the submit\n * route stamps on the row. That stamp is frozen against a client update and\n * written from the row's own path, so it names the document's real parent;\n * the rules check the host role on that site either way.\n */\n const siteOf = useCallback(\n (submission: any): string | null =>\n hostId ??\n (typeof submission?.hostId === 'string' && submission.hostId\n ? submission.hostId\n : null),\n [hostId],\n )\n /*\n * Where the sender's CONTACT is (AGL-2612). A submission that carried an\n * address updated a contact in the CRM at stage Lead; the row links to\n * it by that address, and the Contacts list — which holds the id nothing\n * here does — opens the record. The same hub path the Members & leads\n * rows use to open a lead.\n */\n const routeContext = useRecordRouteContext()\n\n /*\n * The site's forms, for the Submissions filter.\n *\n * `FORMS_MAX_PER_HOST` is a read WINDOW, not a cap on the collection — how\n * many forms a site may hold is `formsPerHost`, enforced at the create in\n * `/api/hosts/resources`, and a staff-set per-org override can raise it\n * past this window. So the window can be smaller than the catalog, and one\n * more document than fits is read on purpose: a filter that quietly listed\n * the first N would report \"this form does not exist\" and \"this form is\n * past the window\" as the same empty answer.\n *\n * Ordered by `__name__`. `displayName` would be the nicer order and is the\n * wrong instrument: `orderBy` on a data field DROPS every document missing\n * it, invisibly, so a form saved without a name would vanish from its own\n * filter. The list is sorted for display below, where a missing name is\n * merely ugly.\n */\n const { data: formDocs } = useFirestoreCollection<any>(\n () =>\n // Forms are one site's catalog. Across every site there is no single\n // catalog to filter by, and picking a site is how a reader gets one.\n scoped || !hostId\n ? null\n : query(\n collection(firestore, 'hosts', hostId, 'forms'),\n orderBy('__name__'),\n limit(FORMS_MAX_PER_HOST + 1),\n ),\n [firestore, hostId, scoped],\n { idField: '$id' },\n )\n /** More forms exist than the window shows; the filter has to say so. */\n const formsTruncated = (formDocs?.length ?? 0) > FORMS_MAX_PER_HOST\n const forms = useMemo(\n () =>\n [...(formDocs ?? [])]\n .slice(0, FORMS_MAX_PER_HOST)\n .sort((left: any, right: any) =>\n String(left.displayName ?? left.$id).localeCompare(\n String(right.displayName ?? right.$id),\n ),\n ),\n [formDocs],\n )\n /** Form is offered where the site's catalog is read. */\n const offersForm = !scoped && Boolean(hostId) && forms.length > 0\n /*\n * WHAT THIS CARD'S LIST CAN BE ASKED (AGL-3321) — every clause and the\n * search on the query, see `SUBMISSION_LIST_QUERY`:\n *\n * - a site's Inbox: From, Read and — where the site has forms — Form;\n * - a card scoped to one form: that form is the list's own scope, and\n * Form has nothing left to pick, so it is not offered. The scope wins\n * over any clause: it is the base, and no clause can reach it;\n * - every site's, on the organization's Inbox: From, Read and Site,\n * under the `orgId` clause the rules require of the group read.\n */\n const declaration = useMemo<ListQueryDeclaration>(() => {\n if (scoped) return FORM_SCOPED_SUBMISSION_LIST_QUERY\n if (hostId == null) return ORG_SUBMISSION_LIST_QUERY\n return offersForm\n ? SUBMISSION_LIST_QUERY\n : {\n ...SUBMISSION_LIST_QUERY,\n fields: SUBMISSION_LIST_QUERY.fields.filter((field) => field.column !== 'formId'),\n }\n }, [scoped, hostId, offersForm])\n const base = useMemo(\n () =>\n formId ? formSubmissionBase(formId) : hostId == null && orgId ? orgSubmissionBase(orgId) : [],\n [formId, hostId, orgId],\n )\n const gridFilter = useListGridFilter({ selectFields: SUBMISSION_SELECT_FIELDS })\n /*\n * EVERY HEADER SORTS (AGL-3680). Received and Read order the QUERY (see\n * `SUBMISSION_LIST_QUERY`); From, Site and Message are drawn from the\n * message, so they sort the page on screen and say so. Null is newest\n * first, the inbox's own order.\n */\n const [askedSort, setAskedSort] = useState<ListQuerySort | null>(null)\n\n /*\n * The inbox WALKS its submissions instead of sampling them (AGL-2501,\n * AGL-2292), and every filter and search word is a predicate on the walk\n * (AGL-3321), so a page is a page of the matches.\n *\n * `limit(200)` carried no `orderBy`, so Firestore answered it in\n * DOCUMENT-ID order over ids `add()` generates — an arbitrary two hundred\n * of the site's messages, which the client sort then arranged newest-first\n * so the result looked like a feed. A site past two hundred submissions\n * could not reach the rest, and the messages missing left no gap: the row\n * dates on screen simply skipped, which reads as a quiet week rather than\n * as an unreachable inbox.\n *\n * `createdAt` is safe to order on, checked against the writer rather than\n * assumed: `libs/plugins/forms/src/lib/server/form-submit.ts` is the only path\n * that creates one and stamps `createdAt: serverTimestamp()` on every add,\n * the v1 API only ever reads and deletes, and `formSubmissions` is absent\n * from `IMPORTABLE_FIELDS`, so no restore path can make one without it.\n *\n * EVERY SITE'S SUBMISSIONS IN ONE QUERY on the organization's Inbox\n * (AGL-3303), not a listener per site: the collection group, newest first.\n * The `orgId` clause is not a filter this card could drop. The rules admit\n * a group read only when it is narrowed to an org the reader spans, so an\n * unfiltered group query is refused outright. Every submission carries\n * `orgId`: the submit route stamps it, and the rows written before it did\n * were stamped once (AGL-3303). A row without one would be in no\n * organization's list, though its own site's Inbox lists it either way.\n */\n const {\n rows: submissions,\n hasMore: hasMoreSubmissions,\n page: submissionPage,\n setPage: setSubmissionPage,\n pageSize: submissionPageSize,\n setPageSize: setSubmissionPageSize,\n plan,\n } = useListQuery<any>({\n collection: pluginRecordListWalk(FORM_SUBMISSION_KIND, firestore, { hostId, orgId }),\n declaration,\n request: {\n clauses: gridFilter.clauses,\n search: gridFilter.searchWords,\n sort: askedSort,\n base,\n },\n deps: [firestore, hostId, orgId],\n idField: '$id',\n })\n const submissionOptions = useMemo<Readonly<Record<string, readonly ListFilterOption[]>>>(\n () => ({\n read: SUBMISSION_READ_OPTIONS,\n ...(offersForm\n ? {\n formId: forms.map((form: any) => ({\n value: String(form.$id),\n label: String(form.displayName || form.$id),\n })),\n }\n : {}),\n ...(hostId == null\n ? {\n hostId: (orgMount?.hosts ?? []).map((host) => ({\n value: host.id,\n label: host.name || host.id,\n })),\n }\n : {}),\n }),\n [offersForm, forms, hostId, orgMount],\n )\n const refusals = useMemo(\n () =>\n listQueryRefusals(plan.refused, {\n fields: declaration.fields,\n headers: SUBMISSION_FILTER_HEADERS,\n options: submissionOptions,\n }),\n [plan.refused, declaration, submissionOptions],\n )\n const submissionPageSorts = useMemo(\n () => ({\n from: (submission: any) => submissionSender(submission.fields).label,\n hostId: (submission: any) => orgSiteName(orgMount, submission.hostId),\n message: (submission: any) => messageTextOf(submission),\n }),\n [orgMount],\n )\n const columnSort = useListColumnSort<any>({\n sorts: declaration.sorts,\n defaultSort: declaration.sorts[0],\n sort: askedSort,\n onSortChange: setAskedSort,\n orderBy: plan.orderBy,\n rows: submissions,\n pageSorts: submissionPageSorts,\n headers: SUBMISSION_PAGE_SORT_HEADERS,\n })\n const searching = gridFilter.searchWords.some((word) => word.trim())\n const filtering = gridFilter.clauses.length > 0 || searching\n /** Narrowed by nothing but a Form clause. */\n const onlyForm =\n !searching &&\n gridFilter.clauses.length > 0 &&\n gridFilter.clauses.every((clause) => clause.field === 'formId')\n\n // Mail reader (AGL-104): opening a submission shows the full message and\n // marks it read.\n const [reader, setReader] = useState<any | null>(null)\n const handleOpenReader = useCallback(\n (submission: any) => () => {\n setReader(submission)\n const site = siteOf(submission)\n const submissionDoc = site\n ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, { hostId: site, id: submission.$id })\n : null\n if (!submission.read && submissionDoc) {\n void updateDoc(submissionDoc, { read: true })\n }\n },\n [firestore, siteOf],\n )\n\n const handleToggleRead = useCallback(\n (submission: any) => () => {\n const site = siteOf(submission)\n const submissionDoc = site\n ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, { hostId: site, id: submission.$id })\n : null\n if (!submissionDoc) return\n void updateDoc(submissionDoc, { read: !submission.read })\n },\n [firestore, siteOf],\n )\n\n /*\n * A submission named in the URL opens in the reader on arrival (AGL-2622).\n *\n * A contact's timeline names the submission that captured the person, and\n * the address it links to is this tab with `?submission={id}`. The\n * document is read once, by id, rather than looked for in the paged\n * window: the window is the newest page of a walk that may not reach a\n * submission from months back, and one document read is what the URL\n * asked for. Opening it marks it read, as a click on the row would. A\n * submission that is gone says so, because a reader that silently stays\n * shut reads as the link having done nothing.\n *\n * Once per id: the ref keeps a re-render — and the same URL re-settling —\n * from reopening a reader the person has since closed. The landing read\n * is judged against that ref rather than an effect cleanup: a listener\n * settling while the read is in flight re-renders this card, and a\n * cleanup keyed on any dep would cancel the answer to the question the\n * URL just asked.\n */\n const searchParams = useSearchParams()\n const seededSubmissionId = searchParams?.get(INBOX_SUBMISSION_PARAM) ?? null\n const seededOpened = useRef<string | null>(null)\n useEffect(() => {\n // A submission link names one site's Inbox; the org's has no site to read\n // the id under.\n if (!hostId) return\n if (!seededSubmissionId || seededOpened.current === seededSubmissionId) return\n seededOpened.current = seededSubmissionId\n const seededDoc = pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, {\n hostId,\n id: seededSubmissionId,\n })\n if (!seededDoc) return\n void getDoc(seededDoc)\n .then((snapshot) => {\n if (seededOpened.current !== snapshot.id) return\n if (!snapshot.exists()) {\n enqueueSnackbar('That submission is no longer in the Inbox.', {\n variant: 'warning',\n persist: false,\n })\n return\n }\n handleOpenReader({ ...snapshot.data(), $id: snapshot.id })()\n })\n .catch(() => undefined)\n }, [seededSubmissionId, firestore, hostId, handleOpenReader, enqueueSnackbar])\n\n const handleDelete = useCallback(\n (submission: any) => async () => {\n const site = siteOf(submission)\n const submissionDoc = site\n ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, { hostId: site, id: submission.$id })\n : null\n if (!site || !submissionDoc) return\n const confirmed = await confirm({\n title: 'Delete this submission?',\n description: 'The submission is removed permanently.',\n confirmationText: 'Delete',\n confirmationButtonProps: { color: 'error' },\n })\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n await deleteDoc(submissionDoc)\n enqueueSnackbar('Submission deleted', {\n variant: 'success',\n persist: false,\n })\n /*\n * Its files go with it (AGL-4098). They are in private storage, which\n * the browser cannot reach, so the forms plugin deletes them once the\n * submission is gone. Best effort: the delete has happened either way.\n */\n if (submissionFiles(submission.files).length) {\n void postPluginApi(FORM_SUBMISSION_FILE_API_PATH, {\n action: 'release',\n hostId: site,\n submissionId: submission.$id,\n })\n }\n /*\n * The form counted this submission when it arrived (AGL-3330), and an\n * increment cannot see a delete: the forms plugin recounts the form\n * from the rows that are left. Best effort — the delete has happened\n * either way, and the recount script catches a follow-up that failed.\n */\n if (typeof submission.formId === 'string' && submission.formId) {\n void postPluginApi(FORM_STATS_API_PATH, { hostId: site, formIds: [submission.formId] })\n }\n },\n [confirm, firestore, siteOf, enqueueSnackbar, postPluginApi],\n )\n\n /*\n * One row per submission, newest first: who sent it, what it said and how\n * long ago. The row opens the reader, which also marks it read.\n */\n const submissionActions = (submission: any): RowActionsMenuItem[] => {\n const senderEmail = submissionSender(submission.fields).email\n // Where the sender's contact is read, asked of whichever plugin keeps\n // people; with none loaded there is no such page, and no menu item.\n const contactsHref = routeContext\n ? pluginRecordListHref('contact', routeContext)\n : null\n return [\n ...(routeContext && contactsHref\n ? [\n {\n key: 'crm',\n label: 'Open contact in CRM',\n icon: <MdiIcon path={mdiAccountArrowRight.path} size={0.8} />,\n ...(senderEmail\n ? {\n href:\n pluginRecordByEmailHref(\n 'contact',\n routeContext,\n senderEmail,\n ) ?? contactsHref,\n }\n : {\n disabled: true,\n disabledReason:\n 'This submission carried no email address, so no contact was updated.',\n }),\n },\n ]\n : []),\n {\n key: 'read',\n label: submission.read ? 'Mark unread' : 'Mark read',\n icon: (\n <MdiIcon\n path={submission.read ? mdiEmailOutline.path : mdiEmailOpenOutline.path}\n size={0.8}\n />\n ),\n onClick: handleToggleRead(submission),\n },\n {\n key: 'delete',\n label: 'Delete',\n icon: <MdiIcon path={mdiDeleteOutline.path} size={0.8} />,\n destructive: true,\n onClick: handleDelete(submission),\n },\n ]\n }\n const submissionColumns: GridColDef[] = [\n {\n /*\n The mockup's list is people, not forms (AGL-2168): an initials avatar,\n the sender, and the form name beneath it. The unread DOT replaces the\n `New` chip — the row is already bold, and a chip that says \"New\" beside\n bold text is the same fact twice.\n */\n field: 'from',\n headerName: 'From',\n flex: 1,\n minWidth: 220,\n valueGetter: (_value, submission) => submissionSender(submission.fields).label,\n renderCell: ({ row: submission }) => {\n const sender = submissionSender(submission.fields)\n const hue = senderHue(sender.label)\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', minWidth: 0 }}>\n {!submission.read ? (\n <Box\n aria-label=\"Unread\"\n sx={{\n width: 8,\n height: 8,\n borderRadius: '50%',\n bgcolor: 'primary.main',\n flexShrink: 0,\n }}\n />\n ) : (\n <Box sx={{ width: 8, flexShrink: 0 }} />\n )}\n <Avatar\n sx={{\n width: 28,\n height: 28,\n fontSize: 13,\n bgcolor: `hsl(${hue} 55% 45%)`,\n }}\n >\n {sender.initials}\n </Avatar>\n <Stack sx={{ minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {sender.label}\n </Typography>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center', minWidth: 0 }}>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {submission.formName ?? 'Form'}\n </Typography>\n {/* A request (AGL-4098) says so in the list, as when it is open. */}\n {submissionRequestLabel(submission.request) ? (\n <Chip size=\"small\" color=\"info\" variant=\"outlined\" label={submissionRequestLabel(submission.request)} />\n ) : null}\n </Stack>\n </Stack>\n </Stack>\n )\n },\n },\n /*\n Which site it was sent to, on the organization's Inbox only — under a\n site every row is that site's, and a column saying so would be noise.\n */\n ...(hostId == null\n ? [\n {\n field: 'hostId',\n headerName: 'Site',\n flex: 1,\n minWidth: 140,\n // Sorted and drawn by name; the filter matches the id.\n valueGetter: (_value: unknown, submission: any) =>\n orgSiteName(orgMount, submission.hostId),\n renderCell: ({ row: submission }: { row: any }) =>\n orgSiteName(orgMount, submission.hostId),\n } satisfies GridColDef,\n ]\n : []),\n {\n field: 'message',\n headerName: 'Message',\n flex: 2,\n minWidth: 260,\n valueGetter: (_value, submission) => messageTextOf(submission),\n renderCell: ({ value }) => (\n <Typography variant=\"body2\" noWrap>\n {value}\n </Typography>\n ),\n },\n {\n /*\n Relative, as the mockup shows it — an inbox is scanned for recency and a\n locale timestamp makes the reader do the subtraction. The absolute time\n stays on the detail dialog, where it is the fact you actually want.\n */\n field: 'createdAt',\n headerName: 'Received',\n width: 130,\n valueGetter: (_value, submission) =>\n submission.createdAt?.toDate?.()?.getTime?.() ?? 0,\n renderCell: ({ row: submission }) => (\n <Tooltip title={submission.createdAt?.toDate?.().toLocaleString() ?? ''}>\n <span>{relativeTime(submission.createdAt?.toDate?.().getTime())}</span>\n </Tooltip>\n ),\n },\n /*\n READ, as the panel picks it — never drawn: the unread dot and the bold\n row already say it. A boolean field has no hidden column of its own (the\n grid's boolean operators are not the select's), so it is declared here,\n kept hidden and out of Manage columns.\n */\n {\n field: 'read',\n headerName: 'Read',\n hideable: false,\n valueGetter: (_value, submission) => String(Boolean(submission.read)),\n },\n /*\n One overflow menu, as the Members & leads rows have: two inline buttons\n had no room for a third, and the contact link is the one a reader\n reaches for after reading. Present but disabled for a submission with no\n address, with the reason — a row that simply lacked the item would read\n as the contact not existing.\n */\n listActionsColumn(\n (submission) => (\n <ListRowActions\n label={String(submissionSender(submission.fields).email ?? submission.$id)}\n items={submissionActions(submission)}\n />\n ),\n { width: 72 },\n ),\n ]\n\n /** The site the open submission was sent to, which its reader acts as. */\n const readerSite = reader ? siteOf(reader) : null\n\n return (\n <>\n <CardDisplay\n header={scoped ? 'Submissions to this form' : 'Form Submissions'}\n help={pluginDocsHelp(\n 'forms',\n // Scoped to one form, this is the form page's own \"Submissions to\n // this form\" card, opened in place — the same card, the same link.\n scoped\n ? { anchor: '#form-submissions' }\n : hostId == null\n ? {\n anchor: '#every-sites-inbox-at-once',\n excerpt:\n 'Every site’s form messages in one list, newest first, ' +\n 'each under the site it was sent to.',\n }\n : {\n anchor: '#the-inbox',\n excerpt:\n 'Messages your forms collected, newest first, showing who ' +\n 'sent each one and where it was routed.',\n },\n )}\n contentGutterX\n contentGutterY\n contentBordered=\"all\"\n >\n {/*\n * The Inbox stays the site-wide answer to \"who is waiting for a\n * reply\" — that question does not decompose by form. The panel's\n * Form filter narrows it on request; it does not turn the page into\n * a per-form view. It is offered only when the site HAS forms, and\n * never on a card already scoped to one.\n */}\n {offersForm && formsTruncated ? (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" sx={{ mb: 1 }}>\n {`The Form filter offers the first ${FORMS_MAX_PER_HOST.toLocaleString()} ` +\n 'forms. Narrow by form is incomplete; with no Form filter the ' +\n 'list still covers every submission.'}\n </Typography>\n ) : null}\n {hostId == null ? (\n <Typography\n variant=\"body2\"\n color=\"text.secondary\"\n sx={{ mb: submissions.length ? 2 : 1 }}\n >\n {'Every site’s submissions, newest first. Choose a site to ' +\n 'narrow them by form.'}\n </Typography>\n ) : null}\n {submissions.length === 0 && !hasMoreSubmissions && !filtering ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {scoped\n ? 'No submissions carry this form’s id yet. Messages this ' +\n 'form’s design collected before it became a form entity are ' +\n 'in the Inbox, filed under the name they were sent with.'\n : hostId == null\n ? 'No form submissions on any site yet.'\n : 'No form submissions yet. Add a Contact Form element to a ' +\n 'page — visitor messages arrive here.'}\n </Typography>\n ) : (\n <>\n <ListFilterChips\n fields={declaration.fields}\n headers={SUBMISSION_FILTER_HEADERS}\n clauses={gridFilter.clauses}\n onChange={gridFilter.setClauses}\n options={submissionOptions}\n />\n <ListQueryNotices\n refused={refusals}\n notices={[...plan.notices, ...columnSort.notices]}\n />\n <ListTable\n aria-label={scoped ? 'Submissions to this form' : 'Form submissions'}\n rows={columnSort.rows}\n columnSort={columnSort}\n columns={listFilterGridColumns(\n submissionColumns,\n declaration.fields,\n submissionOptions,\n SUBMISSION_FILTER_HEADERS,\n )}\n initialState={{ columns: { columnVisibilityModel: SUBMISSION_HIDDEN_COLUMNS } }}\n noRowsLabel={\n onlyForm\n ? 'No submissions for this form yet. Submissions sent before ' +\n 'the form was created are listed with no Form filter.'\n : 'No submissions match these filters'\n }\n rowHeight={TABLE_ROW_HEIGHT}\n onOpen={(_id, submission) => handleOpenReader(submission)()}\n // An unread submission reads bold across its row, which is why\n // the list needs no `New` chip.\n getRowClassName={({ row }) => (row.read ? '' : 'submission-unread')}\n sx={{\n '& .submission-unread .MuiDataGrid-cell, & .submission-unread .MuiTypography-root':\n { fontWeight: 'fontWeightBold' },\n }}\n // Paged by the footer below, so the grid must not also slice.\n hideFooter\n // The panel, the search and the headers go to the query (From,\n // Site and Message sort the page, and say so).\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n />\n <ListPagination\n page={submissionPage}\n pageSize={submissionPageSize}\n rowCount={submissions.length}\n hasMore={hasMoreSubmissions}\n onPageChange={setSubmissionPage}\n onPageSizeChange={setSubmissionPageSize}\n />\n </>\n )}\n </CardDisplay>\n <Dialog\n open={Boolean(reader)}\n onClose={() => setReader(null)}\n maxWidth=\"sm\"\n fullWidth\n >\n <DialogTitle>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <span>{reader?.formName ?? 'Form submission'}</span>\n {submissionRequestLabel(reader?.request) ? (\n <Chip size=\"small\" color=\"info\" variant=\"outlined\" label={submissionRequestLabel(reader?.request)} />\n ) : null}\n </Stack>\n </DialogTitle>\n <DialogContent>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Received ${reader?.createdAt?.toDate?.().toLocaleString() ?? ''}` +\n // The site it was sent to, where the list spans every site.\n (hostId == null && readerSite\n ? ` · ${orgSiteName(orgMount, readerSite)}`\n : '')}\n </Typography>\n {/*\n WHERE IT CAME IN, AND WHAT IT MADE (AGL-3461) — the form, the page\n it was on, and the lead or contact it filed, each a link to its\n own page. The page is also the field the marketing console's\n landing-page grouping joins on, so a reader can check one row\n against that grouping. Each link is asked of the plugin that owns\n the record, and is text where no plugin answers.\n */}\n {reader ? (\n <Stack spacing={0.5} sx={{ mt: 1 }}>\n {submissionLinks({\n submission: reader,\n hrefOf: (kind, id) =>\n routeContext ? pluginRecordHref(kind, routeContext, id) : null,\n siteOrigin:\n hostPublicOrigin({\n subdomain:\n (hostId != null ? routeContext?.host : null) ??\n orgMount?.hosts.find((site) => site.id === readerSite)?.subdomain ??\n null,\n }) ?? null,\n }).map((link) => (\n <Stack key={link.key} direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ minWidth: 72 }}>\n {link.label}\n </Typography>\n {link.href ? (\n <AppLink\n href={link.href}\n {...(link.external ? { target: '_blank', rel: 'noopener' } : {})}\n >\n {link.text}\n </AppLink>\n ) : (\n <Typography variant=\"body2\">{link.text}</Typography>\n )}\n </Stack>\n ))}\n </Stack>\n ) : null}\n <Divider sx={{ my: 1.5 }} />\n <Stack spacing={1.5}>\n {Object.entries(reader?.fields ?? {}).map(([key, value]) => (\n <Stack key={key} spacing={0.25}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {key}\n </Typography>\n <Typography\n variant=\"body2\"\n sx={{ whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}\n >\n {String(value)}\n </Typography>\n </Stack>\n ))}\n </Stack>\n {/* The files it came with (AGL-4098), each downloaded when pressed. */}\n {reader?.$id && readerSite && submissionFiles(reader.files).length ? (\n <SubmissionFiles\n hostId={readerSite}\n submissionId={String(reader.$id)}\n files={submissionFiles(reader.files)}\n />\n ) : null}\n {/*\n What happened to this submission (AGL-2168). The mockup puts\n these under the fields: `Saved to Inbox` and `Added to \"Leads\"\n dataset`. The second is stamped by the submit route only when a\n record was really appended — a form bound to a deleted dataset,\n or one whose record quota is full, shows no chip rather than a\n chip for a row that does not exist. Both are failures the route\n already swallows silently, and a chip that lied about them\n would be worse than the silence.\n */}\n <Stack\n useFlexGap\n direction=\"row\"\n spacing={1}\n sx={{ mt: 2, flexWrap: 'wrap', rowGap: 1 }}\n >\n {routingChips(reader?.routing).map((chip) => (\n <Chip\n key={chip.label}\n size=\"small\"\n label={chip.label}\n color={chip.color}\n variant=\"outlined\"\n />\n ))}\n </Stack>\n {/*\n WHERE THIS SUBMISSION CAME FROM.\n\n One keyed document read — the attribution's id is `form:{id}` and\n the submission's id is that `{id}` — paid when a merchant opens a\n submission rather than once per row of the list. A submission that\n was credited to nobody renders the sentence saying so; it never\n renders a campaign with a zero beside it.\n */}\n {reader?.$id && readerSite ? (\n <Box sx={{ mt: 2 }}>\n <InboxRecordAttributionZone\n hostId={readerSite}\n recordKind=\"form\"\n recordId={String(reader.$id)}\n filedUnder={submissionFiledUnder(reader)}\n />\n </Box>\n ) : null}\n {/*\n Answering the person is the act the Inbox exists for, and it is\n inside the reader rather than on the row because a reply written\n without the message in front of you is the reply that answers the\n wrong question. Mounted with the dialog, so its reads — the site\n name and the replies already sent — are paid when a merchant opens\n a submission and not once per visit to this page.\n */}\n {reader && readerSite ? (\n <SubmissionReply hostId={readerSite} submission={reader} />\n ) : null}\n {/*\n Enrolling the sender in a marketing list — a SEPARATE act from\n answering them, and a separate card, because the person asked to\n be answered and did not ask to be marketed to. Its reads are paid\n only when a merchant presses its own button, so opening a\n submission to read it costs nothing extra.\n */}\n {reader && readerSite ? (\n <SubmissionListAssignment hostId={readerSite} submission={reader} />\n ) : null}\n </DialogContent>\n <DialogActions>\n {/*\n What another plugin offers to do with this submission (AGL-4098):\n Start a quote on a quote request. First, as the act the reader\n came for; nothing draws for an ordinary message.\n */}\n {reader?.$id && readerSite ? (\n <InboxSubmissionActionsZone\n hostId={readerSite}\n submissionId={String(reader.$id)}\n requestKind={submissionRequestKind(reader.request)}\n formName={String(reader.formName ?? 'Form')}\n />\n ) : null}\n <Button\n color=\"error\"\n onClick={async () => {\n const target = reader\n setReader(null)\n if (target) await handleDelete(target)()\n }}\n >\n {'Delete'}\n </Button>\n <Button\n onClick={() => {\n if (reader) void handleToggleRead({ ...reader, read: true })()\n setReader(null)\n }}\n >\n {'Mark unread'}\n </Button>\n <Button variant=\"contained\" onClick={() => setReader(null)}>\n {'Close'}\n </Button>\n </DialogActions>\n </Dialog>\n </>\n )\n}\nSubmissionsCard.displayName = 'SubmissionsCard'\n\nexport default SubmissionsCard\n"],"names":["FORMS_MAX_PER_HOST","pluginDocsHelp","INBOX_SUBMISSION_PARAM","hostPublicOrigin","submissionFiledUnder","submissionLinks","FORM_SUBMISSION_KIND","InboxRecordAttributionZone","pluginRecordByEmailHref","pluginRecordHref","pluginRecordListHref","mdiAccountArrowRight","mdiDeleteOutline","mdiEmailOpenOutline","mdiEmailOutline","AppLink","CardDisplay","MdiIcon","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","listFilterGridColumns","TABLE_ROW_HEIGHT","useListGridFilter","useSnackbar","useFirestore","useFirestoreCollection","usePluginApiPost","useListQuery","useListColumnSort","Avatar","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Divider","Stack","Tooltip","Typography","collection","deleteDoc","getDoc","limit","orderBy","query","updateDoc","pluginRecordListDoc","pluginRecordListWalk","useSearchParams","useCallback","useEffect","useMemo","useRef","useState","relativeTime","routingChips","senderHue","submissionFiles","submissionRequestKind","submissionRequestLabel","submissionSender","InboxSubmissionActionsZone","SubmissionFiles","FORM_SUBMISSION_FILE_API_PATH","FORM_SCOPED_SUBMISSION_LIST_QUERY","ORG_SUBMISSION_LIST_QUERY","SUBMISSION_FILTER_HEADERS","SUBMISSION_LIST_QUERY","SUBMISSION_READ_OPTIONS","formSubmissionBase","orgSubmissionBase","orgSiteName","SubmissionListAssignment","SubmissionReply","useRecordRouteContext","FORM_STATS_API_PATH","SUBMISSION_SELECT_FIELDS","SUBMISSION_HIDDEN_COLUMNS","read","formId","SUBMISSION_PAGE_SORT_HEADERS","from","hostId","message","messageTextOf","submission","Object","entries","fields","map","key","value","join","SubmissionsCard","orgMount","reader","firestore","enqueueSnackbar","postPluginApi","confirm","scoped","Boolean","orgId","siteOf","routeContext","data","formDocs","idField","formsTruncated","length","forms","slice","sort","left","right","String","displayName","$id","localeCompare","offersForm","declaration","filter","field","column","base","gridFilter","selectFields","askedSort","setAskedSort","rows","submissions","hasMore","hasMoreSubmissions","page","submissionPage","setPage","setSubmissionPage","pageSize","submissionPageSize","setPageSize","setSubmissionPageSize","plan","request","clauses","search","searchWords","deps","submissionOptions","form","label","hosts","host","id","name","refusals","refused","headers","options","submissionPageSorts","columnSort","sorts","defaultSort","onSortChange","pageSorts","searching","some","word","trim","filtering","onlyForm","every","clause","setReader","handleOpenReader","site","submissionDoc","handleToggleRead","searchParams","seededSubmissionId","get","seededOpened","current","seededDoc","then","snapshot","exists","variant","persist","catch","undefined","handleDelete","confirmed","title","description","confirmationText","confirmationButtonProps","color","files","action","submissionId","formIds","submissionActions","senderEmail","email","contactsHref","icon","path","size","href","disabled","disabledReason","onClick","destructive","submissionColumns","headerName","flex","minWidth","valueGetter","_value","renderCell","row","sender","hue","direction","spacing","sx","alignItems","aria-label","width","height","borderRadius","bgcolor","flexShrink","fontSize","initials","noWrap","formName","createdAt","toDate","getTime","toLocaleString","span","hideable","items","readerSite","header","help","anchor","excerpt","contentGutterX","contentGutterY","contentBordered","component","mb","onChange","setClauses","notices","columns","initialState","columnVisibilityModel","noRowsLabel","rowHeight","onOpen","_id","getRowClassName","fontWeight","hideFooter","filterMode","filterModel","onFilterModelChange","quickFilter","rowCount","onPageChange","onPageSizeChange","open","onClose","maxWidth","fullWidth","mt","hrefOf","kind","siteOrigin","subdomain","find","link","external","target","rel","text","my","whiteSpace","wordBreak","useFlexGap","flexWrap","rowGap","routing","chip","recordKind","recordId","filedUnder","requestKind"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,kBAAkB,EAClBC,cAAc,QAET,eAAc;AACrB,SAASC,sBAAsB,QAAQ,kCAA8B;AACrE,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,oBAAoB,EAAEC,eAAe,QAAQ,+BAA2B;AAEjF,+DAA+D,GAC/D,MAAMC,uBAAuB;AAC7B,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,SAASC,0BAA0B,QAAQ,8BAA0B;AACrE,6EAA6E;AAC7E,oCAAoC;AACpC,SACEC,uBAAuB,EACvBC,gBAAgB,EAChBC,oBAAoB,QACf,mDAAkD;AACzD,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,eAAe,QACV,yBAAwB;AAC/B,SAASC,OAAO,EAAEC,WAAW,EAAEC,OAAO,EAAEC,sBAAsB,QAAQ,uBAAsB;AAC5F,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,OAAOC,oBACLC,iBAAiB,QACZ,+DAA8D;AACrE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AAE9B,eAAevB,gBAAe"}
@@ -98,3 +98,27 @@ export interface RoutingChip {
98
98
  * the route already swallows silently.
99
99
  */
100
100
  export declare function routingChips(routing: SubmissionRouting | undefined): RoutingChip[];
101
+ /**
102
+ * A file a submission carries (AGL-4098), as the Inbox lists it: its id, the
103
+ * field it answered, its name, type and size. The forms plugin records them;
104
+ * the Inbox reads them off the stored row defensively and downloads each
105
+ * through that plugin's route, never from storage itself.
106
+ */
107
+ export interface SubmissionFile {
108
+ id: string;
109
+ field: string;
110
+ name: string;
111
+ contentType: string;
112
+ size: number;
113
+ }
114
+ /** The files a stored submission names, in order; none for a row without any. */
115
+ export declare function submissionFiles(raw: unknown): SubmissionFile[];
116
+ /** `12 KB`, `3.4 MB`: a file's size as the Inbox shows it. */
117
+ export declare function submissionFileSize(bytes: number): string;
118
+ /**
119
+ * What a submission asks for, as a chip says it (AGL-4098): "Quote request"
120
+ * for a submission from a form marked as asking for a quote, else null.
121
+ */
122
+ export declare function submissionRequestLabel(raw: unknown): string | null;
123
+ /** The kind of request a submission is, for a plugin that answers it, or null. */
124
+ export declare function submissionRequestKind(raw: unknown): string | null;
@@ -127,5 +127,41 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
127
127
  }
128
128
  return chips;
129
129
  }
130
+ /** The most files a submission carries. */ const SUBMISSION_FILES_MAX = 10;
131
+ /** The files a stored submission names, in order; none for a row without any. */ export function submissionFiles(raw) {
132
+ if (!Array.isArray(raw)) return [];
133
+ return raw.slice(0, SUBMISSION_FILES_MAX).flatMap((entry)=>{
134
+ const file = entry && typeof entry === 'object' ? entry : {};
135
+ const id = typeof file['id'] === 'string' ? file['id'] : '';
136
+ const name = typeof file['name'] === 'string' ? file['name'] : '';
137
+ if (!/^[A-Za-z0-9_-]{1,128}$/.test(id) || !name) return [];
138
+ return [
139
+ {
140
+ id,
141
+ field: typeof file['field'] === 'string' ? file['field'] : '',
142
+ name,
143
+ contentType: typeof file['contentType'] === 'string' ? file['contentType'] : '',
144
+ size: Number(file['size']) || 0
145
+ }
146
+ ];
147
+ });
148
+ }
149
+ /** `12 KB`, `3.4 MB`: a file's size as the Inbox shows it. */ export function submissionFileSize(bytes) {
150
+ if (!(bytes > 0)) return '0 KB';
151
+ if (bytes < 1024 * 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`;
152
+ const mb = bytes / (1024 * 1024);
153
+ return `${mb >= 10 ? Math.round(mb) : Math.round(mb * 10) / 10} MB`;
154
+ }
155
+ /**
156
+ * What a submission asks for, as a chip says it (AGL-4098): "Quote request"
157
+ * for a submission from a form marked as asking for a quote, else null.
158
+ */ export function submissionRequestLabel(raw) {
159
+ const kind = raw == null ? void 0 : raw.kind;
160
+ return kind === 'quote' ? 'Quote request' : null;
161
+ }
162
+ /** The kind of request a submission is, for a plugin that answers it, or null. */ export function submissionRequestKind(raw) {
163
+ const kind = raw == null ? void 0 : raw.kind;
164
+ return typeof kind === 'string' && /^[a-z][a-z-]{0,31}$/.test(kind) ? kind : null;
165
+ }
130
166
 
131
167
  //# sourceMappingURL=submission-presenter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/inbox/src/lib/model/submission-presenter.ts"],"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\nimport { messageSender } from '@aglyn/aglyn/app-utils/message-search'\n\n/**\n * How the Inbox renders one submission (AGL-2168).\n *\n * `/product/forms`'s hero mockup IS the Inbox, and it shows every row as a\n * person: a coloured initials avatar, `Priya Nair`, the form name, and\n * `2m`. The console rendered no sender at all — the row's one content cell\n * was every field concatenated as `name: Priya Nair · email: … · message:\n * …`, so the name was in there somewhere, at the mercy of whatever order\n * the author happened to define the fields in.\n */\n\nexport interface SubmissionSender {\n /** Best available display name — a name, else an email, else a fallback. */\n label: string\n /** The email, when one was submitted. */\n email?: string\n /** One or two letters for the avatar. */\n initials: string\n}\n\n/**\n * Who sent it.\n *\n * A form is author-defined, so there is no guaranteed name field — the\n * lookup is by convention and falls back to the email, then to the form's\n * own name. It never returns an empty string: an avatar with no letters in\n * it is worse than a generic one.\n */\nexport function submissionSender(\n fields: Record<string, unknown> | undefined,\n fallback = 'Someone',\n): SubmissionSender {\n // The platform's one convention for who wrote in — the one the list's\n // From filter and search are stamped from (AGL-3321), so the name a row\n // draws is the name it is found by.\n const { name, email } = messageSender(fields)\n const label = name ?? email ?? fallback\n return { label, ...(email ? { email } : {}), initials: initialsOf(label) }\n}\n\n/**\n * Up to two initials. An email falls back to its local part, so\n * `priya@lumen.co` gives `P` rather than a `@`.\n */\nexport function initialsOf(label: string): string {\n const trimmed = String(label ?? '').trim()\n const source = trimmed.includes('@') ? trimmed.split('@')[0] : trimmed\n const words = source\n .split(/[\\s._-]+/)\n .map((word) => word.trim())\n .filter(Boolean)\n const letters = words\n .slice(0, 2)\n .map((word) => word[0])\n .join('')\n return (letters || source[0] || '?').toUpperCase()\n}\n\n/**\n * A deterministic hue for the avatar, so one sender keeps one colour\n * across sessions and machines. The mockup's avatars are coloured, and a\n * random palette index would make the same person a different colour on\n * every render.\n */\nexport function senderHue(label: string): number {\n let hash = 0\n for (let index = 0; index < label.length; index += 1) {\n hash = (hash * 31 + label.charCodeAt(index)) % 360\n }\n return hash\n}\n\n/**\n * `2m`, `18m`, `1h`, `3d` — the relative times the mockup's list shows.\n *\n * The console rendered `toLocaleString()`, which is the right answer to a\n * different question: an inbox is scanned for recency, and \"8/18/2026,\n * 2:04:31 PM\" makes the reader do the subtraction. The absolute time stays\n * on the detail pane, where it is the fact you actually want.\n */\nexport function relativeTime(\n atMs: number | undefined,\n nowMs: number = Date.now(),\n): string {\n if (!atMs || !Number.isFinite(atMs)) return '--'\n const seconds = Math.round((nowMs - atMs) / 1000)\n // A clock skew between the browser and the server can put a fresh\n // submission a few seconds in the future. \"in 4 seconds\" on an inbox row\n // is a bug report waiting to happen; \"now\" is simply true.\n if (seconds < 60) return 'now'\n const minutes = Math.floor(seconds / 60)\n if (minutes < 60) return `${minutes}m`\n const hours = Math.floor(minutes / 60)\n if (hours < 24) return `${hours}h`\n const days = Math.floor(hours / 24)\n if (days < 7) return `${days}d`\n const weeks = Math.floor(days / 7)\n if (weeks < 5) return `${weeks}w`\n return `${Math.floor(days / 30)}mo`\n}\n\nexport interface SubmissionRouting {\n /** The dataset a record was appended to, when one was. */\n dataset?: { id?: string; name?: string; recordId?: string }\n /**\n * The dataset the form is bound to, when the record was refused because a\n * value failed the dataset's model (AGL-2773): field id → the reason.\n */\n datasetRefused?: {\n id?: string\n name?: string\n errors?: Record<string, string>\n }\n}\n\nexport interface RoutingChip {\n label: string\n color: 'success' | 'info' | 'warning' | 'default'\n}\n\n/**\n * The status chips the mockup's detail pane carries under the fields:\n * `Saved to Inbox` (green) and `Added to \"Leads\" dataset` (blue).\n *\n * The first is unconditional and free — every submission that exists is in\n * the Inbox, which is exactly why the mockup shows it: it is the\n * reassurance, not a status.\n *\n * The second reports what the submit route actually DID. It is stamped on\n * the document only when a record was really appended, so a form bound to\n * a dataset that was deleted, or whose record quota was full, shows no chip\n * rather than a chip for a row that does not exist — the two failure modes\n * the route already swallows silently.\n */\nexport function routingChips(routing: SubmissionRouting | undefined): RoutingChip[] {\n const chips: RoutingChip[] = [{ label: 'Saved to Inbox', color: 'success' }]\n const dataset = routing?.dataset\n if (dataset?.recordId) {\n chips.push({\n label: dataset.name\n ? `Added to “${dataset.name}” dataset`\n : 'Added to a dataset',\n color: 'info',\n })\n }\n /*\n * The record the submission did NOT become, and why (AGL-2773). A form\n * bound to a dataset whose model refuses one of the submitted values keeps\n * the submission and writes no row; without this the owner sees a form\n * that \"stopped saving\" and no reason for it.\n */\n const refused = routing?.datasetRefused\n if (refused && !dataset?.recordId) {\n const reasons = Object.values(refused.errors ?? {}).filter(\n (reason) => typeof reason === 'string' && reason,\n )\n const where = refused.name ? `“${refused.name}” dataset` : 'the dataset'\n chips.push({\n label: reasons.length\n ? `Not added to ${where}: ${reasons.join('; ')}`\n : `Not added to ${where}`,\n color: 'warning',\n })\n }\n return chips\n}\n"],"names":["messageSender","submissionSender","fields","fallback","name","email","label","initials","initialsOf","trimmed","String","trim","source","includes","split","words","map","word","filter","Boolean","letters","slice","join","toUpperCase","senderHue","hash","index","length","charCodeAt","relativeTime","atMs","nowMs","Date","now","Number","isFinite","seconds","Math","round","minutes","floor","hours","days","weeks","routingChips","routing","chips","color","dataset","recordId","push","refused","datasetRefused","reasons","Object","values","errors","reason","where"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,wCAAuC;AAsBrE;;;;;;;CAOC,GACD,OAAO,SAASC,iBACdC,MAA2C,EAC3CC,WAAW,SAAS;QAMNC;IAJd,sEAAsE;IACtE,wEAAwE;IACxE,oCAAoC;IACpC,MAAM,EAAEA,IAAI,EAAEC,KAAK,EAAE,GAAGL,cAAcE;IACtC,MAAMI,SAAQF,OAAAA,eAAAA,OAAQC,iBAARD,OAAiBD;IAC/B,OAAO;QAAEG;OAAWD,QAAQ;QAAEA;IAAM,IAAI,CAAC;QAAIE,UAAUC,WAAWF;;AACpE;AAEA;;;CAGC,GACD,OAAO,SAASE,WAAWF,KAAa;IACtC,MAAMG,UAAUC,OAAOJ,gBAAAA,QAAS,IAAIK,IAAI;IACxC,MAAMC,SAASH,QAAQI,QAAQ,CAAC,OAAOJ,QAAQK,KAAK,CAAC,IAAI,CAAC,EAAE,GAAGL;IAC/D,MAAMM,QAAQH,OACXE,KAAK,CAAC,YACNE,GAAG,CAAC,CAACC,OAASA,KAAKN,IAAI,IACvBO,MAAM,CAACC;IACV,MAAMC,UAAUL,MACbM,KAA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aC,OAAsC;IACjE,MAAMC,QAAuB;QAAC;YAAExC,OAAO;YAAkByC,OAAO;QAAU;KAAE;IAC5E,MAAMC,UAAUH,2BAAAA,QAASG,OAAO;IAChC,IAAIA,2BAAAA,QAASC,QAAQ,EAAE;QACrBH,MAAMI,IAAI,CAAC;YACT5C,OAAO0C,QAAQ5C,IAAI,GACf,CAAC,UAAU,EAAE4C,QAAQ5C,IAAI,CAAC,SAAS,CAAC,GACpC;YACJ2C,OAAO;QACT;IACF;IACA;;;;;GAKC,GACD,MAAMI,UAAUN,2BAAAA,QAASO,cAAc;IACvC,IAAID,WAAW,EAACH,2BAAAA,QAASC,QAAQ,GAAE;YACHE;QAA9B,MAAME,UAAUC,OAAOC,MAAM,EAACJ,kBAAAA,QAAQK,MAAM,YAAdL,kBAAkB,CAAC,GAAGjC,MAAM,CACxD,CAACuC,SAAW,OAAOA,WAAW,YAAYA;QAE5C,MAAMC,QAAQP,QAAQ/C,IAAI,GAAG,CAAC,CAAC,EAAE+C,QAAQ/C,IAAI,CAAC,SAAS,CAAC,GAAG;QAC3D0C,MAAMI,IAAI,CAAC;YACT5C,OAAO+C,QAAQ1B,MAAM,GACjB,CAAC,aAAa,EAAE+B,MAAM,EAAE,EAAEL,QAAQ/B,IAAI,CAAC,OAAO,GAC9C,CAAC,aAAa,EAAEoC,OAAO;YAC3BX,OAAO;QACT;IACF;IACA,OAAOD;AACT"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/inbox/src/lib/model/submission-presenter.ts"],"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\nimport { messageSender } from '@aglyn/aglyn/app-utils/message-search'\n\n/**\n * How the Inbox renders one submission (AGL-2168).\n *\n * `/product/forms`'s hero mockup IS the Inbox, and it shows every row as a\n * person: a coloured initials avatar, `Priya Nair`, the form name, and\n * `2m`. The console rendered no sender at all — the row's one content cell\n * was every field concatenated as `name: Priya Nair · email: … · message:\n * …`, so the name was in there somewhere, at the mercy of whatever order\n * the author happened to define the fields in.\n */\n\nexport interface SubmissionSender {\n /** Best available display name — a name, else an email, else a fallback. */\n label: string\n /** The email, when one was submitted. */\n email?: string\n /** One or two letters for the avatar. */\n initials: string\n}\n\n/**\n * Who sent it.\n *\n * A form is author-defined, so there is no guaranteed name field — the\n * lookup is by convention and falls back to the email, then to the form's\n * own name. It never returns an empty string: an avatar with no letters in\n * it is worse than a generic one.\n */\nexport function submissionSender(\n fields: Record<string, unknown> | undefined,\n fallback = 'Someone',\n): SubmissionSender {\n // The platform's one convention for who wrote in — the one the list's\n // From filter and search are stamped from (AGL-3321), so the name a row\n // draws is the name it is found by.\n const { name, email } = messageSender(fields)\n const label = name ?? email ?? fallback\n return { label, ...(email ? { email } : {}), initials: initialsOf(label) }\n}\n\n/**\n * Up to two initials. An email falls back to its local part, so\n * `priya@lumen.co` gives `P` rather than a `@`.\n */\nexport function initialsOf(label: string): string {\n const trimmed = String(label ?? '').trim()\n const source = trimmed.includes('@') ? trimmed.split('@')[0] : trimmed\n const words = source\n .split(/[\\s._-]+/)\n .map((word) => word.trim())\n .filter(Boolean)\n const letters = words\n .slice(0, 2)\n .map((word) => word[0])\n .join('')\n return (letters || source[0] || '?').toUpperCase()\n}\n\n/**\n * A deterministic hue for the avatar, so one sender keeps one colour\n * across sessions and machines. The mockup's avatars are coloured, and a\n * random palette index would make the same person a different colour on\n * every render.\n */\nexport function senderHue(label: string): number {\n let hash = 0\n for (let index = 0; index < label.length; index += 1) {\n hash = (hash * 31 + label.charCodeAt(index)) % 360\n }\n return hash\n}\n\n/**\n * `2m`, `18m`, `1h`, `3d` — the relative times the mockup's list shows.\n *\n * The console rendered `toLocaleString()`, which is the right answer to a\n * different question: an inbox is scanned for recency, and \"8/18/2026,\n * 2:04:31 PM\" makes the reader do the subtraction. The absolute time stays\n * on the detail pane, where it is the fact you actually want.\n */\nexport function relativeTime(\n atMs: number | undefined,\n nowMs: number = Date.now(),\n): string {\n if (!atMs || !Number.isFinite(atMs)) return '--'\n const seconds = Math.round((nowMs - atMs) / 1000)\n // A clock skew between the browser and the server can put a fresh\n // submission a few seconds in the future. \"in 4 seconds\" on an inbox row\n // is a bug report waiting to happen; \"now\" is simply true.\n if (seconds < 60) return 'now'\n const minutes = Math.floor(seconds / 60)\n if (minutes < 60) return `${minutes}m`\n const hours = Math.floor(minutes / 60)\n if (hours < 24) return `${hours}h`\n const days = Math.floor(hours / 24)\n if (days < 7) return `${days}d`\n const weeks = Math.floor(days / 7)\n if (weeks < 5) return `${weeks}w`\n return `${Math.floor(days / 30)}mo`\n}\n\nexport interface SubmissionRouting {\n /** The dataset a record was appended to, when one was. */\n dataset?: { id?: string; name?: string; recordId?: string }\n /**\n * The dataset the form is bound to, when the record was refused because a\n * value failed the dataset's model (AGL-2773): field id → the reason.\n */\n datasetRefused?: {\n id?: string\n name?: string\n errors?: Record<string, string>\n }\n}\n\nexport interface RoutingChip {\n label: string\n color: 'success' | 'info' | 'warning' | 'default'\n}\n\n/**\n * The status chips the mockup's detail pane carries under the fields:\n * `Saved to Inbox` (green) and `Added to \"Leads\" dataset` (blue).\n *\n * The first is unconditional and free — every submission that exists is in\n * the Inbox, which is exactly why the mockup shows it: it is the\n * reassurance, not a status.\n *\n * The second reports what the submit route actually DID. It is stamped on\n * the document only when a record was really appended, so a form bound to\n * a dataset that was deleted, or whose record quota was full, shows no chip\n * rather than a chip for a row that does not exist — the two failure modes\n * the route already swallows silently.\n */\nexport function routingChips(routing: SubmissionRouting | undefined): RoutingChip[] {\n const chips: RoutingChip[] = [{ label: 'Saved to Inbox', color: 'success' }]\n const dataset = routing?.dataset\n if (dataset?.recordId) {\n chips.push({\n label: dataset.name\n ? `Added to “${dataset.name}” dataset`\n : 'Added to a dataset',\n color: 'info',\n })\n }\n /*\n * The record the submission did NOT become, and why (AGL-2773). A form\n * bound to a dataset whose model refuses one of the submitted values keeps\n * the submission and writes no row; without this the owner sees a form\n * that \"stopped saving\" and no reason for it.\n */\n const refused = routing?.datasetRefused\n if (refused && !dataset?.recordId) {\n const reasons = Object.values(refused.errors ?? {}).filter(\n (reason) => typeof reason === 'string' && reason,\n )\n const where = refused.name ? `“${refused.name}” dataset` : 'the dataset'\n chips.push({\n label: reasons.length\n ? `Not added to ${where}: ${reasons.join('; ')}`\n : `Not added to ${where}`,\n color: 'warning',\n })\n }\n return chips\n}\n\n/**\n * A file a submission carries (AGL-4098), as the Inbox lists it: its id, the\n * field it answered, its name, type and size. The forms plugin records them;\n * the Inbox reads them off the stored row defensively and downloads each\n * through that plugin's route, never from storage itself.\n */\nexport interface SubmissionFile {\n id: string\n field: string\n name: string\n contentType: string\n size: number\n}\n\n/** The most files a submission carries. */\nconst SUBMISSION_FILES_MAX = 10\n\n/** The files a stored submission names, in order; none for a row without any. */\nexport function submissionFiles(raw: unknown): SubmissionFile[] {\n if (!Array.isArray(raw)) return []\n return raw.slice(0, SUBMISSION_FILES_MAX).flatMap((entry) => {\n const file = (entry && typeof entry === 'object' ? entry : {}) as Record<string, unknown>\n const id = typeof file['id'] === 'string' ? file['id'] : ''\n const name = typeof file['name'] === 'string' ? file['name'] : ''\n if (!/^[A-Za-z0-9_-]{1,128}$/.test(id) || !name) return []\n return [\n {\n id,\n field: typeof file['field'] === 'string' ? file['field'] : '',\n name,\n contentType: typeof file['contentType'] === 'string' ? file['contentType'] : '',\n size: Number(file['size']) || 0,\n },\n ]\n })\n}\n\n/** `12 KB`, `3.4 MB`: a file's size as the Inbox shows it. */\nexport function submissionFileSize(bytes: number): string {\n if (!(bytes > 0)) return '0 KB'\n if (bytes < 1024 * 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`\n const mb = bytes / (1024 * 1024)\n return `${mb >= 10 ? Math.round(mb) : Math.round(mb * 10) / 10} MB`\n}\n\n/**\n * What a submission asks for, as a chip says it (AGL-4098): \"Quote request\"\n * for a submission from a form marked as asking for a quote, else null.\n */\nexport function submissionRequestLabel(raw: unknown): string | null {\n const kind = (raw as { kind?: unknown } | null | undefined)?.kind\n return kind === 'quote' ? 'Quote request' : null\n}\n\n/** The kind of request a submission is, for a plugin that answers it, or null. */\nexport function submissionRequestKind(raw: unknown): string | null {\n const kind = (raw as { kind?: unknown } | null | undefined)?.kind\n return typeof kind === 'string' && /^[a-z][a-z-]{0,31}$/.test(kind) ? kind : null\n}\n"],"names":["messageSender","submissionSender","fields","fallback","name","email","label","initials","initialsOf","trimmed","String","trim","source","includes","split","words","map","word","filter","Boolean","letters","slice","join","toUpperCase","senderHue","hash","index","length","charCodeAt","relativeTime","atMs","nowMs","Date","now","Number","isFinite","seconds","Math","round","minutes","floor","hours","days","weeks","routingChips","routing","chips","color","dataset","recordId","push","refused","datasetRefused","reasons","Object","values","errors","reason","where","SUBMISSION_FILES_MAX","submissionFiles","raw","Array","isArray","flatMap","entry","file","id","test","field","contentType","size","submissionFileSize","bytes","max","mb","submissionRequestLabel","kind","submissionRequestKind"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,wCAAuC;AAsBrE;;;;;;;CAOC,GACD,OAAO,SAASC,iBACdC,MAA2C,EAC3CC,WAAW,SAAS;QAMNC;IAJd,sEAAsE;IACtE,wEAAwE;IACxE,oCAAoC;IACpC,MAAM,EAAEA,IAAI,EAAEC,KAAK,EAAE,GAAGL,cAAcE;IACtC,MAAMI,SAAQF,OAAAA,eAAAA,OAAQC,iBAARD,OAAiBD;IAC/B,OAAO;QAAEG;OAAWD,QAAQ;QAAEA;IAAM,IAAI,CAAC;QAAIE,UAAUC,WAAWF;;AACpE;AAEA;;;CAGC,GACD,OAAO,SAASE,WAAWF,K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EA,gFAAgF,GAChF,OAAO,SAASC,sBAAsBjB,GAAY;IAChD,MAAMgB,OAAQhB,uBAAD,AAACA,IAA+CgB,IAAI;IACjE,OAAO,OAAOA,SAAS,YAAY,sBAAsBT,IAAI,CAACS,QAAQA,OAAO;AAC/E"}
package/src/lib/plugin.js CHANGED
@@ -19,6 +19,7 @@ import { lazy } from "react";
19
19
  import { INBOX_CONSOLE_SECTIONS, INBOX_ORG_CONSOLE_SECTIONS } from "./components/inbox-console-sections.js";
20
20
  import { registerPluginZone } from "@aglyn/aglyn/plugin-manager/plugin-zones";
21
21
  import { INBOX_CAMPAIGNS_ZONE, INBOX_RECORD_ATTRIBUTION_ZONE } from "./components/inbox-attribution-zone.js";
22
+ import { INBOX_SUBMISSION_ACTIONS_ZONE } from "./components/inbox-submission-actions-zone.js";
22
23
  import { BUNDLE_ID } from "./constants/bundle-common.js";
23
24
  import { registerInboxRecordRoutes } from "./model/inbox-record-routes.js";
24
25
  /** Code-split: the Inbox console page only loads when opened. */ const InboxConsolePage = lazy(()=>import("./components/inbox-console-page.js"));
@@ -46,6 +47,16 @@ import { registerInboxRecordRoutes } from "./model/inbox-record-routes.js";
46
47
  {
47
48
  pluginId: BUNDLE_ID
48
49
  });
50
+ registerPluginZone({
51
+ zone: INBOX_SUBMISSION_ACTIONS_ZONE,
52
+ label: 'Act on an open submission',
53
+ surface: 'console',
54
+ // One button among the open submission's actions: the dialog lays them out.
55
+ layout: 'bare',
56
+ description: 'Among an open submission’s actions, before Delete. A widget here offers something to do with it, such as starting a quote from a quote request; it is handed the site, the submission’s id, what it asks for and its form’s name, reads anything more through the forms plugin’s facts, and writes nothing through the Inbox.'
57
+ }, {
58
+ pluginId: BUNDLE_ID
59
+ });
49
60
  registerPluginZone({
50
61
  zone: INBOX_CAMPAIGNS_ZONE,
51
62
  label: 'The Inbox’s Campaigns section',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/plugins/inbox/src/lib/plugin.ts"],"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\nimport * as Aglyn from '@aglyn/aglyn'\nimport { mdiInboxArrowDown } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport {\n INBOX_CONSOLE_SECTIONS,\n INBOX_ORG_CONSOLE_SECTIONS,\n} from './components/inbox-console-sections'\nimport { registerPluginZone } from '@aglyn/aglyn/plugin-manager/plugin-zones'\nimport {\n INBOX_CAMPAIGNS_ZONE,\n INBOX_RECORD_ATTRIBUTION_ZONE,\n} from './components/inbox-attribution-zone'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { registerInboxRecordRoutes } from './model/inbox-record-routes'\n\n/** Code-split: the Inbox console page only loads when opened. */\nconst InboxConsolePage = lazy(() => import('./components/inbox-console-page'))\n\n/**\n * Code-split: the submissions table loads when a form page asks for it. The\n * zone hands `hostId` and `formId`, which is what the table's own props are.\n */\nconst FormSubmissionsReader = lazy(\n () => import('./components/submissions-card.component'),\n)\n\n/** Dashboard glance card, loaded only where the shell renders the slot. */\nconst InboxGlanceCard = lazy(\n () => import('./components/inbox-glance-card.component'),\n)\n\n/**\n * Inbox feature plugin (AGL-395). Console-only — form submissions, site\n * members/leads and campaigns live in Firestore and have no canvas element,\n * so there is no UI bundle. The console half declares the Inbox nav + its\n * three sections through the ConsoleExtension registry (always-on), once\n * under each site and once for the organization (AGL-3303). The Campaigns\n * section and the attribution shown inside a submission are zones this\n * plugin hosts; the plugin that owns campaigns draws in them.\n */\nexport function registerInboxConsole(): void {\n registerInboxRecordRoutes()\n registerPluginZone(\n {\n zone: INBOX_RECORD_ATTRIBUTION_ZONE,\n label: 'Where a lead or a submission came from',\n surface: 'console',\n description:\n 'In a lead’s “Where this came from” dialog and under an open submission. A widget here says which campaign or link brought it; it is handed the site, what the record is and its id, and it writes nothing.',\n },\n // Named, because a spec calls this registrar without the loader.\n { pluginId: BUNDLE_ID },\n )\n registerPluginZone(\n {\n zone: INBOX_CAMPAIGNS_ZONE,\n label: 'The Inbox’s Campaigns section',\n surface: 'console',\n description:\n 'The body of the Inbox’s Campaigns tab. A widget here lists the site’s campaigns; it is handed the site and nothing else — or, on the organization’s Inbox, no site (`hostId: null`) and the organization with its sites (`orgMount`), and lists every site’s.',\n },\n { pluginId: BUNDLE_ID },\n )\n Aglyn.registerConsoleExtension({\n pluginId: BUNDLE_ID,\n displayName: 'Inbox',\n // The host dashboard's inbox glance. A form submission is the one thing\n // on a site that is waiting for a REPLY, and until this it was two\n // clicks from the page an owner opens first.\n widgets: [\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.hostDashboard,\n widgetId: 'inbox-glance',\n title: 'Inbox',\n Component: InboxGlanceCard,\n },\n // One form's submissions, on the form's own page. The forms plugin\n // hosts the zone and hands it the site and the form; the reader is this\n // plugin's table, narrowed to that form, so the form page gets the same\n // ordered, paged walk the Inbox uses without importing it.\n {\n slot: 'formSubmissions',\n widgetId: 'inbox-form-submissions',\n title: 'Submissions',\n Component: FormSubmissionsReader,\n },\n ],\n navItems: [\n {\n label: 'Inbox',\n href: '/inbox',\n // Sections as ROUTES (AGL-2501): each is a real URL the shell\n // resolves and gates, so the page mounts the one being read.\n sections: INBOX_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-inbox',\n icon: { path: mdiInboxArrowDown.path },\n header: {\n title: 'Inbox',\n icon: { path: mdiInboxArrowDown.path },\n docsTopic: 'forms',\n },\n Component: InboxConsolePage,\n },\n ],\n /*\n * The ORGANIZATION's Inbox, at `/[orgSlug]/inbox` (AGL-3303): every\n * site's submissions in one list, the organization's leads, and every\n * campaign, with a site filter that narrows the page to one site's own\n * view. The page is the same component; handed no site, it draws the\n * org sections.\n *\n * It carries the SITE tab's id on purpose, as the org CRM and Marketing\n * tabs do: `release_inbox` names `nav-tab-inbox`, so one flag holds both\n * levels and the org Inbox cannot ship while the site's is switched off.\n */\n orgNavItems: [\n {\n label: 'Inbox',\n href: '/inbox',\n sections: INBOX_ORG_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-inbox',\n icon: { path: mdiInboxArrowDown.path },\n header: {\n title: 'Inbox',\n icon: { path: mdiInboxArrowDown.path },\n docsTopic: 'forms',\n },\n Component: InboxConsolePage,\n },\n ],\n })\n}\n"],"names":["Aglyn","mdiInboxArrowDown","lazy","INBOX_CONSOLE_SECTIONS","INBOX_ORG_CONSOLE_SECTIONS","registerPluginZone","INBOX_CAMPAIGNS_ZONE","INBOX_RECORD_ATTRIBUTION_ZONE","BUNDLE_ID","registerInboxRecordRoutes","InboxConsolePage","FormSubmissionsReader","InboxGlanceCard","registerInboxConsole","zone","label","surface","description","pluginId","registerConsoleExtension","displayName","widgets","slot","CONSOLE_WIDGET_SLOTS","hostDashboard","widgetId","title","Component","navItems","href","sections","navTabId","icon","path","header","docsTopic","orgNavItems"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,IAAI,QAAQ,QAAO;AAC5B,SACEC,sBAAsB,EACtBC,0BAA0B,QACrB,yCAAqC;AAC5C,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SACEC,oBAAoB,EACpBC,6BAA6B,QACxB,yCAAqC;AAC5C,SAASC,SAAS,QAAQ,+BAA2B;AACrD,SAASC,yBAAyB,QAAQ,iCAA6B;AAEvE,+DAA+D,GAC/D,MAAMC,mBAAmBR,KAAK,IAAM,MAAM,CAAC;AAE3C;;;CAGC,GACD,MAAMS,wBAAwBT,KAC5B,IAAM,MAAM,CAAC;AAGf,yEAAyE,GACzE,MAAM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ugins/inbox/src/lib/plugin.ts"],"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\nimport * as Aglyn from '@aglyn/aglyn'\nimport { mdiInboxArrowDown } from '@aglyn/shared-data-mdi'\nimport { lazy } from 'react'\nimport {\n INBOX_CONSOLE_SECTIONS,\n INBOX_ORG_CONSOLE_SECTIONS,\n} from './components/inbox-console-sections'\nimport { registerPluginZone } from '@aglyn/aglyn/plugin-manager/plugin-zones'\nimport {\n INBOX_CAMPAIGNS_ZONE,\n INBOX_RECORD_ATTRIBUTION_ZONE,\n} from './components/inbox-attribution-zone'\nimport { INBOX_SUBMISSION_ACTIONS_ZONE } from './components/inbox-submission-actions-zone'\nimport { BUNDLE_ID } from './constants/bundle-common'\nimport { registerInboxRecordRoutes } from './model/inbox-record-routes'\n\n/** Code-split: the Inbox console page only loads when opened. */\nconst InboxConsolePage = lazy(() => import('./components/inbox-console-page'))\n\n/**\n * Code-split: the submissions table loads when a form page asks for it. The\n * zone hands `hostId` and `formId`, which is what the table's own props are.\n */\nconst FormSubmissionsReader = lazy(\n () => import('./components/submissions-card.component'),\n)\n\n/** Dashboard glance card, loaded only where the shell renders the slot. */\nconst InboxGlanceCard = lazy(\n () => import('./components/inbox-glance-card.component'),\n)\n\n/**\n * Inbox feature plugin (AGL-395). Console-only — form submissions, site\n * members/leads and campaigns live in Firestore and have no canvas element,\n * so there is no UI bundle. The console half declares the Inbox nav + its\n * three sections through the ConsoleExtension registry (always-on), once\n * under each site and once for the organization (AGL-3303). The Campaigns\n * section and the attribution shown inside a submission are zones this\n * plugin hosts; the plugin that owns campaigns draws in them.\n */\nexport function registerInboxConsole(): void {\n registerInboxRecordRoutes()\n registerPluginZone(\n {\n zone: INBOX_RECORD_ATTRIBUTION_ZONE,\n label: 'Where a lead or a submission came from',\n surface: 'console',\n description:\n 'In a lead’s “Where this came from” dialog and under an open submission. A widget here says which campaign or link brought it; it is handed the site, what the record is and its id, and it writes nothing.',\n },\n // Named, because a spec calls this registrar without the loader.\n { pluginId: BUNDLE_ID },\n )\n registerPluginZone(\n {\n zone: INBOX_SUBMISSION_ACTIONS_ZONE,\n label: 'Act on an open submission',\n surface: 'console',\n // One button among the open submission's actions: the dialog lays them out.\n layout: 'bare',\n description:\n 'Among an open submission’s actions, before Delete. A widget here offers something to do with it, such as starting a quote from a quote request; it is handed the site, the submission’s id, what it asks for and its form’s name, reads anything more through the forms plugin’s facts, and writes nothing through the Inbox.',\n },\n { pluginId: BUNDLE_ID },\n )\n registerPluginZone(\n {\n zone: INBOX_CAMPAIGNS_ZONE,\n label: 'The Inbox’s Campaigns section',\n surface: 'console',\n description:\n 'The body of the Inbox’s Campaigns tab. A widget here lists the site’s campaigns; it is handed the site and nothing else — or, on the organization’s Inbox, no site (`hostId: null`) and the organization with its sites (`orgMount`), and lists every site’s.',\n },\n { pluginId: BUNDLE_ID },\n )\n Aglyn.registerConsoleExtension({\n pluginId: BUNDLE_ID,\n displayName: 'Inbox',\n // The host dashboard's inbox glance. A form submission is the one thing\n // on a site that is waiting for a REPLY, and until this it was two\n // clicks from the page an owner opens first.\n widgets: [\n {\n slot: Aglyn.CONSOLE_WIDGET_SLOTS.hostDashboard,\n widgetId: 'inbox-glance',\n title: 'Inbox',\n Component: InboxGlanceCard,\n },\n // One form's submissions, on the form's own page. The forms plugin\n // hosts the zone and hands it the site and the form; the reader is this\n // plugin's table, narrowed to that form, so the form page gets the same\n // ordered, paged walk the Inbox uses without importing it.\n {\n slot: 'formSubmissions',\n widgetId: 'inbox-form-submissions',\n title: 'Submissions',\n Component: FormSubmissionsReader,\n },\n ],\n navItems: [\n {\n label: 'Inbox',\n href: '/inbox',\n // Sections as ROUTES (AGL-2501): each is a real URL the shell\n // resolves and gates, so the page mounts the one being read.\n sections: INBOX_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-inbox',\n icon: { path: mdiInboxArrowDown.path },\n header: {\n title: 'Inbox',\n icon: { path: mdiInboxArrowDown.path },\n docsTopic: 'forms',\n },\n Component: InboxConsolePage,\n },\n ],\n /*\n * The ORGANIZATION's Inbox, at `/[orgSlug]/inbox` (AGL-3303): every\n * site's submissions in one list, the organization's leads, and every\n * campaign, with a site filter that narrows the page to one site's own\n * view. The page is the same component; handed no site, it draws the\n * org sections.\n *\n * It carries the SITE tab's id on purpose, as the org CRM and Marketing\n * tabs do: `release_inbox` names `nav-tab-inbox`, so one flag holds both\n * levels and the org Inbox cannot ship while the site's is switched off.\n */\n orgNavItems: [\n {\n label: 'Inbox',\n href: '/inbox',\n sections: INBOX_ORG_CONSOLE_SECTIONS,\n navTabId: 'nav-tab-inbox',\n icon: { path: mdiInboxArrowDown.path },\n header: {\n title: 'Inbox',\n icon: { path: mdiInboxArrowDown.path },\n docsTopic: 'forms',\n },\n Component: InboxConsolePage,\n },\n ],\n })\n}\n"],"names":["Aglyn","mdiInboxArrowDown","lazy","INBOX_CONSOLE_SECTIONS","INBOX_ORG_CONSOLE_SECTIONS","registerPluginZone","INBOX_CAMPAIGNS_ZONE","INBOX_RECORD_ATTRIBUTION_ZONE","INBOX_SUBMISSION_ACTIONS_ZONE","BUNDLE_ID","registerInboxRecordRoutes","InboxConsolePage","FormSubmissionsReader","InboxGlanceCard","registerInboxConsole","zone","label","surface","description","pluginId","layout","registerConsoleExtension","displayName","widgets","slot","CONSOLE_WIDGET_SLOTS","hostDashboard","widgetId","title","Component","navItems","href","sections","navTabId","icon","path","header","docsTopic","orgNavItems"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,YAAYA,WAAW,eAAc;AACrC,SAASC,iBAAiB,QAAQ,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