@aglyn/plugins-inbox 1.0.0-beta.221 → 1.0.0-beta.222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -10
- package/src/lib/components/inbox-console-page.js +18 -76
- package/src/lib/components/inbox-console-page.js.map +1 -1
- package/src/lib/components/inbox-glance-card.component.d.ts +1 -1
- package/src/lib/components/inbox-glance-card.component.js +9 -3
- package/src/lib/components/inbox-glance-card.component.js.map +1 -1
- package/src/lib/components/submission-reply.component.js +11 -2
- package/src/lib/components/submission-reply.component.js.map +1 -1
- package/src/lib/components/submissions-card.component.js +34 -10
- package/src/lib/components/submissions-card.component.js.map +1 -1
- package/src/lib/components/visitor-door-notices.component.d.ts +54 -0
- package/src/lib/components/visitor-door-notices.component.js +123 -0
- package/src/lib/components/visitor-door-notices.component.js.map +1 -0
- package/src/lib/server.js +53 -20
- package/src/lib/server.js.map +1 -1
- package/src/lib/testing/stand-in-form-submissions.d.ts +25 -0
- package/src/lib/testing/stand-in-form-submissions.js +103 -0
- package/src/lib/testing/stand-in-form-submissions.js.map +1 -0
- package/src/lib/testing/stand-in-person-records.d.ts +35 -0
- package/src/lib/testing/stand-in-person-records.js +67 -0
- package/src/lib/testing/stand-in-person-records.js.map +1 -0
|
@@ -18,6 +18,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
18
18
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
19
|
import { FORMS_MAX_PER_HOST, pluginDocsHelp } from "@aglyn/aglyn";
|
|
20
20
|
import { INBOX_SUBMISSION_PARAM } from "../model/inbox-record-routes.js";
|
|
21
|
+
/** The forms plugin's record kind this card reads (AGL-3080). */ const FORM_SUBMISSION_KIND = 'formSubmission';
|
|
21
22
|
// A deep import, NOT the plugin barrel (AGL-1151): the barrel is the entry
|
|
22
23
|
// point the tenant's loader dynamically imports to activate the marketing
|
|
23
24
|
// plugin's SITE half, so a console card named there ships to every published
|
|
@@ -39,7 +40,10 @@ import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
|
39
40
|
import { useFirestore, useFirestoreCollection, usePluginApiPost } from "@aglyn/tenant-feature-instance";
|
|
40
41
|
import { useListQuery } from "@aglyn/tenant-feature-instance/hooks/use-list-query";
|
|
41
42
|
import { Avatar, Box, Button, Chip, Dialog, DialogActions, DialogContent, DialogTitle, Divider, Stack, Tooltip, Typography } from "@mui/material";
|
|
42
|
-
import { collection,
|
|
43
|
+
import { collection, deleteDoc, getDoc, limit, orderBy, query, updateDoc } from "firebase/firestore";
|
|
44
|
+
// The submissions are the forms plugin's records, walked and opened through
|
|
45
|
+
// the list source it publishes (AGL-3080).
|
|
46
|
+
import { pluginRecordListDoc, pluginRecordListWalk } from "@aglyn/aglyn/plugin-manager/plugin-record-lists";
|
|
43
47
|
import { useSearchParams } from "next/navigation";
|
|
44
48
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
45
49
|
import { relativeTime, routingChips, senderHue, submissionSender } from "../model/submission-presenter.js";
|
|
@@ -169,7 +173,7 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
|
|
|
169
173
|
* as an unreachable inbox.
|
|
170
174
|
*
|
|
171
175
|
* `createdAt` is safe to order on, checked against the writer rather than
|
|
172
|
-
* assumed: `
|
|
176
|
+
* assumed: `libs/plugins/forms/src/lib/server/form-submit.ts` is the only path
|
|
173
177
|
* that creates one and stamps `createdAt: serverTimestamp()` on every add,
|
|
174
178
|
* the v1 API only ever reads and deletes, and `formSubmissions` is absent
|
|
175
179
|
* from `IMPORTABLE_FIELDS`, so no restore path can make one without it.
|
|
@@ -183,7 +187,10 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
|
|
|
183
187
|
* were stamped once (AGL-3303). A row without one would be in no
|
|
184
188
|
* organization's list, though its own site's Inbox lists it either way.
|
|
185
189
|
*/ const { rows: submissions, hasMore: hasMoreSubmissions, page: submissionPage, setPage: setSubmissionPage, pageSize: submissionPageSize, setPageSize: setSubmissionPageSize, plan } = useListQuery({
|
|
186
|
-
collection:
|
|
190
|
+
collection: pluginRecordListWalk(FORM_SUBMISSION_KIND, firestore, {
|
|
191
|
+
hostId,
|
|
192
|
+
orgId
|
|
193
|
+
}),
|
|
187
194
|
declaration,
|
|
188
195
|
request: {
|
|
189
196
|
clauses: gridFilter.clauses,
|
|
@@ -236,8 +243,12 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
|
|
|
236
243
|
const handleOpenReader = useCallback((submission)=>()=>{
|
|
237
244
|
setReader(submission);
|
|
238
245
|
const site = siteOf(submission);
|
|
239
|
-
|
|
240
|
-
|
|
246
|
+
const submissionDoc = site ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, {
|
|
247
|
+
hostId: site,
|
|
248
|
+
id: submission.$id
|
|
249
|
+
}) : null;
|
|
250
|
+
if (!submission.read && submissionDoc) {
|
|
251
|
+
void updateDoc(submissionDoc, {
|
|
241
252
|
read: true
|
|
242
253
|
});
|
|
243
254
|
}
|
|
@@ -247,8 +258,12 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
|
|
|
247
258
|
]);
|
|
248
259
|
const handleToggleRead = useCallback((submission)=>()=>{
|
|
249
260
|
const site = siteOf(submission);
|
|
250
|
-
|
|
251
|
-
|
|
261
|
+
const submissionDoc = site ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, {
|
|
262
|
+
hostId: site,
|
|
263
|
+
id: submission.$id
|
|
264
|
+
}) : null;
|
|
265
|
+
if (!submissionDoc) return;
|
|
266
|
+
void updateDoc(submissionDoc, {
|
|
252
267
|
read: !submission.read
|
|
253
268
|
});
|
|
254
269
|
}, [
|
|
@@ -282,7 +297,12 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
|
|
|
282
297
|
if (!hostId) return;
|
|
283
298
|
if (!seededSubmissionId || seededOpened.current === seededSubmissionId) return;
|
|
284
299
|
seededOpened.current = seededSubmissionId;
|
|
285
|
-
|
|
300
|
+
const seededDoc = pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, {
|
|
301
|
+
hostId,
|
|
302
|
+
id: seededSubmissionId
|
|
303
|
+
});
|
|
304
|
+
if (!seededDoc) return;
|
|
305
|
+
void getDoc(seededDoc).then((snapshot)=>{
|
|
286
306
|
if (seededOpened.current !== snapshot.id) return;
|
|
287
307
|
if (!snapshot.exists()) {
|
|
288
308
|
enqueueSnackbar('That submission is no longer in the Inbox.', {
|
|
@@ -304,7 +324,11 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
|
|
|
304
324
|
]);
|
|
305
325
|
const handleDelete = useCallback((submission)=>async ()=>{
|
|
306
326
|
const site = siteOf(submission);
|
|
307
|
-
|
|
327
|
+
const submissionDoc = site ? pluginRecordListDoc(FORM_SUBMISSION_KIND, firestore, {
|
|
328
|
+
hostId: site,
|
|
329
|
+
id: submission.$id
|
|
330
|
+
}) : null;
|
|
331
|
+
if (!site || !submissionDoc) return;
|
|
308
332
|
const confirmed = await confirm({
|
|
309
333
|
title: 'Delete this submission?',
|
|
310
334
|
description: 'The submission is removed permanently.',
|
|
@@ -314,7 +338,7 @@ export function SubmissionsCard({ hostId, formId, orgMount }) {
|
|
|
314
338
|
}
|
|
315
339
|
}).then(()=>true).catch(()=>false);
|
|
316
340
|
if (!confirmed) return;
|
|
317
|
-
await deleteDoc(
|
|
341
|
+
await deleteDoc(submissionDoc);
|
|
318
342
|
enqueueSnackbar('Submission deleted', {
|
|
319
343
|
variant: 'success',
|
|
320
344
|
persist: false
|
|
@@ -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'\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 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 { 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 {\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 collectionGroup,\n deleteDoc,\n doc,\n getDoc,\n limit,\n orderBy,\n query,\n updateDoc,\n} from 'firebase/firestore'\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. */\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 /*\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: `apps/tenant/app/api/forms/submit/route.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: hostId\n ? collection(firestore, 'hosts', hostId, 'formSubmissions')\n : orgId\n ? collectionGroup(firestore, 'formSubmissions')\n : null,\n declaration,\n request: { clauses: gridFilter.clauses, search: gridFilter.searchWords, base },\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 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 if (!submission.read && site) {\n void updateDoc(\n doc(firestore, 'hosts', site, 'formSubmissions', submission.$id),\n { read: true },\n )\n }\n },\n [firestore, siteOf],\n )\n\n const handleToggleRead = useCallback(\n (submission: any) => () => {\n const site = siteOf(submission)\n if (!site) return\n void updateDoc(\n doc(firestore, 'hosts', site, 'formSubmissions', submission.$id),\n { read: !submission.read },\n )\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 void getDoc(doc(firestore, 'hosts', hostId, 'formSubmissions', seededSubmissionId))\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 if (!site) 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(\n doc(firestore, 'hosts', site, 'formSubmissions', submission.$id),\n )\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 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 refused={refusals} notices={plan.notices} />\n <ListTable\n aria-label={scoped ? 'Submissions to this form' : 'Form submissions'}\n rows={submissions}\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 and the search go to the query; the grid neither\n // filters nor sorts the page it holds.\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n disableColumnSorting\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 (reader?.screenId ? ` · page ${reader.screenId}` : '')}\n {/*\n THE PAGE THE FORM WAS ON. Stored by the submit route since the\n form existed and rendered by nothing, which is also the field\n the marketing console's landing-page grouping joins on — a\n reader who wants to check one row against that grouping has to\n be able to see the row's own page.\n */}\n {reader?.path ? ` · ${String(reader.path)}` : ''}\n </Typography>\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 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 />\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","InboxRecordAttributionZone","pluginRecordByEmailHref","pluginRecordListHref","mdiAccountArrowRight","mdiDeleteOutline","mdiEmailOpenOutline","mdiEmailOutline","CardDisplay","MdiIcon","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","listFilterGridColumns","TABLE_ROW_HEIGHT","useListGridFilter","useSnackbar","useFirestore","useFirestoreCollection","usePluginApiPost","useListQuery","Avatar","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Divider","Stack","Tooltip","Typography","collection","collectionGroup","deleteDoc","doc","getDoc","limit","orderBy","query","updateDoc","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","messageTextOf","submission","Object","entries","fields","map","key","value","join","SubmissionsCard","hostId","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","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","searching","some","word","trim","filtering","onlyForm","every","clause","setReader","handleOpenReader","site","handleToggleRead","searchParams","seededSubmissionId","get","seededOpened","current","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","disableColumnSorting","rowCount","onPageChange","onPageSizeChange","open","onClose","maxWidth","fullWidth","screenId","my","whiteSpace","wordBreak","mt","flexWrap","rowGap","routing","chip","recordKind","recordId","target"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,kBAAkB,EAClBC,cAAc,QAET,eAAc;AACrB,SAASC,sBAAsB,QAAQ,kCAA8B;AACrE,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,wEAAwE;AACxE,SAASC,0BAA0B,QAAQ,8BAA0B;AACrE,6EAA6E;AAC7E,oCAAoC;AACpC,SACEC,uBAAuB,EACvBC,oBAAoB,QACf,mDAAkD;AACzD,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,eAAe,QACV,yBAAwB;AAC/B,SAASC,WAAW,EAAEC,OAAO,EAAEC,sBAAsB,QAAQ,uBAAsB;AACnF,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,OAAOC,oBACLC,iBAAiB,QACZ,+DAA8D;AACrE,SACEC,cAAc,EACdC,SAAS,EACTC,iBAAiB,QACZ,uDAAsD;AAE7D,SAEEC,qBAAqB,QAChB,8CAA6C;AAEpD,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,iBAAiB,QAAQ,kDAAiD;AACnF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,YAAY,EACZC,sBAAsB,EACtBC,gBAAgB,QACX,iCAAgC;AACvC,SAASC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,KAAKwE,iBAAiB,aAAKxE;wCAAQd,MAAM;;oCACrDmF,UAAU;gCACZ;0CAEC;;0CAEH,KAAC9H;gCAAO0I,SAAQ;gCAAYsB,SAAS,IAAMlC,UAAU;0CAClD;;;;;;;;AAMb;AACAxE,gBAAgBwB,WAAW,GAAG;AAE9B,eAAexB,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'\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 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 { 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 {\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. */\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 /*\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: { clauses: gridFilter.clauses, search: gridFilter.searchWords, base },\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 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 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 refused={refusals} notices={plan.notices} />\n <ListTable\n aria-label={scoped ? 'Submissions to this form' : 'Form submissions'}\n rows={submissions}\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 and the search go to the query; the grid neither\n // filters nor sorts the page it holds.\n filterMode=\"server\"\n filterModel={gridFilter.filterModel}\n onFilterModelChange={gridFilter.onFilterModelChange}\n quickFilter\n disableColumnSorting\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 (reader?.screenId ? ` · page ${reader.screenId}` : '')}\n {/*\n THE PAGE THE FORM WAS ON. Stored by the submit route since the\n form existed and rendered by nothing, which is also the field\n the marketing console's landing-page grouping joins on — a\n reader who wants to check one row against that grouping has to\n be able to see the row's own page.\n */}\n {reader?.path ? ` · ${String(reader.path)}` : ''}\n </Typography>\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 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 />\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","FORM_SUBMISSION_KIND","InboxRecordAttributionZone","pluginRecordByEmailHref","pluginRecordListHref","mdiAccountArrowRight","mdiDeleteOutline","mdiEmailOpenOutline","mdiEmailOutline","CardDisplay","MdiIcon","useConfirmationContext","ListFilterChips","ListPagination","ListQueryNotices","listQueryRefusals","ListRowActions","ListTable","listActionsColumn","listFilterGridColumns","TABLE_ROW_HEIGHT","useListGridFilter","useSnackbar","useFirestore","useFirestoreCollection","usePluginApiPost","useListQuery","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","messageTextOf","submission","Object","entries","fields","map","key","value","join","SubmissionsCard","hostId","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","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","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","disableColumnSorting","rowCount","onPageChange","onPageSizeChange","open","onClose","maxWidth","fullWidth","screenId","my","whiteSpace","wordBreak","mt","flexWrap","rowGap","routing","chip","recordKind","recordId","target"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,kBAAkB,EAClBC,cAAc,QAET,eAAc;AACrB,SAASC,sBAAsB,QAAQ,kCAA8B;AAErE,+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,oBAAoB,QACf,mDAAkD;AACzD,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,mBAAmB,EACnBC,eAAe,QACV,yBAAwB;AAC/B,SAASC,WAAW,EAAEC,OAAO,EAAEC,sBAAsB,QAAQ,uBAAsB;AACnF,OAAOC,qBAAqB,8DAA6D;AACzF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,OAAOC,oBACLC,iBAAiB,QACZ,+DAA8D;AACrE,SACEC,cAAc,EACdC,SAAS,EACTC,iBAAiB,QACZ,uDAAsD;AAE7D,SAEEC,qBAAqB,QAChB,8CAA6C;AAEpD,SAASC,gBAAgB,QAAQ,8CAA6C;AAC9E,SAASC,iBAAiB,QAAQ,kDAAiD;AACnF,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SACEC,YAAY,EACZC,sBAAsB,EACtBC,gBAAgB,QACX,iCAAgC;AACvC,SAASC,YAAY,QAAQ,sDAAqD;AAClF,SACEC,MAAM,EACNC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,OAAO,EACPC,KAAK,EACLC,OAAO,EACPC,UAAU,QACL,gBAAe;AAEtB,SACEC,UAAU,EACVC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,KAAK,EACLC,SAAS,QACJ,qBAAoB;AAC3B,4EAA4E;AAC5E,2CAA2C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AQ,KAAKyE,iBAAiB,aAAKzE;wCAAQd,MAAM;;oCACrDmF,UAAU;gCACZ;0CAEC;;0CAEH,KAAC9H;gCAAO4I,SAAQ;gCAAYsB,SAAS,IAAMpC,UAAU;0CAClD;;;;;;;;AAMb;AACAxE,gBAAgBwB,WAAW,GAAG;AAE9B,eAAexB,gBAAe"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { type VisitorDoorPausedNotice } from '@aglyn/aglyn/plugin-manager/plugin-visitor-doors';
|
|
18
|
+
/** One door's notices for a site: refusing now, and the month's catches. */
|
|
19
|
+
export interface VisitorDoorNoticeState {
|
|
20
|
+
door: string;
|
|
21
|
+
paused: VisitorDoorPausedNotice | null;
|
|
22
|
+
caught: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Every declared public door's flood notices, for the site whose traffic
|
|
26
|
+
* lands here (AGL-1666, AGL-1836, AGL-3080).
|
|
27
|
+
*
|
|
28
|
+
* A door is declared by the plugin that keeps it (`visitorDoors`), which names
|
|
29
|
+
* the two site counters it keeps by month and the words; the Inbox names no
|
|
30
|
+
* door. Each counter is a client-unwritable document host admins can already
|
|
31
|
+
* read (AGL-1367), keyed by the SERVER's month through the shared
|
|
32
|
+
* `utcMonthKey` — a key derived differently here would read zero refusals on
|
|
33
|
+
* exactly the sites being refused.
|
|
34
|
+
*
|
|
35
|
+
* A hook, read by the page above its section guard, so the listens start with
|
|
36
|
+
* the page rather than a frame later with a section. Two listens per door, in
|
|
37
|
+
* the same order on every render: the list is compiled and never changes
|
|
38
|
+
* length, which is what makes a hook per entry safe here.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useVisitorDoorNotices(hostId: string | null | undefined): VisitorDoorNoticeState[];
|
|
41
|
+
/**
|
|
42
|
+
* The notices themselves. The paused notice is a warning: until it, a
|
|
43
|
+
* refusal existed in two places a site owner cannot see — a counters
|
|
44
|
+
* document only Firestore's console renders, and one notification `system.`
|
|
45
|
+
* bucket-muting can suppress at write time. The catch count is info rather
|
|
46
|
+
* than warning on purpose: it reports protection WORKING — caught, dropped,
|
|
47
|
+
* never stored or billed. Each renders nothing below one, because a counter
|
|
48
|
+
* document persists from its first trip and a reassuring zero trains the
|
|
49
|
+
* reader to ignore the row.
|
|
50
|
+
*/
|
|
51
|
+
export declare function VisitorDoorNotices({ notices, }: {
|
|
52
|
+
notices: readonly VisitorDoorNoticeState[];
|
|
53
|
+
}): import("react").JSX.Element;
|
|
54
|
+
export default VisitorDoorNotices;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
// By their own modules rather than the barrel: the Inbox's specs replace
|
|
19
|
+
// `@aglyn/aglyn` with a closed world, and these are small.
|
|
20
|
+
import { utcMonthKey } from "@aglyn/aglyn/app-utils/utc-month";
|
|
21
|
+
import { pluginVisitorDoors, visitorDoorCaughtNotice, visitorDoorPausedNotice } from "@aglyn/aglyn/plugin-manager/plugin-visitor-doors";
|
|
22
|
+
import { useFirestore, useFirestoreDoc } from "@aglyn/tenant-feature-instance";
|
|
23
|
+
import { Alert, AlertTitle, Typography } from "@mui/material";
|
|
24
|
+
import { doc } from "firebase/firestore";
|
|
25
|
+
import { Fragment } from "react";
|
|
26
|
+
/** The declared doors: compiled into the bundle, so the list never changes. */ const DOORS = pluginVisitorDoors();
|
|
27
|
+
/**
|
|
28
|
+
* Every declared public door's flood notices, for the site whose traffic
|
|
29
|
+
* lands here (AGL-1666, AGL-1836, AGL-3080).
|
|
30
|
+
*
|
|
31
|
+
* A door is declared by the plugin that keeps it (`visitorDoors`), which names
|
|
32
|
+
* the two site counters it keeps by month and the words; the Inbox names no
|
|
33
|
+
* door. Each counter is a client-unwritable document host admins can already
|
|
34
|
+
* read (AGL-1367), keyed by the SERVER's month through the shared
|
|
35
|
+
* `utcMonthKey` — a key derived differently here would read zero refusals on
|
|
36
|
+
* exactly the sites being refused.
|
|
37
|
+
*
|
|
38
|
+
* A hook, read by the page above its section guard, so the listens start with
|
|
39
|
+
* the page rather than a frame later with a section. Two listens per door, in
|
|
40
|
+
* the same order on every render: the list is compiled and never changes
|
|
41
|
+
* length, which is what makes a hook per entry safe here.
|
|
42
|
+
*/ export function useVisitorDoorNotices(hostId) {
|
|
43
|
+
const firestore = useFirestore();
|
|
44
|
+
const notices = [];
|
|
45
|
+
for (const door of DOORS){
|
|
46
|
+
var _ref, _ref1;
|
|
47
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- a compiled, fixed-length list
|
|
48
|
+
const { data: refusedCounter } = useFirestoreDoc(()=>hostId ? doc(firestore, 'hosts', hostId, 'counters', door.refusedCounter) : null, [
|
|
49
|
+
firestore,
|
|
50
|
+
hostId,
|
|
51
|
+
door.refusedCounter
|
|
52
|
+
]);
|
|
53
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- a compiled, fixed-length list
|
|
54
|
+
const { data: caughtCounter } = useFirestoreDoc(()=>hostId ? doc(firestore, 'hosts', hostId, 'counters', door.caughtCounter) : null, [
|
|
55
|
+
firestore,
|
|
56
|
+
hostId,
|
|
57
|
+
door.caughtCounter
|
|
58
|
+
]);
|
|
59
|
+
notices.push({
|
|
60
|
+
door: door.door,
|
|
61
|
+
paused: visitorDoorPausedNotice(door, {
|
|
62
|
+
refused: Number((_ref = refusedCounter == null ? void 0 : refusedCounter[utcMonthKey()]) != null ? _ref : 0),
|
|
63
|
+
ceiling: Number(refusedCounter == null ? void 0 : refusedCounter['ceiling']) || undefined
|
|
64
|
+
}),
|
|
65
|
+
caught: visitorDoorCaughtNotice(door, {
|
|
66
|
+
caught: Number((_ref1 = caughtCounter == null ? void 0 : caughtCounter[utcMonthKey()]) != null ? _ref1 : 0)
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return notices;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The notices themselves. The paused notice is a warning: until it, a
|
|
74
|
+
* refusal existed in two places a site owner cannot see — a counters
|
|
75
|
+
* document only Firestore's console renders, and one notification `system.`
|
|
76
|
+
* bucket-muting can suppress at write time. The catch count is info rather
|
|
77
|
+
* than warning on purpose: it reports protection WORKING — caught, dropped,
|
|
78
|
+
* never stored or billed. Each renders nothing below one, because a counter
|
|
79
|
+
* document persists from its first trip and a reassuring zero trains the
|
|
80
|
+
* reader to ignore the row.
|
|
81
|
+
*/ export function VisitorDoorNotices({ notices }) {
|
|
82
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
83
|
+
children: notices.map(({ door, paused, caught })=>/*#__PURE__*/ _jsxs(Fragment, {
|
|
84
|
+
children: [
|
|
85
|
+
paused ? /*#__PURE__*/ _jsxs(Alert, {
|
|
86
|
+
severity: "warning",
|
|
87
|
+
sx: {
|
|
88
|
+
mb: 2
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
/*#__PURE__*/ _jsx(AlertTitle, {
|
|
92
|
+
children: paused.title
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
95
|
+
component: "div",
|
|
96
|
+
variant: "body2",
|
|
97
|
+
children: paused.message
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
100
|
+
component: "div",
|
|
101
|
+
variant: "body2",
|
|
102
|
+
color: "text.secondary",
|
|
103
|
+
sx: {
|
|
104
|
+
mt: 0.5
|
|
105
|
+
},
|
|
106
|
+
children: paused.until
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
}) : null,
|
|
110
|
+
caught ? /*#__PURE__*/ _jsx(Alert, {
|
|
111
|
+
severity: "info",
|
|
112
|
+
sx: {
|
|
113
|
+
mb: 2
|
|
114
|
+
},
|
|
115
|
+
children: caught
|
|
116
|
+
}) : null
|
|
117
|
+
]
|
|
118
|
+
}, door))
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export default VisitorDoorNotices;
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=visitor-door-notices.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/inbox/src/lib/components/visitor-door-notices.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\n// By their own modules rather than the barrel: the Inbox's specs replace\n// `@aglyn/aglyn` with a closed world, and these are small.\nimport { utcMonthKey } from '@aglyn/aglyn/app-utils/utc-month'\nimport {\n pluginVisitorDoors,\n visitorDoorCaughtNotice,\n visitorDoorPausedNotice,\n type VisitorDoorPausedNotice,\n} from '@aglyn/aglyn/plugin-manager/plugin-visitor-doors'\nimport { useFirestore, useFirestoreDoc } from '@aglyn/tenant-feature-instance'\nimport { Alert, AlertTitle, Typography } from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { Fragment } from 'react'\n\n/** The declared doors: compiled into the bundle, so the list never changes. */\nconst DOORS = pluginVisitorDoors()\n\n/** One door's notices for a site: refusing now, and the month's catches. */\nexport interface VisitorDoorNoticeState {\n door: string\n paused: VisitorDoorPausedNotice | null\n caught: string | null\n}\n\n/**\n * Every declared public door's flood notices, for the site whose traffic\n * lands here (AGL-1666, AGL-1836, AGL-3080).\n *\n * A door is declared by the plugin that keeps it (`visitorDoors`), which names\n * the two site counters it keeps by month and the words; the Inbox names no\n * door. Each counter is a client-unwritable document host admins can already\n * read (AGL-1367), keyed by the SERVER's month through the shared\n * `utcMonthKey` — a key derived differently here would read zero refusals on\n * exactly the sites being refused.\n *\n * A hook, read by the page above its section guard, so the listens start with\n * the page rather than a frame later with a section. Two listens per door, in\n * the same order on every render: the list is compiled and never changes\n * length, which is what makes a hook per entry safe here.\n */\nexport function useVisitorDoorNotices(\n hostId: string | null | undefined,\n): VisitorDoorNoticeState[] {\n const firestore = useFirestore()\n const notices: VisitorDoorNoticeState[] = []\n for (const door of DOORS) {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- a compiled, fixed-length list\n const { data: refusedCounter } = useFirestoreDoc<any>(\n () => (hostId ? doc(firestore, 'hosts', hostId, 'counters', door.refusedCounter) : null),\n [firestore, hostId, door.refusedCounter],\n )\n // eslint-disable-next-line react-hooks/rules-of-hooks -- a compiled, fixed-length list\n const { data: caughtCounter } = useFirestoreDoc<any>(\n () => (hostId ? doc(firestore, 'hosts', hostId, 'counters', door.caughtCounter) : null),\n [firestore, hostId, door.caughtCounter],\n )\n notices.push({\n door: door.door,\n paused: visitorDoorPausedNotice(door, {\n refused: Number(refusedCounter?.[utcMonthKey()] ?? 0),\n ceiling: Number(refusedCounter?.['ceiling']) || undefined,\n }),\n caught: visitorDoorCaughtNotice(door, {\n caught: Number(caughtCounter?.[utcMonthKey()] ?? 0),\n }),\n })\n }\n return notices\n}\n\n/**\n * The notices themselves. The paused notice is a warning: until it, a\n * refusal existed in two places a site owner cannot see — a counters\n * document only Firestore's console renders, and one notification `system.`\n * bucket-muting can suppress at write time. The catch count is info rather\n * than warning on purpose: it reports protection WORKING — caught, dropped,\n * never stored or billed. Each renders nothing below one, because a counter\n * document persists from its first trip and a reassuring zero trains the\n * reader to ignore the row.\n */\nexport function VisitorDoorNotices({\n notices,\n}: {\n notices: readonly VisitorDoorNoticeState[]\n}) {\n return (\n <>\n {notices.map(({ door, paused, caught }) => (\n <Fragment key={door}>\n {paused ? (\n <Alert severity=\"warning\" sx={{ mb: 2 }}>\n <AlertTitle>{paused.title}</AlertTitle>\n <Typography component=\"div\" variant=\"body2\">\n {paused.message}\n </Typography>\n <Typography\n component=\"div\"\n variant=\"body2\"\n color=\"text.secondary\"\n sx={{ mt: 0.5 }}\n >\n {paused.until}\n </Typography>\n </Alert>\n ) : null}\n {caught ? (\n <Alert severity=\"info\" sx={{ mb: 2 }}>\n {caught}\n </Alert>\n ) : null}\n </Fragment>\n ))}\n </>\n )\n}\n\nexport default VisitorDoorNotices\n"],"names":["utcMonthKey","pluginVisitorDoors","visitorDoorCaughtNotice","visitorDoorPausedNotice","useFirestore","useFirestoreDoc","Alert","AlertTitle","Typography","doc","Fragment","DOORS","useVisitorDoorNotices","hostId","firestore","notices","door","data","refusedCounter","caughtCounter","push","paused","refused","Number","ceiling","undefined","caught","VisitorDoorNotices","map","severity","sx","mb","title","component","variant","message","color","mt","until"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,yEAAyE;AACzE,2DAA2D;AAC3D,SAASA,WAAW,QAAQ,mCAAkC;AAC9D,SACEC,kBAAkB,EAClBC,uBAAuB,EACvBC,uBAAuB,QAElB,mDAAkD;AACzD,SAASC,YAAY,EAAEC,eAAe,QAAQ,iCAAgC;AAC9E,SAASC,KAAK,EAAEC,UAAU,EAAEC,UAAU,QAAQ,gBAAe;AAC7D,SAASC,GAAG,QAAQ,qBAAoB;AACxC,SAASC,QAAQ,QAAQ,QAAO;AAEhC,6EAA6E,GAC7E,MAAMC,QAAQV;AASd;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASW,sBACdC,MAAiC;IAEjC,MAAMC,YAAYV;IAClB,MAAMW,UAAoC,EAAE;IAC5C,KAAK,MAAMC,QAAQL,MAAO;;QACxB,uFAAuF;QACvF,MAAM,EAAEM,MAAMC,cAAc,EAAE,GAAGb,gBAC/B,IAAOQ,SAASJ,IAAIK,WAAW,SAASD,QAAQ,YAAYG,KAAKE,cAAc,IAAI,MACnF;YAACJ;YAAWD;YAAQG,KAAKE,cAAc;SAAC;QAE1C,uFAAuF;QACvF,MAAM,EAAED,MAAME,aAAa,EAAE,GAAGd,gBAC9B,IAAOQ,SAASJ,IAAIK,WAAW,SAASD,QAAQ,YAAYG,KAAKG,aAAa,IAAI,MAClF;YAACL;YAAWD;YAAQG,KAAKG,aAAa;SAAC;QAEzCJ,QAAQK,IAAI,CAAC;YACXJ,MAAMA,KAAKA,IAAI;YACfK,QAAQlB,wBAAwBa,MAAM;gBACpCM,SAASC,eAAOL,kCAAAA,cAAgB,CAAClB,cAAc,mBAAI;gBACnDwB,SAASD,OAAOL,kCAAAA,cAAgB,CAAC,UAAU,KAAKO;YAClD;YACAC,QAAQxB,wBAAw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