@aglyn/plugins-crm 1.30.0 → 1.32.0
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 -14
- package/src/lib/components/activity-list.js +31 -9
- package/src/lib/components/activity-list.js.map +1 -1
- package/src/lib/components/activity-recording.d.ts +74 -0
- package/src/lib/components/activity-recording.js +608 -0
- package/src/lib/components/activity-recording.js.map +1 -0
- package/src/lib/components/log-activity-dialog.js +38 -3
- package/src/lib/components/log-activity-dialog.js.map +1 -1
- package/src/lib/model/crm-search-sources.js +2 -1
- package/src/lib/model/crm-search-sources.js.map +1 -1
- package/src/lib/server/api-v1/crm-activities.js +119 -14
- package/src/lib/server/api-v1/crm-activities.js.map +1 -1
- package/src/lib/server/api-v1/openapi.js +50 -2
- package/src/lib/server/api-v1/openapi.js.map +1 -1
- package/src/lib/server/person-eraser.d.ts +30 -0
- package/src/lib/server/person-eraser.js +88 -1
- package/src/lib/server/person-eraser.js.map +1 -1
- package/src/lib/server/record-timeline.js +11 -1
- package/src/lib/server/record-timeline.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/activity-recording.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 CALL_RECORDING_CONSENT_REQUIRED,\n CALL_RECORDING_CONSENT_STATEMENT,\n CRM_ACTIVITY_MEDIA_IDS_MAX,\n CRM_ACTIVITY_TRANSCRIPT_MAX,\n CRM_CALL_RECORDINGS_FOLDER_PATH,\n formatMediaRef,\n MediaUploadError,\n normalizeCrmActivityMediaIds,\n resolveMediaSrc,\n useMediaPicker,\n} from '@aglyn/aglyn'\nimport {\n mdiClose,\n mdiFileMusicOutline,\n mdiFolderMusicOutline,\n mdiTextBoxOutline,\n mdiTrayArrowDown,\n mdiTrayArrowUp,\n} from '@aglyn/shared-data-mdi'\nimport { MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Checkbox,\n FormControlLabel,\n IconButton,\n LinearProgress,\n MenuItem,\n Stack,\n TextField,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport { doc, type Firestore, getDoc } from 'firebase/firestore'\nimport {\n type DragEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\n/*\n * CALL RECORDINGS ON AN ACTIVITY.\n *\n * A call or a meeting carries its recording as organization-library media\n * ids — the same reference a record's Files card stores — so the file lives\n * in the library (CRM / Calls), private, and the activity names it. The\n * player resolves each id at read time: a private file through a signed,\n * expiring link the console mints for a member who may see it, a public one\n * through the CDN route.\n */\n\n/** What one recording is known by once its media document has been read. */\nexport interface ActivityRecording {\n mediaId: string\n fileName: string\n contentType: string\n isPrivate: boolean\n /** The address the audio plays from, or undefined while signing or when it cannot be read. */\n src?: string\n /** The file could not be read: gone from the library, or not this reader's to see. */\n missing?: boolean\n}\n\n/** One playback speed the player offers. */\nconst SPEEDS = [0.75, 1, 1.25, 1.5, 2] as const\n\n/** A signed link for a private org asset, from the console's `/api/media/sign`. */\nasync function signPrivateMedia(\n user: Parameters<typeof authorizedFetch>[0],\n orgId: string,\n mediaId: string,\n): Promise<string | undefined> {\n const response = await authorizedFetch(user, '/api/media/sign', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ orgId, mediaId }),\n })\n if (!response.ok) return undefined\n const payload = (await response.json().catch(() => ({}))) as { url?: unknown }\n return typeof payload.url === 'string' ? payload.url : undefined\n}\n\n/**\n * The recordings an activity names, read from the organization's library.\n *\n * One `getDoc` per recording, bounded by {@link CRM_ACTIVITY_MEDIA_IDS_MAX}\n * and paid only when the row is opened. A recording the library no longer\n * holds is still listed, as missing, the way a record's files are.\n */\nexport function useActivityRecordings(\n firestore: Firestore,\n orgId: string | null | undefined,\n mediaIds: unknown,\n enabled = true,\n): ActivityRecording[] | null {\n const { data: user } = useUser()\n // Read through a ref, keyed by uid: the user object's identity changes on\n // renders that change nothing about who is signed in, and an effect keyed\n // by it would read every recording again on each one.\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid ?? ''\n const ids = useMemo(() => normalizeCrmActivityMediaIds(mediaIds), [mediaIds])\n const key = ids.join('\\n')\n const [rows, setRows] = useState<ActivityRecording[] | null>(null)\n\n useEffect(() => {\n if (!enabled || !orgId) return undefined\n const wanted = key ? key.split('\\n') : []\n if (!wanted.length) {\n setRows((current) => (current && current.length === 0 ? current : []))\n return undefined\n }\n let live = true\n void Promise.all(\n wanted.map(async (mediaId): Promise<ActivityRecording> => {\n try {\n const snapshot = await getDoc(\n doc(firestore, 'orgs', orgId, 'media', mediaId),\n )\n if (!snapshot.exists()) {\n return {\n mediaId,\n fileName: '',\n contentType: '',\n isPrivate: false,\n missing: true,\n }\n }\n const data = (snapshot.data() ?? {}) as Record<string, unknown>\n const isPrivate = data['private'] === true\n const signer = userRef.current\n const src = isPrivate\n ? signer\n ? await signPrivateMedia(signer, orgId, mediaId)\n : undefined\n : resolveMediaSrc(\n formatMediaRef(`org:${orgId}`, mediaId) ?? undefined,\n )\n return {\n mediaId,\n fileName: String(data['fileName'] ?? ''),\n contentType: String(data['contentType'] ?? ''),\n isPrivate,\n src,\n missing: !src,\n }\n } catch {\n return {\n mediaId,\n fileName: '',\n contentType: '',\n isPrivate: false,\n missing: true,\n }\n }\n }),\n ).then((resolved) => {\n if (live) setRows(resolved)\n })\n return () => {\n live = false\n }\n }, [firestore, orgId, key, enabled, uid])\n\n return rows\n}\n\n/**\n * One recording: the browser's own audio controls (play, pause, scrub,\n * volume), a speed menu, and a download.\n */\nexport function ActivityRecordingPlayer(props: {\n recording: ActivityRecording\n}) {\n const { recording } = props\n const audio = useRef<HTMLAudioElement | null>(null)\n const [speed, setSpeed] = useState<number>(1)\n useEffect(() => {\n if (audio.current) audio.current.playbackRate = speed\n }, [speed])\n const name = recording.fileName || recording.mediaId\n if (recording.missing || !recording.src) {\n return (\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n data-testid=\"activity-recording-missing\"\n >\n {`${name}: this recording is no longer in the library, or you cannot play it.`}\n </Typography>\n )\n }\n return (\n <Stack spacing={0.5} data-testid=\"activity-recording\">\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <MdiIcon\n path={mdiFileMusicOutline.path}\n size={0.8}\n sx={{ color: 'text.secondary' }}\n />\n <Typography variant=\"body2\" noWrap sx={{ flex: 1, minWidth: 0 }}>\n {name}\n </Typography>\n <TextField\n select\n size=\"small\"\n label=\"Speed\"\n value={speed}\n onChange={(event) => setSpeed(Number(event.target.value) || 1)}\n sx={{ width: 96 }}\n slotProps={{\n htmlInput: { 'aria-label': `Playback speed for ${name}` },\n }}\n >\n {SPEEDS.map((value) => (\n <MenuItem key={value} value={value}>\n {`${value}×`}\n </MenuItem>\n ))}\n </TextField>\n <Tooltip title=\"Download\">\n <IconButton\n size=\"small\"\n component=\"a\"\n href={recording.src}\n download={recording.fileName || true}\n aria-label={`Download ${name}`}\n >\n <MdiIcon path={mdiTrayArrowDown.path} size={0.8} />\n </IconButton>\n </Tooltip>\n </Stack>\n <Box\n component=\"audio\"\n ref={audio}\n controls\n preload=\"metadata\"\n src={recording.src}\n onLoadedMetadata={() => {\n if (audio.current) audio.current.playbackRate = speed\n }}\n sx={{ width: '100%' }}\n />\n </Stack>\n )\n}\nActivityRecordingPlayer.displayName = 'ActivityRecordingPlayer'\n\n/** An activity's transcript, closed until asked for: a 25-minute call is pages of text. */\nexport function ActivityTranscript(props: { transcript: string }) {\n const [open, setOpen] = useState(false)\n return (\n <Stack spacing={0.5}>\n <Button\n size=\"small\"\n sx={{ alignSelf: 'flex-start' }}\n startIcon={<MdiIcon path={mdiTextBoxOutline.path} size={0.8} />}\n onClick={() => setOpen((value) => !value)}\n aria-expanded={open}\n >\n {open ? 'Hide transcript' : 'Show transcript'}\n </Button>\n {open ? (\n <Typography\n variant=\"body2\"\n data-testid=\"activity-transcript\"\n sx={{\n whiteSpace: 'pre-wrap',\n overflowWrap: 'anywhere',\n maxHeight: 360,\n overflowY: 'auto',\n p: 1,\n borderRadius: 1,\n bgcolor: 'action.hover',\n }}\n >\n {props.transcript}\n </Typography>\n ) : null}\n </Stack>\n )\n}\nActivityTranscript.displayName = 'ActivityTranscript'\n\n/** What an opened activity row shows under its body: the players and the transcript. */\nexport function ActivityRecordingsBlock(props: {\n firestore: Firestore\n orgId: string | null | undefined\n mediaIds: unknown\n transcript?: unknown\n}) {\n const recordings = useActivityRecordings(\n props.firestore,\n props.orgId,\n props.mediaIds,\n )\n const transcript =\n typeof props.transcript === 'string' ? props.transcript.trim() : ''\n const hasIds = normalizeCrmActivityMediaIds(props.mediaIds).length > 0\n if (!hasIds && !transcript) return null\n return (\n <Stack spacing={1} sx={{ mt: 1 }}>\n {hasIds && recordings === null ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {'Reading the recording…'}\n </Typography>\n ) : null}\n {(recordings ?? []).map((recording) => (\n <ActivityRecordingPlayer\n key={recording.mediaId}\n recording={recording}\n />\n ))}\n {transcript ? <ActivityTranscript transcript={transcript} /> : null}\n </Stack>\n )\n}\nActivityRecordingsBlock.displayName = 'ActivityRecordingsBlock'\n\n/** A `.txt` read as text, refused when it is not plain text. */\nexport async function readTranscriptFile(file: File): Promise<string> {\n const name = file.name.toLowerCase()\n if (!(file.type === 'text/plain' || name.endsWith('.txt'))) {\n throw new MediaUploadError('A transcript is a plain-text (.txt) file.')\n }\n return (await file.text()).slice(0, CRM_ACTIVITY_TRANSCRIPT_MAX)\n}\n\nexport interface ActivityRecordingFieldsProps {\n firestore: Firestore\n orgId: string | null | undefined\n mediaIds: readonly string[]\n onMediaIdsChange: (next: string[]) => void\n transcript: string\n onTranscriptChange: (next: string) => void\n disabled?: boolean\n /** Tells the dialog an upload is running, so it does not save half a recording. */\n onBusyChange?: (busy: boolean) => void\n}\n\n/**\n * The Recording section of the log-activity dialog: upload a recording\n * (pick or drop), or choose one already in the library; and a transcript,\n * typed, pasted, or loaded from a `.txt`.\n *\n * The file goes to the organization's library, private, in CRM / Calls.\n * While {@link CALL_RECORDING_CONSENT_REQUIRED} is on, an upload first asks\n * its uploader to confirm {@link CALL_RECORDING_CONSENT_STATEMENT}; it is off\n * (the owner's decision), so nothing is asked.\n */\nexport function ActivityRecordingFields(props: ActivityRecordingFieldsProps) {\n const {\n firestore,\n orgId,\n mediaIds,\n onMediaIdsChange,\n transcript,\n onTranscriptChange,\n disabled,\n onBusyChange,\n } = props\n const { pickMedia, uploadMedia } = useMediaPicker()\n const [consent, setConsent] = useState(false)\n const [uploading, setUploading] = useState<string | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [dragging, setDragging] = useState(false)\n const fileInput = useRef<HTMLInputElement | null>(null)\n const transcriptInput = useRef<HTMLInputElement | null>(null)\n const recordings = useActivityRecordings(firestore, orgId, mediaIds)\n const full = mediaIds.length >= CRM_ACTIVITY_MEDIA_IDS_MAX\n\n useEffect(() => {\n onBusyChange?.(uploading !== null)\n }, [uploading, onBusyChange])\n\n const add = useCallback(\n (mediaId: string) => {\n if (mediaIds.includes(mediaId)) return\n onMediaIdsChange(normalizeCrmActivityMediaIds([...mediaIds, mediaId]))\n },\n [mediaIds, onMediaIdsChange],\n )\n\n const upload = useCallback(\n async (file: File | undefined) => {\n if (!file || !uploadMedia || disabled || uploading) return\n setError(null)\n if (full) {\n setError(\n `An activity holds at most ${CRM_ACTIVITY_MEDIA_IDS_MAX} recordings.`,\n )\n return\n }\n if (CALL_RECORDING_CONSENT_REQUIRED && !consent) {\n setError(\n 'Confirm that everyone on the call knew it was being recorded first.',\n )\n return\n }\n setUploading(file.name)\n try {\n const picked = await uploadMedia(file, {\n folderPath: CRM_CALL_RECORDINGS_FOLDER_PATH,\n private: true,\n purpose: 'callRecording',\n ...(CALL_RECORDING_CONSENT_REQUIRED ? { confirmed: true } : {}),\n kind: 'audio',\n })\n if (picked.mediaId) add(picked.mediaId)\n } catch (caught) {\n setError(\n caught instanceof MediaUploadError\n ? caught.message\n : `Upload failed for \"${file.name}\" — try again.`,\n )\n } finally {\n setUploading(null)\n }\n },\n [uploadMedia, disabled, uploading, full, consent, add],\n )\n\n const choose = useCallback(async () => {\n if (!pickMedia || disabled) return\n setError(null)\n const picked = await pickMedia({ kind: 'audio', allowPrivate: true })\n if (!picked?.mediaId) return\n if (full) {\n setError(\n `An activity holds at most ${CRM_ACTIVITY_MEDIA_IDS_MAX} recordings.`,\n )\n return\n }\n add(picked.mediaId)\n }, [pickMedia, disabled, full, add])\n\n const onDrop = useCallback(\n (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault()\n setDragging(false)\n void upload(event.dataTransfer.files?.[0])\n },\n [upload],\n )\n\n const loadTranscript = useCallback(\n async (file: File | undefined) => {\n if (!file) return\n setError(null)\n try {\n onTranscriptChange(await readTranscriptFile(file))\n } catch (caught) {\n setError(\n caught instanceof Error\n ? caught.message\n : 'The transcript could not be read.',\n )\n }\n },\n [onTranscriptChange],\n )\n\n const names = new Map(\n (recordings ?? []).map((row) => [row.mediaId, row.fileName]),\n )\n\n return (\n <Stack spacing={1} data-testid=\"activity-recording-fields\">\n <Typography variant=\"subtitle2\">{'Recording'}</Typography>\n {mediaIds.map((mediaId) => (\n <Stack\n key={mediaId}\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center' }}\n >\n <MdiIcon\n path={mdiFileMusicOutline.path}\n size={0.8}\n sx={{ color: 'text.secondary' }}\n />\n <Typography variant=\"body2\" noWrap sx={{ flex: 1, minWidth: 0 }}>\n {names.get(mediaId) || mediaId}\n </Typography>\n <IconButton\n size=\"small\"\n aria-label={`Remove ${names.get(mediaId) || 'recording'}`}\n disabled={disabled || uploading !== null}\n onClick={() =>\n onMediaIdsChange(mediaIds.filter((id) => id !== mediaId))\n }\n >\n <MdiIcon path={mdiClose.path} size={0.8} />\n </IconButton>\n </Stack>\n ))}\n {full ? null : (\n <Box\n onDragOver={(event) => {\n event.preventDefault()\n setDragging(true)\n }}\n onDragLeave={() => setDragging(false)}\n onDrop={onDrop}\n data-testid=\"activity-recording-drop\"\n sx={{\n border: 1,\n borderStyle: 'dashed',\n borderColor: dragging ? 'primary.main' : 'divider',\n borderRadius: 1,\n p: 1.5,\n }}\n >\n <Stack spacing={1}>\n {CALL_RECORDING_CONSENT_REQUIRED ? (\n <FormControlLabel\n control={\n <Checkbox\n size=\"small\"\n checked={consent}\n onChange={(event) => setConsent(event.target.checked)}\n disabled={disabled}\n />\n }\n label={\n <Typography variant=\"body2\">\n {CALL_RECORDING_CONSENT_STATEMENT}\n </Typography>\n }\n />\n ) : null}\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{ flexWrap: 'wrap', rowGap: 1 }}\n >\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiTrayArrowUp.path} size={0.8} />}\n disabled={!uploadMedia || disabled || uploading !== null}\n onClick={() => fileInput.current?.click()}\n >\n {'Upload recording'}\n </Button>\n <Button\n size=\"small\"\n startIcon={\n <MdiIcon path={mdiFolderMusicOutline.path} size={0.8} />\n }\n disabled={!pickMedia || disabled || uploading !== null}\n onClick={() => void choose()}\n >\n {'Choose from library'}\n </Button>\n </Stack>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {\n 'Drop an MP3, M4A, WAV, AAC or OGG file here, up to 50 MB. It is kept private in your media library, under CRM / Calls.'\n }\n </Typography>\n <input\n ref={fileInput}\n type=\"file\"\n hidden\n accept=\"audio/*,.m4a,.mp3,.wav,.aac,.ogg\"\n data-testid=\"activity-recording-input\"\n onChange={(event) => {\n const file = event.target.files?.[0]\n event.target.value = ''\n void upload(file)\n }}\n />\n </Stack>\n </Box>\n )}\n {uploading ? (\n <Stack spacing={0.5}>\n <Typography variant=\"caption\">{`Uploading \"${uploading}\"…`}</Typography>\n <LinearProgress />\n </Stack>\n ) : null}\n {!uploadMedia ? (\n <Alert severity=\"info\">\n {'Uploading is not available on this surface.'}\n </Alert>\n ) : null}\n {error ? <Alert severity=\"warning\">{error}</Alert> : null}\n <TextField\n size=\"small\"\n label=\"Transcript\"\n placeholder=\"Paste what was said, or load a .txt\"\n value={transcript}\n onChange={(event) => onTranscriptChange(event.target.value)}\n multiline\n minRows={2}\n maxRows={10}\n disabled={disabled}\n slotProps={{ htmlInput: { maxLength: CRM_ACTIVITY_TRANSCRIPT_MAX } }}\n />\n <Stack direction=\"row\" spacing={1}>\n <Button\n size=\"small\"\n startIcon={<MdiIcon path={mdiTextBoxOutline.path} size={0.8} />}\n disabled={disabled}\n onClick={() => transcriptInput.current?.click()}\n >\n {'Load transcript (.txt)'}\n </Button>\n <input\n ref={transcriptInput}\n type=\"file\"\n hidden\n accept=\".txt,text/plain\"\n data-testid=\"activity-transcript-input\"\n onChange={(event) => {\n const file = event.target.files?.[0]\n event.target.value = ''\n void loadTranscript(file)\n }}\n />\n </Stack>\n </Stack>\n )\n}\nActivityRecordingFields.displayName = 'ActivityRecordingFields'\n"],"names":["CALL_RECORDING_CONSENT_REQUIRED","CALL_RECORDING_CONSENT_STATEMENT","CRM_ACTIVITY_MEDIA_IDS_MAX","CRM_ACTIVITY_TRANSCRIPT_MAX","CRM_CALL_RECORDINGS_FOLDER_PATH","formatMediaRef","MediaUploadError","normalizeCrmActivityMediaIds","resolveMediaSrc","useMediaPicker","mdiClose","mdiFileMusicOutline","mdiFolderMusicOutline","mdiTextBoxOutline","mdiTrayArrowDown","mdiTrayArrowUp","MdiIcon","authorizedFetch","useUser","Alert","Box","Button","Checkbox","FormControlLabel","IconButton","LinearProgress","MenuItem","Stack","TextField","Tooltip","Typography","doc","getDoc","useCallback","useEffect","useMemo","useRef","useState","SPEEDS","signPrivateMedia","user","orgId","mediaId","response","method","headers","body","JSON","stringify","ok","undefined","payload","json","catch","url","useActivityRecordings","firestore","mediaIds","enabled","data","userRef","current","uid","ids","key","join","rows","setRows","wanted","split","length","live","Promise","all","map","snapshot","exists","fileName","contentType","isPrivate","missing","signer","src","String","then","resolved","ActivityRecordingPlayer","props","recording","audio","speed","setSpeed","playbackRate","name","variant","color","data-testid","spacing","direction","sx","alignItems","path","size","noWrap","flex","minWidth","select","label","value","onChange","event","Number","target","width","slotProps","htmlInput","title","component","href","download","aria-label","ref","controls","preload","onLoadedMetadata","displayName","ActivityTranscript","open","setOpen","alignSelf","startIcon","onClick","aria-expanded","whiteSpace","overflowWrap","maxHeight","overflowY","p","borderRadius","bgcolor","transcript","ActivityRecordingsBlock","recordings","trim","hasIds","mt","readTranscriptFile","file","toLowerCase","type","endsWith","text","slice","ActivityRecordingFields","onMediaIdsChange","onTranscriptChange","disabled","onBusyChange","pickMedia","uploadMedia","consent","setConsent","uploading","setUploading","error","setError","dragging","setDragging","fileInput","transcriptInput","full","add","includes","upload","picked","folderPath","private","purpose","confirmed","kind","caught","message","choose","allowPrivate","onDrop","preventDefault","dataTransfer","files","loadTranscript","Error","names","Map","row","get","filter","id","onDragOver","onDragLeave","border","borderStyle","borderColor","control","checked","flexWrap","rowGap","click","input","hidden","accept","severity","placeholder","multiline","minRows","maxRows","maxLength"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,+BAA+B,EAC/BC,gCAAgC,EAChCC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,+BAA+B,EAC/BC,cAAc,EACdC,gBAAgB,EAChBC,4BAA4B,EAC5BC,eAAe,EACfC,cAAc,QACT,eAAc;AACrB,SACEC,QAAQ,EACRC,mBAAmB,EACn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B7C,MAAME,MAAM,CAACJ,KAAK;gBAC1DuG,SAAS;gBACTC,SAAS;gBACTC,SAAS;gBACTzD,UAAUA;gBACV1C,WAAW;oBAAEC,WAAW;wBAAEmG,WAAWnN;oBAA4B;gBAAE;;0BAErE,MAACwB;gBAAMuE,WAAU;gBAAMD,SAAS;;kCAC9B,KAAC5E;wBACCiF,MAAK;wBACL4B,yBAAW,KAAClH;4BAAQqF,MAAMxF,kBAAkBwF,IAAI;4BAAEC,MAAM;;wBACxDsD,UAAUA;wBACVzB,SAAS;gCAAMsC;oCAAAA,2BAAAA,gBAAgB5G,OAAO,qBAAvB4G,yBAAyBoC,KAAK;;kCAE5C;;kCAEH,KAACC;wBACCrF,KAAKgD;wBACLpB,MAAK;wBACL0D,MAAM;wBACNC,QAAO;wBACPhH,eAAY;wBACZa,UAAU,CAACC;gCACIA;4BAAb,MAAMqC,QAAOrC,sBAAAA,MAAME,MAAM,CAAC2E,KAAK,qBAAlB7E,mBAAoB,CAAC,EAAE;4BACpCA,MAAME,MAAM,CAACJ,KAAK,GAAG;4BACrB,KAAKgF,eAAezC;wBACtB;;;;;;AAKV;AACAM,wBAAwB5B,WAAW,GAAG"}
|
|
@@ -27,6 +27,7 @@ import { crmVisibleToClause } from "../hooks/use-crm-scope.js";
|
|
|
27
27
|
import { useCrmDefaultMarkFollowUp } from "../hooks/use-crm-sharing.js";
|
|
28
28
|
import { crmActivityLinkFromPicks, crmActivityPicksEqual, crmActivityPicksFrom, resolveCrmActivityCompany } from "../model/crm-activity-link.js";
|
|
29
29
|
import { ActivityLinkFields } from "./activity-link-fields.js";
|
|
30
|
+
import { ActivityRecordingFields } from "./activity-recording.js";
|
|
30
31
|
import { CrmSitePicker } from "./crm-site-picker.js";
|
|
31
32
|
/** The longest body a single activity stores — a call summary, not a document. */ const BODY_MAX = 4000;
|
|
32
33
|
const OUTCOME_MAX = 200;
|
|
@@ -55,7 +56,9 @@ const freshDraft = (kind = DEFAULT_KIND, picks = crmActivityPicksFrom({}))=>({
|
|
|
55
56
|
durationMinutes: '',
|
|
56
57
|
// Most logged calls and emails are the team's own.
|
|
57
58
|
direction: 'outbound',
|
|
58
|
-
picks
|
|
59
|
+
picks,
|
|
60
|
+
mediaIds: [],
|
|
61
|
+
transcript: ''
|
|
59
62
|
});
|
|
60
63
|
const draftFrom = (activity)=>{
|
|
61
64
|
var _activity_body, _activity_outcome, _Aglyn_crmActivityDirection;
|
|
@@ -66,7 +69,9 @@ const draftFrom = (activity)=>{
|
|
|
66
69
|
outcome: (_activity_outcome = activity.outcome) != null ? _activity_outcome : '',
|
|
67
70
|
durationMinutes: typeof activity.durationMinutes === 'number' ? String(activity.durationMinutes) : '',
|
|
68
71
|
direction: (_Aglyn_crmActivityDirection = Aglyn.crmActivityDirection(activity.kind, activity.direction)) != null ? _Aglyn_crmActivityDirection : '',
|
|
69
|
-
picks: crmActivityPicksFrom(activity)
|
|
72
|
+
picks: crmActivityPicksFrom(activity),
|
|
73
|
+
mediaIds: Aglyn.normalizeCrmActivityMediaIds(activity.mediaIds),
|
|
74
|
+
transcript: typeof activity.transcript === 'string' ? activity.transcript : ''
|
|
70
75
|
};
|
|
71
76
|
};
|
|
72
77
|
/**
|
|
@@ -119,6 +124,8 @@ const draftFrom = (activity)=>{
|
|
|
119
124
|
const { enqueueSnackbar } = useSnackbar();
|
|
120
125
|
const [draft, setDraft] = useState(freshDraft);
|
|
121
126
|
const [saving, setSaving] = useState(false);
|
|
127
|
+
// A recording still uploading: saving now would file the call without it.
|
|
128
|
+
const [uploading, setUploading] = useState(false);
|
|
122
129
|
/*
|
|
123
130
|
* Seeded on OPEN, not on mount: the dialog stays mounted between uses so
|
|
124
131
|
* its state survives a close, and "log another call" must start from now
|
|
@@ -149,6 +156,7 @@ const draftFrom = (activity)=>{
|
|
|
149
156
|
presetKind
|
|
150
157
|
]);
|
|
151
158
|
const hasOutcome = Aglyn.activityKindHasOutcome(draft.kind);
|
|
159
|
+
const takesRecording = Aglyn.activityKindTakesRecording(draft.kind);
|
|
152
160
|
const directions = (_Aglyn_CRM_ACTIVITY_DIRECTIONS_draft_kind = Aglyn.CRM_ACTIVITY_DIRECTIONS[draft.kind]) != null ? _Aglyn_CRM_ACTIVITY_DIRECTIONS_draft_kind : [];
|
|
153
161
|
const direction = Aglyn.crmActivityDirection(draft.kind, draft.direction);
|
|
154
162
|
const atMs = fromLocalInput(draft.at);
|
|
@@ -168,7 +176,7 @@ const draftFrom = (activity)=>{
|
|
|
168
176
|
// sees the CRM's records, else the picked site's — and in an org that
|
|
169
177
|
// keeps its sites apart there is nothing to write until one is picked
|
|
170
178
|
// (AGL-2630). An edit never touches either.
|
|
171
|
-
(Boolean(activity) || writeTokens.length > 0) && body.length > 0 && atMs !== null && durationValid && linked && !saving;
|
|
179
|
+
(Boolean(activity) || writeTokens.length > 0) && body.length > 0 && atMs !== null && durationValid && linked && !uploading && !saving;
|
|
172
180
|
const handleSave = useCallback(async ()=>{
|
|
173
181
|
// Every guard the button reads, again — a callback can outlive the
|
|
174
182
|
// render that disabled it.
|
|
@@ -190,6 +198,10 @@ const draftFrom = (activity)=>{
|
|
|
190
198
|
};
|
|
191
199
|
const outcome = hasOutcome ? draft.outcome.trim().slice(0, OUTCOME_MAX) : '';
|
|
192
200
|
const durationMinutes = hasOutcome && duration !== null ? duration : null;
|
|
201
|
+
// Only a call or a meeting keeps a recording; one turned into a note
|
|
202
|
+
// lets it go, and the file stays in the library where it was filed.
|
|
203
|
+
const mediaIds = takesRecording ? Aglyn.normalizeCrmActivityMediaIds(draft.mediaIds) : [];
|
|
204
|
+
const transcript = takesRecording ? Aglyn.normalizeCrmActivityTranscript(draft.transcript) : '';
|
|
193
205
|
if (activity) {
|
|
194
206
|
var _relinked_contactId, _relinked_dealId, _relinked_companyId;
|
|
195
207
|
const relinked = crmActivityPicksEqual(picks, crmActivityPicksFrom(activity)) ? null : await stamped();
|
|
@@ -203,6 +215,8 @@ const draftFrom = (activity)=>{
|
|
|
203
215
|
outcome: outcome ? outcome : deleteField(),
|
|
204
216
|
direction: direction != null ? direction : deleteField(),
|
|
205
217
|
durationMinutes: durationMinutes !== null ? durationMinutes : deleteField(),
|
|
218
|
+
mediaIds: mediaIds.length ? mediaIds : deleteField(),
|
|
219
|
+
transcript: transcript ? transcript : deleteField(),
|
|
206
220
|
updatedAt: new Date()
|
|
207
221
|
}));
|
|
208
222
|
enqueueSnackbar('Activity updated', {
|
|
@@ -235,6 +249,10 @@ const draftFrom = (activity)=>{
|
|
|
235
249
|
durationMinutes
|
|
236
250
|
} : {}, direction ? {
|
|
237
251
|
direction
|
|
252
|
+
} : {}, mediaIds.length ? {
|
|
253
|
+
mediaIds
|
|
254
|
+
} : {}, transcript ? {
|
|
255
|
+
transcript
|
|
238
256
|
} : {}, links, {
|
|
239
257
|
visibleTo: writeTokens,
|
|
240
258
|
hostId,
|
|
@@ -272,6 +290,9 @@ const draftFrom = (activity)=>{
|
|
|
272
290
|
durationValid,
|
|
273
291
|
draft.kind,
|
|
274
292
|
draft.outcome,
|
|
293
|
+
draft.mediaIds,
|
|
294
|
+
draft.transcript,
|
|
295
|
+
takesRecording,
|
|
275
296
|
direction,
|
|
276
297
|
hasOutcome,
|
|
277
298
|
duration,
|
|
@@ -444,6 +465,20 @@ const draftFrom = (activity)=>{
|
|
|
444
465
|
})
|
|
445
466
|
]
|
|
446
467
|
}) : null,
|
|
468
|
+
takesRecording ? /*#__PURE__*/ _jsx(ActivityRecordingFields, {
|
|
469
|
+
firestore: firestore,
|
|
470
|
+
orgId: scope.orgId,
|
|
471
|
+
mediaIds: draft.mediaIds,
|
|
472
|
+
onMediaIdsChange: (next)=>setDraft((prev)=>_extends({}, prev, {
|
|
473
|
+
mediaIds: next
|
|
474
|
+
})),
|
|
475
|
+
transcript: draft.transcript,
|
|
476
|
+
onTranscriptChange: (next)=>setDraft((prev)=>_extends({}, prev, {
|
|
477
|
+
transcript: next
|
|
478
|
+
})),
|
|
479
|
+
disabled: saving,
|
|
480
|
+
onBusyChange: setUploading
|
|
481
|
+
}) : null,
|
|
447
482
|
leadOnly ? null : /*#__PURE__*/ _jsx(ActivityLinkFields, {
|
|
448
483
|
scope: scope,
|
|
449
484
|
picks: picks,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/log-activity-dialog.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 * as Aglyn from '@aglyn/aglyn'\nimport type { CrmActivityKind, CrmActivityRow } from '@aglyn/aglyn'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser, useUserName } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n MenuItem,\n Stack,\n TextField,\n} from '@mui/material'\nimport {\n addDoc,\n collection,\n deleteField,\n doc,\n getCountFromServer,\n query,\n updateDoc,\n where,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { crmActivityClientReads } from '../hooks/crm-activity-client-reads'\nimport { crmVisibleToClause } from '../hooks/use-crm-scope'\nimport { useCrmDefaultMarkFollowUp } from '../hooks/use-crm-sharing'\nimport {\n crmActivityLinkFromPicks,\n crmActivityPicksEqual,\n crmActivityPicksFrom,\n type CrmActivityPicks,\n resolveCrmActivityCompany,\n} from '../model/crm-activity-link'\nimport { ActivityLinkFields } from './activity-link-fields'\nimport type { ActivityRecordLink, ActivityScope } from './activity-queries'\nimport { CrmSitePicker } from './crm-site-picker'\n\n/** The longest body a single activity stores — a call summary, not a document. */\nconst BODY_MAX = 4000\nconst OUTCOME_MAX = 200\nconst DURATION_MAX_MINUTES = 24 * 60\n\n/**\n * Epoch millis as the value a `datetime-local` input holds, in the LOCAL\n * zone — the input has no zone of its own, so an ISO string with a `Z`\n * would land the call an offset away from when it happened.\n */\nfunction toLocalInput(ms: number): string {\n if (!Number.isFinite(ms)) return ''\n const date = new Date(ms)\n const pad = (value: number) => String(value).padStart(2, '0')\n return (\n `${date.getFullYear()}-${pad(date.getMonth() + 1)}-` +\n `${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`\n )\n}\n\n/** The inverse: a `datetime-local` value parsed as local time, or `null`. */\nfunction fromLocalInput(value: string): number | null {\n if (!value) return null\n const ms = new Date(value).getTime()\n return Number.isFinite(ms) ? ms : null\n}\n\ninterface Draft {\n kind: CrmActivityKind\n body: string\n /** The `datetime-local` string, not millis — what the input holds. */\n at: string\n outcome: string\n /** Free text until save, so a half-typed number does not snap to zero. */\n durationMinutes: string\n /**\n * Which way a call or an email went (AGL-3517) — Salesforce's Call Type\n * for a call — or `''` for not said. Kept across a kind change and\n * written only when the kind takes it.\n */\n direction: string\n /** **Name** and **Related To**, as the reader has left them. */\n picks: CrmActivityPicks\n}\n\n/** The kind a new activity opens on when the caller names none. */\nconst DEFAULT_KIND: CrmActivityKind = 'call'\n\nconst freshDraft = (\n kind: CrmActivityKind = DEFAULT_KIND,\n picks: CrmActivityPicks = crmActivityPicksFrom({}),\n): Draft => ({\n kind,\n body: '',\n at: toLocalInput(Date.now()),\n outcome: '',\n durationMinutes: '',\n // Most logged calls and emails are the team's own.\n direction: 'outbound',\n picks,\n})\n\nconst draftFrom = (activity: CrmActivityRow): Draft => ({\n kind: Aglyn.isCrmActivityKind(activity.kind) ? activity.kind : 'other',\n body: activity.body ?? '',\n at: toLocalInput(activity.atMs),\n outcome: activity.outcome ?? '',\n durationMinutes:\n typeof activity.durationMinutes === 'number'\n ? String(activity.durationMinutes)\n : '',\n direction: Aglyn.crmActivityDirection(activity.kind, activity.direction) ?? '',\n picks: crmActivityPicksFrom(activity),\n})\n\nexport interface LogActivityDialogProps {\n open: boolean\n onClose: () => void\n /** Where the activity is written, from `useActivityScope`. */\n scope: ActivityScope\n /**\n * The record the dialog was opened on, which prefills **Name** and\n * **Related To** (AGL-4123). A lead's own log offers neither: the lead is\n * the entry's only link until it converts.\n */\n link: ActivityRecordLink\n /**\n * The deal the dialog was opened on, as its page read it: **Name** opens on\n * its Primary and its contact roles lead the list.\n */\n deal?: { contactId?: unknown; contactRoles?: unknown } | null\n /**\n * When set, the dialog EDITS this activity rather than logging a new one.\n * The author and the scope stay what they were; what was said, when, how\n * it went, and who and what it is about can change.\n */\n activity?: CrmActivityRow | null\n /**\n * What a NEW activity opens as (AGL-2661) — the click-to-call button\n * opens the dialog already a call, so logging one is the button and a\n * sentence rather than the button, the kind and a sentence. Ignored for\n * an edit, whose kind is the activity's own.\n */\n kind?: CrmActivityKind\n}\n\n/**\n * Log a call, an email, a meeting, a note or something else against a\n * record (AGL-2600) — or correct one already logged.\n *\n * ## Who, what and which account\n *\n * **Name** and **Related To** are Salesforce's Who and What (AGL-4123), and\n * the company an entry rolls up to is stamped from them when it is saved —\n * `model/crm-activity-link.ts` has the rule, shared with every other writer.\n * The fields open on the record the dialog was opened from and the reader may\n * change them: an entry named for a deal shows on the deal, on the person's\n * timeline and on the company, whichever page it was logged from.\n *\n * ## What is written\n *\n * A new activity carries the whole `CrmScoped` stamp: `visibleTo` from\n * `crmScopeTokens`, so it lands in exactly the scope a contact captured on\n * this site would; `hostId` as provenance; `byUid` and `byName` for the\n * author, the name denormalized because a colleague reading the log cannot\n * resolve a uid (see `CrmActivity.byName`); `atMs` for when it HAPPENED,\n * which the reader picks and which defaults to now; and the timestamps.\n * Under the CRM default \"All sites except…\" the server then adds the marker a\n * site added later joins by, which the rules refuse from a browser (AGL-4047).\n *\n * An edit rewrites only the fields the dialog shows. `visibleTo` is never\n * touched — the rules refuse a scoped member changing it, and widening a\n * record is an act for an org-wide member on the record itself — and neither\n * is the author. The links are rewritten only when **Name** or **Related To**\n * changed, and then the company is worked out again, so an edit that corrects\n * a typo cannot move an entry off a timeline it was filed on. A kind that\n * stops taking an outcome takes the outcome and the duration off the document\n * rather than leaving a stale \"left a voicemail\" on what is now a note.\n *\n * ## Who may write\n *\n * The rules admit any member who may write scoped org data, on create and\n * on update alike; they do not distinguish the author. The card that opens\n * this dialog for an edit checks the author itself (`useCanEditActivity`),\n * so what reaches here has already passed the console's verdict.\n */\nexport function LogActivityDialog(props: LogActivityDialogProps) {\n const { open, onClose, scope, link, deal, activity, kind: presetKind } = props\n const { firestore, dataScope, hostId, mountedHostId, readTokens, writeTokens, needsSite } =\n scope\n const { consentGroup, org } = scope\n const markUnderDefault = useCrmDefaultMarkFollowUp(mountedHostId, dataScope?.[1] ?? null, org)\n const { data: user } = useUser()\n const authorName = useUserName()\n const { enqueueSnackbar } = useSnackbar()\n const [draft, setDraft] = useState<Draft>(freshDraft)\n const [saving, setSaving] = useState(false)\n\n /*\n * Seeded on OPEN, not on mount: the dialog stays mounted between uses so\n * its state survives a close, and \"log another call\" must start from now\n * rather than from the last call's timestamp. The record is read through a\n * ref, because a deal is a live document and a colleague's save to it must\n * not wipe what the reader has typed so far.\n */\n const openedOn = useRef({ link, deal })\n useEffect(() => {\n openedOn.current = { link, deal }\n }, [link, deal])\n useEffect(() => {\n if (!open) return\n const seed = openedOn.current\n const primary = seed.deal ? Aglyn.dealPrimaryContactId(Aglyn.dealContactRolesOf(seed.deal)) : null\n setDraft(\n activity\n ? draftFrom(activity)\n : freshDraft(presetKind, crmActivityPicksFrom(seed.link, primary)),\n )\n }, [open, activity, presetKind])\n\n const hasOutcome = Aglyn.activityKindHasOutcome(draft.kind)\n const directions = Aglyn.CRM_ACTIVITY_DIRECTIONS[draft.kind] ?? []\n const direction = Aglyn.crmActivityDirection(draft.kind, draft.direction)\n const atMs = fromLocalInput(draft.at)\n const body = draft.body.trim()\n /*\n * A lead's own log shows neither field: a lead is not a contact **Name**\n * could hold, and in Salesforce's model too it names no What. A contact\n * beside the lead means it converted, and the entry reads like any other.\n */\n const filedOn = activity ?? link\n const leadOnly = Boolean(filedOn.leadId) && !filedOn.contactId\n const { picks } = draft\n // An activity attached to nothing is a sentence nobody can find (AGL-2606).\n const linked = leadOnly || Boolean(picks.contactId || picks.related)\n const duration = draft.durationMinutes.trim()\n ? Number(draft.durationMinutes)\n : null\n const durationValid =\n duration === null ||\n (Number.isInteger(duration) &&\n duration >= 0 &&\n duration <= DURATION_MAX_MINUTES)\n const canSave =\n Boolean(dataScope) &&\n Boolean(user?.uid) &&\n // A NEW activity is stamped with a scope: the whole org where every site\n // sees the CRM's records, else the picked site's — and in an org that\n // keeps its sites apart there is nothing to write until one is picked\n // (AGL-2630). An edit never touches either.\n (Boolean(activity) || writeTokens.length > 0) &&\n body.length > 0 &&\n atMs !== null &&\n durationValid &&\n linked &&\n !saving\n\n const handleSave = useCallback(async () => {\n // Every guard the button reads, again — a callback can outlive the\n // render that disabled it.\n if (!dataScope || !user?.uid || !body || atMs === null || !durationValid || !linked) {\n return\n }\n if (!activity && !writeTokens.length) return\n setSaving(true)\n try {\n const named = crmActivityLinkFromPicks(picks, filedOn.leadId)\n const stamped = () =>\n resolveCrmActivityCompany(\n named,\n { groupId: consentGroup?.groupId, org },\n crmActivityClientReads(firestore, dataScope[1]),\n )\n const said = {\n kind: draft.kind,\n body: body.slice(0, BODY_MAX),\n atMs,\n }\n const outcome = hasOutcome ? draft.outcome.trim().slice(0, OUTCOME_MAX) : ''\n const durationMinutes = hasOutcome && duration !== null ? duration : null\n if (activity) {\n const relinked = crmActivityPicksEqual(picks, crmActivityPicksFrom(activity))\n ? null\n : await stamped()\n await updateDoc(\n doc(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n activity.$id,\n ),\n {\n ...said,\n // Cleared rather than left: an entry moved off a deal must stop\n // showing on it. A lead's own link is never the fields' to change.\n ...(relinked\n ? {\n contactId: relinked.contactId ?? deleteField(),\n dealId: relinked.dealId ?? deleteField(),\n companyId: relinked.companyId ?? deleteField(),\n }\n : {}),\n // Cleared rather than left: a call turned into a note must not\n // keep the call's outcome, and Firestore refuses `undefined`.\n outcome: outcome ? outcome : deleteField(),\n direction: direction ?? deleteField(),\n durationMinutes:\n durationMinutes !== null ? durationMinutes : deleteField(),\n updatedAt: new Date(),\n },\n )\n enqueueSnackbar('Activity updated', { variant: 'success', persist: false })\n } else {\n /*\n * THE PER-RECORD CEILING (AGL-2611): one aggregate on the record\n * this dialog is filing under, before the write — the same count\n * the automation step and the REST create take, on the same link.\n * Scoped to the tokens this viewer may list, as every activity\n * listener is, so the rules admit the aggregate for a scoped\n * member exactly as they admit the timeline.\n */\n const lead = Aglyn.crmActivityCeilingLink(named)\n if (lead) {\n const logged = (\n await getCountFromServer(\n query(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n ...crmVisibleToClause(readTokens),\n where(lead.field, '==', lead.id),\n ),\n )\n ).data().count\n if (!Aglyn.crmActivityLogHasRoom(logged)) {\n enqueueSnackbar(Aglyn.CRM_ACTIVITY_LOG_FULL_MESSAGE, {\n variant: 'warning',\n persist: false,\n })\n return\n }\n }\n const links = await stamped()\n const added = await addDoc(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n {\n ...said,\n ...(outcome ? { outcome } : {}),\n ...(durationMinutes !== null ? { durationMinutes } : {}),\n ...(direction ? { direction } : {}),\n // Only the links it has: `stampCrmActivityCompany` leaves no blank\n // key, and Firestore refuses `undefined`.\n ...links,\n visibleTo: writeTokens,\n hostId,\n byUid: user.uid,\n // Absent rather than blank while the profile is still resolving:\n // the row reads a stored name over anything else, and an empty\n // string would be a name.\n ...(authorName ? { byName: authorName } : {}),\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n )\n // Under \"All sites except…\", the marker a site added later joins by (AGL-4047).\n markUnderDefault([added.id])\n enqueueSnackbar('Activity logged', { variant: 'success', persist: false })\n }\n onClose()\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setSaving(false)\n }\n }, [\n dataScope,\n user,\n body,\n atMs,\n durationValid,\n draft.kind,\n draft.outcome,\n direction,\n hasOutcome,\n duration,\n activity,\n firestore,\n enqueueSnackbar,\n linked,\n picks,\n filedOn.leadId,\n consentGroup,\n org,\n readTokens,\n writeTokens,\n hostId,\n authorName,\n markUnderDefault,\n onClose,\n ])\n\n return (\n <Dialog open={open} onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{activity ? 'Edit activity' : 'Log activity'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n {/* Only for a new activity at the organization level — see `canSave`. */}\n {activity ? null : (\n <CrmSitePicker\n hostId={mountedHostId}\n disabled={saving}\n optional={needsSite === false}\n helperText={\n needsSite === false\n ? undefined\n : 'The site this activity is logged from — it decides which of your sites may see it.'\n }\n />\n )}\n <Stack direction=\"row\" spacing={1} sx={{ mt: 1 }}>\n <TextField\n select\n size=\"small\"\n label=\"Kind\"\n value={draft.kind}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n kind: Aglyn.isCrmActivityKind(event.target.value)\n ? event.target.value\n : prev.kind,\n }))\n }\n sx={{ minWidth: 140 }}\n >\n {Aglyn.CRM_ACTIVITY_KINDS.map((kind) => (\n <MenuItem key={kind} value={kind}>\n {Aglyn.CRM_ACTIVITY_KIND_LABELS[kind]}\n </MenuItem>\n ))}\n </TextField>\n {directions.length ? (\n <TextField\n select\n size=\"small\"\n label=\"Direction\"\n value={direction ?? ''}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, direction: String(event.target.value) }))\n }\n slotProps={{ select: { displayEmpty: true }, inputLabel: { shrink: true } }}\n sx={{ minWidth: 130 }}\n >\n <MenuItem value=\"\">{'Not said'}</MenuItem>\n {directions.map((entry) => (\n <MenuItem key={entry} value={entry}>\n {Aglyn.CRM_ACTIVITY_DIRECTION_LABELS[entry]}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n <TextField\n size=\"small\"\n label=\"When\"\n type=\"datetime-local\"\n value={draft.at}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, at: event.target.value }))\n }\n error={draft.at.length > 0 && atMs === null}\n slotProps={{ inputLabel: { shrink: true } }}\n sx={{ flex: 1 }}\n />\n </Stack>\n <TextField\n size=\"small\"\n label=\"What happened\"\n value={draft.body}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, body: event.target.value }))\n }\n multiline\n minRows={3}\n autoFocus\n slotProps={{ htmlInput: { maxLength: BODY_MAX } }}\n />\n {hasOutcome ? (\n <Stack direction=\"row\" spacing={1}>\n <TextField\n size=\"small\"\n label=\"Outcome\"\n placeholder=\"Left a voicemail\"\n value={draft.outcome}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, outcome: event.target.value }))\n }\n slotProps={{ htmlInput: { maxLength: OUTCOME_MAX } }}\n sx={{ flex: 1 }}\n />\n <TextField\n size=\"small\"\n label=\"Minutes\"\n type=\"number\"\n value={draft.durationMinutes}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n durationMinutes: event.target.value,\n }))\n }\n error={!durationValid}\n slotProps={{\n htmlInput: { min: 0, max: DURATION_MAX_MINUTES, step: 1 },\n }}\n sx={{ width: 120 }}\n />\n </Stack>\n ) : null}\n {leadOnly ? null : (\n <ActivityLinkFields\n scope={scope}\n picks={picks}\n onChange={(next) => setDraft((prev) => ({ ...prev, picks: next }))}\n link={link}\n deal={deal}\n disabled={saving}\n />\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={saving}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!canSave}\n onClick={handleSave}\n >\n {activity ? 'Save' : 'Log'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\nLogActivityDialog.displayName = 'LogActivityDialog'\n\nexport default LogActivityDialog\n"],"names":["Aglyn","useSnackbar","useUser","useUserName","Button","Dialog","DialogActions","DialogContent","DialogTitle","MenuItem","Stack","TextField","addDoc","collection","deleteField","doc","getCountFromServer","query","updateDoc","where","useCallback","useEffect","useRef","useState","crmActivityClientReads","crmVisibleToClause","useCrmDefaultMarkFollowUp","crmActivityLinkFromPicks","crmActivityPicksEqual","crmActivityPicksFrom","resolveCrmActivityCompany","ActivityLinkFields","CrmSitePicker","BODY_MAX","OUTCOME_MAX","DURATION_MAX_MINUTES","toLocalInput","ms","Number","isFinite","date","Date","pad","value","String","padStart","getFullYear","getMonth","getDate","getHours","getMinutes","fromLocalInput","getTime","DEFAULT_KIND","freshDraft","kind","picks","body","at","now","outcome","durationMinutes","direction","draftFrom","activity","isCrmActivityKind","atMs","crmActivityDirection","LogActivityDialog","props","open","onClose","scope","link","deal","presetKind","firestore","dataScope","hostId","mountedHostId","readTokens","writeTokens","needsSite","consentGroup","org","markUnderDefault","data","user","authorName","enqueueSnackbar","draft","setDraft","saving","setSaving","openedOn","current","seed","primary","dealPrimaryContactId","dealContactRolesOf","hasOutcome","activityKindHasOutcome","directions","CRM_ACTIVITY_DIRECTIONS","trim","filedOn","leadOnly","Boolean","leadId","contactId","linked","related","duration","durationValid","isInteger","canSave","uid","length","handleSave","named","stamped","groupId","said","slice","relinked","CRM_COLLECTIONS","activities","$id","dealId","companyId","updatedAt","variant","persist","lead","crmActivityCeilingLink","logged","field","id","count","crmActivityLogHasRoom","CRM_ACTIVITY_LOG_FULL_MESSAGE","links","added","visibleTo","byUid","byName","createdAt","error","console","allowDuplicate","maxWidth","fullWidth","sx","display","flexDirection","gap","disabled","optional","helperText","undefined","spacing","mt","select","size","label","onChange","event","prev","target","minWidth","CRM_ACTIVITY_KINDS","map","CRM_ACTIVITY_KIND_LABELS","slotProps","displayEmpty","inputLabel","shrink","entry","CRM_ACTIVITY_DIRECTION_LABELS","type","flex","multiline","minRows","autoFocus","htmlInput","maxLength","placeholder","min","max","step","width","next","onClick","color","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AAErC,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,EAAEC,WAAW,QAAQ,iCAAgC;AACrE,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,QAAQ,EACRC,KAAK,EACLC,SAAS,QACJ,gBAAe;AACtB,SACEC,MAAM,EACNC,UAAU,EACVC,WAAW,EACXC,GAAG,EACHC,kBAAkB,EAClBC,KAAK,EACLC,SAAS,EACTC,KAAK,QACA,qBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,sBAAsB,QAAQ,wCAAoC;AAC3E,SAASC,kBAAkB,QAAQ,4BAAwB;AAC3D,SAASC,yBAAyB,QAAQ,8BAA0B;AACpE,SACEC,wBAAwB,EACxBC,qBAAqB,EACrBC,oBAAoB,EAEpBC,yBAAyB,QACpB,gCAA4B;AACnC,SAASC,kBAAkB,QAAQ,4BAAwB;AAE3D,SAASC,aAAa,QAAQ,uBAAmB;AAEjD,gFAAgF,GAChF,MAAMC,WAAW;AACjB,MAAMC,cAAc;AACpB,MAAMC,uBAAuB,KAAK;AAElC;;;;CAIC,GACD,SAASC,aAAaC,EAAU;IAC9B,IAAI,CAACC,OAAOC,QAAQ,CAACF,KAAK,OAAO;IACjC,MAAMG,OAAO,IAAIC,KAAKJ;IACtB,MAAMK,MAAM,CAACC,QAAkBC,OAAOD,OAAOE,QAAQ,CAAC,GAAG;IACzD,OACE,GAAGL,KAAKM,WAAW,GAAG,CAAC,EAAEJ,IAAIF,KAAKO,QAAQ,KAAK,GAAG,CAAC,CAAC,GACpD,GAAGL,IAAIF,KAAKQ,OAAO,IAAI,CAAC,EAAEN,IAAIF,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A;4CACH1G,iBAAiByG,MAAME,MAAM,CAAC7H,KAAK;;gCAGvCwG,OAAO,CAAClC;gCACR4D,WAAW;oCACTW,WAAW;wCAAEG,KAAK;wCAAGC,KAAKzJ;wCAAsB0J,MAAM;oCAAE;gCAC1D;gCACArC,IAAI;oCAAEsC,OAAO;gCAAI;;;yBAGnB;oBACHpF,WAAW,qBACV,KAAC3E;wBACCyC,OAAOA;wBACPhB,OAAOA;wBACP6G,UAAU,CAAC0B,OAASpG,SAAS,CAAC4E,OAAU,aAAKA;oCAAM/G,OAAOuI;;wBAC1DtH,MAAMA;wBACNC,MAAMA;wBACNkF,UAAUhE;;;;0BAIhB,MAACtF;;kCACC,KAACF;wBAAO4L,SAASzH;wBAASqF,UAAUhE;kCACjC;;kCAEH,KAACxF;wBACC+H,SAAQ;wBACR8D,OAAM;wBACNrC,UAAU,CAACzC;wBACX6E,SAAS1E;kCAERtD,WAAW,SAAS;;;;;;AAK/B;AACAI,kBAAkB8H,WAAW,GAAG;AAEhC,eAAe9H,kBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/log-activity-dialog.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 * as Aglyn from '@aglyn/aglyn'\nimport type { CrmActivityKind, CrmActivityRow } from '@aglyn/aglyn'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser, useUserName } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n MenuItem,\n Stack,\n TextField,\n} from '@mui/material'\nimport {\n addDoc,\n collection,\n deleteField,\n doc,\n getCountFromServer,\n query,\n updateDoc,\n where,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { crmActivityClientReads } from '../hooks/crm-activity-client-reads'\nimport { crmVisibleToClause } from '../hooks/use-crm-scope'\nimport { useCrmDefaultMarkFollowUp } from '../hooks/use-crm-sharing'\nimport {\n crmActivityLinkFromPicks,\n crmActivityPicksEqual,\n crmActivityPicksFrom,\n type CrmActivityPicks,\n resolveCrmActivityCompany,\n} from '../model/crm-activity-link'\nimport { ActivityLinkFields } from './activity-link-fields'\nimport { ActivityRecordingFields } from './activity-recording'\nimport type { ActivityRecordLink, ActivityScope } from './activity-queries'\nimport { CrmSitePicker } from './crm-site-picker'\n\n/** The longest body a single activity stores — a call summary, not a document. */\nconst BODY_MAX = 4000\nconst OUTCOME_MAX = 200\nconst DURATION_MAX_MINUTES = 24 * 60\n\n/**\n * Epoch millis as the value a `datetime-local` input holds, in the LOCAL\n * zone — the input has no zone of its own, so an ISO string with a `Z`\n * would land the call an offset away from when it happened.\n */\nfunction toLocalInput(ms: number): string {\n if (!Number.isFinite(ms)) return ''\n const date = new Date(ms)\n const pad = (value: number) => String(value).padStart(2, '0')\n return (\n `${date.getFullYear()}-${pad(date.getMonth() + 1)}-` +\n `${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`\n )\n}\n\n/** The inverse: a `datetime-local` value parsed as local time, or `null`. */\nfunction fromLocalInput(value: string): number | null {\n if (!value) return null\n const ms = new Date(value).getTime()\n return Number.isFinite(ms) ? ms : null\n}\n\ninterface Draft {\n kind: CrmActivityKind\n body: string\n /** The `datetime-local` string, not millis — what the input holds. */\n at: string\n outcome: string\n /** Free text until save, so a half-typed number does not snap to zero. */\n durationMinutes: string\n /**\n * Which way a call or an email went (AGL-3517) — Salesforce's Call Type\n * for a call — or `''` for not said. Kept across a kind change and\n * written only when the kind takes it.\n */\n direction: string\n /** **Name** and **Related To**, as the reader has left them. */\n picks: CrmActivityPicks\n /** A call's or a meeting's recordings, as library media ids. */\n mediaIds: string[]\n /** What was said, pasted or loaded from a `.txt`. */\n transcript: string\n}\n\n/** The kind a new activity opens on when the caller names none. */\nconst DEFAULT_KIND: CrmActivityKind = 'call'\n\nconst freshDraft = (\n kind: CrmActivityKind = DEFAULT_KIND,\n picks: CrmActivityPicks = crmActivityPicksFrom({}),\n): Draft => ({\n kind,\n body: '',\n at: toLocalInput(Date.now()),\n outcome: '',\n durationMinutes: '',\n // Most logged calls and emails are the team's own.\n direction: 'outbound',\n picks,\n mediaIds: [],\n transcript: '',\n})\n\nconst draftFrom = (activity: CrmActivityRow): Draft => ({\n kind: Aglyn.isCrmActivityKind(activity.kind) ? activity.kind : 'other',\n body: activity.body ?? '',\n at: toLocalInput(activity.atMs),\n outcome: activity.outcome ?? '',\n durationMinutes:\n typeof activity.durationMinutes === 'number'\n ? String(activity.durationMinutes)\n : '',\n direction: Aglyn.crmActivityDirection(activity.kind, activity.direction) ?? '',\n picks: crmActivityPicksFrom(activity),\n mediaIds: Aglyn.normalizeCrmActivityMediaIds(activity.mediaIds),\n transcript: typeof activity.transcript === 'string' ? activity.transcript : '',\n})\n\nexport interface LogActivityDialogProps {\n open: boolean\n onClose: () => void\n /** Where the activity is written, from `useActivityScope`. */\n scope: ActivityScope\n /**\n * The record the dialog was opened on, which prefills **Name** and\n * **Related To** (AGL-4123). A lead's own log offers neither: the lead is\n * the entry's only link until it converts.\n */\n link: ActivityRecordLink\n /**\n * The deal the dialog was opened on, as its page read it: **Name** opens on\n * its Primary and its contact roles lead the list.\n */\n deal?: { contactId?: unknown; contactRoles?: unknown } | null\n /**\n * When set, the dialog EDITS this activity rather than logging a new one.\n * The author and the scope stay what they were; what was said, when, how\n * it went, and who and what it is about can change.\n */\n activity?: CrmActivityRow | null\n /**\n * What a NEW activity opens as (AGL-2661) — the click-to-call button\n * opens the dialog already a call, so logging one is the button and a\n * sentence rather than the button, the kind and a sentence. Ignored for\n * an edit, whose kind is the activity's own.\n */\n kind?: CrmActivityKind\n}\n\n/**\n * Log a call, an email, a meeting, a note or something else against a\n * record (AGL-2600) — or correct one already logged.\n *\n * ## Who, what and which account\n *\n * **Name** and **Related To** are Salesforce's Who and What (AGL-4123), and\n * the company an entry rolls up to is stamped from them when it is saved —\n * `model/crm-activity-link.ts` has the rule, shared with every other writer.\n * The fields open on the record the dialog was opened from and the reader may\n * change them: an entry named for a deal shows on the deal, on the person's\n * timeline and on the company, whichever page it was logged from.\n *\n * ## What is written\n *\n * A new activity carries the whole `CrmScoped` stamp: `visibleTo` from\n * `crmScopeTokens`, so it lands in exactly the scope a contact captured on\n * this site would; `hostId` as provenance; `byUid` and `byName` for the\n * author, the name denormalized because a colleague reading the log cannot\n * resolve a uid (see `CrmActivity.byName`); `atMs` for when it HAPPENED,\n * which the reader picks and which defaults to now; and the timestamps.\n * Under the CRM default \"All sites except…\" the server then adds the marker a\n * site added later joins by, which the rules refuse from a browser (AGL-4047).\n *\n * An edit rewrites only the fields the dialog shows. `visibleTo` is never\n * touched — the rules refuse a scoped member changing it, and widening a\n * record is an act for an org-wide member on the record itself — and neither\n * is the author. The links are rewritten only when **Name** or **Related To**\n * changed, and then the company is worked out again, so an edit that corrects\n * a typo cannot move an entry off a timeline it was filed on. A kind that\n * stops taking an outcome takes the outcome and the duration off the document\n * rather than leaving a stale \"left a voicemail\" on what is now a note.\n *\n * ## Who may write\n *\n * The rules admit any member who may write scoped org data, on create and\n * on update alike; they do not distinguish the author. The card that opens\n * this dialog for an edit checks the author itself (`useCanEditActivity`),\n * so what reaches here has already passed the console's verdict.\n */\nexport function LogActivityDialog(props: LogActivityDialogProps) {\n const { open, onClose, scope, link, deal, activity, kind: presetKind } = props\n const { firestore, dataScope, hostId, mountedHostId, readTokens, writeTokens, needsSite } =\n scope\n const { consentGroup, org } = scope\n const markUnderDefault = useCrmDefaultMarkFollowUp(mountedHostId, dataScope?.[1] ?? null, org)\n const { data: user } = useUser()\n const authorName = useUserName()\n const { enqueueSnackbar } = useSnackbar()\n const [draft, setDraft] = useState<Draft>(freshDraft)\n const [saving, setSaving] = useState(false)\n // A recording still uploading: saving now would file the call without it.\n const [uploading, setUploading] = useState(false)\n\n /*\n * Seeded on OPEN, not on mount: the dialog stays mounted between uses so\n * its state survives a close, and \"log another call\" must start from now\n * rather than from the last call's timestamp. The record is read through a\n * ref, because a deal is a live document and a colleague's save to it must\n * not wipe what the reader has typed so far.\n */\n const openedOn = useRef({ link, deal })\n useEffect(() => {\n openedOn.current = { link, deal }\n }, [link, deal])\n useEffect(() => {\n if (!open) return\n const seed = openedOn.current\n const primary = seed.deal ? Aglyn.dealPrimaryContactId(Aglyn.dealContactRolesOf(seed.deal)) : null\n setDraft(\n activity\n ? draftFrom(activity)\n : freshDraft(presetKind, crmActivityPicksFrom(seed.link, primary)),\n )\n }, [open, activity, presetKind])\n\n const hasOutcome = Aglyn.activityKindHasOutcome(draft.kind)\n const takesRecording = Aglyn.activityKindTakesRecording(draft.kind)\n const directions = Aglyn.CRM_ACTIVITY_DIRECTIONS[draft.kind] ?? []\n const direction = Aglyn.crmActivityDirection(draft.kind, draft.direction)\n const atMs = fromLocalInput(draft.at)\n const body = draft.body.trim()\n /*\n * A lead's own log shows neither field: a lead is not a contact **Name**\n * could hold, and in Salesforce's model too it names no What. A contact\n * beside the lead means it converted, and the entry reads like any other.\n */\n const filedOn = activity ?? link\n const leadOnly = Boolean(filedOn.leadId) && !filedOn.contactId\n const { picks } = draft\n // An activity attached to nothing is a sentence nobody can find (AGL-2606).\n const linked = leadOnly || Boolean(picks.contactId || picks.related)\n const duration = draft.durationMinutes.trim()\n ? Number(draft.durationMinutes)\n : null\n const durationValid =\n duration === null ||\n (Number.isInteger(duration) &&\n duration >= 0 &&\n duration <= DURATION_MAX_MINUTES)\n const canSave =\n Boolean(dataScope) &&\n Boolean(user?.uid) &&\n // A NEW activity is stamped with a scope: the whole org where every site\n // sees the CRM's records, else the picked site's — and in an org that\n // keeps its sites apart there is nothing to write until one is picked\n // (AGL-2630). An edit never touches either.\n (Boolean(activity) || writeTokens.length > 0) &&\n body.length > 0 &&\n atMs !== null &&\n durationValid &&\n linked &&\n !uploading &&\n !saving\n\n const handleSave = useCallback(async () => {\n // Every guard the button reads, again — a callback can outlive the\n // render that disabled it.\n if (!dataScope || !user?.uid || !body || atMs === null || !durationValid || !linked) {\n return\n }\n if (!activity && !writeTokens.length) return\n setSaving(true)\n try {\n const named = crmActivityLinkFromPicks(picks, filedOn.leadId)\n const stamped = () =>\n resolveCrmActivityCompany(\n named,\n { groupId: consentGroup?.groupId, org },\n crmActivityClientReads(firestore, dataScope[1]),\n )\n const said = {\n kind: draft.kind,\n body: body.slice(0, BODY_MAX),\n atMs,\n }\n const outcome = hasOutcome ? draft.outcome.trim().slice(0, OUTCOME_MAX) : ''\n const durationMinutes = hasOutcome && duration !== null ? duration : null\n // Only a call or a meeting keeps a recording; one turned into a note\n // lets it go, and the file stays in the library where it was filed.\n const mediaIds = takesRecording ? Aglyn.normalizeCrmActivityMediaIds(draft.mediaIds) : []\n const transcript = takesRecording ? Aglyn.normalizeCrmActivityTranscript(draft.transcript) : ''\n if (activity) {\n const relinked = crmActivityPicksEqual(picks, crmActivityPicksFrom(activity))\n ? null\n : await stamped()\n await updateDoc(\n doc(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n activity.$id,\n ),\n {\n ...said,\n // Cleared rather than left: an entry moved off a deal must stop\n // showing on it. A lead's own link is never the fields' to change.\n ...(relinked\n ? {\n contactId: relinked.contactId ?? deleteField(),\n dealId: relinked.dealId ?? deleteField(),\n companyId: relinked.companyId ?? deleteField(),\n }\n : {}),\n // Cleared rather than left: a call turned into a note must not\n // keep the call's outcome, and Firestore refuses `undefined`.\n outcome: outcome ? outcome : deleteField(),\n direction: direction ?? deleteField(),\n durationMinutes:\n durationMinutes !== null ? durationMinutes : deleteField(),\n mediaIds: mediaIds.length ? mediaIds : deleteField(),\n transcript: transcript ? transcript : deleteField(),\n updatedAt: new Date(),\n },\n )\n enqueueSnackbar('Activity updated', { variant: 'success', persist: false })\n } else {\n /*\n * THE PER-RECORD CEILING (AGL-2611): one aggregate on the record\n * this dialog is filing under, before the write — the same count\n * the automation step and the REST create take, on the same link.\n * Scoped to the tokens this viewer may list, as every activity\n * listener is, so the rules admit the aggregate for a scoped\n * member exactly as they admit the timeline.\n */\n const lead = Aglyn.crmActivityCeilingLink(named)\n if (lead) {\n const logged = (\n await getCountFromServer(\n query(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n ...crmVisibleToClause(readTokens),\n where(lead.field, '==', lead.id),\n ),\n )\n ).data().count\n if (!Aglyn.crmActivityLogHasRoom(logged)) {\n enqueueSnackbar(Aglyn.CRM_ACTIVITY_LOG_FULL_MESSAGE, {\n variant: 'warning',\n persist: false,\n })\n return\n }\n }\n const links = await stamped()\n const added = await addDoc(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n {\n ...said,\n ...(outcome ? { outcome } : {}),\n ...(durationMinutes !== null ? { durationMinutes } : {}),\n ...(direction ? { direction } : {}),\n ...(mediaIds.length ? { mediaIds } : {}),\n ...(transcript ? { transcript } : {}),\n // Only the links it has: `stampCrmActivityCompany` leaves no blank\n // key, and Firestore refuses `undefined`.\n ...links,\n visibleTo: writeTokens,\n hostId,\n byUid: user.uid,\n // Absent rather than blank while the profile is still resolving:\n // the row reads a stored name over anything else, and an empty\n // string would be a name.\n ...(authorName ? { byName: authorName } : {}),\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n )\n // Under \"All sites except…\", the marker a site added later joins by (AGL-4047).\n markUnderDefault([added.id])\n enqueueSnackbar('Activity logged', { variant: 'success', persist: false })\n }\n onClose()\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setSaving(false)\n }\n }, [\n dataScope,\n user,\n body,\n atMs,\n durationValid,\n draft.kind,\n draft.outcome,\n draft.mediaIds,\n draft.transcript,\n takesRecording,\n direction,\n hasOutcome,\n duration,\n activity,\n firestore,\n enqueueSnackbar,\n linked,\n picks,\n filedOn.leadId,\n consentGroup,\n org,\n readTokens,\n writeTokens,\n hostId,\n authorName,\n markUnderDefault,\n onClose,\n ])\n\n return (\n <Dialog open={open} onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{activity ? 'Edit activity' : 'Log activity'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n {/* Only for a new activity at the organization level — see `canSave`. */}\n {activity ? null : (\n <CrmSitePicker\n hostId={mountedHostId}\n disabled={saving}\n optional={needsSite === false}\n helperText={\n needsSite === false\n ? undefined\n : 'The site this activity is logged from — it decides which of your sites may see it.'\n }\n />\n )}\n <Stack direction=\"row\" spacing={1} sx={{ mt: 1 }}>\n <TextField\n select\n size=\"small\"\n label=\"Kind\"\n value={draft.kind}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n kind: Aglyn.isCrmActivityKind(event.target.value)\n ? event.target.value\n : prev.kind,\n }))\n }\n sx={{ minWidth: 140 }}\n >\n {Aglyn.CRM_ACTIVITY_KINDS.map((kind) => (\n <MenuItem key={kind} value={kind}>\n {Aglyn.CRM_ACTIVITY_KIND_LABELS[kind]}\n </MenuItem>\n ))}\n </TextField>\n {directions.length ? (\n <TextField\n select\n size=\"small\"\n label=\"Direction\"\n value={direction ?? ''}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, direction: String(event.target.value) }))\n }\n slotProps={{ select: { displayEmpty: true }, inputLabel: { shrink: true } }}\n sx={{ minWidth: 130 }}\n >\n <MenuItem value=\"\">{'Not said'}</MenuItem>\n {directions.map((entry) => (\n <MenuItem key={entry} value={entry}>\n {Aglyn.CRM_ACTIVITY_DIRECTION_LABELS[entry]}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n <TextField\n size=\"small\"\n label=\"When\"\n type=\"datetime-local\"\n value={draft.at}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, at: event.target.value }))\n }\n error={draft.at.length > 0 && atMs === null}\n slotProps={{ inputLabel: { shrink: true } }}\n sx={{ flex: 1 }}\n />\n </Stack>\n <TextField\n size=\"small\"\n label=\"What happened\"\n value={draft.body}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, body: event.target.value }))\n }\n multiline\n minRows={3}\n autoFocus\n slotProps={{ htmlInput: { maxLength: BODY_MAX } }}\n />\n {hasOutcome ? (\n <Stack direction=\"row\" spacing={1}>\n <TextField\n size=\"small\"\n label=\"Outcome\"\n placeholder=\"Left a voicemail\"\n value={draft.outcome}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, outcome: event.target.value }))\n }\n slotProps={{ htmlInput: { maxLength: OUTCOME_MAX } }}\n sx={{ flex: 1 }}\n />\n <TextField\n size=\"small\"\n label=\"Minutes\"\n type=\"number\"\n value={draft.durationMinutes}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n durationMinutes: event.target.value,\n }))\n }\n error={!durationValid}\n slotProps={{\n htmlInput: { min: 0, max: DURATION_MAX_MINUTES, step: 1 },\n }}\n sx={{ width: 120 }}\n />\n </Stack>\n ) : null}\n {takesRecording ? (\n <ActivityRecordingFields\n firestore={firestore}\n orgId={scope.orgId}\n mediaIds={draft.mediaIds}\n onMediaIdsChange={(next) => setDraft((prev) => ({ ...prev, mediaIds: next }))}\n transcript={draft.transcript}\n onTranscriptChange={(next) => setDraft((prev) => ({ ...prev, transcript: next }))}\n disabled={saving}\n onBusyChange={setUploading}\n />\n ) : null}\n {leadOnly ? null : (\n <ActivityLinkFields\n scope={scope}\n picks={picks}\n onChange={(next) => setDraft((prev) => ({ ...prev, picks: next }))}\n link={link}\n deal={deal}\n disabled={saving}\n />\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={saving}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!canSave}\n onClick={handleSave}\n >\n {activity ? 'Save' : 'Log'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\nLogActivityDialog.displayName = 'LogActivityDialog'\n\nexport default LogActivityDialog\n"],"names":["Aglyn","useSnackbar","useUser","useUserName","Button","Dialog","DialogActions","DialogContent","DialogTitle","MenuItem","Stack","TextField","addDoc","collection","deleteField","doc","getCountFromServer","query","updateDoc","where","useCallback","useEffect","useRef","useState","crmActivityClientReads","crmVisibleToClause","useCrmDefaultMarkFollowUp","crmActivityLinkFromPicks","crmActivityPicksEqual","crmActivityPicksFrom","resolveCrmActivityCompany","ActivityLinkFields","ActivityRecordingFields","CrmSitePicker","BODY_MAX","OUTCOME_MAX","DURATION_MAX_MINUTES","toLocalInput","ms","Number","isFinite","date","Date","pad","value","String","padStart","getFullYear","getMonth","getDate","getHours","getMinutes","fromLocalInput","getTime","DEFAULT_KIND","freshDraft","kind","picks","body","at","now","outcome","durationMinutes","direction","mediaIds","transcript","draftFrom","activity","isCrmActivityKind","atMs","crmActivityDirection","normalizeCrmActivityMediaIds","LogActivityDialog","props","open","onClose","scope","link","deal","presetKind","firestore","dataScope","hostId","mountedHostId","readTokens","writeTokens","needsSite","consentGroup","org","markUnderDefault","data","user","authorName","enqueueSnackbar","draft","setDraft","saving","setSaving","uploading","setUploading","openedOn","current","seed","primary","dealPrimaryContactId","dealContactRolesOf","hasOutcome","activityKindHasOutcome","takesRecording","activityKindTakesRecording","directions","CRM_ACTIVITY_DIRECTIONS","trim","filedOn","leadOnly","Boolean","leadId","contactId","linked","related","duration","durationValid","isInteger","canSave","uid","length","handleSave","named","stamped","groupId","said","slice","normalizeCrmActivityTranscript","relinked","CRM_COLLECTIONS","activities","$id","dealId","companyId","updatedAt","variant","persist","lead","crmActivityCeilingLink","logged","field","id","count","crmActivityLogHasRoom","CRM_ACTIVITY_LOG_FULL_MESSAGE","links","added","visibleTo","byUid","byName","createdAt","error","console","allowDuplicate","maxWidth","fullWidth","sx","display","flexDirection","gap","disabled","optional","helperText","undefined","spacing","mt","select","size","label","onChange","event","prev","target","minWidth","CRM_ACTIVITY_KINDS","map","CRM_ACTIVITY_KIND_LABELS","slotProps","displayEmpty","inputLabel","shrink","entry","CRM_ACTIVITY_DIRECTION_LABELS","type","flex","multiline","minRows","autoFocus","htmlInput","maxLength","placeholder","min","max","step","width","orgId","onMediaIdsChange","next","onTranscriptChange","onBusyChange","onClick","color","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AAErC,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,EAAEC,WAAW,QAAQ,iCAAgC;AACrE,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,QAAQ,EACRC,KAAK,EACLC,SAAS,QACJ,gBAAe;AACtB,SACEC,MAAM,EACNC,UAAU,EACVC,WAAW,EACXC,GAAG,EACHC,kBAAkB,EAClBC,KAAK,EACLC,SAAS,EACTC,KAAK,QACA,qBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,sBAAsB,QAAQ,wCAAoC;AAC3E,SAASC,kBAAkB,QAAQ,4BAAwB;AAC3D,SAASC,yBAAyB,QAAQ,8BAA0B;AACpE,SACEC,wBAAwB,EACxBC,qBAAqB,EACrBC,oBAAoB,EAEpBC,yBAAyB,QACpB,gCAA4B;AACnC,SAASC,kBAAkB,QAAQ,4BAAwB;AAC3D,SAASC,uBAAuB,QAAQ,0BAAsB;AAE9D,SAASC,aAAa,QAAQ,uBAAmB;AAEjD,gFAAgF,GAChF,MAAMC,WAAW;AACjB,MAAMC,cAAc;AACpB,MAAMC,uBAAuB,KAAK;AAElC;;;;CAIC,GACD,SAASC,aAAaC,EAAU;IAC9B,IAA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AAWA;wBACXwH,OAAO5H,MAAM4H,KAAK;wBAClBxI,UAAU8B,MAAM9B,QAAQ;wBACxByI,kBAAkB,CAACC,OAAS3G,SAAS,CAACiF,OAAU,aAAKA;oCAAMhH,UAAU0I;;wBACrEzI,YAAY6B,MAAM7B,UAAU;wBAC5B0I,oBAAoB,CAACD,OAAS3G,SAAS,CAACiF,OAAU,aAAKA;oCAAM/G,YAAYyI;;wBACzErC,UAAUrE;wBACV4G,cAAczG;yBAEd;oBACHe,WAAW,qBACV,KAACnF;wBACC6C,OAAOA;wBACPnB,OAAOA;wBACPqH,UAAU,CAAC4B,OAAS3G,SAAS,CAACiF,OAAU,aAAKA;oCAAMvH,OAAOiJ;;wBAC1D7H,MAAMA;wBACNC,MAAMA;wBACNuF,UAAUrE;;;;0BAIhB,MAAC1F;;kCACC,KAACF;wBAAOyM,SAASlI;wBAAS0F,UAAUrE;kCACjC;;kCAEH,KAAC5F;wBACCwI,SAAQ;wBACRkE,OAAM;wBACNzC,UAAU,CAAC1C;wBACXkF,SAAS/E;kCAER3D,WAAW,SAAS;;;;;;AAK/B;AACAK,kBAAkBuI,WAAW,GAAG;AAEhC,eAAevI,kBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/model/crm-search-sources.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\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 * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleSearchSource } from '@aglyn/aglyn'\nimport { CRM_COLLECTIONS } from '@aglyn/aglyn/app-utils/crm'\nimport type { PluginRecordRouteContext } from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { crmHubRoutes } from './crm-record-routes'\n\n/**\n * What the console's search finds in the CRM (AGL-3080): people, leads,\n * companies, deals, and the team's tasks and activities, each opening on its\n * record in the hub at the scope the reader stands at.\n *\n * Every group is the organization's shared data, read through the reader's\n * `visibleTo` tokens under a site and unfiltered at the organization level,\n * where only an org-wide member is offered it — the same reading the hub's\n * own lists make. The extension's `crm` plan flag and `data.manage`\n * permission gate all six, as they gate the hub the rows open in.\n *\n * Listed after the site's own pages and emails (30) and before its building\n * blocks (100): a person is the thing most often looked up after a page.\n */\n\n/** A row's field as the plain string an address is built from. */\nfunction text(value: unknown): string {\n return typeof value === 'string' ? value : ''\n}\n\n/** One record's page, or `null` for a row without an id. */\nfunction recordHref(\n row: Readonly<Record<string, unknown>>,\n open: (id: string) => string,\n): string | null {\n const id = text(row['$id'])\n return id ? open(id) : null\n}\n\n/**\n * Where a task or an activity opens: the record it was filed under.\n *\n * Neither has a page of its own — a task is a row in a record's Tasks card\n * and in the Tasks list, an activity a line on a timeline — so the useful\n * destination is the deal, company, person or lead it belongs to, in that\n * order: a task filed on a deal is about that deal, and landing on the\n * contact would make the reader find it again. A lead addresses by its id\n * alone at both levels (AGL-3275), so one filed on a lead opens the lead.\n *\n * A task that names no record — a standing task somebody typed into the list\n * — lands on the Tasks section, which is where it is. An activity that names\n * none has nowhere to go and answers `null`, which drops the row.\n */\nfunction workHref(\n kind: 'task' | 'activity',\n row: Readonly<Record<string, unknown>>,\n context: PluginRecordRouteContext,\n): string | null {\n const routes = crmHubRoutes(context)\n const dealId = text(row['dealId'])\n if (dealId) return routes.deal(dealId)\n const companyId = text(row['companyId'])\n if (companyId) return routes.company(companyId)\n const contactId = text(row['contactId'])\n if (contactId) return routes.contact(contactId)\n const leadId = text(row['leadId'])\n if (leadId) return routes.lead(leadId)\n return kind === 'task' ? routes.section('tasks') : null\n}\n\nexport const CRM_SEARCH_SOURCES: readonly ConsoleSearchSource[] = [\n {\n /*\n * People, by name, email, phone number or company (AGL-2596). The phone\n * and the company name are top-level echoes of the viewing holder's\n * facet, written by every path that sets them, precisely so a read that\n * never resolves a facet can hit them. A person a checkout captured with\n * no name is labeled by the address, as the Contacts list labels them.\n */\n id: 'contacts',\n group: 'Contacts',\n noun: 'contacts',\n scope: 'orgData',\n collection: 'contacts',\n nameField: 'name',\n fallbackNameField: 'email',\n extraFields: ['email', 'phone', 'companyName'],\n order: 40,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).contact(id)),\n },\n {\n /*\n * People captured and not yet qualified, by name or address. One org\n * document per person, scoped by `visibleTo` like a contact (AGL-3275),\n * so the group reads and gates exactly as contacts do.\n */\n id: 'leads',\n group: 'Leads',\n noun: 'leads',\n scope: 'orgData',\n collection: 'leads',\n nameField: 'name',\n fallbackNameField: 'email',\n extraFields: ['email'],\n order: 41,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).lead(id)),\n },\n {\n // A company by its name or its domain (AGL-2622).\n id: 'companies',\n group: 'Companies',\n noun: 'companies',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.companies,\n nameField: 'name',\n extraFields: ['domain'],\n order: 42,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).company(id)),\n },\n {\n id: 'deals',\n group: 'Deals',\n noun: 'deals',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.deals,\n nameField: 'title',\n order: 43,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).deal(id)),\n },\n {\n /*\n * The team's own work (AGL-2662): a task by its title or notes. The\n * collection is the PREFIXED name — `crmTasks` — because `tasks` is a\n * word the org document wants for other things.\n */\n id: 'tasks',\n group: 'Tasks',\n noun: 'tasks',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.tasks,\n nameField: 'title',\n extraFields: ['notes'],\n order: 44,\n href: (row, context) => workHref('task', row, context),\n },\n {\n // A sent email carries a subject; everything a person logs by hand\n // carries only the body it was written into, and a row labeled by its\n // document id is a row nobody recognizes.\n id: 'activities',\n group: 'Activities',\n noun: 'activities',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.activities,\n nameField: 'subject',\n fallbackNameField: 'body',\n extraFields: ['body', 'outcome'],\n order: 45,\n href: (row, context) => workHref('activity', row, context),\n },\n]\n"],"names":["CRM_COLLECTIONS","crmHubRoutes","text","value","recordHref","row","open","id","workHref","kind","context","routes","dealId","deal","companyId","company","contactId","contact","leadId","lead","section","CRM_SEARCH_SOURCES","group","noun","scope","collection","nameField","fallbackNameField","extraFields","order","href","companies","deals","tasks","activities"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAGD,SAASA,eAAe,QAAQ,6BAA4B;AAE5D,SAASC,YAAY,QAAQ,yBAAqB;AAElD;;;;;;;;;;;;;CAaC,GAED,gEAAgE,GAChE,SAASC,KAAKC,KAAc;IAC1B,OAAO,OAAOA,UAAU,WAAWA,QAAQ;AAC7C;AAEA,0DAA0D,GAC1D,SAASC,WACPC,GAAsC,EACtCC,IAA4B;IAE5B,MAAMC,KAAKL,KAAKG,GAAG,CAAC,MAAM;IAC1B,OAAOE,KAAKD,KAAKC,MAAM;AACzB;AAEA;;;;;;;;;;;;;CAaC,GACD,SAASC,SACPC,IAAyB,EACzBJ,GAAsC,EACtCK,OAAiC;IAEjC,MAAMC,SAASV,aAAaS;IAC5B,MAAME,SAASV,KAAKG,GAAG,CAAC,SAAS;IACjC,IAAIO,QAAQ,OAAOD,OAAOE,IAAI,CAACD;IAC/B,MAAME,YAAYZ,KAAKG,GAAG,CAAC,YAAY;IACvC,IAAIS,WAAW,OAAOH,OAAOI,OAAO,CAACD;IACrC,MAAME,YAAYd,KAAKG,GAAG,CAAC,YAAY;IACvC,IAAIW,WAAW,OAAOL,OAAOM,OAAO,CAACD;IACrC,MAAME,SAAShB,KAAKG,GAAG,CAAC,SAAS;IACjC,IAAIa,QAAQ,OAAOP,OAAOQ,IAAI,CAACD;IAC/B,OAAOT,SAAS,SAASE,OAAOS,OAAO,CAAC,WAA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;QACJe,OAAO;QACPC,MAAM;QACNC,OAAO;QACPC,YAAYzB,gBAAgBkC,UAAU;QACtCR,WAAW;QACXC,mBAAmB;QACnBC,aAAa;YAAC;YAAQ;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/model/crm-search-sources.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\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 * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ConsoleSearchSource } from '@aglyn/aglyn'\nimport { CRM_COLLECTIONS } from '@aglyn/aglyn/app-utils/crm'\nimport type { PluginRecordRouteContext } from '@aglyn/aglyn/plugin-manager/plugin-record-routes'\nimport { crmHubRoutes } from './crm-record-routes'\n\n/**\n * What the console's search finds in the CRM (AGL-3080): people, leads,\n * companies, deals, and the team's tasks and activities, each opening on its\n * record in the hub at the scope the reader stands at.\n *\n * Every group is the organization's shared data, read through the reader's\n * `visibleTo` tokens under a site and unfiltered at the organization level,\n * where only an org-wide member is offered it — the same reading the hub's\n * own lists make. The extension's `crm` plan flag and `data.manage`\n * permission gate all six, as they gate the hub the rows open in.\n *\n * Listed after the site's own pages and emails (30) and before its building\n * blocks (100): a person is the thing most often looked up after a page.\n */\n\n/** A row's field as the plain string an address is built from. */\nfunction text(value: unknown): string {\n return typeof value === 'string' ? value : ''\n}\n\n/** One record's page, or `null` for a row without an id. */\nfunction recordHref(\n row: Readonly<Record<string, unknown>>,\n open: (id: string) => string,\n): string | null {\n const id = text(row['$id'])\n return id ? open(id) : null\n}\n\n/**\n * Where a task or an activity opens: the record it was filed under.\n *\n * Neither has a page of its own — a task is a row in a record's Tasks card\n * and in the Tasks list, an activity a line on a timeline — so the useful\n * destination is the deal, company, person or lead it belongs to, in that\n * order: a task filed on a deal is about that deal, and landing on the\n * contact would make the reader find it again. A lead addresses by its id\n * alone at both levels (AGL-3275), so one filed on a lead opens the lead.\n *\n * A task that names no record — a standing task somebody typed into the list\n * — lands on the Tasks section, which is where it is. An activity that names\n * none has nowhere to go and answers `null`, which drops the row.\n */\nfunction workHref(\n kind: 'task' | 'activity',\n row: Readonly<Record<string, unknown>>,\n context: PluginRecordRouteContext,\n): string | null {\n const routes = crmHubRoutes(context)\n const dealId = text(row['dealId'])\n if (dealId) return routes.deal(dealId)\n const companyId = text(row['companyId'])\n if (companyId) return routes.company(companyId)\n const contactId = text(row['contactId'])\n if (contactId) return routes.contact(contactId)\n const leadId = text(row['leadId'])\n if (leadId) return routes.lead(leadId)\n return kind === 'task' ? routes.section('tasks') : null\n}\n\nexport const CRM_SEARCH_SOURCES: readonly ConsoleSearchSource[] = [\n {\n /*\n * People, by name, email, phone number or company (AGL-2596). The phone\n * and the company name are top-level echoes of the viewing holder's\n * facet, written by every path that sets them, precisely so a read that\n * never resolves a facet can hit them. A person a checkout captured with\n * no name is labeled by the address, as the Contacts list labels them.\n */\n id: 'contacts',\n group: 'Contacts',\n noun: 'contacts',\n scope: 'orgData',\n collection: 'contacts',\n nameField: 'name',\n fallbackNameField: 'email',\n extraFields: ['email', 'phone', 'companyName'],\n order: 40,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).contact(id)),\n },\n {\n /*\n * People captured and not yet qualified, by name or address. One org\n * document per person, scoped by `visibleTo` like a contact (AGL-3275),\n * so the group reads and gates exactly as contacts do.\n */\n id: 'leads',\n group: 'Leads',\n noun: 'leads',\n scope: 'orgData',\n collection: 'leads',\n nameField: 'name',\n fallbackNameField: 'email',\n extraFields: ['email'],\n order: 41,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).lead(id)),\n },\n {\n // A company by its name or its domain (AGL-2622).\n id: 'companies',\n group: 'Companies',\n noun: 'companies',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.companies,\n nameField: 'name',\n extraFields: ['domain'],\n order: 42,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).company(id)),\n },\n {\n id: 'deals',\n group: 'Deals',\n noun: 'deals',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.deals,\n nameField: 'title',\n order: 43,\n href: (row, context) =>\n recordHref(row, (id) => crmHubRoutes(context).deal(id)),\n },\n {\n /*\n * The team's own work (AGL-2662): a task by its title or notes. The\n * collection is the PREFIXED name — `crmTasks` — because `tasks` is a\n * word the org document wants for other things.\n */\n id: 'tasks',\n group: 'Tasks',\n noun: 'tasks',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.tasks,\n nameField: 'title',\n extraFields: ['notes'],\n order: 44,\n href: (row, context) => workHref('task', row, context),\n },\n {\n // A sent email carries a subject; everything a person logs by hand\n // carries only the body it was written into, and a row labeled by its\n // document id is a row nobody recognizes.\n id: 'activities',\n group: 'Activities',\n noun: 'activities',\n scope: 'orgData',\n collection: CRM_COLLECTIONS.activities,\n nameField: 'subject',\n fallbackNameField: 'body',\n extraFields: ['body', 'outcome', 'transcript'],\n order: 45,\n href: (row, context) => workHref('activity', row, context),\n },\n]\n"],"names":["CRM_COLLECTIONS","crmHubRoutes","text","value","recordHref","row","open","id","workHref","kind","context","routes","dealId","deal","companyId","company","contactId","contact","leadId","lead","section","CRM_SEARCH_SOURCES","group","noun","scope","collection","nameField","fallbackNameField","extraFields","order","href","companies","deals","tasks","activities"],"mappings":"AAAA;;;;;;;;;;;;CAYC,GAGD,SAASA,eAAe,QAAQ,6BAA4B;AAE5D,SAASC,YAAY,QAAQ,yBAAqB;AAElD;;;;;;;;;;;;;CAaC,GAED,gEAAgE,GAChE,SAASC,KAAKC,KAAc;IAC1B,OAAO,OAAOA,UAAU,WAAWA,QAAQ;AAC7C;AAEA,0DAA0D,GAC1D,SAASC,WACPC,GAAsC,EACtCC,IAA4B;IAE5B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