@aglyn/plugins-ai 1.0.0-beta.199 → 1.0.0-beta.201
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 +17 -17
- package/src/lib/components/ai-products-hub-card.component.js +3 -0
- package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
- package/src/lib/components/ai-products-proposals.component.js +4 -0
- package/src/lib/components/ai-products-proposals.component.js.map +1 -1
- package/src/lib/components/ai-site-batch-card.component.js +5 -1
- package/src/lib/components/ai-site-batch-card.component.js.map +1 -1
- package/src/lib/components/billing-ai-allotments.component.d.ts +6 -0
- package/src/lib/components/billing-ai-allotments.component.js +17 -5
- package/src/lib/components/billing-ai-allotments.component.js.map +1 -1
- package/src/lib/components/billing-ai-top-users.component.js +8 -3
- package/src/lib/components/billing-ai-top-users.component.js.map +1 -1
- package/src/lib/components/staff-org-ai-card.component.js +12 -4
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/components/staff-user-ai-usage-card.component.js +7 -3
- package/src/lib/components/staff-user-ai-usage-card.component.js.map +1 -1
- package/src/lib/jobs/ai-job-drafts.d.ts +3 -1
- package/src/lib/jobs/ai-job-drafts.js +23 -7
- package/src/lib/jobs/ai-job-drafts.js.map +1 -1
- package/src/lib/jobs/ai-jobs.js +2 -1
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/server/ai-allotments.js +2 -1
- package/src/lib/server/ai-allotments.js.map +1 -1
- package/src/lib/server/ai-usage.js +2 -1
- package/src/lib/server/ai-usage.js.map +1 -1
- package/src/lib/server/billing-overage.js +3 -2
- package/src/lib/server/billing-overage.js.map +1 -1
- package/src/lib/usage/assist-free-taste.js +2 -1
- package/src/lib/usage/assist-free-taste.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.201",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-data-types": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.0.0-beta.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.0.0-beta.
|
|
36
|
-
"@aglyn/shared-util-email": "1.0.0-beta.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.0.0-beta.
|
|
38
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.0.0-beta.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.0.0-beta.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.0.0-beta.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.201",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.0.0-beta.201",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.201",
|
|
31
|
+
"@aglyn/shared-data-types": "1.0.0-beta.201",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.0.0-beta.201",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.201",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.0.0-beta.201",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.0.0-beta.201",
|
|
36
|
+
"@aglyn/shared-util-email": "1.0.0-beta.201",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.0.0-beta.201",
|
|
38
|
+
"@aglyn/shared-util-http": "1.0.0-beta.201",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.0.0-beta.201",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.201",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.0.0-beta.201",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.0.0-beta.201",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.0.0-beta.201",
|
|
44
44
|
"@swc/helpers": "0.5.23"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -295,6 +295,9 @@ export function AiProductsHubCard(props) {
|
|
|
295
295
|
/*#__PURE__*/ _jsx(ListTable, {
|
|
296
296
|
rows: pickerRows,
|
|
297
297
|
columns: pickerColumns,
|
|
298
|
+
// A picker over the rows the hub hands its zone, not a list to
|
|
299
|
+
// search: a filter here would narrow only those rows (AGL-3321).
|
|
300
|
+
disableColumnFilter: true,
|
|
298
301
|
quickFilter: false,
|
|
299
302
|
selectable: {
|
|
300
303
|
selected: picked,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-hub-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleProductsHubZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n AI_PRODUCTS_BULK_MAX,\n AI_PRODUCTS_IMPORT_WRITE_COPY,\n aiProductsBulkBrief,\n aiProductsBulkCount,\n aiProductsJobInputs,\n aiProductsProposalOfKind,\n} from '../model/ai-products'\nimport { AiBulkCopyReview, AiCatalogReview, AiCategoriesReview } from './ai-products-proposals.component'\nimport { useAiProductsJobs } from './use-ai-products-jobs'\n\n/**\n * Commerce by AI on the products hub (AGL-2916), through the `productsHub`\n * zone. Three things a person asks for, each a `products` job, and each\n * proposal reviewed in a table before anything is written:\n *\n * - **Write copy for products** — up to 50 saved products, picked from the\n * hub's rows; a job works through them a product at a time, and each row is\n * applied on its own or all at once.\n * - **Propose products** — a store's first products from a brief, created as\n * drafts with their prices empty and no photo, both marked for the person to\n * set.\n * - **Propose categories and discounts** — from a brief, created as the\n * catalog and discounts cards create them, every discount switched off.\n *\n * An import whose `productImport` option asked for it starts a copy job for\n * the products the import created, as they land. Every write is the hub's\n * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.\n */\n\nconst BRIEF_MAX_CHARS = 4_000\n\n/** A column of the product picker, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\ntype BriefKind = 'catalog' | 'categories'\n\n/** What each brief dialog says. */\nexport const AI_PRODUCTS_BRIEF_COPY: Readonly<\n Record<BriefKind, { title: string; label: string; placeholder: string; next: string; submit: string }>\n> = {\n catalog: {\n title: 'Propose products',\n label: 'What does the store sell?',\n placeholder: 'A candle studio in Asheville: hand-poured soy candles in 8 oz and 16 oz jars, and wax melts',\n next:\n 'You review up to twelve proposed products before any is created. Each is created as a draft with its ' +\n 'price left empty and no photo, and nothing is on your storefront until you price it and activate it.',\n submit: 'Propose products',\n },\n categories: {\n title: 'Propose categories and discounts',\n label: 'What should shoppers be able to browse, and what offers suit the store?',\n placeholder: 'A trail running shop: shoes, apparel and hydration packs, with a welcome offer for new runners',\n next:\n 'You review the proposed categories and discounts before any is created. Discounts are created switched ' +\n 'off, and a shopper sees none until you switch it on.',\n submit: 'Propose',\n },\n}\n\nconst nameKey = (name: string) => name.replace(/\\s+/g, ' ').trim().toLowerCase()\n\n/** Which card a `products` job belongs to: from what it proposed, or from what this card started. */\nfunction targetOf(job: AiJobSummary, started: Readonly<Record<string, string>>): string | null {\n if (started[job.id]) return started[job.id]\n if (aiProductsBulkCount(job) !== null) return 'bulk'\n if (aiProductsProposalOfKind(job, 'catalog')) return 'catalog'\n if (aiProductsProposalOfKind(job, 'categories')) return 'categories'\n return null\n}\n\nexport function AiProductsHubCard(props: ConsoleProductsHubZoneProps) {\n const { hostId, products, lastImport, applyProductCopy, createProductDrafts, createCategories, createDiscountDrafts } =\n props\n const { orgId, verdict, jobs, notice, start } = useAiProductsJobs({\n hostId,\n orgId: props.orgId,\n // A bulk job is known by its brief while it runs; a catalog or categories\n // job started elsewhere is shown once it has proposed.\n follows: (job) => aiProductsBulkCount(job) !== null,\n })\n const [started, setStarted] = useState<Record<string, string>>({})\n const [picking, setPicking] = useState(false)\n const [picked, setPicked] = useState<string[]>([])\n const [brief, setBrief] = useState<{ kind: BriefKind; text: string } | null>(null)\n const [busy, setBusy] = useState(false)\n const handledImports = useRef(new Set<string>())\n\n const startBulk = useCallback(\n async (productIds: readonly string[]) => {\n const ids = productIds.slice(0, AI_PRODUCTS_BULK_MAX)\n if (!ids.length) return false\n const job = await start(aiProductsBulkBrief(ids.length), aiProductsJobInputs({ target: 'bulk', productIds: [...ids] }))\n if (job) setStarted((current) => ({ ...current, [job.id]: 'bulk' }))\n return Boolean(job)\n },\n [start],\n )\n\n // An import that asked for its copy starts the job once, as the import lands.\n useEffect(() => {\n if (verdict !== 'ready' || !lastImport || handledImports.current.has(lastImport.key)) return\n handledImports.current.add(lastImport.key)\n if (lastImport.options[AI_PRODUCTS_IMPORT_WRITE_COPY] && lastImport.productIds.length) {\n void startBulk(lastImport.productIds)\n }\n }, [verdict, lastImport, startBulk])\n\n const heldNames = useMemo(() => new Set(products.map((product) => nameKey(product.name))), [products])\n const pickerRows = useMemo(\n () =>\n products.map((product) => ({\n $id: product.id,\n name: product.name,\n status: product.status,\n photo: product.hasPhoto ? 'Yes' : 'No photo',\n })),\n [products],\n )\n const pickerColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'status', headerName: 'Status', width: 110 },\n { field: 'photo', headerName: 'Photo', width: 110 },\n ],\n [],\n )\n\n if (verdict !== 'ready') return null\n\n const latest = (target: string) => jobs.find((job) => targetOf(job, started) === target) ?? null\n const bulkJob = latest('bulk')\n const catalogJob = latest('catalog')\n const categoriesJob = latest('categories')\n const tooMany = picked.length > AI_PRODUCTS_BULK_MAX\n const help = pluginDocsHelp('aiProducts', {\n excerpt:\n 'Write product copy, propose a first catalog, or propose categories and discounts from a brief. You review every proposal before anything is saved.',\n })\n const copy = brief ? AI_PRODUCTS_BRIEF_COPY[brief.kind] : null\n\n const submitBrief = async () => {\n if (!brief?.text.trim()) return\n setBusy(true)\n try {\n const job = await start(brief.text.trim(), aiProductsJobInputs({ target: brief.kind }))\n if (job) {\n setStarted((current) => ({ ...current, [job.id]: brief.kind }))\n setBrief(null)\n }\n } finally {\n setBusy(false)\n }\n }\n\n const submitPicked = async () => {\n setBusy(true)\n try {\n if (await startBulk(picked)) {\n setPicking(false)\n setPicked([])\n }\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 1.5 }} aria-label=\"Products assistant\">\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"subtitle2\" sx={{ flexGrow: 1 }}>\n {'Build your catalog with AI'}\n </Typography>\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" variant=\"caption\" title={help.excerpt}>\n {'How it works'}\n </Link>\n </Stack>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId || !products.length} onClick={() => setPicking(true)}>\n {'Write copy for products'}\n </Button>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId} onClick={() => setBrief({ kind: 'catalog', text: '' })}>\n {'Propose products'}\n </Button>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={!orgId}\n onClick={() => setBrief({ kind: 'categories', text: '' })}\n >\n {'Propose categories and discounts'}\n </Button>\n </Stack>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {bulkJob ? (\n <AiBulkCopyReview key={bulkJob.id} job={bulkJob} applyProductCopy={applyProductCopy} />\n ) : null}\n {catalogJob ? (\n <AiCatalogReview\n key={catalogJob.id}\n job={catalogJob}\n heldNames={heldNames}\n createProductDrafts={createProductDrafts}\n />\n ) : null}\n {categoriesJob ? (\n <AiCategoriesReview\n key={categoriesJob.id}\n job={categoriesJob}\n createCategories={createCategories}\n createDiscountDrafts={createDiscountDrafts}\n />\n ) : null}\n </Stack>\n\n <Dialog open={picking} onClose={busy ? undefined : () => setPicking(false)} fullWidth maxWidth=\"md\">\n <DialogTitle>{'Write copy for products'}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Pick up to ${AI_PRODUCTS_BULK_MAX} products. Each gets a proposed description, search listing and ` +\n 'tags from its name, text, options and first photo, and you review every one before it is saved. ' +\n 'Prices are never written.'}\n </Typography>\n <ListTable\n rows={pickerRows}\n columns={pickerColumns}\n quickFilter={false}\n selectable={{ selected: picked, onChange: setPicked }}\n />\n {tooMany ? (\n <Alert severity=\"info\">{`Pick at most ${AI_PRODUCTS_BULK_MAX} products at a time.`}</Alert>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPicking(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !picked.length || tooMany} onClick={() => void submitPicked()}>\n {picked.length ? `Write copy for ${picked.length}` : 'Write copy'}\n </Button>\n </DialogActions>\n </Dialog>\n\n <Dialog open={Boolean(brief)} onClose={busy ? undefined : () => setBrief(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy?.title}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy?.label}\n placeholder={copy?.placeholder}\n multiline\n minRows={4}\n value={brief?.text ?? ''}\n onChange={(event) =>\n setBrief((current) => (current ? { ...current, text: event.target.value.slice(0, BRIEF_MAX_CHARS) } : current))\n }\n helperText={`${(brief?.text.length ?? 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={busy}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy?.next}\n </Typography>\n {brief?.kind === 'catalog' ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Prices stay empty\" />\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Photos are yours to add\" />\n </Stack>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setBrief(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !orgId || !brief?.text.trim()} onClick={() => void submitBrief()}>\n {copy?.submit}\n </Button>\n </DialogActions>\n </Dialog>\n </Box>\n )\n}\nAiProductsHubCard.displayName = 'AiProductsHubCard'\n\nexport default AiProductsHubCard\n"],"names":["pluginDocsHelp","ListTable","Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_PRODUCTS_BULK_MAX","AI_PRODUCTS_IMPORT_WRITE_COPY","aiProductsBulkBrief","aiProductsBulkCount","aiProductsJobInputs","aiProductsProposalOfKind","AiBulkCopyReview","AiCatalogReview","AiCategoriesReview","useAiProductsJobs","BRIEF_MAX_CHARS","AI_PRODUCTS_BRIEF_COPY","catalog","title","label","placeholder","next","submit","categories","nameKey","name","replace","trim","toLowerCase","targetOf","job","started","id","AiProductsHubCard","props","hostId","products","lastImport","applyProductCopy","createProductDrafts","createCategories","createDiscountDrafts","orgId","verdict","jobs","notice","start","follows","setStarted","picking","setPicking","picked","setPicked","brief","setBrief","busy","setBusy","handledImports","Set","startBulk","productIds","ids","slice","length","target","current","Boolean","has","key","add","options","heldNames","map","product","pickerRows","$id","status","photo","hasPhoto","pickerColumns","field","headerName","flex","minWidth","width","latest","find","bulkJob","catalogJob","categoriesJob","tooMany","help","excerpt","copy","kind","submitBrief","text","submitPicked","sx","border","borderColor","borderRadius","p","aria-label","spacing","direction","alignItems","variant","flexGrow","href","rel","xs","sm","size","disabled","onClick","severity","open","onClose","undefined","fullWidth","maxWidth","pt","color","rows","columns","quickFilter","selectable","selected","onChange","multiline","minRows","value","event","helperText","toLocaleString","autoFocus","useFlexGap","flexWrap","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,SAAS,QAA6B,uDAAsD;AACrG,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;A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O6H,SAAS,IAAM7D,SAAS;gCAAO4D,UAAU3D;0CAC9C;;0CAEH,KAACjE;gCAAOqH,SAAQ;gCAAYO,UAAU3D,QAAQ,CAACb,SAAS,EAACW,yBAAAA,MAAO2C,IAAI,CAACrE,IAAI;gCAAIwF,SAAS,IAAM,KAAKpB;0CAC9FF,wBAAAA,KAAMvE,MAAM;;;;;;;;AAMzB;AACAW,kBAAkB0G,WAAW,GAAG;AAEhC,eAAe1G,kBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-hub-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport type { ConsoleProductsHubZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Link,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n AI_PRODUCTS_BULK_MAX,\n AI_PRODUCTS_IMPORT_WRITE_COPY,\n aiProductsBulkBrief,\n aiProductsBulkCount,\n aiProductsJobInputs,\n aiProductsProposalOfKind,\n} from '../model/ai-products'\nimport { AiBulkCopyReview, AiCatalogReview, AiCategoriesReview } from './ai-products-proposals.component'\nimport { useAiProductsJobs } from './use-ai-products-jobs'\n\n/**\n * Commerce by AI on the products hub (AGL-2916), through the `productsHub`\n * zone. Three things a person asks for, each a `products` job, and each\n * proposal reviewed in a table before anything is written:\n *\n * - **Write copy for products** — up to 50 saved products, picked from the\n * hub's rows; a job works through them a product at a time, and each row is\n * applied on its own or all at once.\n * - **Propose products** — a store's first products from a brief, created as\n * drafts with their prices empty and no photo, both marked for the person to\n * set.\n * - **Propose categories and discounts** — from a brief, created as the\n * catalog and discounts cards create them, every discount switched off.\n *\n * An import whose `productImport` option asked for it starts a copy job for\n * the products the import created, as they land. Every write is the hub's\n * (`ConsoleProductsHubZoneProps`); this card writes nothing itself.\n */\n\nconst BRIEF_MAX_CHARS = 4_000\n\n/** A column of the product picker, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\ntype BriefKind = 'catalog' | 'categories'\n\n/** What each brief dialog says. */\nexport const AI_PRODUCTS_BRIEF_COPY: Readonly<\n Record<BriefKind, { title: string; label: string; placeholder: string; next: string; submit: string }>\n> = {\n catalog: {\n title: 'Propose products',\n label: 'What does the store sell?',\n placeholder: 'A candle studio in Asheville: hand-poured soy candles in 8 oz and 16 oz jars, and wax melts',\n next:\n 'You review up to twelve proposed products before any is created. Each is created as a draft with its ' +\n 'price left empty and no photo, and nothing is on your storefront until you price it and activate it.',\n submit: 'Propose products',\n },\n categories: {\n title: 'Propose categories and discounts',\n label: 'What should shoppers be able to browse, and what offers suit the store?',\n placeholder: 'A trail running shop: shoes, apparel and hydration packs, with a welcome offer for new runners',\n next:\n 'You review the proposed categories and discounts before any is created. Discounts are created switched ' +\n 'off, and a shopper sees none until you switch it on.',\n submit: 'Propose',\n },\n}\n\nconst nameKey = (name: string) => name.replace(/\\s+/g, ' ').trim().toLowerCase()\n\n/** Which card a `products` job belongs to: from what it proposed, or from what this card started. */\nfunction targetOf(job: AiJobSummary, started: Readonly<Record<string, string>>): string | null {\n if (started[job.id]) return started[job.id]\n if (aiProductsBulkCount(job) !== null) return 'bulk'\n if (aiProductsProposalOfKind(job, 'catalog')) return 'catalog'\n if (aiProductsProposalOfKind(job, 'categories')) return 'categories'\n return null\n}\n\nexport function AiProductsHubCard(props: ConsoleProductsHubZoneProps) {\n const { hostId, products, lastImport, applyProductCopy, createProductDrafts, createCategories, createDiscountDrafts } =\n props\n const { orgId, verdict, jobs, notice, start } = useAiProductsJobs({\n hostId,\n orgId: props.orgId,\n // A bulk job is known by its brief while it runs; a catalog or categories\n // job started elsewhere is shown once it has proposed.\n follows: (job) => aiProductsBulkCount(job) !== null,\n })\n const [started, setStarted] = useState<Record<string, string>>({})\n const [picking, setPicking] = useState(false)\n const [picked, setPicked] = useState<string[]>([])\n const [brief, setBrief] = useState<{ kind: BriefKind; text: string } | null>(null)\n const [busy, setBusy] = useState(false)\n const handledImports = useRef(new Set<string>())\n\n const startBulk = useCallback(\n async (productIds: readonly string[]) => {\n const ids = productIds.slice(0, AI_PRODUCTS_BULK_MAX)\n if (!ids.length) return false\n const job = await start(aiProductsBulkBrief(ids.length), aiProductsJobInputs({ target: 'bulk', productIds: [...ids] }))\n if (job) setStarted((current) => ({ ...current, [job.id]: 'bulk' }))\n return Boolean(job)\n },\n [start],\n )\n\n // An import that asked for its copy starts the job once, as the import lands.\n useEffect(() => {\n if (verdict !== 'ready' || !lastImport || handledImports.current.has(lastImport.key)) return\n handledImports.current.add(lastImport.key)\n if (lastImport.options[AI_PRODUCTS_IMPORT_WRITE_COPY] && lastImport.productIds.length) {\n void startBulk(lastImport.productIds)\n }\n }, [verdict, lastImport, startBulk])\n\n const heldNames = useMemo(() => new Set(products.map((product) => nameKey(product.name))), [products])\n const pickerRows = useMemo(\n () =>\n products.map((product) => ({\n $id: product.id,\n name: product.name,\n status: product.status,\n photo: product.hasPhoto ? 'Yes' : 'No photo',\n })),\n [products],\n )\n const pickerColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'status', headerName: 'Status', width: 110 },\n { field: 'photo', headerName: 'Photo', width: 110 },\n ],\n [],\n )\n\n if (verdict !== 'ready') return null\n\n const latest = (target: string) => jobs.find((job) => targetOf(job, started) === target) ?? null\n const bulkJob = latest('bulk')\n const catalogJob = latest('catalog')\n const categoriesJob = latest('categories')\n const tooMany = picked.length > AI_PRODUCTS_BULK_MAX\n const help = pluginDocsHelp('aiProducts', {\n excerpt:\n 'Write product copy, propose a first catalog, or propose categories and discounts from a brief. You review every proposal before anything is saved.',\n })\n const copy = brief ? AI_PRODUCTS_BRIEF_COPY[brief.kind] : null\n\n const submitBrief = async () => {\n if (!brief?.text.trim()) return\n setBusy(true)\n try {\n const job = await start(brief.text.trim(), aiProductsJobInputs({ target: brief.kind }))\n if (job) {\n setStarted((current) => ({ ...current, [job.id]: brief.kind }))\n setBrief(null)\n }\n } finally {\n setBusy(false)\n }\n }\n\n const submitPicked = async () => {\n setBusy(true)\n try {\n if (await startBulk(picked)) {\n setPicking(false)\n setPicked([])\n }\n } finally {\n setBusy(false)\n }\n }\n\n return (\n <Box sx={{ border: 1, borderColor: 'divider', borderRadius: 1, p: 1.5 }} aria-label=\"Products assistant\">\n <Stack spacing={1.5}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'baseline' }}>\n <Typography variant=\"subtitle2\" sx={{ flexGrow: 1 }}>\n {'Build your catalog with AI'}\n </Typography>\n <Link href={help.href} target=\"_blank\" rel=\"noopener\" variant=\"caption\" title={help.excerpt}>\n {'How it works'}\n </Link>\n </Stack>\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId || !products.length} onClick={() => setPicking(true)}>\n {'Write copy for products'}\n </Button>\n <Button size=\"small\" variant=\"outlined\" disabled={!orgId} onClick={() => setBrief({ kind: 'catalog', text: '' })}>\n {'Propose products'}\n </Button>\n <Button\n size=\"small\"\n variant=\"outlined\"\n disabled={!orgId}\n onClick={() => setBrief({ kind: 'categories', text: '' })}\n >\n {'Propose categories and discounts'}\n </Button>\n </Stack>\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n {bulkJob ? (\n <AiBulkCopyReview key={bulkJob.id} job={bulkJob} applyProductCopy={applyProductCopy} />\n ) : null}\n {catalogJob ? (\n <AiCatalogReview\n key={catalogJob.id}\n job={catalogJob}\n heldNames={heldNames}\n createProductDrafts={createProductDrafts}\n />\n ) : null}\n {categoriesJob ? (\n <AiCategoriesReview\n key={categoriesJob.id}\n job={categoriesJob}\n createCategories={createCategories}\n createDiscountDrafts={createDiscountDrafts}\n />\n ) : null}\n </Stack>\n\n <Dialog open={picking} onClose={busy ? undefined : () => setPicking(false)} fullWidth maxWidth=\"md\">\n <DialogTitle>{'Write copy for products'}</DialogTitle>\n <DialogContent>\n <Stack spacing={1.5} sx={{ pt: 1 }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Pick up to ${AI_PRODUCTS_BULK_MAX} products. Each gets a proposed description, search listing and ` +\n 'tags from its name, text, options and first photo, and you review every one before it is saved. ' +\n 'Prices are never written.'}\n </Typography>\n <ListTable\n rows={pickerRows}\n columns={pickerColumns}\n // A picker over the rows the hub hands its zone, not a list to\n // search: a filter here would narrow only those rows (AGL-3321).\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: picked, onChange: setPicked }}\n />\n {tooMany ? (\n <Alert severity=\"info\">{`Pick at most ${AI_PRODUCTS_BULK_MAX} products at a time.`}</Alert>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setPicking(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !picked.length || tooMany} onClick={() => void submitPicked()}>\n {picked.length ? `Write copy for ${picked.length}` : 'Write copy'}\n </Button>\n </DialogActions>\n </Dialog>\n\n <Dialog open={Boolean(brief)} onClose={busy ? undefined : () => setBrief(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>{copy?.title}</DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n label={copy?.label}\n placeholder={copy?.placeholder}\n multiline\n minRows={4}\n value={brief?.text ?? ''}\n onChange={(event) =>\n setBrief((current) => (current ? { ...current, text: event.target.value.slice(0, BRIEF_MAX_CHARS) } : current))\n }\n helperText={`${(brief?.text.length ?? 0).toLocaleString('en-US')} / ${BRIEF_MAX_CHARS.toLocaleString('en-US')}`}\n disabled={busy}\n autoFocus\n />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {copy?.next}\n </Typography>\n {brief?.kind === 'catalog' ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Prices stay empty\" />\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Photos are yours to add\" />\n </Stack>\n ) : null}\n {notice ? <Alert severity=\"warning\">{notice}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setBrief(null)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy || !orgId || !brief?.text.trim()} onClick={() => void submitBrief()}>\n {copy?.submit}\n </Button>\n </DialogActions>\n </Dialog>\n </Box>\n )\n}\nAiProductsHubCard.displayName = 'AiProductsHubCard'\n\nexport default AiProductsHubCard\n"],"names":["pluginDocsHelp","ListTable","Alert","Box","Button","Chip","Dialog","DialogActions","DialogContent","DialogTitle","Link","Stack","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_PRODUCTS_BULK_MAX","AI_PRODUCTS_IMPORT_WRITE_COPY","aiProductsBulkBrief","aiProductsBulkCount","aiProductsJobInputs","aiProductsProposalOfKind","AiBulkCopyReview","AiCatalogReview","AiCategoriesReview","useAiProductsJobs","BRIEF_MAX_CHARS","AI_PRODUCTS_BRIEF_COPY","catalog","title","label","placeholder","next","submit","categories","nameKey","name","replace","trim","toLowerCase","targetOf","job","started","id","AiProductsHubCard","props","hostId","products","lastImport","applyProductCopy","createProductDrafts","createCategories","createDiscountDrafts","orgId","verdict","jobs","notice","start","follows","setStarted","picking","setPicking","picked","setPicked","brief","setBrief","busy","setBusy","handledImports","Set","startBulk","productIds","ids","slice","length","target","current","Boolean","has","key","add","options","heldNames","map","product","pickerRows","$id","status","photo","hasPhoto","pickerColumns","field","headerName","flex","minWidth","width","latest","find","bulkJob","catalogJob","categoriesJob","tooMany","help","excerpt","copy","kind","submitBrief","text","submitPicked","sx","border","borderColor","borderRadius","p","aria-label","spacing","direction","alignItems","variant","flexGrow","href","rel","xs","sm","size","disabled","onClick","severity","open","onClose","undefined","fullWidth","maxWidth","pt","color","rows","columns","disableColumnFilter","quickFilter","selectable","selected","onChange","multiline","minRows","value","event","helperText","toLocaleString","autoFocus","useFlexGap","flexWrap","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,mCAAkC;AAEjE,SAASC,SAAS,QAA6B,uDAAsD;AACrG,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,IAAI,EACJC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAEzE,SACEC,oBAAoB,EACpBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,mBAAmB,EACnBC,mBAAmB,EACnBC,wBAAwB,QACnB,0BAAsB;AAC7B,SAASC,gBAAgB,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,uCAAmC;AACzG,SAASC,iBAAiB,QAAQ,4BAAwB;AAE1D;;;;;;;;;;;;;;;;;CAiBC,GAED,MAAMC,kBAAkB;AAOxB,iCAAiC,GACjC,OAAO,MAAMC,yBAET;IACFC,SAAS;QACPC,OAAO;QACP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
|
columns: columns,
|
|
187
187
|
hideFooter: true,
|
|
188
|
+
disableColumnFilter: true,
|
|
188
189
|
quickFilter: false
|
|
189
190
|
}) : null,
|
|
190
191
|
gaps ? /*#__PURE__*/ _jsx(Alert, {
|
|
@@ -360,6 +361,7 @@ export function AiBulkCopyReview(props) {
|
|
|
360
361
|
rows: rows,
|
|
361
362
|
columns: columns,
|
|
362
363
|
hideFooter: true,
|
|
364
|
+
disableColumnFilter: true,
|
|
363
365
|
quickFilter: false,
|
|
364
366
|
getRowHeight: ()=>'auto',
|
|
365
367
|
selectable: {
|
|
@@ -510,6 +512,7 @@ export function AiBulkCopyReview(props) {
|
|
|
510
512
|
rows: categoryRows,
|
|
511
513
|
columns: categoryColumns,
|
|
512
514
|
hideFooter: true,
|
|
515
|
+
disableColumnFilter: true,
|
|
513
516
|
quickFilter: false,
|
|
514
517
|
selectable: {
|
|
515
518
|
selected: chosenCategories,
|
|
@@ -520,6 +523,7 @@ export function AiBulkCopyReview(props) {
|
|
|
520
523
|
rows: discountRows,
|
|
521
524
|
columns: discountColumns,
|
|
522
525
|
hideFooter: true,
|
|
526
|
+
disableColumnFilter: true,
|
|
523
527
|
quickFilter: false,
|
|
524
528
|
selectable: {
|
|
525
529
|
selected: chosenDiscounts,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-proposals.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { ConsoleProductsHubZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { Alert, Button, Chip, CircularProgress, Stack, Typography } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n aiProductCopyProposals,\n aiProductsBulkCount,\n aiProductsProposalOfKind,\n type AiProductCopyProposal,\n type AiProposedDiscount,\n} from '../model/ai-products'\nimport { aiProductCopyValues } from './ai-product-copy-card.component'\nimport { isAiJobMoving } from './use-ai-products-jobs'\n\n/**\n * The review tables of the products hub's AI card (AGL-2916): what a\n * `products` job proposed, row by row, before anything is written. Every\n * write is one the hub makes when a person asks for it — Apply, Apply to all,\n * Create drafts, Create selected — and the hub passes over what the site\n * already has, so a proposal applied twice creates nothing twice.\n */\n\n/** A column of a review table, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\nconst clip = (text: string, max: number) => (text.length > max ? `${text.slice(0, max - 1)}…` : text)\n\nconst messageOf = (error: unknown, fallback: string) =>\n error instanceof Error && error.message ? error.message : fallback\n\n/** A discount's offer, in the words the discounts card uses. */\nexport function aiDiscountOffer(discount: AiProposedDiscount): string {\n if (discount.kind === 'percent') return `${discount.valuePct ?? 0}% off`\n if (discount.kind === 'fixed') return `$${((discount.valueCents ?? 0) / 100).toFixed(2)} off`\n return 'Free shipping'\n}\n\nfunction JobState(props: { job: AiJobSummary; doing: string }) {\n const { job } = props\n if (isAiJobMoving(job)) {\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <CircularProgress size={16} aria-label={props.doing} />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {props.doing}\n </Typography>\n </Stack>\n )\n }\n return job.error ? <Alert severity={job.status === 'failed' ? 'error' : 'warning'}>{job.error}</Alert> : null\n}\n\n/* ------------------------------------------------------------------------ *\n * Copy for many products\n * ------------------------------------------------------------------------ */\n\ntype RowState = 'applying' | 'applied' | { error: string }\n\nexport function AiBulkCopyReview(props: {\n job: AiJobSummary\n applyProductCopy: ConsoleProductsHubZoneProps['applyProductCopy']\n}) {\n const { job, applyProductCopy } = props\n const proposals = aiProductCopyProposals(job)\n const asked = aiProductsBulkCount(job) ?? proposals.length\n const [rows, setRows] = useState<Record<string, RowState>>({})\n const [applyingAll, setApplyingAll] = useState(false)\n\n const ready = (proposal: AiProductCopyProposal) =>\n Boolean(proposal.values && proposal.product.id) && rows[proposal.product.id as string] !== 'applied'\n\n const apply = useCallback(\n async (proposal: AiProductCopyProposal) => {\n const id = proposal.product.id\n if (!id || !proposal.values) return\n setRows((current) => ({ ...current, [id]: 'applying' }))\n try {\n await applyProductCopy(id, aiProductCopyValues(proposal))\n setRows((current) => ({ ...current, [id]: 'applied' }))\n } catch (error) {\n setRows((current) => ({ ...current, [id]: { error: messageOf(error, 'The copy could not be saved.') } }))\n }\n },\n [applyProductCopy],\n )\n\n /** Applies each proposal in turn, so one refusal names its product and the rest still land. */\n const applyAll = useCallback(\n async (targets: readonly AiProductCopyProposal[]) => {\n setApplyingAll(true)\n try {\n for (const proposal of targets) await apply(proposal)\n } finally {\n setApplyingAll(false)\n }\n },\n [apply],\n )\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 160 },\n { field: 'description', headerName: 'Proposed description', flex: 2, minWidth: 220 },\n { field: 'seoTitle', headerName: 'Search title', flex: 1, minWidth: 160 },\n {\n field: 'actions',\n headerName: '',\n width: 170,\n sortable: false,\n renderCell: ({ row }: { row: { proposal: AiProductCopyProposal } }) => {\n const { proposal } = row\n if (proposal.skipped) return <Chip size=\"small\" variant=\"outlined\" label=\"Skipped\" title={proposal.skipped} />\n const state = proposal.product.id ? rows[proposal.product.id] : undefined\n if (state === 'applied') return <Chip size=\"small\" color=\"success\" variant=\"outlined\" label=\"Applied\" />\n if (typeof state === 'object') return <Chip size=\"small\" color=\"error\" variant=\"outlined\" label=\"Not saved\" title={state.error} />\n return (\n <Button size=\"small\" disabled={state === 'applying' || applyingAll} onClick={() => void apply(proposal)}>\n {'Apply'}\n </Button>\n )\n },\n },\n ],\n [rows, applyingAll, apply],\n )\n\n const tableRows = proposals.map((proposal) => ({\n $id: proposal.product.id ?? proposal.product.name,\n name: proposal.product.name,\n description: proposal.values ? clip(proposal.values.description, 140) : (proposal.skipped ?? ''),\n seoTitle: proposal.values?.seoTitle ?? '',\n proposal,\n }))\n const readyCount = proposals.filter(ready).length\n const errors = Object.values(rows).filter((state): state is { error: string } => typeof state === 'object')\n const gaps = proposals.filter((proposal) => proposal.gaps.length).length\n\n return (\n <Stack spacing={1} aria-label=\"Proposed product copy\">\n <Typography variant=\"subtitle2\">{`Product copy · ${proposals.length} of ${asked}`}</Typography>\n <JobState job={job} doing={`Writing copy: ${proposals.length} of ${asked}`} />\n {tableRows.length ? <ListTable rows={tableRows} columns={columns} hideFooter quickFilter={false} /> : null}\n {gaps ? (\n <Alert severity=\"warning\">\n {`${gaps} ${gaps === 1 ? 'description marks' : 'descriptions mark'} facts in [brackets] to fill in before you publish.`}\n </Alert>\n ) : null}\n {errors.length ? <Alert severity=\"error\">{errors[0].error}</Alert> : null}\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={!readyCount || applyingAll}\n onClick={() => void applyAll(proposals.filter(ready))}\n >\n {readyCount ? `Apply to all ${readyCount}` : 'Apply to all'}\n </Button>\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * A store's first products\n * ------------------------------------------------------------------------ */\n\nexport function AiCatalogReview(props: {\n job: AiJobSummary\n heldNames: ReadonlySet<string>\n createProductDrafts: ConsoleProductsHubZoneProps['createProductDrafts']\n}) {\n const { job, heldNames, createProductDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'catalog')\n const products = useMemo(() => proposal?.products ?? [], [proposal])\n const held = (name: string) => heldNames.has(name.replace(/\\s+/g, ' ').trim().toLowerCase())\n const [selected, setSelected] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n\n const rows = products.map((product, index) => ({\n $id: `p${index}`,\n name: product.name,\n type: product.type,\n options: product.options.map((option) => `${option.name}: ${option.values.join(', ')}`).join(' · ') || '—',\n photo: product.photo,\n inCatalog: held(product.name),\n product,\n }))\n const chosen = selected ?? rows.filter((row) => !row.inCatalog).map((row) => row.$id)\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'options', headerName: 'Options', flex: 1, minWidth: 160 },\n {\n field: 'price',\n headerName: 'Price',\n width: 130,\n sortable: false,\n // Never proposed: prices are the merchant's to set.\n renderCell: () => <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Set a price\" />,\n },\n {\n field: 'photo',\n headerName: 'Photo',\n flex: 1,\n minWidth: 200,\n sortable: false,\n renderCell: ({ row }: { row: { photo: string; inCatalog: boolean } }) => (\n <Stack spacing={0.25} sx={{ py: 0.5 }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Needs a photo\" sx={{ alignSelf: 'flex-start' }} />\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ whiteSpace: 'normal' }}>\n {row.photo}\n </Typography>\n </Stack>\n ),\n },\n {\n field: 'inCatalog',\n headerName: '',\n width: 150,\n sortable: false,\n renderCell: ({ row }: { row: { inCatalog: boolean } }) =>\n row.inCatalog ? <Chip size=\"small\" variant=\"outlined\" label=\"In your catalog\" /> : null,\n },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n const picks = rows.filter((row) => chosen.includes(row.$id)).map((row) => row.product)\n if (!picks.length) return\n setBusy(true)\n setResult(null)\n try {\n const created = await createProductDrafts(\n picks.map((product) => ({\n name: product.name,\n type: product.type,\n description: product.description,\n tags: product.tags,\n options: product.options,\n seoTitle: product.seoTitle,\n seoDescription: product.seoDescription,\n })),\n )\n const passed = picks.length - created.length\n setResult({\n severity: 'success',\n text:\n `Created ${created.length} draft ${created.length === 1 ? 'product' : 'products'}. ` +\n 'Each needs a price and a photo before you activate it.' +\n (passed ? ` ${passed} already in your catalog ${passed === 1 ? 'was' : 'were'} left as they are.` : ''),\n })\n setSelected([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The draft products could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [rows, chosen, createProductDrafts])\n\n return (\n <Stack spacing={1} aria-label=\"Proposed products\">\n <Typography variant=\"subtitle2\">{'Proposed products'}</Typography>\n <JobState job={job} doing=\"Proposing products from your brief\" />\n {rows.length ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Each is created as a draft with its price left empty and no photo. Set both in the product editor, ' +\n 'then activate it.'}\n </Typography>\n <ListTable\n rows={rows}\n columns={columns}\n hideFooter\n quickFilter={false}\n getRowHeight={() => 'auto'}\n selectable={{ selected: chosen, onChange: setSelected }}\n />\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !chosen.length}\n onClick={() => void create()}\n >\n {`Create ${chosen.length} ${chosen.length === 1 ? 'draft' : 'drafts'}`}\n </Button>\n </>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * Categories and discounts\n * ------------------------------------------------------------------------ */\n\nexport function AiCategoriesReview(props: {\n job: AiJobSummary\n createCategories: ConsoleProductsHubZoneProps['createCategories']\n createDiscountDrafts: ConsoleProductsHubZoneProps['createDiscountDrafts']\n}) {\n const { job, createCategories, createDiscountDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'categories')\n const categoryRows = (proposal?.categories ?? []).map((category, index) => ({\n $id: `c${index}`,\n name: category.name,\n why: category.why,\n }))\n const discountRows = (proposal?.discounts ?? []).map((discount, index) => ({\n $id: `d${index}`,\n name: discount.name,\n code: discount.code ?? 'Applies on its own',\n offer: aiDiscountOffer(discount),\n minimum: discount.minSubtotalCents ? `$${(discount.minSubtotalCents / 100).toFixed(2)}` : 'Any order',\n why: discount.why,\n discount,\n }))\n const [categories, setCategories] = useState<string[] | null>(null)\n const [discounts, setDiscounts] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n const chosenCategories = categories ?? categoryRows.map((row) => row.$id)\n const chosenDiscounts = discounts ?? discountRows.map((row) => row.$id)\n\n const categoryColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Category', flex: 1, minWidth: 160 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 220 },\n ],\n [],\n )\n const discountColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Discount', flex: 1, minWidth: 150 },\n { field: 'code', headerName: 'Code', width: 150 },\n { field: 'offer', headerName: 'Offer', width: 120 },\n { field: 'minimum', headerName: 'Minimum order', width: 130 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 200 },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n setBusy(true)\n setResult(null)\n try {\n const madeCategories = await createCategories(\n categoryRows.filter((row) => chosenCategories.includes(row.$id)).map((row) => row.name),\n )\n const madeDiscounts = await createDiscountDrafts(\n discountRows\n .filter((row) => chosenDiscounts.includes(row.$id))\n .map(({ discount }) => ({\n name: discount.name,\n code: discount.code,\n kind: discount.kind,\n valuePct: discount.valuePct,\n valueCents: discount.valueCents,\n minSubtotalCents: discount.minSubtotalCents,\n })),\n )\n setResult({\n severity: 'success',\n text:\n `Created ${madeCategories} ${madeCategories === 1 ? 'category' : 'categories'} and ` +\n `${madeDiscounts} ${madeDiscounts === 1 ? 'discount' : 'discounts'}. ` +\n 'Discounts start switched off: switch each on under Promotions when you are ready. ' +\n 'Anything your store already had was left as it is.',\n })\n setCategories([])\n setDiscounts([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The categories and discounts could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [categoryRows, discountRows, chosenCategories, chosenDiscounts, createCategories, createDiscountDrafts])\n\n const any = chosenCategories.length + chosenDiscounts.length\n return (\n <Stack spacing={1} aria-label=\"Proposed categories and discounts\">\n <Typography variant=\"subtitle2\">{'Proposed categories and discounts'}</Typography>\n <JobState job={job} doing=\"Proposing categories and discounts from your brief\" />\n {categoryRows.length ? (\n <ListTable\n rows={categoryRows}\n columns={categoryColumns}\n hideFooter\n quickFilter={false}\n selectable={{ selected: chosenCategories, onChange: setCategories }}\n />\n ) : null}\n {discountRows.length ? (\n <ListTable\n rows={discountRows}\n columns={discountColumns}\n hideFooter\n quickFilter={false}\n selectable={{ selected: chosenDiscounts, onChange: setDiscounts }}\n />\n ) : null}\n {categoryRows.length || discountRows.length ? (\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !any}\n onClick={() => void create()}\n >\n {'Create selected'}\n </Button>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n"],"names":["ListTable","Alert","Button","Chip","CircularProgress","Stack","Typography","useCallback","useMemo","useState","aiProductCopyProposals","aiProductsBulkCount","aiProductsProposalOfKind","aiProductCopyValues","isAiJobMoving","clip","text","max","length","slice","messageOf","error","fallback","Error","message","aiDiscountOffer","discount","kind","valuePct","valueCents","toFixed","JobState","props","job","direction","spacing","sx","alignItems","size","aria-label","doing","variant","color","severity","status","AiBulkCopyReview","applyProductCopy","proposals","asked","rows","setRows","applyingAll","setApplyingAll","ready","proposal","Boolean","values","product","id","apply","current","applyAll","targets","columns","field","headerName","flex","minWidth","width","sortable","renderCell","row","skipped","label","title","state","undefined","disabled","onClick","tableRows","map","$id","name","description","seoTitle","readyCount","filter","errors","Object","gaps","hideFooter","quickFilter","alignSelf","AiCatalogReview","heldNames","createProductDrafts","products","held","has","replace","trim","toLowerCase","selected","setSelected","busy","setBusy","result","setResult","index","type","options","option","join","photo","inCatalog","chosen","py","whiteSpace","create","picks","includes","created","tags","seoDescription","passed","getRowHeight","selectable","onChange","AiCategoriesReview","createCategories","createDiscountDrafts","categoryRows","categories","category","why","discountRows","discounts","code","offer","minimum","minSubtotalCents","setCategories","setDiscounts","chosenCategories","chosenDiscounts","categoryColumns","discountColumns","madeCategories","madeDiscounts","any"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAA6B,uDAAsD;AACrG,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACxF,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAEtD,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,wBAAwB,QAGnB,0BAAsB;AAC7B,SAASC,mBAAmB,QAAQ,sCAAkC;AACtE,SAASC,aAAa,QAAQ,4BAAwB;AAatD,MAAMC,OAAO,CAACC,MAAcC,MAAiBD,KAAKE,MAAM,GAAGD,MAAM,GAAGD,KAAKG,KAAK,CAAC,GAAGF,MAAM,GAAG,CAAC,CAAC,GAAGD;AAEhG,MAAMI,YAAY,CAACC,OAAgBC,WACjCD,iBAAiBE,SAASF,MAAMG,OAAO,GAAGH,MAAMG,OAAO,GAAGF;AAE5D,8DAA8D,GAC9D,OAAO,SAASG,gBAAgBC,QAA4B;QACfA,oBACCA;IAD5C,IAAIA,SAASC,IAAI,KAAK,WAAW,OAAO,IAAGD,qBAAAA,SAASE,QAAQ,YAAjBF,qBAAqB,EAAE,KAAK,CAAC;IACxE,IAAIA,SAASC,IAAI,KAAK,SAAS,OAAO,CAAC,CAAC,EAAE,AAAC,CAAA,EAACD,uBAAAA,SAASG,UAAU,YAAnBH,uBAAuB,KAAK,GAAE,EAAGI,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7F,OAAO;AACT;AAEA,SAASC,SAASC,KAA2C;IAC3D,MAAM,EAAEC,GAAG,EAAE,G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BAClB,KAAClB;gBACCiD,MAAMsF;gBACNxE,SAASmF;gBACTxD,UAAU;gBACVC,aAAa;gBACbmC,YAAY;oBAAExB,UAAU0C;oBAAiBjB,UAAUe;gBAAa;iBAEhE;YACHX,aAAajH,MAAM,IAAIqH,aAAarH,MAAM,iBACzC,KAAChB;gBACCoC,MAAK;gBACLG,SAAQ;gBACRL,IAAI;oBAAEwD,WAAW;gBAAa;gBAC9Bf,UAAU2B,QAAQ,CAAC6C;gBACnBvE,SAAS,IAAM,KAAKwC;0BAEnB;iBAED;YACHZ,uBAAS,KAACzG;gBAAM0C,UAAU+D,OAAO/D,QAAQ;0BAAG+D,OAAO1F,IAAI;iBAAY;;;AAG1E"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-products-proposals.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport type { ConsoleProductsHubZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { ListTable, type ListTableProps } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { Alert, Button, Chip, CircularProgress, Stack, Typography } from '@mui/material'\nimport { useCallback, useMemo, useState } from 'react'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport {\n aiProductCopyProposals,\n aiProductsBulkCount,\n aiProductsProposalOfKind,\n type AiProductCopyProposal,\n type AiProposedDiscount,\n} from '../model/ai-products'\nimport { aiProductCopyValues } from './ai-product-copy-card.component'\nimport { isAiJobMoving } from './use-ai-products-jobs'\n\n/**\n * The review tables of the products hub's AI card (AGL-2916): what a\n * `products` job proposed, row by row, before anything is written. Every\n * write is one the hub makes when a person asks for it — Apply, Apply to all,\n * Create drafts, Create selected — and the hub passes over what the site\n * already has, so a proposal applied twice creates nothing twice.\n *\n * Each table is one job's whole answer, held in hand and capped by the job\n * (`AI_PRODUCTS_BULK_MAX`, `AI_CATEGORIES_MAX`, `AI_DISCOUNTS_MAX`, a dozen\n * proposed products), so none offers a Filters panel or a search box: a\n * bounded readout is read whole, and a grid that filtered the rows it holds\n * is the pattern every list is leaving (AGL-3321).\n */\n\n/** A column of a review table, in the shared list table's own terms. */\ntype GridColDef = NonNullable<ListTableProps['columns']>[number]\n\nconst clip = (text: string, max: number) => (text.length > max ? `${text.slice(0, max - 1)}…` : text)\n\nconst messageOf = (error: unknown, fallback: string) =>\n error instanceof Error && error.message ? error.message : fallback\n\n/** A discount's offer, in the words the discounts card uses. */\nexport function aiDiscountOffer(discount: AiProposedDiscount): string {\n if (discount.kind === 'percent') return `${discount.valuePct ?? 0}% off`\n if (discount.kind === 'fixed') return `$${((discount.valueCents ?? 0) / 100).toFixed(2)} off`\n return 'Free shipping'\n}\n\nfunction JobState(props: { job: AiJobSummary; doing: string }) {\n const { job } = props\n if (isAiJobMoving(job)) {\n return (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <CircularProgress size={16} aria-label={props.doing} />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {props.doing}\n </Typography>\n </Stack>\n )\n }\n return job.error ? <Alert severity={job.status === 'failed' ? 'error' : 'warning'}>{job.error}</Alert> : null\n}\n\n/* ------------------------------------------------------------------------ *\n * Copy for many products\n * ------------------------------------------------------------------------ */\n\ntype RowState = 'applying' | 'applied' | { error: string }\n\nexport function AiBulkCopyReview(props: {\n job: AiJobSummary\n applyProductCopy: ConsoleProductsHubZoneProps['applyProductCopy']\n}) {\n const { job, applyProductCopy } = props\n const proposals = aiProductCopyProposals(job)\n const asked = aiProductsBulkCount(job) ?? proposals.length\n const [rows, setRows] = useState<Record<string, RowState>>({})\n const [applyingAll, setApplyingAll] = useState(false)\n\n const ready = (proposal: AiProductCopyProposal) =>\n Boolean(proposal.values && proposal.product.id) && rows[proposal.product.id as string] !== 'applied'\n\n const apply = useCallback(\n async (proposal: AiProductCopyProposal) => {\n const id = proposal.product.id\n if (!id || !proposal.values) return\n setRows((current) => ({ ...current, [id]: 'applying' }))\n try {\n await applyProductCopy(id, aiProductCopyValues(proposal))\n setRows((current) => ({ ...current, [id]: 'applied' }))\n } catch (error) {\n setRows((current) => ({ ...current, [id]: { error: messageOf(error, 'The copy could not be saved.') } }))\n }\n },\n [applyProductCopy],\n )\n\n /** Applies each proposal in turn, so one refusal names its product and the rest still land. */\n const applyAll = useCallback(\n async (targets: readonly AiProductCopyProposal[]) => {\n setApplyingAll(true)\n try {\n for (const proposal of targets) await apply(proposal)\n } finally {\n setApplyingAll(false)\n }\n },\n [apply],\n )\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 160 },\n { field: 'description', headerName: 'Proposed description', flex: 2, minWidth: 220 },\n { field: 'seoTitle', headerName: 'Search title', flex: 1, minWidth: 160 },\n {\n field: 'actions',\n headerName: '',\n width: 170,\n sortable: false,\n renderCell: ({ row }: { row: { proposal: AiProductCopyProposal } }) => {\n const { proposal } = row\n if (proposal.skipped) return <Chip size=\"small\" variant=\"outlined\" label=\"Skipped\" title={proposal.skipped} />\n const state = proposal.product.id ? rows[proposal.product.id] : undefined\n if (state === 'applied') return <Chip size=\"small\" color=\"success\" variant=\"outlined\" label=\"Applied\" />\n if (typeof state === 'object') return <Chip size=\"small\" color=\"error\" variant=\"outlined\" label=\"Not saved\" title={state.error} />\n return (\n <Button size=\"small\" disabled={state === 'applying' || applyingAll} onClick={() => void apply(proposal)}>\n {'Apply'}\n </Button>\n )\n },\n },\n ],\n [rows, applyingAll, apply],\n )\n\n const tableRows = proposals.map((proposal) => ({\n $id: proposal.product.id ?? proposal.product.name,\n name: proposal.product.name,\n description: proposal.values ? clip(proposal.values.description, 140) : (proposal.skipped ?? ''),\n seoTitle: proposal.values?.seoTitle ?? '',\n proposal,\n }))\n const readyCount = proposals.filter(ready).length\n const errors = Object.values(rows).filter((state): state is { error: string } => typeof state === 'object')\n const gaps = proposals.filter((proposal) => proposal.gaps.length).length\n\n return (\n <Stack spacing={1} aria-label=\"Proposed product copy\">\n <Typography variant=\"subtitle2\">{`Product copy · ${proposals.length} of ${asked}`}</Typography>\n <JobState job={job} doing={`Writing copy: ${proposals.length} of ${asked}`} />\n {tableRows.length ? <ListTable rows={tableRows} columns={columns} hideFooter disableColumnFilter quickFilter={false} /> : null}\n {gaps ? (\n <Alert severity=\"warning\">\n {`${gaps} ${gaps === 1 ? 'description marks' : 'descriptions mark'} facts in [brackets] to fill in before you publish.`}\n </Alert>\n ) : null}\n {errors.length ? <Alert severity=\"error\">{errors[0].error}</Alert> : null}\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={!readyCount || applyingAll}\n onClick={() => void applyAll(proposals.filter(ready))}\n >\n {readyCount ? `Apply to all ${readyCount}` : 'Apply to all'}\n </Button>\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * A store's first products\n * ------------------------------------------------------------------------ */\n\nexport function AiCatalogReview(props: {\n job: AiJobSummary\n heldNames: ReadonlySet<string>\n createProductDrafts: ConsoleProductsHubZoneProps['createProductDrafts']\n}) {\n const { job, heldNames, createProductDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'catalog')\n const products = useMemo(() => proposal?.products ?? [], [proposal])\n const held = (name: string) => heldNames.has(name.replace(/\\s+/g, ' ').trim().toLowerCase())\n const [selected, setSelected] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n\n const rows = products.map((product, index) => ({\n $id: `p${index}`,\n name: product.name,\n type: product.type,\n options: product.options.map((option) => `${option.name}: ${option.values.join(', ')}`).join(' · ') || '—',\n photo: product.photo,\n inCatalog: held(product.name),\n product,\n }))\n const chosen = selected ?? rows.filter((row) => !row.inCatalog).map((row) => row.$id)\n\n const columns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Product', flex: 1, minWidth: 180 },\n { field: 'options', headerName: 'Options', flex: 1, minWidth: 160 },\n {\n field: 'price',\n headerName: 'Price',\n width: 130,\n sortable: false,\n // Never proposed: prices are the merchant's to set.\n renderCell: () => <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Set a price\" />,\n },\n {\n field: 'photo',\n headerName: 'Photo',\n flex: 1,\n minWidth: 200,\n sortable: false,\n renderCell: ({ row }: { row: { photo: string; inCatalog: boolean } }) => (\n <Stack spacing={0.25} sx={{ py: 0.5 }}>\n <Chip size=\"small\" color=\"warning\" variant=\"outlined\" label=\"Needs a photo\" sx={{ alignSelf: 'flex-start' }} />\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ whiteSpace: 'normal' }}>\n {row.photo}\n </Typography>\n </Stack>\n ),\n },\n {\n field: 'inCatalog',\n headerName: '',\n width: 150,\n sortable: false,\n renderCell: ({ row }: { row: { inCatalog: boolean } }) =>\n row.inCatalog ? <Chip size=\"small\" variant=\"outlined\" label=\"In your catalog\" /> : null,\n },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n const picks = rows.filter((row) => chosen.includes(row.$id)).map((row) => row.product)\n if (!picks.length) return\n setBusy(true)\n setResult(null)\n try {\n const created = await createProductDrafts(\n picks.map((product) => ({\n name: product.name,\n type: product.type,\n description: product.description,\n tags: product.tags,\n options: product.options,\n seoTitle: product.seoTitle,\n seoDescription: product.seoDescription,\n })),\n )\n const passed = picks.length - created.length\n setResult({\n severity: 'success',\n text:\n `Created ${created.length} draft ${created.length === 1 ? 'product' : 'products'}. ` +\n 'Each needs a price and a photo before you activate it.' +\n (passed ? ` ${passed} already in your catalog ${passed === 1 ? 'was' : 'were'} left as they are.` : ''),\n })\n setSelected([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The draft products could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [rows, chosen, createProductDrafts])\n\n return (\n <Stack spacing={1} aria-label=\"Proposed products\">\n <Typography variant=\"subtitle2\">{'Proposed products'}</Typography>\n <JobState job={job} doing=\"Proposing products from your brief\" />\n {rows.length ? (\n <>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Each is created as a draft with its price left empty and no photo. Set both in the product editor, ' +\n 'then activate it.'}\n </Typography>\n <ListTable\n rows={rows}\n columns={columns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n getRowHeight={() => 'auto'}\n selectable={{ selected: chosen, onChange: setSelected }}\n />\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !chosen.length}\n onClick={() => void create()}\n >\n {`Create ${chosen.length} ${chosen.length === 1 ? 'draft' : 'drafts'}`}\n </Button>\n </>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n\n/* ------------------------------------------------------------------------ *\n * Categories and discounts\n * ------------------------------------------------------------------------ */\n\nexport function AiCategoriesReview(props: {\n job: AiJobSummary\n createCategories: ConsoleProductsHubZoneProps['createCategories']\n createDiscountDrafts: ConsoleProductsHubZoneProps['createDiscountDrafts']\n}) {\n const { job, createCategories, createDiscountDrafts } = props\n const proposal = aiProductsProposalOfKind(job, 'categories')\n const categoryRows = (proposal?.categories ?? []).map((category, index) => ({\n $id: `c${index}`,\n name: category.name,\n why: category.why,\n }))\n const discountRows = (proposal?.discounts ?? []).map((discount, index) => ({\n $id: `d${index}`,\n name: discount.name,\n code: discount.code ?? 'Applies on its own',\n offer: aiDiscountOffer(discount),\n minimum: discount.minSubtotalCents ? `$${(discount.minSubtotalCents / 100).toFixed(2)}` : 'Any order',\n why: discount.why,\n discount,\n }))\n const [categories, setCategories] = useState<string[] | null>(null)\n const [discounts, setDiscounts] = useState<string[] | null>(null)\n const [busy, setBusy] = useState(false)\n const [result, setResult] = useState<{ severity: 'success' | 'error'; text: string } | null>(null)\n const chosenCategories = categories ?? categoryRows.map((row) => row.$id)\n const chosenDiscounts = discounts ?? discountRows.map((row) => row.$id)\n\n const categoryColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Category', flex: 1, minWidth: 160 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 220 },\n ],\n [],\n )\n const discountColumns = useMemo<GridColDef[]>(\n () => [\n { field: 'name', headerName: 'Discount', flex: 1, minWidth: 150 },\n { field: 'code', headerName: 'Code', width: 150 },\n { field: 'offer', headerName: 'Offer', width: 120 },\n { field: 'minimum', headerName: 'Minimum order', width: 130 },\n { field: 'why', headerName: 'Why', flex: 2, minWidth: 200 },\n ],\n [],\n )\n\n const create = useCallback(async () => {\n setBusy(true)\n setResult(null)\n try {\n const madeCategories = await createCategories(\n categoryRows.filter((row) => chosenCategories.includes(row.$id)).map((row) => row.name),\n )\n const madeDiscounts = await createDiscountDrafts(\n discountRows\n .filter((row) => chosenDiscounts.includes(row.$id))\n .map(({ discount }) => ({\n name: discount.name,\n code: discount.code,\n kind: discount.kind,\n valuePct: discount.valuePct,\n valueCents: discount.valueCents,\n minSubtotalCents: discount.minSubtotalCents,\n })),\n )\n setResult({\n severity: 'success',\n text:\n `Created ${madeCategories} ${madeCategories === 1 ? 'category' : 'categories'} and ` +\n `${madeDiscounts} ${madeDiscounts === 1 ? 'discount' : 'discounts'}. ` +\n 'Discounts start switched off: switch each on under Promotions when you are ready. ' +\n 'Anything your store already had was left as it is.',\n })\n setCategories([])\n setDiscounts([])\n } catch (error) {\n setResult({ severity: 'error', text: messageOf(error, 'The categories and discounts could not be created.') })\n } finally {\n setBusy(false)\n }\n }, [categoryRows, discountRows, chosenCategories, chosenDiscounts, createCategories, createDiscountDrafts])\n\n const any = chosenCategories.length + chosenDiscounts.length\n return (\n <Stack spacing={1} aria-label=\"Proposed categories and discounts\">\n <Typography variant=\"subtitle2\">{'Proposed categories and discounts'}</Typography>\n <JobState job={job} doing=\"Proposing categories and discounts from your brief\" />\n {categoryRows.length ? (\n <ListTable\n rows={categoryRows}\n columns={categoryColumns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: chosenCategories, onChange: setCategories }}\n />\n ) : null}\n {discountRows.length ? (\n <ListTable\n rows={discountRows}\n columns={discountColumns}\n hideFooter\n disableColumnFilter\n quickFilter={false}\n selectable={{ selected: chosenDiscounts, onChange: setDiscounts }}\n />\n ) : null}\n {categoryRows.length || discountRows.length ? (\n <Button\n size=\"small\"\n variant=\"contained\"\n sx={{ alignSelf: 'flex-start' }}\n disabled={busy || !any}\n onClick={() => void create()}\n >\n {'Create selected'}\n </Button>\n ) : null}\n {result ? <Alert severity={result.severity}>{result.text}</Alert> : null}\n </Stack>\n )\n}\n"],"names":["ListTable","Alert","Button","Chip","CircularProgress","Stack","Typography","useCallback","useMemo","useState","aiProductCopyProposals","aiProductsBulkCount","aiProductsProposalOfKind","aiProductCopyValues","isAiJobMoving","clip","text","max","length","slice","messageOf","error","fallback","Error","message","aiDiscountOffer","discount","kind","valuePct","valueCents","toFixed","JobState","props","job","direction","spacing","sx","alignItems","size","aria-label","doing","variant","color","severity","status","AiBulkCopyReview","applyProductCopy","proposals","asked","rows","setRows","applyingAll","setApplyingAll","ready","proposal","Boolean","values","product","id","apply","current","applyAll","targets","columns","field","headerName","flex","minWidth","width","sortable","renderCell","row","skipped","label","title","state","undefined","disabled","onClick","tableRows","map","$id","name","description","seoTitle","readyCount","filter","errors","Object","gaps","hideFooter","disableColumnFilter","quickFilter","alignSelf","AiCatalogReview","heldNames","createProductDrafts","products","held","has","replace","trim","toLowerCase","selected","setSelected","busy","setBusy","result","setResult","index","type","options","option","join","photo","inCatalog","chosen","py","whiteSpace","create","picks","includes","created","tags","seoDescription","passed","getRowHeight","selectable","onChange","AiCategoriesReview","createCategories","createDiscountDrafts","categoryRows","categories","category","why","discountRows","discounts","code","offer","minimum","minSubtotalCents","setCategories","setDiscounts","chosenCategories","chosenDiscounts","categoryColumns","discountColumns","madeCategories","madeDiscounts","any"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,SAAS,QAA6B,uDAAsD;AACrG,SAASC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACxF,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAEtD,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,wBAAwB,QAGnB,0BAAsB;AAC7B,SAASC,mBAAmB,QAAQ,sCAAkC;AACtE,SAASC,aAAa,QAAQ,4BAAwB;AAmBtD,MAAMC,OAAO,CAACC,MAAcC,MAAiBD,KAAKE,MAAM,GAAGD,MAAM,GAAGD,KAAKG,KAAK,CAAC,GAAGF,MAAM,GAAG,CAAC,CAAC,GAAGD;AAEhG,MAAMI,YAAY,CAACC,OAAgBC,WACjCD,iBAAiBE,SAASF,MAAMG,OAAO,GAAGH,MAAMG,OAAO,GAAGF;AAE5D,8DAA8D,GAC9D,OAAO,SAASG,gBAAgBC,QAA4B;QACfA,oBACCA;IAD5C,IAAIA,SAASC,IAAI,KAAK,WAAW,OAAO,IAAGD,qBAAAA,SAASE,QAAQ,YAAjBF,qBAAqB,EAAE,KAAK,CAAC;IACxE,IAAIA,SAASC,IAAI,KAAK,SAAS,OAAO,CAAC,CAAC,EAAE,AAAC,CAAA,EAACD,uBAAAA,SAASG,UAAU,YAAnBH,uBAAuB,KAAK,GAAE,EAAGI,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7F,OAAO;AACT;AAEA,SAASC,SAASC,KAA2C;IAC3D,MAAM,EAAEC,GAAG,EAAE,GAAGD;IAChB,IAAIlB,cAAcmB,MAAM;QACtB,qBACE,MAAC5B;YAAM6B,WAAU;YAAMC,SAAS;YAAGC,IAAI;gBAAEC,YAAY;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AmB;gBACnBC,aAAa;gBACbmC,YAAY;oBAAExB,UAAU0C;oBAAiBjB,UAAUe;gBAAa;iBAEhE;YACHX,aAAalH,MAAM,IAAIsH,aAAatH,MAAM,iBACzC,KAAChB;gBACCoC,MAAK;gBACLG,SAAQ;gBACRL,IAAI;oBAAEyD,WAAW;gBAAa;gBAC9BhB,UAAU4B,QAAQ,CAAC6C;gBACnBxE,SAAS,IAAM,KAAKyC;0BAEnB;iBAED;YACHZ,uBAAS,KAAC1G;gBAAM0C,UAAUgE,OAAOhE,QAAQ;0BAAGgE,OAAO3F,IAAI;iBAAY;;;AAG1E"}
|
|
@@ -314,7 +314,11 @@ export function AiSiteBatchCard(props) {
|
|
|
314
314
|
rows: runJobs,
|
|
315
315
|
columns: runColumns,
|
|
316
316
|
getRowId: (job)=>job.id,
|
|
317
|
-
rowHeight: TABLE_ROW_HEIGHT
|
|
317
|
+
rowHeight: TABLE_ROW_HEIGHT,
|
|
318
|
+
// One run's sites, at most `AI_SITE_BATCH_MAX`, read whole: a
|
|
319
|
+
// bounded readout offers no filter to narrow it (AGL-3321).
|
|
320
|
+
disableColumnFilter: true,
|
|
321
|
+
quickFilter: false
|
|
318
322
|
})
|
|
319
323
|
]
|
|
320
324
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-batch-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport { lockdownRefusalText, parseLockdownRefusal } from '@aglyn/aglyn'\nimport type { ConsoleOrgSitesZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\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 Chip,\n CircularProgress,\n Collapse,\n MenuItem,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n TextField,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n AI_JOB_TERMINAL_STATUSES,\n type AiJobStatus,\n type AiJobSummary,\n} from '../model/ai-jobs.types'\nimport {\n AI_SITE_BATCH_MAX,\n AI_SITE_PAGES,\n AI_SITE_SUBMISSION_CHOICES,\n aiSiteCreditEstimate,\n type AiSiteSubmissions,\n} from '../model/ai-site-job'\n\n/**\n * The agency batch (AGL-2911), on the organization's Sites page: one brief,\n * with the business name, the city and the brand changed per site, started\n * across many of the org's sites at once.\n *\n * What it starts are ordinary site scaffolds. Each plans first and waits for\n * its own confirmation in the Assist panel before it builds anything, and\n * everything it then builds is a draft — so this card publishes nothing and\n * changes no live site, however many sites it is pointed at.\n *\n * The estimate beside the button is the guard rail the issue asks for: what\n * one site is estimated to cost, and what the whole run is, before a credit\n * is spent on any of it.\n *\n * Where a contact form's submissions go is asked once for the run and binds\n * every site's form step (AGL-2918), in the words the guided start asks it\n * in: one decision, worded once, whether it is asked of one site or twenty.\n */\n\n/** Jobs the card reads to find the batches this workspace has run. */\nconst RECENT_JOBS_READ = 100\n\n/** A batch over one site is a scaffold; the card is for the other case. */\nconst MIN_SITES = 2\n\nconst STATUS_LABEL: Record<AiJobStatus, string> = {\n queued: 'Queued',\n running: 'Running',\n needs_input: 'Needs attention',\n needs_review: 'Confirm the plan',\n done: 'Done',\n failed: 'Failed',\n canceled: 'Canceled',\n}\n\nconst STATUS_COLOR: Record<\n AiJobStatus,\n 'default' | 'primary' | 'success' | 'error' | 'warning'\n> = {\n queued: 'default',\n running: 'primary',\n needs_input: 'warning',\n needs_review: 'warning',\n done: 'success',\n failed: 'error',\n canceled: 'default',\n}\n\n/** A site's per-run variables, as the member typed them. */\nexport interface AiSiteBatchRow {\n hostId: string\n picked: boolean\n businessName: string\n city: string\n brand: string\n}\n\ntype Verdict = 'checking' | 'ready' | 'hidden'\n\nconst isTerminal = (job: AiJobSummary) =>\n AI_JOB_TERMINAL_STATUSES.includes(job.status)\n\n/** The jobs of one batch, newest batch first, as the list route serves them. */\nexport function aiSiteBatchJobs(\n jobs: readonly AiJobSummary[],\n batchId: string | null,\n): AiJobSummary[] {\n if (!batchId) return []\n return jobs.filter((job) => job.batch === batchId)\n}\n\n/** The batch a list of jobs most recently ran, or `null` when none did. */\nexport function aiLatestSiteBatch(\n jobs: readonly AiJobSummary[],\n): string | null {\n return jobs.find((job) => job.kind === 'site' && job.batch)?.batch ?? null\n}\n\nexport function AiSiteBatchCard(\n props: ConsoleOrgSitesZoneProps,\n): JSX.Element | null {\n const { orgMount, basePath } = props\n const { orgId, hosts, hostsReady } = orgMount\n const { data: user } = useUser()\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid ?? null\n const orgSlug = basePath.split('/').filter(Boolean)[0] ?? ''\n\n const [verdict, setVerdict] = useState<Verdict>('checking')\n const [open, setOpen] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n const [busy, setBusy] = useState(false)\n const [brief, setBrief] = useState('')\n const [businessType, setBusinessType] = useState('')\n const [pages, setPages] = useState<number>(AI_SITE_PAGES.min + 1)\n const [welcomeEmail, setWelcomeEmail] = useState(true)\n /*\n * One routing answer for the whole run. It starts on the Inbox — what every\n * submission does anyway — because filing a lead as well is the addition,\n * and an addition is the thing somebody should have to choose.\n */\n const [submissions, setSubmissions] = useState<AiSiteSubmissions>('inbox')\n const [rows, setRows] = useState<AiSiteBatchRow[]>([])\n const [batchId, setBatchId] = useState<string | null>(null)\n const [jobs, setJobs] = useState<AiJobSummary[]>([])\n\n // One row per site the page resolved for this reader, kept as the list moves.\n useEffect(() => {\n setRows((current) => {\n const byId = new Map(current.map((row) => [row.hostId, row]))\n return hosts.map(\n (host) =>\n byId.get(host.id) ?? {\n hostId: host.id,\n picked: false,\n businessName: host.name,\n city: '',\n brand: '',\n },\n )\n })\n }, [hosts])\n\n const load = useCallback(async () => {\n if (!orgId) return\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&limit=${RECENT_JOBS_READ}`,\n )\n // The generative doors answer 404 behind their release flag and 403\n // without the add-on: a feature that is not released does not exist.\n if (response.status === 404 || response.status === 403)\n return 'hidden' as const\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked ? lockdownRefusalText(locked) : String(payload?.error ?? ''),\n )\n return 'ready' as const\n }\n const listed = (payload?.jobs ?? []) as AiJobSummary[]\n setJobs(listed)\n setBatchId((current) => current ?? aiLatestSiteBatch(listed))\n return 'ready' as const\n }, [orgId])\n\n useEffect(() => {\n if (!orgId || !uid) return\n let active = true\n setVerdict('checking')\n void (async () => {\n try {\n const answer = await load()\n if (active && answer) setVerdict(answer)\n } catch {\n if (active) setVerdict('ready')\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, uid, load])\n\n const picked = useMemo(() => rows.filter((row) => row.picked), [rows])\n const perSite = aiSiteCreditEstimate(pages, { welcomeEmail })\n const runJobs = useMemo(() => aiSiteBatchJobs(jobs, batchId), [jobs, batchId])\n const siteName = useCallback(\n (hostId: string | null) =>\n hosts.find((host) => host.id === hostId)?.name ?? 'This site',\n [hosts],\n )\n const siteHref = useCallback(\n (hostId: string | null) => {\n const subdomain = hosts.find((host) => host.id === hostId)?.subdomain\n return subdomain ? `${orgMount.hostsPath}/${subdomain}` : null\n },\n [hosts, orgMount.hostsPath],\n )\n /*\n * One row per job of the run. A job has no page of its own — it is\n * confirmed and followed in the Assist panel — so the row opens nothing,\n * and the site it built for is a link when the console has an address for\n * that site.\n */\n const runColumns = useMemo<GridColDef<AiJobSummary>[]>(\n () => [\n {\n field: 'site',\n headerName: 'Site',\n flex: 1,\n minWidth: 180,\n valueGetter: (_value, job) => siteName(job.hostId),\n renderCell: ({ row: job }) => {\n const href = siteHref(job.hostId)\n return href ? (\n <AppLink href={href}>{siteName(job.hostId)}</AppLink>\n ) : (\n siteName(job.hostId)\n )\n },\n },\n {\n field: 'status',\n headerName: 'Status',\n width: 180,\n valueGetter: (_value, job) => STATUS_LABEL[job.status],\n renderCell: ({ row: job }) => (\n <Chip\n size=\"small\"\n label={STATUS_LABEL[job.status]}\n color={STATUS_COLOR[job.status]}\n />\n ),\n },\n {\n field: 'drafts',\n headerName: 'Drafts',\n type: 'number',\n align: 'right',\n headerAlign: 'right',\n width: 100,\n valueGetter: (_value, job) =>\n isTerminal(job) || job.outputs.length ? job.outputs.length : null,\n valueFormatter: (value: number | null) =>\n value === null ? '—' : String(value),\n },\n ],\n [siteHref, siteName],\n )\n\n const update = (hostId: string, patch: Partial<AiSiteBatchRow>) =>\n setRows((current) =>\n current.map((row) =>\n row.hostId === hostId ? { ...row, ...patch } : row,\n ),\n )\n\n const start = useCallback(async () => {\n if (!orgId || !picked.length) return\n setBusy(true)\n setNotice(null)\n try {\n const response = await authorizedFetch(\n userRef.current,\n '/api/ai/jobs/batch',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n brief,\n businessType,\n pages,\n welcomeEmail,\n submissions,\n sites: picked.map((row) => ({\n hostId: row.hostId,\n businessName: row.businessName,\n city: row.city,\n brand: row.brand,\n })),\n }),\n },\n )\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The sites could not be started.'),\n )\n return\n }\n setBatchId(String(payload?.batchId ?? '') || null)\n setJobs((payload?.jobs ?? []) as AiJobSummary[])\n setOpen(false)\n const refused = (payload?.refused ?? []) as Array<{\n hostId: string\n error: string\n }>\n if (refused.length) {\n setNotice(\n refused\n .map((entry) => `${siteName(entry.hostId)}: ${entry.error}`)\n .join(' · '),\n )\n }\n } catch {\n setNotice('The sites could not be started.')\n } finally {\n setBusy(false)\n }\n }, [\n orgId,\n picked,\n brief,\n businessType,\n pages,\n welcomeEmail,\n submissions,\n siteName,\n ])\n\n if (verdict !== 'ready' || !hostsReady || hosts.length < MIN_SITES)\n return null\n\n return (\n <CardDisplay\n contentGutterX\n contentGutterY\n HeaderProps={{\n title: 'Generate sites with AI',\n subheader:\n 'One brief across many of your sites. Each site plans first and waits for you to ' +\n 'confirm it; everything it builds is a draft.',\n }}\n >\n <Stack spacing={2}>\n {notice && <Alert severity=\"info\">{notice}</Alert>}\n {runJobs.length > 0 && (\n <Box>\n <Typography variant=\"subtitle2\" gutterBottom>\n {`Last run · ${runJobs.length} ${runJobs.length === 1 ? 'site' : 'sites'}`}\n </Typography>\n <ListTable\n aria-label=\"Sites in this run\"\n rows={runJobs}\n columns={runColumns}\n getRowId={(job: AiJobSummary) => job.id}\n rowHeight={TABLE_ROW_HEIGHT}\n />\n </Box>\n )}\n <Box>\n <Button\n variant={open ? 'text' : 'contained'}\n onClick={() => setOpen(!open)}\n >\n {open ? 'Close' : 'Generate for several sites'}\n </Button>\n </Box>\n <Collapse in={open} unmountOnExit>\n <Stack spacing={2}>\n <TextField\n label=\"What these sites are for\"\n placeholder=\"A neighborhood dog groomer that takes bookings\"\n multiline\n minRows={2}\n value={brief}\n onChange={(event) => setBrief(event.target.value)}\n />\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField\n label=\"Kind of business\"\n placeholder=\"dog groomer\"\n value={businessType}\n onChange={(event) => setBusinessType(event.target.value)}\n sx={{ flex: 1 }}\n />\n <TextField\n select\n label=\"Pages per site\"\n value={pages}\n onChange={(event) => setPages(Number(event.target.value))}\n sx={{ minWidth: 160 }}\n >\n {Array.from(\n { length: AI_SITE_PAGES.max - AI_SITE_PAGES.min + 1 },\n (_, index) => AI_SITE_PAGES.min + index,\n ).map((count) => (\n <MenuItem key={count} value={count}>\n {count}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n select\n label=\"Welcome email\"\n value={welcomeEmail ? 'yes' : 'no'}\n onChange={(event) =>\n setWelcomeEmail(event.target.value === 'yes')\n }\n sx={{ minWidth: 160 }}\n >\n <MenuItem value=\"yes\">{'Draft one'}</MenuItem>\n <MenuItem value=\"no\">{'No'}</MenuItem>\n </TextField>\n </Stack>\n {/*\n Asked of the run, not of each site (AGL-2918): the forms a batch\n makes are the same form, and where a submission goes is the one\n thing about a contact form a model cannot know. Left unasked,\n twenty sites each kept a proposal nobody made.\n */}\n <TextField\n select\n fullWidth\n label=\"Where do form submissions go?\"\n value={submissions}\n onChange={(event) =>\n setSubmissions(event.target.value as AiSiteSubmissions)\n }\n helperText=\"The same for every site in this run. You can change it on any form afterwards.\"\n >\n {AI_SITE_SUBMISSION_CHOICES.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {`${option.label} — ${option.blurb}`}\n </MenuItem>\n ))}\n </TextField>\n <ScrollTable size=\"small\" aria-label=\"Sites to generate for\">\n <TableHead>\n <TableRow>\n <TableCell padding=\"checkbox\" />\n <TableCell>{'Site'}</TableCell>\n <TableCell>{'Business name'}</TableCell>\n <TableCell>{'City'}</TableCell>\n <TableCell>{'Brand'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {rows.map((row) => (\n <TableRow key={row.hostId}>\n <TableCell padding=\"checkbox\">\n <Checkbox\n checked={row.picked}\n slotProps={{\n input: {\n 'aria-label': `Generate for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, { picked: event.target.checked })\n }\n />\n </TableCell>\n <TableCell>{siteName(row.hostId)}</TableCell>\n <TableCell>\n <TextField\n size=\"small\"\n variant=\"standard\"\n value={row.businessName}\n slotProps={{\n htmlInput: {\n 'aria-label': `Business name for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, {\n businessName: event.target.value,\n })\n }\n />\n </TableCell>\n <TableCell>\n <TextField\n size=\"small\"\n variant=\"standard\"\n value={row.city}\n slotProps={{\n htmlInput: {\n 'aria-label': `City for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, { city: event.target.value })\n }\n />\n </TableCell>\n <TableCell>\n <TextField\n size=\"small\"\n variant=\"standard\"\n value={row.brand}\n slotProps={{\n htmlInput: {\n 'aria-label': `Brand for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, { brand: event.target.value })\n }\n />\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {picked.length\n ? `Estimated cost: about ${perSite.toLocaleString('en-US')} credits a site, ` +\n `${(perSite * picked.length).toLocaleString('en-US')} for ${picked.length} ` +\n `${picked.length === 1 ? 'site' : 'sites'}. What each site really costs is ` +\n 'what its own steps spend.'\n : `Pick up to ${AI_SITE_BATCH_MAX} sites.`}\n </Typography>\n <Box>\n <Button\n variant=\"contained\"\n disabled={\n busy ||\n !brief.trim() ||\n !businessType.trim() ||\n picked.length === 0 ||\n picked.length > AI_SITE_BATCH_MAX\n }\n onClick={() => void start()}\n startIcon={busy ? <CircularProgress size={16} /> : undefined}\n >\n {picked.length\n ? `Generate for ${picked.length} ${picked.length === 1 ? 'site' : 'sites'}`\n : 'Generate'}\n </Button>\n </Box>\n {orgSlug && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {\n 'Each site waits for you to confirm its plan in the assistant panel.'\n }\n </Typography>\n )}\n </Stack>\n </Collapse>\n </Stack>\n </CardDisplay>\n )\n}\n\nexport default AiSiteBatchCard\n"],"names":["lockdownRefusalText","parseLockdownRefusal","AppLink","CardDisplay","ListTable","ScrollTable","TABLE_ROW_HEIGHT","authorizedFetch","useUser","Alert","Box","Button","Checkbox","Chip","CircularProgress","Collapse","MenuItem","Stack","TableBody","TableCell","TableHead","TableRow","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_JOB_TERMINAL_STATUSES","AI_SITE_BATCH_MAX","AI_SITE_PAGES","AI_SITE_SUBMISSION_CHOICES","aiSiteCreditEstimate","RECENT_JOBS_READ","MIN_SITES","STATUS_LABEL","queued","running","needs_input","needs_review","done","failed","canceled","STATUS_COLOR","isTerminal","job","includes","status","aiSiteBatchJobs","jobs","batchId","filter","batch","aiLatestSiteBatch","find","kind","AiSiteBatchCard","props","basePath","orgMount","orgId","hosts","hostsReady","data","user","userRef","current","uid","orgSlug","split","Boolean","verdict","setVerdict","open","setOpen","notice","setNotice","busy","setBusy","brief","setBrief","businessType","setBusinessType","pages","setPages","min","welcomeEmail","setWelcomeEmail","submissions","setSubmissions","rows","setRows","setBatchId","setJobs","byId","Map","map","row","hostId","host","get","id","picked","businessName","name","city","brand","load","response","encodeURIComponent","payload","json","catch","ok","locked","String","error","listed","active","answer","perSite","runJobs","siteName","siteHref","subdomain","hostsPath","runColumns","field","headerName","flex","minWidth","valueGetter","_value","renderCell","href","width","size","label","color","type","align","headerAlign","outputs","length","valueFormatter","value","update","patch","start","method","headers","body","JSON","stringify","sites","refused","entry","join","contentGutterX","contentGutterY","HeaderProps","title","subheader","spacing","severity","variant","gutterBottom","aria-label","columns","getRowId","rowHeight","onClick","in","unmountOnExit","placeholder","multiline","minRows","onChange","event","target","direction","xs","sm","sx","select","Number","Array","from","max","_","index","count","fullWidth","helperText","option","blurb","padding","checked","slotProps","input","htmlInput","toLocaleString","disabled","trim","startIcon","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC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AQ,iCAAiC,CAAC,GAC5E,8BACA,CAAC,WAAW,EAAElH,kBAAkB,OAAO,CAAC;;0CAE9C,KAACpB;0CACC,cAAA,KAACC;oCACC2J,SAAQ;oCACRqC,UACE7H,QACA,CAACE,MAAM4H,IAAI,MACX,CAAC1H,aAAa0H,IAAI,MAClBrG,OAAOyC,MAAM,KAAK,KAClBzC,OAAOyC,MAAM,GAAGlH;oCAElB8I,SAAS,IAAM,KAAKvB;oCACpBwD,WAAW/H,qBAAO,KAAChE;wCAAiB2H,MAAM;yCAASqE;8CAElDvG,OAAOyC,MAAM,GACV,CAAC,aAAa,EAAEzC,OAAOyC,MAAM,CAAC,CAAC,EAAEzC,OAAOyC,MAAM,KAAK,IAAI,SAAS,SAAS,GACzE;;;4BAGP3E,yBACC,KAAC9C;gCAAW+I,SAAQ;gCAAU3B,OAAM;0CAEhC;;;;;;;;AASlB;AAEA,eAAelF,gBAAe"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-site-batch-card.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport { lockdownRefusalText, parseLockdownRefusal } from '@aglyn/aglyn'\nimport type { ConsoleOrgSitesZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { AppLink, CardDisplay } from '@aglyn/shared-ui-jsx'\nimport { ListTable } from '@aglyn/shared-ui-jsx/components/list-table.component'\nimport { ScrollTable } from '@aglyn/shared-ui-jsx/components/scroll-table.component'\nimport { TABLE_ROW_HEIGHT } from '@aglyn/shared-ui-jsx/const/table-pagination'\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 Chip,\n CircularProgress,\n Collapse,\n MenuItem,\n Stack,\n TableBody,\n TableCell,\n TableHead,\n TableRow,\n TextField,\n Typography,\n} from '@mui/material'\nimport type { GridColDef } from '@mui/x-data-grid'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport {\n AI_JOB_TERMINAL_STATUSES,\n type AiJobStatus,\n type AiJobSummary,\n} from '../model/ai-jobs.types'\nimport {\n AI_SITE_BATCH_MAX,\n AI_SITE_PAGES,\n AI_SITE_SUBMISSION_CHOICES,\n aiSiteCreditEstimate,\n type AiSiteSubmissions,\n} from '../model/ai-site-job'\n\n/**\n * The agency batch (AGL-2911), on the organization's Sites page: one brief,\n * with the business name, the city and the brand changed per site, started\n * across many of the org's sites at once.\n *\n * What it starts are ordinary site scaffolds. Each plans first and waits for\n * its own confirmation in the Assist panel before it builds anything, and\n * everything it then builds is a draft — so this card publishes nothing and\n * changes no live site, however many sites it is pointed at.\n *\n * The estimate beside the button is the guard rail the issue asks for: what\n * one site is estimated to cost, and what the whole run is, before a credit\n * is spent on any of it.\n *\n * Where a contact form's submissions go is asked once for the run and binds\n * every site's form step (AGL-2918), in the words the guided start asks it\n * in: one decision, worded once, whether it is asked of one site or twenty.\n */\n\n/** Jobs the card reads to find the batches this workspace has run. */\nconst RECENT_JOBS_READ = 100\n\n/** A batch over one site is a scaffold; the card is for the other case. */\nconst MIN_SITES = 2\n\nconst STATUS_LABEL: Record<AiJobStatus, string> = {\n queued: 'Queued',\n running: 'Running',\n needs_input: 'Needs attention',\n needs_review: 'Confirm the plan',\n done: 'Done',\n failed: 'Failed',\n canceled: 'Canceled',\n}\n\nconst STATUS_COLOR: Record<\n AiJobStatus,\n 'default' | 'primary' | 'success' | 'error' | 'warning'\n> = {\n queued: 'default',\n running: 'primary',\n needs_input: 'warning',\n needs_review: 'warning',\n done: 'success',\n failed: 'error',\n canceled: 'default',\n}\n\n/** A site's per-run variables, as the member typed them. */\nexport interface AiSiteBatchRow {\n hostId: string\n picked: boolean\n businessName: string\n city: string\n brand: string\n}\n\ntype Verdict = 'checking' | 'ready' | 'hidden'\n\nconst isTerminal = (job: AiJobSummary) =>\n AI_JOB_TERMINAL_STATUSES.includes(job.status)\n\n/** The jobs of one batch, newest batch first, as the list route serves them. */\nexport function aiSiteBatchJobs(\n jobs: readonly AiJobSummary[],\n batchId: string | null,\n): AiJobSummary[] {\n if (!batchId) return []\n return jobs.filter((job) => job.batch === batchId)\n}\n\n/** The batch a list of jobs most recently ran, or `null` when none did. */\nexport function aiLatestSiteBatch(\n jobs: readonly AiJobSummary[],\n): string | null {\n return jobs.find((job) => job.kind === 'site' && job.batch)?.batch ?? null\n}\n\nexport function AiSiteBatchCard(\n props: ConsoleOrgSitesZoneProps,\n): JSX.Element | null {\n const { orgMount, basePath } = props\n const { orgId, hosts, hostsReady } = orgMount\n const { data: user } = useUser()\n const userRef = useRef(user)\n userRef.current = user\n const uid = user?.uid ?? null\n const orgSlug = basePath.split('/').filter(Boolean)[0] ?? ''\n\n const [verdict, setVerdict] = useState<Verdict>('checking')\n const [open, setOpen] = useState(false)\n const [notice, setNotice] = useState<string | null>(null)\n const [busy, setBusy] = useState(false)\n const [brief, setBrief] = useState('')\n const [businessType, setBusinessType] = useState('')\n const [pages, setPages] = useState<number>(AI_SITE_PAGES.min + 1)\n const [welcomeEmail, setWelcomeEmail] = useState(true)\n /*\n * One routing answer for the whole run. It starts on the Inbox — what every\n * submission does anyway — because filing a lead as well is the addition,\n * and an addition is the thing somebody should have to choose.\n */\n const [submissions, setSubmissions] = useState<AiSiteSubmissions>('inbox')\n const [rows, setRows] = useState<AiSiteBatchRow[]>([])\n const [batchId, setBatchId] = useState<string | null>(null)\n const [jobs, setJobs] = useState<AiJobSummary[]>([])\n\n // One row per site the page resolved for this reader, kept as the list moves.\n useEffect(() => {\n setRows((current) => {\n const byId = new Map(current.map((row) => [row.hostId, row]))\n return hosts.map(\n (host) =>\n byId.get(host.id) ?? {\n hostId: host.id,\n picked: false,\n businessName: host.name,\n city: '',\n brand: '',\n },\n )\n })\n }, [hosts])\n\n const load = useCallback(async () => {\n if (!orgId) return\n const response = await authorizedFetch(\n userRef.current,\n `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&limit=${RECENT_JOBS_READ}`,\n )\n // The generative doors answer 404 behind their release flag and 403\n // without the add-on: a feature that is not released does not exist.\n if (response.status === 404 || response.status === 403)\n return 'hidden' as const\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked ? lockdownRefusalText(locked) : String(payload?.error ?? ''),\n )\n return 'ready' as const\n }\n const listed = (payload?.jobs ?? []) as AiJobSummary[]\n setJobs(listed)\n setBatchId((current) => current ?? aiLatestSiteBatch(listed))\n return 'ready' as const\n }, [orgId])\n\n useEffect(() => {\n if (!orgId || !uid) return\n let active = true\n setVerdict('checking')\n void (async () => {\n try {\n const answer = await load()\n if (active && answer) setVerdict(answer)\n } catch {\n if (active) setVerdict('ready')\n }\n })()\n return () => {\n active = false\n }\n }, [orgId, uid, load])\n\n const picked = useMemo(() => rows.filter((row) => row.picked), [rows])\n const perSite = aiSiteCreditEstimate(pages, { welcomeEmail })\n const runJobs = useMemo(() => aiSiteBatchJobs(jobs, batchId), [jobs, batchId])\n const siteName = useCallback(\n (hostId: string | null) =>\n hosts.find((host) => host.id === hostId)?.name ?? 'This site',\n [hosts],\n )\n const siteHref = useCallback(\n (hostId: string | null) => {\n const subdomain = hosts.find((host) => host.id === hostId)?.subdomain\n return subdomain ? `${orgMount.hostsPath}/${subdomain}` : null\n },\n [hosts, orgMount.hostsPath],\n )\n /*\n * One row per job of the run. A job has no page of its own — it is\n * confirmed and followed in the Assist panel — so the row opens nothing,\n * and the site it built for is a link when the console has an address for\n * that site.\n */\n const runColumns = useMemo<GridColDef<AiJobSummary>[]>(\n () => [\n {\n field: 'site',\n headerName: 'Site',\n flex: 1,\n minWidth: 180,\n valueGetter: (_value, job) => siteName(job.hostId),\n renderCell: ({ row: job }) => {\n const href = siteHref(job.hostId)\n return href ? (\n <AppLink href={href}>{siteName(job.hostId)}</AppLink>\n ) : (\n siteName(job.hostId)\n )\n },\n },\n {\n field: 'status',\n headerName: 'Status',\n width: 180,\n valueGetter: (_value, job) => STATUS_LABEL[job.status],\n renderCell: ({ row: job }) => (\n <Chip\n size=\"small\"\n label={STATUS_LABEL[job.status]}\n color={STATUS_COLOR[job.status]}\n />\n ),\n },\n {\n field: 'drafts',\n headerName: 'Drafts',\n type: 'number',\n align: 'right',\n headerAlign: 'right',\n width: 100,\n valueGetter: (_value, job) =>\n isTerminal(job) || job.outputs.length ? job.outputs.length : null,\n valueFormatter: (value: number | null) =>\n value === null ? '—' : String(value),\n },\n ],\n [siteHref, siteName],\n )\n\n const update = (hostId: string, patch: Partial<AiSiteBatchRow>) =>\n setRows((current) =>\n current.map((row) =>\n row.hostId === hostId ? { ...row, ...patch } : row,\n ),\n )\n\n const start = useCallback(async () => {\n if (!orgId || !picked.length) return\n setBusy(true)\n setNotice(null)\n try {\n const response = await authorizedFetch(\n userRef.current,\n '/api/ai/jobs/batch',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n brief,\n businessType,\n pages,\n welcomeEmail,\n submissions,\n sites: picked.map((row) => ({\n hostId: row.hostId,\n businessName: row.businessName,\n city: row.city,\n brand: row.brand,\n })),\n }),\n },\n )\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice(\n locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The sites could not be started.'),\n )\n return\n }\n setBatchId(String(payload?.batchId ?? '') || null)\n setJobs((payload?.jobs ?? []) as AiJobSummary[])\n setOpen(false)\n const refused = (payload?.refused ?? []) as Array<{\n hostId: string\n error: string\n }>\n if (refused.length) {\n setNotice(\n refused\n .map((entry) => `${siteName(entry.hostId)}: ${entry.error}`)\n .join(' · '),\n )\n }\n } catch {\n setNotice('The sites could not be started.')\n } finally {\n setBusy(false)\n }\n }, [\n orgId,\n picked,\n brief,\n businessType,\n pages,\n welcomeEmail,\n submissions,\n siteName,\n ])\n\n if (verdict !== 'ready' || !hostsReady || hosts.length < MIN_SITES)\n return null\n\n return (\n <CardDisplay\n contentGutterX\n contentGutterY\n HeaderProps={{\n title: 'Generate sites with AI',\n subheader:\n 'One brief across many of your sites. Each site plans first and waits for you to ' +\n 'confirm it; everything it builds is a draft.',\n }}\n >\n <Stack spacing={2}>\n {notice && <Alert severity=\"info\">{notice}</Alert>}\n {runJobs.length > 0 && (\n <Box>\n <Typography variant=\"subtitle2\" gutterBottom>\n {`Last run · ${runJobs.length} ${runJobs.length === 1 ? 'site' : 'sites'}`}\n </Typography>\n <ListTable\n aria-label=\"Sites in this run\"\n rows={runJobs}\n columns={runColumns}\n getRowId={(job: AiJobSummary) => job.id}\n rowHeight={TABLE_ROW_HEIGHT}\n // One run's sites, at most `AI_SITE_BATCH_MAX`, read whole: a\n // bounded readout offers no filter to narrow it (AGL-3321).\n disableColumnFilter\n quickFilter={false}\n />\n </Box>\n )}\n <Box>\n <Button\n variant={open ? 'text' : 'contained'}\n onClick={() => setOpen(!open)}\n >\n {open ? 'Close' : 'Generate for several sites'}\n </Button>\n </Box>\n <Collapse in={open} unmountOnExit>\n <Stack spacing={2}>\n <TextField\n label=\"What these sites are for\"\n placeholder=\"A neighborhood dog groomer that takes bookings\"\n multiline\n minRows={2}\n value={brief}\n onChange={(event) => setBrief(event.target.value)}\n />\n <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField\n label=\"Kind of business\"\n placeholder=\"dog groomer\"\n value={businessType}\n onChange={(event) => setBusinessType(event.target.value)}\n sx={{ flex: 1 }}\n />\n <TextField\n select\n label=\"Pages per site\"\n value={pages}\n onChange={(event) => setPages(Number(event.target.value))}\n sx={{ minWidth: 160 }}\n >\n {Array.from(\n { length: AI_SITE_PAGES.max - AI_SITE_PAGES.min + 1 },\n (_, index) => AI_SITE_PAGES.min + index,\n ).map((count) => (\n <MenuItem key={count} value={count}>\n {count}\n </MenuItem>\n ))}\n </TextField>\n <TextField\n select\n label=\"Welcome email\"\n value={welcomeEmail ? 'yes' : 'no'}\n onChange={(event) =>\n setWelcomeEmail(event.target.value === 'yes')\n }\n sx={{ minWidth: 160 }}\n >\n <MenuItem value=\"yes\">{'Draft one'}</MenuItem>\n <MenuItem value=\"no\">{'No'}</MenuItem>\n </TextField>\n </Stack>\n {/*\n Asked of the run, not of each site (AGL-2918): the forms a batch\n makes are the same form, and where a submission goes is the one\n thing about a contact form a model cannot know. Left unasked,\n twenty sites each kept a proposal nobody made.\n */}\n <TextField\n select\n fullWidth\n label=\"Where do form submissions go?\"\n value={submissions}\n onChange={(event) =>\n setSubmissions(event.target.value as AiSiteSubmissions)\n }\n helperText=\"The same for every site in this run. You can change it on any form afterwards.\"\n >\n {AI_SITE_SUBMISSION_CHOICES.map((option) => (\n <MenuItem key={option.id} value={option.id}>\n {`${option.label} — ${option.blurb}`}\n </MenuItem>\n ))}\n </TextField>\n <ScrollTable size=\"small\" aria-label=\"Sites to generate for\">\n <TableHead>\n <TableRow>\n <TableCell padding=\"checkbox\" />\n <TableCell>{'Site'}</TableCell>\n <TableCell>{'Business name'}</TableCell>\n <TableCell>{'City'}</TableCell>\n <TableCell>{'Brand'}</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {rows.map((row) => (\n <TableRow key={row.hostId}>\n <TableCell padding=\"checkbox\">\n <Checkbox\n checked={row.picked}\n slotProps={{\n input: {\n 'aria-label': `Generate for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, { picked: event.target.checked })\n }\n />\n </TableCell>\n <TableCell>{siteName(row.hostId)}</TableCell>\n <TableCell>\n <TextField\n size=\"small\"\n variant=\"standard\"\n value={row.businessName}\n slotProps={{\n htmlInput: {\n 'aria-label': `Business name for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, {\n businessName: event.target.value,\n })\n }\n />\n </TableCell>\n <TableCell>\n <TextField\n size=\"small\"\n variant=\"standard\"\n value={row.city}\n slotProps={{\n htmlInput: {\n 'aria-label': `City for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, { city: event.target.value })\n }\n />\n </TableCell>\n <TableCell>\n <TextField\n size=\"small\"\n variant=\"standard\"\n value={row.brand}\n slotProps={{\n htmlInput: {\n 'aria-label': `Brand for ${siteName(row.hostId)}`,\n },\n }}\n onChange={(event) =>\n update(row.hostId, { brand: event.target.value })\n }\n />\n </TableCell>\n </TableRow>\n ))}\n </TableBody>\n </ScrollTable>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {picked.length\n ? `Estimated cost: about ${perSite.toLocaleString('en-US')} credits a site, ` +\n `${(perSite * picked.length).toLocaleString('en-US')} for ${picked.length} ` +\n `${picked.length === 1 ? 'site' : 'sites'}. What each site really costs is ` +\n 'what its own steps spend.'\n : `Pick up to ${AI_SITE_BATCH_MAX} sites.`}\n </Typography>\n <Box>\n <Button\n variant=\"contained\"\n disabled={\n busy ||\n !brief.trim() ||\n !businessType.trim() ||\n picked.length === 0 ||\n picked.length > AI_SITE_BATCH_MAX\n }\n onClick={() => void start()}\n startIcon={busy ? <CircularProgress size={16} /> : undefined}\n >\n {picked.length\n ? `Generate for ${picked.length} ${picked.length === 1 ? 'site' : 'sites'}`\n : 'Generate'}\n </Button>\n </Box>\n {orgSlug && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {\n 'Each site waits for you to confirm its plan in the assistant panel.'\n }\n </Typography>\n )}\n </Stack>\n </Collapse>\n </Stack>\n </CardDisplay>\n )\n}\n\nexport default AiSiteBatchCard\n"],"names":["lockdownRefusalText","parseLockdownRefusal","AppLink","CardDisplay","ListTable","ScrollTable","TABLE_ROW_HEIGHT","authorizedFetch","useUser","Alert","Box","Button","Checkbox","Chip","CircularProgress","Collapse","MenuItem","Stack","TableBody","TableCell","TableHead","TableRow","TextField","Typography","useCallback","useEffect","useMemo","useRef","useState","AI_JOB_TERMINAL_STATUSES","AI_SITE_BATCH_MAX","AI_SITE_PAGES","AI_SITE_SUBMISSION_CHOICES","aiSiteCreditEstimate","RECENT_JOBS_READ","MIN_SITES","STATUS_LABEL","queued","running","needs_input","needs_review","done","failed","canceled","STATUS_COLOR","isTerminal","job","includes","status","aiSiteBatchJobs","jobs","batchId","filter","batch","aiLatestSiteBatch","find","kind","AiSiteBatchCard","props","basePath","orgMount","orgId","hosts","hostsReady","data","user","userRef","current","uid","orgSlug","split","Boolean","verdict","setVerdict","open","setOpen","notice","setNotice","busy","setBusy","brief","setBrief","businessType","setBusinessType","pages","setPages","min","welcomeEmail","setWelcomeEmail","submissions","setSubmissions","rows","setRows","setBatchId","setJobs","byId","Map","map","row","hostId","host","get","id","picked","businessName","name","city","brand","load","response","encodeURIComponent","payload","json","catch","ok","locked","String","error","listed","active","answer","perSite","runJobs","siteName","siteHref","subdomain","hostsPath","runColumns","field","headerName","flex","minWidth","valueGetter","_value","renderCell","href","width","size","label","color","type","align","headerAlign","outputs","length","valueFormatter","value","update","patch","start","method","headers","body","JSON","stringify","sites","refused","entry","join","contentGutterX","contentGutterY","HeaderProps","title","subheader","spacing","severity","variant","gutterBottom","aria-label","columns","getRowId","rowHeight","disableColumnFilter","quickFilter","onClick","in","unmountOnExit","placeholder","multiline","minRows","onChange","event","target","direction","xs","sm","sx","select","Number","Array","from","max","_","index","count","fullWidth","helperText","option","blurb","padding","checked","slotProps","input","htmlInput","toLocaleString","disabled","trim","startIcon","undefined"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,mBAAmB,EAAEC,oBAAoB,QAAQ,eAAc;AAExE,SAASC,OAAO,EAAEC,WAAW,QAAQ,uBAAsB;A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C,WAAW,EAAElH,kBAAkB,OAAO,CAAC;;0CAE9C,KAACpB;0CACC,cAAA,KAACC;oCACC2J,SAAQ;oCACRuC,UACE/H,QACA,CAACE,MAAM8H,IAAI,MACX,CAAC5H,aAAa4H,IAAI,MAClBvG,OAAOyC,MAAM,KAAK,KAClBzC,OAAOyC,MAAM,GAAGlH;oCAElBgJ,SAAS,IAAM,KAAKzB;oCACpB0D,WAAWjI,qBAAO,KAAChE;wCAAiB2H,MAAM;yCAASuE;8CAElDzG,OAAOyC,MAAM,GACV,CAAC,aAAa,EAAEzC,OAAOyC,MAAM,CAAC,CAAC,EAAEzC,OAAOyC,MAAM,KAAK,IAAI,SAAS,SAAS,GACzE;;;4BAGP3E,yBACC,KAAC9C;gCAAW+I,SAAQ;gCAAU3B,OAAM;0CAEhC;;;;;;;;AASlB;AAEA,eAAelF,gBAAe"}
|
|
@@ -16,6 +16,12 @@ export declare function aiAllotmentTone(row: Pick<AiAllotmentRowWire, 'credits'
|
|
|
16
16
|
*
|
|
17
17
|
* Read with `billing.view`; the controls appear with `billing.manage`, and
|
|
18
18
|
* the route refuses a write without it whatever this card draws.
|
|
19
|
+
*
|
|
20
|
+
* The three tables are the route's whole answer — the roster the plan's
|
|
21
|
+
* seats bound, the organization's sites, the collaborator allotments — so
|
|
22
|
+
* they offer no Filters panel and no search: a bounded readout is read
|
|
23
|
+
* whole, and a grid that narrowed the rows it holds is the pattern every
|
|
24
|
+
* list is leaving (AGL-3321).
|
|
19
25
|
*/
|
|
20
26
|
export declare function BillingAiAllotments({ orgId }: {
|
|
21
27
|
orgId?: string;
|