@aglyn/plugins-crm 1.0.0-beta.217 → 1.0.0-beta.219
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 +14 -13
- package/src/index.d.ts +1 -0
- package/src/index.js.map +1 -1
- package/src/lib/components/companies-bulk-bar.js +12 -4
- package/src/lib/components/companies-bulk-bar.js.map +1 -1
- package/src/lib/components/company-detail-page.js +11 -0
- package/src/lib/components/company-detail-page.js.map +1 -1
- package/src/lib/components/company-edit-drawer.js +12 -2
- package/src/lib/components/company-edit-drawer.js.map +1 -1
- package/src/lib/components/company-import-drawer.d.ts +1 -1
- package/src/lib/components/company-picker.js +10 -3
- package/src/lib/components/company-picker.js.map +1 -1
- package/src/lib/components/contact-detail-page.d.ts +4 -4
- package/src/lib/components/contact-detail-page.js +50 -53
- package/src/lib/components/contact-detail-page.js.map +1 -1
- package/src/lib/components/contact-list-columns.d.ts +3 -0
- package/src/lib/components/contact-list-columns.js +21 -5
- package/src/lib/components/contact-list-columns.js.map +1 -1
- package/src/lib/components/contact-merge-dialog.js +2 -1
- package/src/lib/components/contact-merge-dialog.js.map +1 -1
- package/src/lib/components/contact-timeline-card.js +4 -3
- package/src/lib/components/contact-timeline-card.js.map +1 -1
- package/src/lib/components/contacts-bulk-bar.d.ts +3 -3
- package/src/lib/components/contacts-bulk-bar.js +24 -51
- package/src/lib/components/contacts-bulk-bar.js.map +1 -1
- package/src/lib/components/contacts-section.js +9 -3
- package/src/lib/components/contacts-section.js.map +1 -1
- package/src/lib/components/crm-export-all-button.d.ts +1 -1
- package/src/lib/components/crm-export-all-button.js.map +1 -1
- package/src/lib/components/crm-send-email-dialog.js +9 -6
- package/src/lib/components/crm-send-email-dialog.js.map +1 -1
- package/src/lib/components/csv-import-drawer.js +2 -2
- package/src/lib/components/csv-import-drawer.js.map +1 -1
- package/src/lib/components/deal-detail-page.js +18 -2
- package/src/lib/components/deal-detail-page.js.map +1 -1
- package/src/lib/components/deal-edit-drawer.js +10 -0
- package/src/lib/components/deal-edit-drawer.js.map +1 -1
- package/src/lib/components/deals-bulk-bar.js +13 -5
- package/src/lib/components/deals-bulk-bar.js.map +1 -1
- package/src/lib/components/lead-campaigns-card.js +6 -0
- package/src/lib/components/lead-campaigns-card.js.map +1 -1
- package/src/lib/components/lead-detail-page.js +25 -5
- package/src/lib/components/lead-detail-page.js.map +1 -1
- package/src/lib/components/lead-properties-card.js +6 -0
- package/src/lib/components/lead-properties-card.js.map +1 -1
- package/src/lib/components/lead-surfaces-note.js +4 -5
- package/src/lib/components/lead-surfaces-note.js.map +1 -1
- package/src/lib/components/lead-unqualify-dialog.js +6 -0
- package/src/lib/components/lead-unqualify-dialog.js.map +1 -1
- package/src/lib/components/leads-bulk-bar.js +28 -3
- package/src/lib/components/leads-bulk-bar.js.map +1 -1
- package/src/lib/components/leads-section.js +36 -7
- package/src/lib/components/leads-section.js.map +1 -1
- package/src/lib/components/org-lead-surfaces-note.js +6 -2
- package/src/lib/components/org-lead-surfaces-note.js.map +1 -1
- package/src/lib/components/recipes-card.js +9 -4
- package/src/lib/components/recipes-card.js.map +1 -1
- package/src/lib/components/record-sharing-card.d.ts +57 -0
- package/src/lib/components/record-sharing-card.js +244 -0
- package/src/lib/components/record-sharing-card.js.map +1 -0
- package/src/lib/components/settings-section.js +7 -0
- package/src/lib/components/settings-section.js.map +1 -1
- package/src/lib/components/share-records-dialog.d.ts +28 -0
- package/src/lib/components/share-records-dialog.js +184 -0
- package/src/lib/components/share-records-dialog.js.map +1 -0
- package/src/lib/components/sharing-rule-drawer.d.ts +37 -0
- package/src/lib/components/sharing-rule-drawer.js +374 -0
- package/src/lib/components/sharing-rule-drawer.js.map +1 -0
- package/src/lib/components/sharing-rules-card.d.ts +24 -0
- package/src/lib/components/sharing-rules-card.js +287 -0
- package/src/lib/components/sharing-rules-card.js.map +1 -0
- package/src/lib/components/use-crm-api.d.ts +1 -1
- package/src/lib/components/use-crm-api.js.map +1 -1
- package/src/lib/components/use-site-route-context.d.ts +25 -0
- package/src/lib/components/use-site-route-context.js +58 -0
- package/src/lib/components/use-site-route-context.js.map +1 -0
- package/src/lib/constants/api-routes.d.ts +31 -0
- package/src/lib/constants/api-routes.js +27 -1
- package/src/lib/constants/api-routes.js.map +1 -1
- package/src/lib/declarations.console-server.d.ts +37 -0
- package/src/lib/declarations.console-server.js +103 -0
- package/src/lib/declarations.console-server.js.map +1 -0
- package/src/lib/declarations.server.d.ts +6 -0
- package/src/lib/declarations.server.js +33 -0
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/hooks/use-contact-remove.d.ts +35 -0
- package/src/lib/hooks/use-contact-remove.js +77 -0
- package/src/lib/hooks/use-contact-remove.js.map +1 -0
- package/src/lib/hooks/use-crm-sharing.d.ts +30 -0
- package/src/lib/hooks/use-crm-sharing.js +109 -0
- package/src/lib/hooks/use-crm-sharing.js.map +1 -0
- package/src/lib/model/companies-csv.d.ts +1 -1
- package/src/lib/model/companies-csv.js +2 -2
- package/src/lib/model/companies-csv.js.map +1 -1
- package/src/lib/model/contact-holder.d.ts +68 -0
- package/src/lib/model/contact-holder.js +129 -0
- package/src/lib/model/contact-holder.js.map +1 -0
- package/src/lib/model/contact-interaction-links.d.ts +46 -0
- package/src/lib/model/contact-interaction-links.js +65 -0
- package/src/lib/model/contact-interaction-links.js.map +1 -0
- package/src/lib/model/contact-merge.d.ts +136 -0
- package/src/lib/model/contact-merge.js +412 -0
- package/src/lib/model/contact-merge.js.map +1 -0
- package/src/lib/model/contact-record.d.ts +7 -1
- package/src/lib/model/contact-record.js +6 -5
- package/src/lib/model/contact-record.js.map +1 -1
- package/src/lib/model/contact-remove.d.ts +48 -0
- package/src/lib/model/contact-remove.js +22 -0
- package/src/lib/model/contact-remove.js.map +1 -0
- package/src/lib/model/contacts-bulk-writes.d.ts +2 -71
- package/src/lib/model/contacts-bulk-writes.js +2 -82
- package/src/lib/model/contacts-bulk-writes.js.map +1 -1
- package/src/lib/model/contacts-csv.d.ts +2 -2
- package/src/lib/model/contacts-csv.js +2 -2
- package/src/lib/model/contacts-csv.js.map +1 -1
- package/src/lib/model/crm-csv.d.ts +239 -0
- package/src/lib/model/crm-csv.js +467 -0
- package/src/lib/model/crm-csv.js.map +1 -0
- package/src/lib/model/crm-digest.d.ts +185 -0
- package/src/lib/model/crm-digest.js +272 -0
- package/src/lib/model/crm-digest.js.map +1 -0
- package/src/lib/model/crm-import.d.ts +7 -1
- package/src/lib/model/crm-import.js +2 -1
- package/src/lib/model/crm-import.js.map +1 -1
- package/src/lib/model/crm-record-routes.d.ts +5 -0
- package/src/lib/model/crm-record-routes.js +7 -0
- package/src/lib/model/crm-record-routes.js.map +1 -1
- package/src/lib/model/crm-routes.d.ts +6 -5
- package/src/lib/model/crm-routes.js +7 -7
- package/src/lib/model/crm-routes.js.map +1 -1
- package/src/lib/model/crm-search-sources.d.ts +15 -0
- package/src/lib/model/crm-search-sources.js +162 -0
- package/src/lib/model/crm-search-sources.js.map +1 -0
- package/src/lib/model/crm-sharing-api.d.ts +32 -0
- package/src/lib/model/crm-sharing-api.js +59 -0
- package/src/lib/model/crm-sharing-api.js.map +1 -0
- package/src/lib/model/crm-sharing.d.ts +333 -0
- package/src/lib/model/crm-sharing.js +603 -0
- package/src/lib/model/crm-sharing.js.map +1 -0
- package/src/lib/model/deals-csv.d.ts +1 -1
- package/src/lib/model/deals-csv.js +4 -5
- package/src/lib/model/deals-csv.js.map +1 -1
- package/src/lib/model/lead-filters.d.ts +1 -1
- package/src/lib/model/leads-csv.d.ts +1 -1
- package/src/lib/model/leads-csv.js +1 -1
- package/src/lib/model/leads-csv.js.map +1 -1
- package/src/lib/model/tasks-csv.d.ts +1 -1
- package/src/lib/model/tasks-csv.js +1 -1
- package/src/lib/model/tasks-csv.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +75 -0
- package/src/lib/plan-entitlements.js +56 -0
- package/src/lib/plan-entitlements.js.map +1 -0
- package/src/lib/plugin.js +3 -0
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/server/api-v1/contacts-merge.d.ts +20 -0
- package/src/lib/server/api-v1/contacts-merge.js +120 -0
- package/src/lib/server/api-v1/contacts-merge.js.map +1 -0
- package/src/lib/server/api-v1/contacts.d.ts +18 -0
- package/src/lib/server/api-v1/contacts.js +1076 -0
- package/src/lib/server/api-v1/contacts.js.map +1 -0
- package/src/lib/server/api-v1/crm-activities.d.ts +18 -0
- package/src/lib/server/api-v1/crm-activities.js +269 -0
- package/src/lib/server/api-v1/crm-activities.js.map +1 -0
- package/src/lib/server/api-v1/crm-companies.d.ts +18 -0
- package/src/lib/server/api-v1/crm-companies.js +391 -0
- package/src/lib/server/api-v1/crm-companies.js.map +1 -0
- package/src/lib/server/api-v1/crm-deals.d.ts +18 -0
- package/src/lib/server/api-v1/crm-deals.js +631 -0
- package/src/lib/server/api-v1/crm-deals.js.map +1 -0
- package/src/lib/server/api-v1/crm-email-templates.d.ts +18 -0
- package/src/lib/server/api-v1/crm-email-templates.js +336 -0
- package/src/lib/server/api-v1/crm-email-templates.js.map +1 -0
- package/src/lib/server/api-v1/crm-leads.d.ts +18 -0
- package/src/lib/server/api-v1/crm-leads.js +832 -0
- package/src/lib/server/api-v1/crm-leads.js.map +1 -0
- package/src/lib/server/api-v1/crm-pipelines.d.ts +76 -0
- package/src/lib/server/api-v1/crm-pipelines.js +146 -0
- package/src/lib/server/api-v1/crm-pipelines.js.map +1 -0
- package/src/lib/server/api-v1/crm-shared.d.ts +271 -0
- package/src/lib/server/api-v1/crm-shared.js +436 -0
- package/src/lib/server/api-v1/crm-shared.js.map +1 -0
- package/src/lib/server/api-v1/crm-tasks.d.ts +18 -0
- package/src/lib/server/api-v1/crm-tasks.js +398 -0
- package/src/lib/server/api-v1/crm-tasks.js.map +1 -0
- package/src/lib/server/api-v1/openapi.d.ts +29 -0
- package/src/lib/server/api-v1/openapi.js +985 -0
- package/src/lib/server/api-v1/openapi.js.map +1 -0
- package/src/lib/server/api-v1/usage.d.ts +26 -0
- package/src/lib/server/api-v1/usage.js +73 -0
- package/src/lib/server/api-v1/usage.js.map +1 -0
- package/src/lib/server/consent-group-participant.js +1 -1
- package/src/lib/server/consent-group-participant.js.map +1 -1
- package/src/lib/server/contact-lifecycle-floor.d.ts +89 -0
- package/src/lib/server/contact-lifecycle-floor.js +91 -0
- package/src/lib/server/contact-lifecycle-floor.js.map +1 -0
- package/src/lib/server/contact-remove.d.ts +75 -0
- package/src/lib/server/contact-remove.js +244 -0
- package/src/lib/server/contact-remove.js.map +1 -0
- package/src/lib/server/contact-update.js +2 -1
- package/src/lib/server/contact-update.js.map +1 -1
- package/src/lib/server/contacts-import.d.ts +47 -11
- package/src/lib/server/contacts-import.js +171 -71
- package/src/lib/server/contacts-import.js.map +1 -1
- package/src/lib/server/contacts-merge.d.ts +1 -1
- package/src/lib/server/contacts-merge.js +3 -2
- package/src/lib/server/contacts-merge.js.map +1 -1
- package/src/lib/server/convert-host-lead.d.ts +189 -0
- package/src/lib/server/convert-host-lead.js +518 -0
- package/src/lib/server/convert-host-lead.js.map +1 -0
- package/src/lib/server/crm-sharing.d.ts +108 -0
- package/src/lib/server/crm-sharing.js +790 -0
- package/src/lib/server/crm-sharing.js.map +1 -0
- package/src/lib/server/daily-digest-route.d.ts +107 -0
- package/src/lib/server/daily-digest-route.js +588 -0
- package/src/lib/server/daily-digest-route.js.map +1 -0
- package/src/lib/server/export-route.d.ts +60 -0
- package/src/lib/server/export-route.js +447 -0
- package/src/lib/server/export-route.js.map +1 -0
- package/src/lib/server/inbound-route.d.ts +74 -0
- package/src/lib/server/inbound-route.js +257 -0
- package/src/lib/server/inbound-route.js.map +1 -0
- package/src/lib/server/lead-convert.d.ts +1 -1
- package/src/lib/server/lead-convert.js +2 -2
- package/src/lib/server/lead-convert.js.map +1 -1
- package/src/lib/server/merge-contacts.d.ts +55 -0
- package/src/lib/server/merge-contacts.js +274 -0
- package/src/lib/server/merge-contacts.js.map +1 -0
- package/src/lib/server/pipeline-record-index.d.ts +36 -0
- package/src/lib/server/pipeline-record-index.js +87 -0
- package/src/lib/server/pipeline-record-index.js.map +1 -0
- package/src/lib/server/record-facts.js +2 -1
- package/src/lib/server/record-facts.js.map +1 -1
- package/src/lib/server/task-reminders-route.d.ts +82 -0
- package/src/lib/server/task-reminders-route.js +497 -0
- package/src/lib/server/task-reminders-route.js.map +1 -0
- package/src/lib/server-deal-stage.js +2 -1
- package/src/lib/server-deal-stage.js.map +1 -1
- package/src/lib/server.d.ts +5 -2
- package/src/lib/server.js +47 -2
- package/src/lib/server.js.map +1 -1
- package/src/lib/testing/stand-in-site-record-routes.d.ts +26 -0
- package/src/lib/testing/stand-in-site-record-routes.js +55 -0
- package/src/lib/testing/stand-in-site-record-routes.js.map +1 -0
- package/src/lib/usage-axes.d.ts +35 -0
- package/src/lib/usage-axes.js +68 -0
- package/src/lib/usage-axes.js.map +1 -0
- package/src/lib/components/use-emails-hub-path.d.ts +0 -24
- package/src/lib/components/use-emails-hub-path.js +0 -59
- package/src/lib/components/use-emails-hub-path.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/contacts-bulk-bar.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\n/**\n * The bar over the contacts table, for whatever rows are ticked (AGL-2603).\n *\n * The table's selection is opt-in and this is what it is for: a chosen set\n * of people, and one act over all of them. Tag or untag them, hand them to\n * an owner, move them along the funnel, put them on an email audience, take\n * them into a spreadsheet, or let them go from this site's CRM.\n *\n * ## The chrome is the shared frame\n *\n * This bar settled how a bar over a table reads — it appears only for a\n * selection and says how many, its actions sit in one wrapping row with\n * Clear at the end, and whatever the last action could not do is listed by\n * name in an alert under it — and the companies, deals and tasks bars were\n * built on that shape as `CrmBulkBarFrame` and `useCrmBulkApply` (AGL-2621).\n * The contacts bar stands on the same two (AGL-2635): what is its own is the\n * actions, the dialog's field, the audience door, and how each act is sent.\n *\n * ## Each act goes where its field is written (AGL-2804)\n *\n * A contact's tags, owner and company live in the holder's facet, which is\n * the server's to write — the rules cannot tell one field of a facet from\n * another — so each of those acts is ONE request to `crm/contact-update` for\n * the rows it reaches (`contacts-bulk-writes.ts` decides which), sent in\n * pieces the route accepts. A stage move is `crm/contact-stage`, row by row:\n * a move is what an automation listens for, and only the route that\n * performed it can announce it. Letting the rows go is the one act written\n * client-direct, because a holder dropping its own facet is the one facet\n * change the rules leave the browser.\n *\n * ## A refused row is named\n *\n * Whatever the server or the store refused comes back by address into the\n * alert under the bar — not into a count, and not into the console. A\n * merchant who tagged four hundred people and got three hundred and\n * ninety-eight needs the two addresses.\n *\n * ## Add to list goes through the audience's own door\n *\n * The membership routes, with the check-then-attest sequence the Emails\n * console runs — see `add-to-list-dialog.tsx`. Nothing here writes a\n * membership document.\n */\n\nimport {\n type AglynOrgBilling,\n CONTACT_LIFECYCLE_STAGE_LABELS,\n CONTACT_LIFECYCLE_STAGES,\n type ConsentGroup,\n type ContactLifecycleStage,\n crmMemberPickerLabel,\n} from '@aglyn/aglyn'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { Button, MenuItem, TextField } from '@mui/material'\nimport { deleteDoc, doc, updateDoc, writeBatch } from 'firebase/firestore'\nimport { useCallback, useMemo, useState } from 'react'\nimport {\n useFirestore,\n useOrgMemberOptions,\n useUser,\n} from '@aglyn/tenant-feature-instance'\nimport { useContactUpdate } from '../hooks/use-contact-update'\nimport { useCrmBulkApply } from '../hooks/use-crm-bulk-apply'\nimport { useCrmScope } from '../hooks/use-crm-scope'\nimport { CRM_CONTACT_UPDATE_MAX, type ContactUpdateFields } from '../model/contact-update'\nimport { setContactStage } from '../model/crm-api'\nimport {\n contactBulkAddressOf,\n normalizeBulkTag,\n planAddTag,\n planDetach,\n planRemoveTag,\n planSetCompany,\n type ContactBulkRow,\n type ContactBulkSelection,\n type ContactBulkSkip,\n type ContactBulkWrite,\n} from '../model/contacts-bulk-writes'\nimport {\n type ContactCsvOptions,\n type ContactCsvRow,\n contactsCsv,\n downloadTextFile,\n} from '../model/contacts-csv'\nimport {\n type CrmBulkOutcome,\n runCrmBulkBatch,\n runCrmBulkCalls,\n runCrmBulkWrites,\n} from '../model/crm-bulk-writes'\nimport AddToListDialog from './add-to-list-dialog'\nimport {\n CompanyPicker,\n type CompanyOption,\n useCompanyOptions,\n useCreateCompany,\n} from './company-picker'\nimport {\n type CrmBulkNoun,\n CrmBulkBarFrame,\n CrmBulkValueDialog,\n countNoun,\n} from './crm-bulk-bar-frame'\nimport CrmExportAllButton from './crm-export-all-button'\nimport { restampCrmListFields } from '../model/list-fields-api'\nimport { crmTaskCallScope } from '../model/task-routes'\nimport { CrmSuiteLockedButton } from './crm-suite-lock'\n\nexport interface ContactsBulkBarProps {\n /** The site the list is read under, or `null` at the organization level. */\n hostId: string | null\n /** The org document the shell passed, for the company picker's scope. */\n org?: Partial<AglynOrgBilling> | null\n /** `['orgs', orgId]`, or `null` while the org is unresolved. */\n scope: readonly [string, string] | null\n /**\n * The holder these rows are being read AS — whose facet the acts land in.\n * `null` at the organization level (AGL-2630), where each row's own holder\n * (`groupId`) takes the act instead, and \"Remove from this site\" is not\n * offered because there is no site to remove from.\n */\n consentGroup: ConsentGroup | null\n /** The table's rows, already projected through the holder's facet. */\n rows: readonly (ContactBulkRow & ContactCsvRow)[]\n selected: readonly string[]\n onSelectedChange: (ids: string[]) => void\n /**\n * How the export names an owner and which custom fields it carries — the\n * table's own options, so the selection's file and the table's are one\n * format (AGL-2621).\n */\n csv?: ContactCsvOptions\n /**\n * The org's plan lacks the CRM (AGL-2788), which the shell mounts no CRM\n * page for (AGL-2851). The owner, the stage and the company stand locked;\n * tags, the exports, the audience door and removing people from a site\n * draw no lock of their own.\n */\n suiteLocked?: boolean\n}\n\nconst NOUN: CrmBulkNoun = { singular: 'contact', plural: 'contacts' }\n\n/** The one small dialog the value-taking actions share. */\ntype PendingAction = 'add-tag' | 'remove-tag' | 'owner' | 'stage' | 'company'\n\nconst ACTION_TITLES: Record<PendingAction, string> = {\n 'add-tag': 'Add a tag',\n 'remove-tag': 'Remove a tag',\n owner: 'Set the owner',\n stage: 'Set the lifecycle stage',\n company: 'Set the company',\n}\n\n/** How a finished action reads, given how many rows it reached. */\nconst doneSentence = (action: PendingAction | 'detach', done: number): string => {\n const people = countNoun(done, NOUN)\n switch (action) {\n case 'add-tag':\n return `Tagged ${people}`\n case 'remove-tag':\n return `Removed the tag from ${people}`\n case 'owner':\n return `Owner set on ${people}`\n case 'stage':\n return `Stage set on ${people}`\n case 'company':\n return `Company set on ${people}`\n case 'detach':\n return `${people} removed from this site`\n }\n}\n\n/** The report's line for a row an act left out on purpose. */\nconst skippedLine = (row: ContactBulkSkip) => ({ label: row.email, reason: row.reason })\n\n/**\n * The bar, or nothing.\n *\n * The empty state is a separate component boundary on purpose: with no\n * selection the body below is never mounted, so none of its hooks run — no\n * roster hook armed, no dialog state held — on the visit to the list that\n * every reader makes and most never tick a row on.\n */\nexport function ContactsBulkBar(props: ContactsBulkBarProps) {\n if (!props.selected.length) return null\n return <ContactsBulkBarBody {...props} />\n}\nContactsBulkBar.displayName = 'ContactsBulkBar'\n\nfunction ContactsBulkBarBody(props: ContactsBulkBarProps) {\n const {\n hostId,\n org,\n scope,\n consentGroup,\n rows,\n selected,\n onSelectedChange,\n csv,\n suiteLocked = false,\n } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { confirm } = useConfirmationContext()\n const { busy, report, apply, dismissReport } = useCrmBulkApply({ recordKind: 'contact' })\n const contactUpdate = useContactUpdate(hostId)\n\n const selectedRows = useMemo(() => {\n const chosen = new Set(selected)\n return rows.filter((row) => chosen.has(row.$id))\n }, [rows, selected])\n\n const [pending, setPending] = useState<PendingAction | null>(null)\n const [value, setValue] = useState('')\n const [company, setCompany] = useState<CompanyOption | null>(null)\n const [listOpen, setListOpen] = useState(false)\n\n /*\n * The roster, read only while the owner dialog is open. A bulk bar sits on\n * every visit to the list; the team is a request for a control nobody has\n * opened until they open it. The company list follows the same rule for\n * its own dialog (AGL-2613).\n */\n const team = useOrgMemberOptions(scope?.[1], { enabled: pending === 'owner' })\n const companies = useCompanyOptions({\n hostId,\n org,\n enabled: pending === 'company',\n })\n const createCompany = useCreateCompany({ hostId, org })\n // The site the audiences API is asked from: the mounted one, or at the\n // organization level the one the reader picked (AGL-2630).\n const { createHostId } = useCrmScope({ hostId, org })\n\n const openAction = (action: PendingAction) => {\n setValue('')\n setCompany(null)\n setPending(action)\n }\n\n /**\n * The Firestore writers for the one act written client-direct: letting the\n * rows go, a batch at a time and a row at a time for a batch that failed.\n */\n const writers = useMemo(() => {\n const refFor = (id: string) =>\n doc(firestore, scope?.[0] ?? 'orgs', scope?.[1] ?? '', 'contacts', id)\n return {\n commitBatch: async (writes: readonly ContactBulkWrite[]) => {\n const batch = writeBatch(firestore)\n for (const write of writes) {\n if (write.kind === 'delete') batch.delete(refFor(write.id))\n else batch.update(refFor(write.id), write.data)\n }\n await batch.commit()\n },\n commitOne: async (write: ContactBulkWrite) => {\n if (write.kind === 'delete') await deleteDoc(refFor(write.id))\n else await updateDoc(refFor(write.id), write.data)\n },\n }\n }, [firestore, scope])\n\n /** One act's request for the rows it reaches, in the pieces the route accepts. */\n const saveThroughRoute = useCallback(\n (targets: readonly ContactBulkRow[], set: ContactUpdateFields) =>\n runCrmBulkBatch(\n targets,\n (row) => row.$id,\n contactBulkAddressOf,\n (piece) => contactUpdate.updateMany(piece.map((row) => row.$id), set),\n CRM_CONTACT_UPDATE_MAX,\n ),\n [contactUpdate],\n )\n\n const handleApply = useCallback(async () => {\n if (!pending || !scope) return\n /*\n * A row no site holds has no facet to write. Under a site every selected\n * row is the viewing group's; at the organization level (AGL-2630) each\n * row was flattened through its own primary holder and is written back\n * through it, so a row nobody holds yet is left out and says so.\n */\n const held: ContactBulkRow[] = []\n const unheld: ContactBulkSkip[] = []\n for (const row of selectedRows) {\n if (consentGroup || row.groupId) held.push(row)\n else {\n unheld.push({\n email: contactBulkAddressOf(row),\n reason: 'no site holds this contact yet',\n })\n }\n }\n\n const planned = ((): { selection: ContactBulkSelection; job: () => Promise<CrmBulkOutcome> } | null => {\n if (pending === 'add-tag' || pending === 'remove-tag') {\n const tag = normalizeBulkTag(value)\n if (!tag) return null\n const selection =\n pending === 'add-tag' ? planAddTag(held, tag) : planRemoveTag(held, tag)\n const set: ContactUpdateFields =\n pending === 'add-tag' ? { addTag: tag } : { removeTag: tag }\n return { selection, job: () => saveThroughRoute(selection.rows, set) }\n }\n if (pending === 'owner') {\n return {\n selection: { rows: held, skipped: [] },\n job: () => saveThroughRoute(held, { ownerUid: value }),\n }\n }\n if (pending === 'company') {\n const companyId = company?.id ?? null\n const selection = planSetCompany(held, companyId)\n return { selection, job: () => saveThroughRoute(selection.rows, { companyId }) }\n }\n if (!value) return null\n const stage = value as ContactLifecycleStage\n return {\n selection: { rows: held, skipped: [] },\n /*\n * One row at a time through the one writer of a contact's stage, on\n * the site that holds the row: the mounted site, or at the\n * organization level the row's own holder's.\n */\n job: () =>\n runCrmBulkCalls(held, contactBulkAddressOf, async (row) => {\n const site = hostId ?? (row.holderHostId || null)\n if (!site) throw new Error('no site holds this contact yet')\n await setContactStage(user, site, row.$id, stage)\n }),\n }\n })()\n if (!planned) return\n const action = pending\n setPending(null)\n await apply({\n attempted: planned.selection.rows.length,\n skipped: [...unheld, ...planned.selection.skipped].map(skippedLine),\n job: planned.job,\n done: (count) => doneSentence(action, count),\n })\n }, [\n pending,\n scope,\n selectedRows,\n consentGroup,\n value,\n company,\n saveThroughRoute,\n hostId,\n user,\n apply,\n ])\n\n const handleExport = useCallback(() => {\n downloadTextFile(\n 'contacts-selected.csv',\n 'text/csv',\n contactsCsv(selectedRows, csv),\n )\n }, [selectedRows, csv])\n\n const handleDetach = useCallback(async () => {\n if (!scope || !selectedRows.length || !consentGroup) return\n const count = selectedRows.length\n const confirmed = await confirm({\n title: count === 1 ? 'Remove this contact?' : `Remove ${count} contacts?`,\n description:\n `${count === 1 ? 'This person is' : `These ${count} people are`} ` +\n \"removed from this site's Contacts, along with their notes, tags and \" +\n 'timeline. Other sites that captured the same people keep their own ' +\n 'records. Their form submissions, orders, bookings, and membership ' +\n 'records are separate — delete those from their own pages if the ' +\n 'request covers them.',\n confirmationText: count === 1 ? 'Remove contact' : 'Remove contacts',\n confirmationButtonProps: { color: 'error' },\n })\n // `confirm` resolves with no value and REJECTS on cancel.\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n const plan = planDetach(selectedRows, consentGroup, Date.now())\n const outcome = await apply({\n attempted: plan.writes.length,\n skipped: plan.skipped.map(skippedLine),\n job: () => runCrmBulkWrites(writers, plan.writes, (write) => write.email),\n done: (done) => doneSentence('detach', done),\n })\n // The rows that went are gone from the table; the refused ones stay\n // selected, so the reader can see which they are and try again.\n const refused = new Set(outcome.refused.map((row) => row.label))\n // A detached row still carries the facet keys and scoped search tokens\n // of the holder that let it go; the rules keep a client from restamping\n // them, so the route does (AGL-3321). A deleted row answers `missing`.\n await restampCrmListFields(\n user,\n crmTaskCallScope(hostId, scope?.[1] ?? null),\n 'contacts',\n selectedRows\n .filter((row) => !refused.has(contactBulkAddressOf(row)))\n .map((row) => row.$id),\n )\n onSelectedChange(\n selectedRows\n .filter((row) => refused.has(contactBulkAddressOf(row)))\n .map((row) => row.$id),\n )\n }, [scope, selectedRows, confirm, apply, writers, consentGroup, onSelectedChange, user, hostId])\n\n const emails = selectedRows\n .map((row) => String(row.email ?? '').trim())\n .filter(Boolean)\n\n return (\n <CrmBulkBarFrame\n count={selected.length}\n noun={NOUN}\n busy={busy}\n onClear={() => onSelectedChange([])}\n report={report}\n onDismissReport={dismissReport}\n extras={\n <>\n <CrmBulkValueDialog\n open={pending !== null}\n title={pending ? ACTION_TITLES[pending] : ''}\n count={selected.length}\n noun={NOUN}\n busy={busy}\n canApply={\n !(pending === 'stage' && !value) &&\n !(\n (pending === 'add-tag' || pending === 'remove-tag') &&\n !normalizeBulkTag(value)\n )\n }\n onClose={() => setPending(null)}\n onApply={() => void handleApply()}\n >\n {pending === 'add-tag' || pending === 'remove-tag' ? (\n <TextField\n autoFocus\n size=\"small\"\n label=\"Tag\"\n placeholder=\"vip\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n helperText={\n pending === 'add-tag'\n ? 'Lowercased, like the tags on a profile'\n : 'Removed wherever it is present'\n }\n />\n ) : pending === 'owner' ? (\n <TextField\n select\n size=\"small\"\n label=\"Owner\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n error={Boolean(team.error)}\n helperText={team.error ?? (team.ready ? undefined : 'Loading the team…')}\n >\n <MenuItem value=\"\">{'Nobody — clear the owner'}</MenuItem>\n {team.options.map((member) => (\n <MenuItem key={member.uid} value={member.uid}>\n {crmMemberPickerLabel(member)}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'stage' ? (\n <TextField\n select\n size=\"small\"\n label=\"Lifecycle stage\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n >\n {CONTACT_LIFECYCLE_STAGES.map((stage) => (\n <MenuItem key={stage} value={stage}>\n {CONTACT_LIFECYCLE_STAGE_LABELS[stage]}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'company' ? (\n <CompanyPicker\n options={companies.options}\n ready={companies.ready}\n truncated={companies.truncated}\n value={company?.id ?? null}\n onChange={(_id, picked) => setCompany(picked)}\n onCreate={createCompany}\n helperText=\"Leave it empty to unlink the selected contacts from their companies.\"\n />\n ) : null}\n </CrmBulkValueDialog>\n {listOpen ? (\n <AddToListDialog\n open\n onClose={() => setListOpen(false)}\n hostId={createHostId}\n scope={scope}\n emails={emails}\n />\n ) : null}\n </>\n }\n >\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('add-tag')}>\n {'Add tag'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('remove-tag')}\n >\n {'Remove tag'}\n </Button>\n {suiteLocked ? (\n <>\n <CrmSuiteLockedButton>{'Set owner'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set stage'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set company'}</CrmSuiteLockedButton>\n </>\n ) : (\n <>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('owner')}>\n {'Set owner'}\n </Button>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('stage')}>\n {'Set stage'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('company')}\n >\n {'Set company'}\n </Button>\n </>\n )}\n <Button\n size=\"small\"\n disabled={busy || !scope || !emails.length || !createHostId}\n onClick={() => setListOpen(true)}\n >\n {'Add to list'}\n </Button>\n <Button size=\"small\" disabled={busy} onClick={handleExport}>\n {'Export CSV'}\n </Button>\n {/*\n The selection's file is the rows on screen; this one is the whole\n collection, streamed by the server (AGL-2662).\n */}\n <CrmExportAllButton\n resource=\"contacts\"\n orgId={scope?.[1] ?? null}\n hostId={hostId}\n disabled={busy}\n />\n {/*\n Only under a site. The act is a DETACH from the viewing site's\n CRM, and at the organization level there is no viewing site — an\n org-wide member removes a person from a site by opening the record\n under that site.\n */}\n {consentGroup ? (\n <Button\n size=\"small\"\n color=\"error\"\n disabled={busy || !scope}\n onClick={() => void handleDetach()}\n >\n {'Remove from this site'}\n </Button>\n ) : null}\n </CrmBulkBarFrame>\n )\n}\nContactsBulkBarBody.displayName = 'ContactsBulkBarBody'\n\nexport default ContactsBulkBar\n"],"names":["CONTACT_LIFECYCLE_STAGE_LABELS","CONTACT_LIFECYCLE_STAGES","crmMemberPickerLabel","useConfirmationContext","Button","MenuItem","TextField","deleteDoc","doc","updateDoc","writeBatch","useCallback","useMemo","useState","useFirestore","useOrgMemberOptions","useUser","useContactUpdate","useCrmBulkApply","useCrmScope","CRM_CONTACT_UPDATE_MAX","setContactStage","contactBulkAddressOf","normalizeBulkTag","planAddTag","planDetach","planRemoveTag","planSetCompany","contactsCsv","downloadTextFile","runCrmBulkBatch","runCrmBulkCalls","runCrmBulkWrites","AddToListDialog","CompanyPicker","useCompanyOptions","useCreateCompany","CrmBulkBarFrame","CrmBulkValueDialog","countNoun","CrmExportAllButton","restampCrmListFields","crmTaskCallScope","CrmSuiteLockedButton","NOUN","singular","plural","ACTION_TITLES","owner","stage","company","doneSentence","action","done","people","skippedLine","row","label","email","reason","ContactsBulkBar","props","selected","length","ContactsBulkBarBody","displayName","team","hostId","org","scope","consentGroup","rows","onSelectedChange","csv","suiteLocked","firestore","data","user","confirm","busy","report","apply","dismissReport","recordKind","contactUpdate","selectedRows","chosen","Set","filter","has","$id","pending","setPending","value","setValue","setCompany","listOpen","setListOpen","enabled","companies","createCompany","createHostId","openAction","writers","refFor","id","commitBatch","writes","batch","write","kind","delete","update","commit","commitOne","saveThroughRoute","targets","set","piece","updateMany","map","handleApply","held","unheld","groupId","push","planned","tag","selection","addTag","removeTag","job","skipped","ownerUid","companyId","site","holderHostId","Error","attempted","count","handleExport","handleDetach","confirmed","title","description","confirmationText","confirmationButtonProps","color","then","catch","plan","Date","now","outcome","refused","emails","String","trim","Boolean","noun","onClear","onDismissReport","extras","open","canApply","onClose","onApply","autoFocus","size","placeholder","onChange","event","target","helperText","select","error","ready","undefined","options","member","uid","truncated","_id","picked","onCreate","disabled","onClick","resource","orgId"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GAED,SAEEA,8BAA8B,EAC9BC,wBAAwB,EAGxBC,oBAAoB,QACf,eAAc;AACrB,SAASC,sBAAsB,QAAQ,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BAAQiB,UAAU1G,QAAQ,CAACV;wBAAOqH,SAAS,IAAMpF,WAAW;kCACtE;;kCAEH,KAAClG;wBACCoK,MAAK;wBACLiB,UAAU1G,QAAQ,CAACV;wBACnBqH,SAAS,IAAMpF,WAAW;kCAEzB;;;;0BAIP,KAAClG;gBACCoK,MAAK;gBACLiB,UAAU1G,QAAQ,CAACV,SAAS,CAACsF,OAAO5F,MAAM,IAAI,CAACsC;gBAC/CqF,SAAS,IAAMzF,YAAY;0BAE1B;;0BAEH,KAAC7F;gBAAOoK,MAAK;gBAAQiB,UAAU1G;gBAAM2G,SAAS9C;0BAC3C;;0BAMH,KAACpG;gBACCmJ,UAAS;gBACTC,KAAK,WAAEvH,yBAAAA,KAAO,CAAC,EAAE,oBAAI;gBACrBF,QAAQA;gBACRsH,UAAU1G;;YAQXT,6BACC,KAAClE;gBACCoK,MAAK;gBACLrB,OAAM;gBACNsC,UAAU1G,QAAQ,CAACV;gBACnBqH,SAAS,IAAM,KAAK7C;0BAEnB;iBAED;;;AAGV;AACA7E,oBAAoBC,WAAW,GAAG;AAElC,eAAeL,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/contacts-bulk-bar.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\n/**\n * The bar over the contacts table, for whatever rows are ticked (AGL-2603).\n *\n * The table's selection is opt-in and this is what it is for: a chosen set\n * of people, and one act over all of them. Tag or untag them, hand them to\n * an owner, move them along the funnel, put them on an email audience, take\n * them into a spreadsheet, or let them go from this site's CRM.\n *\n * ## The chrome is the shared frame\n *\n * This bar settled how a bar over a table reads — it appears only for a\n * selection and says how many, its actions sit in one wrapping row with\n * Clear at the end, and whatever the last action could not do is listed by\n * name in an alert under it — and the companies, deals and tasks bars were\n * built on that shape as `CrmBulkBarFrame` and `useCrmBulkApply` (AGL-2621).\n * The contacts bar stands on the same two (AGL-2635): what is its own is the\n * actions, the dialog's field, the audience door, and how each act is sent.\n *\n * ## Each act goes where its field is written (AGL-2804)\n *\n * A contact's tags, owner and company live in the holder's facet, which is\n * the server's to write — the rules cannot tell one field of a facet from\n * another — so each of those acts is ONE request to `crm/contact-update` for\n * the rows it reaches (`contacts-bulk-writes.ts` decides which), sent in\n * pieces the route accepts. A stage move is `crm/contact-stage`, row by row:\n * a move is what an automation listens for, and only the route that\n * performed it can announce it. Letting the rows go is `crm/contact-remove`\n * (AGL-3338): the route decides detach or delete against each stored\n * document and keeps any marketing refusal the person gave.\n *\n * ## A refused row is named\n *\n * Whatever the server or the store refused comes back by address into the\n * alert under the bar — not into a count, and not into the console. A\n * merchant who tagged four hundred people and got three hundred and\n * ninety-eight needs the two addresses.\n *\n * ## Add to list goes through the audience's own door\n *\n * The membership routes, with the check-then-attest sequence the Emails\n * console runs — see `add-to-list-dialog.tsx`. Nothing here writes a\n * membership document.\n */\n\nimport {\n type AglynOrgBilling,\n CONTACT_LIFECYCLE_STAGE_LABELS,\n CONTACT_LIFECYCLE_STAGES,\n type ConsentGroup,\n type ContactLifecycleStage,\n crmMemberPickerLabel,\n} from '@aglyn/aglyn'\nimport { useConfirmationContext } from '@aglyn/shared-ui-jsx'\nimport { Button, MenuItem, TextField } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useOrgMemberOptions, useUser } from '@aglyn/tenant-feature-instance'\nimport { useContactRemove } from '../hooks/use-contact-remove'\nimport { useContactUpdate } from '../hooks/use-contact-update'\nimport { useCrmBulkApply } from '../hooks/use-crm-bulk-apply'\nimport { useCrmScope } from '../hooks/use-crm-scope'\nimport { CRM_CONTACT_REMOVE_MAX } from '../model/contact-remove'\nimport { CRM_CONTACT_UPDATE_MAX, type ContactUpdateFields } from '../model/contact-update'\nimport { setContactStage } from '../model/crm-api'\nimport {\n contactBulkAddressOf,\n normalizeBulkTag,\n planAddTag,\n planRemoveTag,\n planSetCompany,\n type ContactBulkRow,\n type ContactBulkSelection,\n type ContactBulkSkip,\n} from '../model/contacts-bulk-writes'\nimport {\n type ContactCsvOptions,\n type ContactCsvRow,\n contactsCsv,\n downloadTextFile,\n} from '../model/contacts-csv'\nimport {\n type CrmBulkOutcome,\n runCrmBulkBatch,\n runCrmBulkCalls,\n} from '../model/crm-bulk-writes'\nimport AddToListDialog from './add-to-list-dialog'\nimport {\n CompanyPicker,\n type CompanyOption,\n useCompanyOptions,\n useCreateCompany,\n} from './company-picker'\nimport {\n type CrmBulkNoun,\n CrmBulkBarFrame,\n CrmBulkValueDialog,\n countNoun,\n} from './crm-bulk-bar-frame'\nimport CrmExportAllButton from './crm-export-all-button'\nimport { CrmBulkShareButton } from './record-sharing-card'\nimport { CrmSuiteLockedButton } from './crm-suite-lock'\n\nexport interface ContactsBulkBarProps {\n /** The site the list is read under, or `null` at the organization level. */\n hostId: string | null\n /** The org document the shell passed, for the company picker's scope. */\n org?: Partial<AglynOrgBilling> | null\n /** `['orgs', orgId]`, or `null` while the org is unresolved. */\n scope: readonly [string, string] | null\n /**\n * The holder these rows are being read AS — whose facet the acts land in.\n * `null` at the organization level (AGL-2630), where each row's own holder\n * (`groupId`) takes the act instead, and \"Remove from this site\" is not\n * offered because there is no site to remove from.\n */\n consentGroup: ConsentGroup | null\n /** The table's rows, already projected through the holder's facet. */\n rows: readonly (ContactBulkRow & ContactCsvRow)[]\n selected: readonly string[]\n onSelectedChange: (ids: string[]) => void\n /**\n * How the export names an owner and which custom fields it carries — the\n * table's own options, so the selection's file and the table's are one\n * format (AGL-2621).\n */\n csv?: ContactCsvOptions\n /**\n * The org's plan lacks the CRM (AGL-2788), which the shell mounts no CRM\n * page for (AGL-2851). The owner, the stage and the company stand locked;\n * tags, the exports, the audience door and removing people from a site\n * draw no lock of their own.\n */\n suiteLocked?: boolean\n}\n\nconst NOUN: CrmBulkNoun = { singular: 'contact', plural: 'contacts' }\n\n/** The one small dialog the value-taking actions share. */\ntype PendingAction = 'add-tag' | 'remove-tag' | 'owner' | 'stage' | 'company'\n\nconst ACTION_TITLES: Record<PendingAction, string> = {\n 'add-tag': 'Add a tag',\n 'remove-tag': 'Remove a tag',\n owner: 'Set the owner',\n stage: 'Set the lifecycle stage',\n company: 'Set the company',\n}\n\n/** How a finished action reads, given how many rows it reached. */\nconst doneSentence = (action: PendingAction | 'detach', done: number): string => {\n const people = countNoun(done, NOUN)\n switch (action) {\n case 'add-tag':\n return `Tagged ${people}`\n case 'remove-tag':\n return `Removed the tag from ${people}`\n case 'owner':\n return `Owner set on ${people}`\n case 'stage':\n return `Stage set on ${people}`\n case 'company':\n return `Company set on ${people}`\n case 'detach':\n return `${people} removed from this site`\n }\n}\n\n/** The report's line for a row an act left out on purpose. */\nconst skippedLine = (row: ContactBulkSkip) => ({ label: row.email, reason: row.reason })\n\n/**\n * The bar, or nothing.\n *\n * The empty state is a separate component boundary on purpose: with no\n * selection the body below is never mounted, so none of its hooks run — no\n * roster hook armed, no dialog state held — on the visit to the list that\n * every reader makes and most never tick a row on.\n */\nexport function ContactsBulkBar(props: ContactsBulkBarProps) {\n if (!props.selected.length) return null\n return <ContactsBulkBarBody {...props} />\n}\nContactsBulkBar.displayName = 'ContactsBulkBar'\n\nfunction ContactsBulkBarBody(props: ContactsBulkBarProps) {\n const {\n hostId,\n org,\n scope,\n consentGroup,\n rows,\n selected,\n onSelectedChange,\n csv,\n suiteLocked = false,\n } = props\n const { data: user } = useUser()\n const { confirm } = useConfirmationContext()\n const { busy, report, apply, dismissReport } = useCrmBulkApply({ recordKind: 'contact' })\n const contactUpdate = useContactUpdate(hostId)\n const contactRemove = useContactRemove(hostId)\n\n const selectedRows = useMemo(() => {\n const chosen = new Set(selected)\n return rows.filter((row) => chosen.has(row.$id))\n }, [rows, selected])\n\n const [pending, setPending] = useState<PendingAction | null>(null)\n const [value, setValue] = useState('')\n const [company, setCompany] = useState<CompanyOption | null>(null)\n const [listOpen, setListOpen] = useState(false)\n\n /*\n * The roster, read only while the owner dialog is open. A bulk bar sits on\n * every visit to the list; the team is a request for a control nobody has\n * opened until they open it. The company list follows the same rule for\n * its own dialog (AGL-2613).\n */\n const team = useOrgMemberOptions(scope?.[1], { enabled: pending === 'owner' })\n const companies = useCompanyOptions({\n hostId,\n org,\n enabled: pending === 'company',\n })\n const createCompany = useCreateCompany({ hostId, org })\n // The site the audiences API is asked from: the mounted one, or at the\n // organization level the one the reader picked (AGL-2630).\n const { createHostId } = useCrmScope({ hostId, org })\n\n const openAction = (action: PendingAction) => {\n setValue('')\n setCompany(null)\n setPending(action)\n }\n\n /** One act's request for the rows it reaches, in the pieces the route accepts. */\n const saveThroughRoute = useCallback(\n (targets: readonly ContactBulkRow[], set: ContactUpdateFields) =>\n runCrmBulkBatch(\n targets,\n (row) => row.$id,\n contactBulkAddressOf,\n (piece) => contactUpdate.updateMany(piece.map((row) => row.$id), set),\n CRM_CONTACT_UPDATE_MAX,\n ),\n [contactUpdate],\n )\n\n const handleApply = useCallback(async () => {\n if (!pending || !scope) return\n /*\n * A row no site holds has no facet to write. Under a site every selected\n * row is the viewing group's; at the organization level (AGL-2630) each\n * row was flattened through its own primary holder and is written back\n * through it, so a row nobody holds yet is left out and says so.\n */\n const held: ContactBulkRow[] = []\n const unheld: ContactBulkSkip[] = []\n for (const row of selectedRows) {\n if (consentGroup || row.groupId) held.push(row)\n else {\n unheld.push({\n email: contactBulkAddressOf(row),\n reason: 'no site holds this contact yet',\n })\n }\n }\n\n const planned = ((): { selection: ContactBulkSelection; job: () => Promise<CrmBulkOutcome> } | null => {\n if (pending === 'add-tag' || pending === 'remove-tag') {\n const tag = normalizeBulkTag(value)\n if (!tag) return null\n const selection =\n pending === 'add-tag' ? planAddTag(held, tag) : planRemoveTag(held, tag)\n const set: ContactUpdateFields =\n pending === 'add-tag' ? { addTag: tag } : { removeTag: tag }\n return { selection, job: () => saveThroughRoute(selection.rows, set) }\n }\n if (pending === 'owner') {\n return {\n selection: { rows: held, skipped: [] },\n job: () => saveThroughRoute(held, { ownerUid: value }),\n }\n }\n if (pending === 'company') {\n const companyId = company?.id ?? null\n const selection = planSetCompany(held, companyId)\n return { selection, job: () => saveThroughRoute(selection.rows, { companyId }) }\n }\n if (!value) return null\n const stage = value as ContactLifecycleStage\n return {\n selection: { rows: held, skipped: [] },\n /*\n * One row at a time through the one writer of a contact's stage, on\n * the site that holds the row: the mounted site, or at the\n * organization level the row's own holder's.\n */\n job: () =>\n runCrmBulkCalls(held, contactBulkAddressOf, async (row) => {\n const site = hostId ?? (row.holderHostId || null)\n if (!site) throw new Error('no site holds this contact yet')\n await setContactStage(user, site, row.$id, stage)\n }),\n }\n })()\n if (!planned) return\n const action = pending\n setPending(null)\n await apply({\n attempted: planned.selection.rows.length,\n skipped: [...unheld, ...planned.selection.skipped].map(skippedLine),\n job: planned.job,\n done: (count) => doneSentence(action, count),\n })\n }, [\n pending,\n scope,\n selectedRows,\n consentGroup,\n value,\n company,\n saveThroughRoute,\n hostId,\n user,\n apply,\n ])\n\n const handleExport = useCallback(() => {\n downloadTextFile(\n 'contacts-selected.csv',\n 'text/csv',\n contactsCsv(selectedRows, csv),\n )\n }, [selectedRows, csv])\n\n const handleDetach = useCallback(async () => {\n if (!scope || !selectedRows.length || !consentGroup) return\n const count = selectedRows.length\n const confirmed = await confirm({\n title: count === 1 ? 'Remove this contact?' : `Remove ${count} contacts?`,\n description:\n `${count === 1 ? 'This person is' : `These ${count} people are`} ` +\n \"removed from this site's Contacts, along with their notes, tags and \" +\n 'timeline. Other sites that captured the same people keep their own ' +\n 'records. Their form submissions, orders, bookings, and membership ' +\n 'records are separate — delete those from their own pages if the ' +\n 'request covers them.',\n confirmationText: count === 1 ? 'Remove contact' : 'Remove contacts',\n confirmationButtonProps: { color: 'error' },\n })\n // `confirm` resolves with no value and REJECTS on cancel.\n .then(() => true)\n .catch(() => false)\n if (!confirmed) return\n const outcome = await apply({\n attempted: selectedRows.length,\n skipped: [],\n job: () =>\n runCrmBulkBatch(\n selectedRows,\n (row) => row.$id,\n contactBulkAddressOf,\n (piece) => contactRemove.removeMany(piece.map((row) => row.$id)),\n CRM_CONTACT_REMOVE_MAX,\n ),\n done: (done) => doneSentence('detach', done),\n })\n // The rows that went are gone from the table; the refused ones stay\n // selected, so the reader can see which they are and try again.\n const refused = new Set(outcome.refused.map((row) => row.label))\n onSelectedChange(\n selectedRows\n .filter((row) => refused.has(contactBulkAddressOf(row)))\n .map((row) => row.$id),\n )\n }, [scope, selectedRows, confirm, apply, contactRemove, consentGroup, onSelectedChange])\n\n const emails = selectedRows\n .map((row) => String(row.email ?? '').trim())\n .filter(Boolean)\n\n return (\n <CrmBulkBarFrame\n count={selected.length}\n noun={NOUN}\n busy={busy}\n onClear={() => onSelectedChange([])}\n report={report}\n onDismissReport={dismissReport}\n extras={\n <>\n <CrmBulkValueDialog\n open={pending !== null}\n title={pending ? ACTION_TITLES[pending] : ''}\n count={selected.length}\n noun={NOUN}\n busy={busy}\n canApply={\n !(pending === 'stage' && !value) &&\n !(\n (pending === 'add-tag' || pending === 'remove-tag') &&\n !normalizeBulkTag(value)\n )\n }\n onClose={() => setPending(null)}\n onApply={() => void handleApply()}\n >\n {pending === 'add-tag' || pending === 'remove-tag' ? (\n <TextField\n autoFocus\n size=\"small\"\n label=\"Tag\"\n placeholder=\"vip\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n helperText={\n pending === 'add-tag'\n ? 'Lowercased, like the tags on a profile'\n : 'Removed wherever it is present'\n }\n />\n ) : pending === 'owner' ? (\n <TextField\n select\n size=\"small\"\n label=\"Owner\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n error={Boolean(team.error)}\n helperText={team.error ?? (team.ready ? undefined : 'Loading the team…')}\n >\n <MenuItem value=\"\">{'Nobody — clear the owner'}</MenuItem>\n {team.options.map((member) => (\n <MenuItem key={member.uid} value={member.uid}>\n {crmMemberPickerLabel(member)}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'stage' ? (\n <TextField\n select\n size=\"small\"\n label=\"Lifecycle stage\"\n value={value}\n onChange={(event) => setValue(event.target.value)}\n >\n {CONTACT_LIFECYCLE_STAGES.map((stage) => (\n <MenuItem key={stage} value={stage}>\n {CONTACT_LIFECYCLE_STAGE_LABELS[stage]}\n </MenuItem>\n ))}\n </TextField>\n ) : pending === 'company' ? (\n <CompanyPicker\n options={companies.options}\n ready={companies.ready}\n truncated={companies.truncated}\n value={company?.id ?? null}\n onChange={(_id, picked) => setCompany(picked)}\n onCreate={createCompany}\n helperText=\"Leave it empty to unlink the selected contacts from their companies.\"\n />\n ) : null}\n </CrmBulkValueDialog>\n {listOpen ? (\n <AddToListDialog\n open\n onClose={() => setListOpen(false)}\n hostId={createHostId}\n scope={scope}\n emails={emails}\n />\n ) : null}\n </>\n }\n >\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('add-tag')}>\n {'Add tag'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('remove-tag')}\n >\n {'Remove tag'}\n </Button>\n {suiteLocked ? (\n <>\n <CrmSuiteLockedButton>{'Set owner'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set stage'}</CrmSuiteLockedButton>\n <CrmSuiteLockedButton>{'Set company'}</CrmSuiteLockedButton>\n </>\n ) : (\n <>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('owner')}>\n {'Set owner'}\n </Button>\n <Button size=\"small\" disabled={busy || !scope} onClick={() => openAction('stage')}>\n {'Set stage'}\n </Button>\n <Button\n size=\"small\"\n disabled={busy || !scope}\n onClick={() => openAction('company')}\n >\n {'Set company'}\n </Button>\n </>\n )}\n <Button\n size=\"small\"\n disabled={busy || !scope || !emails.length || !createHostId}\n onClick={() => setListOpen(true)}\n >\n {'Add to list'}\n </Button>\n <CrmBulkShareButton\n object=\"contacts\"\n ids={selectedRows.map((row) => row.$id)}\n hostId={hostId ?? null}\n orgId={scope?.[1] ?? null}\n disabled={busy}\n />\n <Button size=\"small\" disabled={busy} onClick={handleExport}>\n {'Export CSV'}\n </Button>\n {/*\n The selection's file is the rows on screen; this one is the whole\n collection, streamed by the server (AGL-2662).\n */}\n <CrmExportAllButton\n resource=\"contacts\"\n orgId={scope?.[1] ?? null}\n hostId={hostId}\n disabled={busy}\n />\n {/*\n Only under a site. The act is a DETACH from the viewing site's\n CRM, and at the organization level there is no viewing site — an\n org-wide member removes a person from a site by opening the record\n under that site.\n */}\n {consentGroup ? (\n <Button\n size=\"small\"\n color=\"error\"\n disabled={busy || !scope}\n onClick={() => void handleDetach()}\n >\n {'Remove from this site'}\n </Button>\n ) : null}\n </CrmBulkBarFrame>\n )\n}\nContactsBulkBarBody.displayName = 'ContactsBulkBarBody'\n\nexport default ContactsBulkBar\n"],"names":["CONTACT_LIFECYCLE_STAGE_LABELS","CONTACT_LIFECYCLE_STAGES","crmMemberPickerLabel","useConfirmationContext","Button","MenuItem","TextField","useCallback","useMemo","useState","useOrgMemberOptions","useUser","useContactRemove","useContactUpdate","useCrmBulkApply","useCrmScope","CRM_CONTACT_REMOVE_MAX","CRM_CONTACT_UPDATE_MAX","setContactStage","contactBulkAddressOf","normalizeBulkTag","planAddTag","planRemoveTag","planSetCompany","contactsCsv","downloadTextFile","runCrmBulkBatch","runCrmBulkCalls","AddToListDialog","CompanyPicker","useCompanyOptions","useCreateCompany","CrmBulkBarFrame","CrmBulkValueDialog","countNoun","CrmExportAllButton","CrmBulkShareButton","CrmSuiteLockedButton","NOUN","singular","plural","ACTION_TITLES","owner","stage","company","doneSentence","action","done","people","skippedLine","row","label","email","reason","ContactsBulkBar","props","selected","length","ContactsBulkBarBody","displayName","team","hostId","org","scope","consentGroup","rows","onSelectedChange","csv","suiteLocked","data","user","confirm","busy","report","apply","dismissReport","recordKind","contactUpdate","contactRemove","selectedRows","chosen","Set","filter","has","$id","pending","setPending","value","setValue","setCompany","listOpen","setListOpen","enabled","companies","createCompany","createHostId","openAction","saveThroughRoute","targets","set","piece","updateMany","map","handleApply","held","unheld","groupId","push","planned","tag","selection","addTag","removeTag","job","skipped","ownerUid","companyId","id","site","holderHostId","Error","attempted","count","handleExport","handleDetach","confirmed","title","description","confirmationText","confirmationButtonProps","color","then","catch","outcome","removeMany","refused","emails","String","trim","Boolean","noun","onClear","onDismissReport","extras","open","canApply","onClose","onApply","autoFocus","size","placeholder","onChange","event","target","helperText","select","error","ready","undefined","options","member","uid","truncated","_id","picked","onCreate","disabled","onClick","object","ids","orgId","resource"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GAED,SAEEA,8BAA8B,EAC9BC,wBAAwB,EAGxBC,oBAAoB,QACf,eAAc;AACrB,SAASC,sBAAsB,QAAQ,uBAAsB;AAC7D,SAASC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,gBAAe;AAC3D,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACtD,SAASC,mBAAmB,EAAEC,OAAO,QAAQ,iCAAgC;AAC7E,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,eAAe,QAAQ,iCAA6B;AAC7D,SAASC,WAAW,QAAQ,4BAAwB;AACpD,SAASC,sBAAsB,QAAQ,6BAAyB;AAChE,SAASC,sBAAsB,QAAkC,6BAAyB;AAC1F,SAASC,eAAe,QAAQ,sBAAkB;AAClD,SACEC,oBAAoB,EACpBC,gBAAgB,EAChBC,UAAU,EACVC,aAAa,EACbC,cAAc,QAIT,mCAA+B;AACtC,SAGEC,WAAW,EACXC,gBAAgB,QACX,2BAAuB;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D,MAAQA,IAAIkC,GAAG;gBACtCvB,MAAM,EAAEA,iBAAAA,SAAU;gBAClB6G,KAAK,WAAE3G,yBAAAA,KAAO,CAAC,EAAE,oBAAI;gBACrBuG,UAAU9F;;0BAEZ,KAACpE;gBAAOiJ,MAAK;gBAAQiB,UAAU9F;gBAAM+F,SAAS5C;0BAC3C;;0BAMH,KAACxF;gBACCwI,UAAS;gBACTD,KAAK,WAAE3G,yBAAAA,KAAO,CAAC,EAAE,oBAAI;gBACrBF,QAAQA;gBACRyG,UAAU9F;;YAQXR,6BACC,KAAC5D;gBACCiJ,MAAK;gBACLnB,OAAM;gBACNoC,UAAU9F,QAAQ,CAACT;gBACnBwG,SAAS,IAAM,KAAK3C;0BAEnB;iBAED;;;AAGV;AACAlE,oBAAoBC,WAAW,GAAG;AAElC,eAAeL,gBAAe"}
|
|
@@ -27,6 +27,8 @@ import { crmAskClauses, crmQueryRefusals } from "../model/crm-list-query.js";
|
|
|
27
27
|
import { useCrmFoldsScope, useCrmListQuery } from "../hooks/use-crm-list-query.js";
|
|
28
28
|
import { contactPrimaryGroup, contactRecordFromDoc } from "../model/contact-record.js";
|
|
29
29
|
import { useCrmOrgMount } from "../hooks/use-crm-org-mount.js";
|
|
30
|
+
import { useCrmSharingRules } from "../hooks/use-crm-sharing.js";
|
|
31
|
+
import { crmShareChipLabel } from "../model/crm-sharing.js";
|
|
30
32
|
import { useCrmScope } from "../hooks/use-crm-scope.js";
|
|
31
33
|
import { contactsListSeed } from "../model/contacts-list-seed.js";
|
|
32
34
|
import { crmRoutes } from "../model/crm-routes.js";
|
|
@@ -535,18 +537,22 @@ import { CrmSuiteLockedButton, CrmSuiteNotice, crmSuiteIncluded } from "./crm-su
|
|
|
535
537
|
filterHeaders,
|
|
536
538
|
filterOptions
|
|
537
539
|
]);
|
|
538
|
-
/* One row grammar, the console's (AGL-2501) — the same table everywhere. */
|
|
540
|
+
/* One row grammar, the console's (AGL-2501) — the same table everywhere. */ // The org's sharing rules, to name the rule behind a shared row (AGL-3336).
|
|
541
|
+
const sharingRules = useCrmSharingRules(org);
|
|
542
|
+
const contactColumns = useMemo(()=>[
|
|
539
543
|
...contactListColumns({
|
|
540
544
|
memberName: members.memberName,
|
|
541
545
|
// "Known by", at the organization level only (AGL-2630).
|
|
542
|
-
siteName: mount ? mount.siteName : undefined
|
|
546
|
+
siteName: mount ? mount.siteName : undefined,
|
|
547
|
+
shareChipLabel: (chip)=>crmShareChipLabel(chip, sharingRules)
|
|
543
548
|
}),
|
|
544
549
|
// The org's custom fields as optional columns (AGL-2601).
|
|
545
550
|
...customFieldColumns(customFields.active)
|
|
546
551
|
], [
|
|
547
552
|
members.memberName,
|
|
548
553
|
mount,
|
|
549
|
-
customFields.active
|
|
554
|
+
customFields.active,
|
|
555
|
+
sharingRules
|
|
550
556
|
]);
|
|
551
557
|
/*
|
|
552
558
|
* The grid's column and sort models are the VIEW'S (AGL-2617). The
|