Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
feat(cms): connect a brand's Wix site from Settings › Integrations and send pages to it from Send to CMS (#1331) (#1749)
Cihan0b721ce78258
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 4d493bb42..fb8158849 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -4663,6 +4663,12 @@"failed": "The last send to WordPress failed, {when}","published": "Published {when}"},+ "wix": {+ "queued": "Sending to Wix since {when}",+ "sent": "In Wix as a draft post since {when}",+ "failed": "The last send to Wix failed, {when}",+ "published": "Published {when}"+ },"framer": {"queued": "Sending to Framer since {when}","sent": "In Framer as a draft item since {when}",@@ -4681,6 +4687,7 @@"description": "Each page goes to the brand's webhook as it is ready to publish, with the slug and meta of its last send, else the page's. Open a page in the editor to change them.","descriptionWebflow": "Each page goes to {collection} in Webflow as a draft item, as it is ready to publish, with the slug and meta of its last send, else the page's. Open a page in the editor to change them.","descriptionWordPress": "Each page goes to {site} in WordPress as a draft post, as it is ready to publish, with the slug and meta description (as its excerpt) of its last send, else the page's. Open a page in the editor to change them. A page whose post is already published or scheduled goes as a new draft post. The meta title and JSON-LD aren't sent: set them in your SEO plugin.",+ "descriptionWix": "Each page goes to {site}'s Wix Blog as a draft post, as it is ready to publish, with its slug, meta title, meta description and JSON-LD as the post's SEO settings. Images aren't sent: add them in Wix. A page whose post is already published updates its draft there; you publish the changes in Wix.","descriptionFramer": "Each page goes to {collection} in Framer as a draft item, as it is ready to publish, with the slug and meta of its last send, else the page's. Open a page in the editor to change them. A page whose item isn't a draft is updated there: the change goes live with your next publish of the site. Images aren't sent yet.","readFailed": "Couldn't read the pages. Try again.","retry": "Try again",@@ -4713,6 +4720,7 @@"skipped": "{count, plural, one {# page wasn't sent} other {# pages weren't sent}}: the workspace has sent 200 pages in the last 24 hours. Try again later.","inProgress": "A page is already on its way to Webflow. Wait for it, then send again.","inProgressWordPress": "A page is already on its way to WordPress. Wait for it, then send again.",+ "inProgressWix": "A page is already on its way to Wix. Wait for it, then send again.","inProgressFramer": "A page is already on its way to Framer. Wait for it, then send again.","close": "Close","cancel": "Cancel",@@ -5814,6 +5822,7 @@"description": "The page goes to the brand's webhook, for your workflow tool (Zapier, Make, n8n) to publish it in your CMS.","descriptionWebflow": "The page goes to {collection} in Webflow as a draft item, with its slug and meta. You publish it in Webflow.","descriptionWordPress": "The page goes to {site} in WordPress as a draft post, with its slug, and its meta description as the excerpt. The meta title isn't sent: set it in your SEO plugin. You publish it in WordPress.",+ "descriptionWix": "The page goes to {site}'s Wix Blog as a draft post, with its slug, and its meta title, meta description and JSON-LD as the post's SEO settings. You publish it in Wix.","descriptionFramer": "The page goes to {collection} in Framer as a draft item, with its slug and meta. Images aren't sent yet. You publish it in Framer.","descriptionReading": "The page goes to your CMS with its slug and meta, kept on the page.","target": {@@ -5835,12 +5844,18 @@"collection": "your collection","notReady": "Not ready: connect it again or pick its collection and fields in Settings › Integrations"},+ "wix": {+ "title": "Wix",+ "hint": "A draft post on {site}'s Blog",+ "notReady": "API key refused: connect Wix again in Settings › Integrations"+ },"webhook": {"title": "Your workflow","hint": "The brand's webhook (Zapier, Make, n8n)"},"unchecked": "Couldn't check Webflow just now, so this send goes to your workflow.","uncheckedWordPress": "Couldn't check WordPress just now, so this send goes to your workflow.",+ "uncheckedWix": "Couldn't check Wix just now, so this send goes to your workflow.","uncheckedFramer": "Couldn't check Framer just now, so this send goes to your workflow.","retry": "Try again"},@@ -5883,6 +5898,12 @@"failed": "The last send to WordPress failed, {when}.","published": "Published {when}."},+ "lastWix": {+ "queued": "Last sent to Wix {when}, still on its way.",+ "sent": "In Wix as a draft post since {when}.",+ "failed": "The last send to Wix failed, {when}.",+ "published": "Published {when}."+ },"lastFramer": {"queued": "Last sent to Framer {when}, still on its way.","sent": "In Framer as a draft item since {when}.",@@ -5909,11 +5930,17 @@"in_progress": "This page is already on its way to Webflow. Wait for it, then send again.","no_webhookWebflow": "This brand's Webflow isn't ready, and it has no webhook. Connect Webflow again or pick its collection in Settings › Integrations.","wordpressFailed": "WordPress didn't take the page: {reason}",+ "wixFailed": "Wix didn't take the page: {reason}","wordpress_not_configured": "WordPress isn't set up on this server. Send to your workflow instead.","no_wordpress": "Connect WordPress in Settings › Integrations first.","wordpress_refused": "WordPress refused the sign-in. Connect it again in Settings › Integrations.",+ "wix_not_configured": "Wix isn't set up on this server. Send to your workflow instead.",+ "no_wix": "Connect Wix in Settings › Integrations first.",+ "wix_refused": "Wix refused the API key. Connect it again in Settings › Integrations.","in_progressWordPress": "This page is already on its way to WordPress. Wait for it, then send again.",+ "in_progressWix": "This page is already on its way to Wix. Wait for it, then send again.","no_webhookWordPress": "This brand's WordPress refused the sign-in, and it has no webhook. Connect WordPress again in Settings › Integrations.",+ "no_webhookWix": "This brand's Wix refused the API key, and it has no webhook. Connect Wix again in Settings › Integrations.","framerFailed": "Framer didn't take the page: {reason}","framer_not_configured": "Framer isn't set up on this server. Send to your workflow instead.","no_framer": "Connect Framer in Settings › Integrations first.",@@ -5936,7 +5963,10 @@"sentFramer": "Sent to Framer as a draft item","sentFramerUpdated": "Updated in Framer","framerImages": "{images, plural, one {# image wasn't sent: add it in Framer.} other {# images weren't sent: add them in Framer.}}",- "framerLive": "The item isn't a draft in Framer, so the change goes live with your next publish of the site."+ "framerLive": "The item isn't a draft in Framer, so the change goes live with your next publish of the site.",+ "sentWix": "Sent to Wix as a draft post",+ "sentWixUpdated": "Draft post updated in Wix",+ "wixImages": "{images, plural, one {# image wasn't sent: add it in Wix.} other {# images weren't sent: add them in Wix.}}"},"rulesChip": "Rules {met}/{total}","rulesChipReading": "Rules · reading",@@ -10298,6 +10328,49 @@"failed": "Couldn't reach Framer. Try again later."}},+ "wix": {+ "title": "Wix",+ "description": "Send to CMS puts {brand}'s pages on its Wix site's Blog as draft posts. You publish them in Wix.",+ "noBrand": "Pick a brand to connect its Wix site.",+ "unavailable": "Couldn't read the Wix connection right now.",+ "notConfigured": "Wix isn't set up on this server yet.",+ "connected": "Connected",+ "refused": "API key refused",+ "site": "Site: {site}",+ "notConnectedMember": "Not connected. Admins and managers can connect Wix.",+ "refusedMember": "Wix refused the API key. Pages can't go there until an admin or manager connects it again.",+ "pagesGoTo": "Pages go to {site}'s Blog as draft posts.",+ "siteLabel": "Site id",+ "sitePlaceholder": "The site's id, or its dashboard address",+ "keyLabel": "API key",+ "keyPlaceholder": "Paste the API key",+ "keyHint": "In Wix, the site's owner makes it: Account Settings › API Keys Manager › Generate API Key, with this site picked and the Manage Blog (Wix Blog) and Manage Ricos Document (Ricos) permissions. The site id is the long code after manage.wix.com/dashboard/ in the dashboard's address. The key is kept encrypted by our API, never shown again. Ansvisor writes drafts only.",+ "connect": "Connect",+ "connecting": "Checking the site…",+ "connectedToast": "Wix connected",+ "refusedNote": "Wix refused the saved API key. Connect it again to send pages.",+ "replace": "Change API key",+ "cancel": "Cancel",+ "disconnect": "Disconnect",+ "disconnectTitle": "Disconnect Wix?",+ "disconnectDescription": "Pages stop going to Wix and its API key is deleted here. Posts already sent stay in Wix. To end the key itself, delete it in Wix's API Keys Manager.",+ "disconnected": "Wix disconnected. Delete the API key in Wix's API Keys Manager too.",+ "errors": {+ "not_configured": "Wix isn't set up on this server yet.",+ "invalid": "Check the site id (it's in the dashboard's address) and that you pasted the whole API key.",+ "forbidden": "Only admins and managers can change the Wix connection.",+ "auth_failed": "Wix refused the API key. Check it and try again.",+ "no_access": "The API key isn't allowed to write the site's Blog. Give it the Wix Blog permissions in the API Keys Manager.",+ "no_ricos_permission": "The key needs the Ricos permission (Manage Ricos Document) too: Wix uses it to turn pages into posts. Add it to the key in the API Keys Manager, then connect again.",+ "no_blog": "This site has no Wix Blog. Add the Blog to the site first.",+ "no_member": "Wix needs a site member to own the posts. Write one post on the Blog as the site's owner, then connect again.",+ "unreachable": "Wix couldn't be reached. Try again later.",+ "session": "Your session expired. Sign in again.",+ "workspace": "This brand isn't in your workspace.",+ "busy": "Too many requests. Wait a few minutes.",+ "failed": "Couldn't reach Wix. Try again later."+ }+ },"integrations_connected": "Connected","integrations_notConfigured": "Not configured","integrations_comingSoon": "Coming soon",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsxindex 1e8e13e7d..9cb339ce9 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx@@ -119,6 +119,7 @@ export function BulkSendDialog({webflow,wordpress,framer,+ wix,target,pick,sent: keepTarget,@@ -133,6 +134,7 @@ export function BulkSendDialog({const framerCollection = framer?.ready? framer.collection || tEditor('send.target.framer.collection'): '';+ const wixSite = wix?.ready ? wix.site : '';useEffect(() => {let cancelled = false;@@ -322,14 +324,23 @@ export function BulkSendDialog({? 'inProgressWordPress': to === 'framer'? 'inProgressFramer'- : 'inProgress',+ : to === 'wix'+ ? 'inProgressWix'+ : 'inProgress',);}// No CMS ready sent the pages to the webhook: what to fix is the one connected.- if (code === 'no_webhook' && !webflow?.ready && !wordpress?.ready && !framer?.ready) {+ if (+ code === 'no_webhook' &&+ !webflow?.ready &&+ !wordpress?.ready &&+ !framer?.ready &&+ !wix?.ready+ ) {if (webflow) return tEditor('send.errors.no_webhookWebflow');if (wordpress) return tEditor('send.errors.no_webhookWordPress');if (framer) return tEditor('send.errors.no_webhookFramer');+ if (wix) return tEditor('send.errors.no_webhookWix');}return tEditor(`send.errors.${code}`);};@@ -359,17 +370,20 @@ export function BulkSendDialog({? t('descriptionWordPress', { site }): target === 'framer'? t('descriptionFramer', { collection: framerCollection })- : t('description')}+ : target === 'wix'+ ? t('descriptionWix', { site: wixSite })+ : t('description')}</DialogDescription></DialogHeader>{/* Where the pages go, before they go: a CMS once Settings has it ready. */}- {(webflow || wordpress || framer) && target && !after && (+ {(webflow || wordpress || framer || wix) && target && !after && (<CmsTargetPickervalue={target}webflow={webflow}wordpress={wordpress}framer={framer}+ wix={wix}disabled={phase.kind === 'sending'}onChange={(next) => {pick(next);diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsxindex a28bf2345..95e5fdc5f 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx@@ -389,7 +389,10 @@ function CmsStatusMark({ status }: { status: CmsStatus }) {const live = status.status === 'published' ? status.publishedUrl : null;// A send to a CMS (#1331, phase 2) says so: sent, it's a draft item or post there.const label = t(- status.target === 'webflow' || status.target === 'wordpress' || status.target === 'framer'+ status.target === 'webflow' ||+ status.target === 'wordpress' ||+ status.target === 'framer' ||+ status.target === 'wix'? `${status.target}.${status.status}`: status.status,{ when },diff --git a/web/src/components/content/cms-target.tsx b/web/src/components/content/cms-target.tsxindex 73c8e66ca..ca8e73ca9 100644--- a/web/src/components/content/cms-target.tsx+++ b/web/src/components/content/cms-target.tsx@@ -8,17 +8,19 @@ import { cn } from '@/lib/utils';import type { CmsTarget } from '@/lib/content/cms-send-client';import { readFramer } from '@/lib/framer-client';import { readWebflow } from '@/lib/webflow-client';+import { readWix } from '@/lib/wix-client';import { readWordPress } from '@/lib/wordpress-client';/*** Where Send to CMS sends (#1331, phase 2): the brand's webhook, its* Webflow collection once Settings › Integrations has it ready (connected,* a collection with a body field), its WordPress site once connected- * (00294; no collection or fields to pick there), or its Framer collection+ * (00294; no collection or fields to pick there), its Framer collection* once ready (00295; connected, a collection with its title and body- * fields). The choice, picked or sent to, is remembered per brand, in this- * browser; the first ready of Webflow, WordPress and Framer is the first- * choice where none is remembered, or the remembered one is no longer+ * fields), or its Wix site's Blog once connected (00372; its API key not+ * refused). The choice, picked or sent to, is remembered per brand, in this+ * browser; the first ready of Webflow, WordPress, Framer and Wix is the+ * first choice where none is remembered, or the remembered one is no longer* connected. One remembered and connected but not ready leaves the* webhook, as before: the page never goes to another CMS than the one* picked. A brand with one connected but not ready sees it, off, so its@@ -36,7 +38,11 @@ const storageKey = (brandId: string) => `aeo:cms-target:${brandId}`;function remembered(brandId: string): CmsTarget | null {try {const value = localStorage.getItem(storageKey(brandId));- return value === 'webhook' || value === 'webflow' || value === 'wordpress' || value === 'framer'+ return value === 'webhook' ||+ value === 'webflow' ||+ value === 'wordpress' ||+ value === 'framer' ||+ value === 'wix'? value: null;} catch {@@ -79,6 +85,23 @@ export type CmsFramer =/** Not connected, not set up on this server, or not read. */| null;+/** The brand's Wix, as Send to CMS reads it. */+export type CmsWix =+ /** Ready: pages go to this site's Blog as draft posts (its name, else its id). */+ | { ready: true; site: string }+ /** Connected, but its API key refused. */+ | { ready: false }+ /** Not connected, not set up on this server, or not read. */+ | null;++function wixOf(result: Awaited<ReturnType<typeof readWix>>): CmsWix {+ const connection = result.ok && result.configured ? result.connection : null;+ if (!connection) return null;+ return connection.status === 'connected'+ ? { ready: true, site: connection.siteName || connection.siteId }+ : { ready: false };+}+function webflowOf(result: Awaited<ReturnType<typeof readWebflow>>): CmsWebflow {const connection = result.ok && result.configured ? result.connection : null;if (!connection) return null;@@ -107,8 +130,8 @@ function framerOf(result: Awaited<ReturnType<typeof readFramer>>): CmsFramer {}/**- * The brand's send target: undefined while its Webflow, WordPress and- * Framer connections are read, then where pages go and how to change it. A+ * The brand's send target: undefined while its Webflow, WordPress, Framer+ * and Wix connections are read, then where pages go and how to change it. A* failed read leaves that one out; `unchecked` names it when the person* picked it before, and the page goes to the webhook, with `retry`.*/@@ -118,6 +141,7 @@ export function useCmsTarget(brandId: string) {webflow: CmsWebflow;wordpress: CmsWordPress;framer: CmsFramer;+ wix: CmsWix;/** The connections that couldn't be read. */failed: CmsLocal[];} | null>(null);@@ -127,22 +151,27 @@ export function useCmsTarget(brandId: string) {useEffect(() => {let cancelled = false;- Promise.all([readWebflow(brandId), readWordPress(brandId), readFramer(brandId)]).then(- ([webflow, wordpress, framer]) => {- if (cancelled) return;- setRead({- key,- webflow: webflowOf(webflow),- wordpress: wordpressOf(wordpress),- framer: framerOf(framer),- failed: [- ...(webflow.ok ? [] : ['webflow' as const]),- ...(wordpress.ok ? [] : ['wordpress' as const]),- ...(framer.ok ? [] : ['framer' as const]),- ],- });- },- );+ Promise.all([+ readWebflow(brandId),+ readWordPress(brandId),+ readFramer(brandId),+ readWix(brandId),+ ]).then(([webflow, wordpress, framer, wix]) => {+ if (cancelled) return;+ setRead({+ key,+ webflow: webflowOf(webflow),+ wordpress: wordpressOf(wordpress),+ framer: framerOf(framer),+ wix: wixOf(wix),+ failed: [+ ...(webflow.ok ? [] : ['webflow' as const]),+ ...(wordpress.ok ? [] : ['wordpress' as const]),+ ...(framer.ok ? [] : ['framer' as const]),+ ...(wix.ok ? [] : ['wix' as const]),+ ],+ });+ });return () => {cancelled = true;};@@ -152,11 +181,12 @@ export function useCmsTarget(brandId: string) {const webflow = current ? current.webflow : undefined;const wordpress = current ? current.wordpress : undefined;const framer = current ? current.framer : undefined;+ const wix = current ? current.wix : undefined;const chosen = picked?.brandId === brandId ? picked.target : remembered(brandId);// Read again after a failure: the note stays, as trying, until the answer.const failed = current ? current.failed : read?.key.startsWith(`${brandId}:`) ? read.failed : [];const unchecked = chosen && chosen !== 'webhook' && failed.includes(chosen) ? chosen : null;- const connectionOf = (to: CmsLocal) => ({ webflow, wordpress, framer })[to];+ const connectionOf = (to: CmsLocal) => ({ webflow, wordpress, framer, wix })[to];// The choice stands while it's still connected; ready or not, it's never swapped for another CMS.const kept = chosen && (chosen === 'webhook' || connectionOf(chosen)) ? chosen : null;const target: CmsTarget | undefined = !current@@ -173,7 +203,9 @@ export function useCmsTarget(brandId: string) {? 'wordpress': framer?.ready? 'framer'- : 'webhook';+ : wix?.ready+ ? 'wix'+ : 'webhook';return {/** The brand's Webflow; undefined while read; null without one, or when it couldn't be read. */@@ -182,6 +214,8 @@ export function useCmsTarget(brandId: string) {wordpress,/** The brand's Framer, as `webflow`. */framer,+ /** The brand's Wix, as `webflow`. */+ wix,target,/*** The target the person picked before that couldn't be read: the page@@ -200,20 +234,21 @@ export function useCmsTarget(brandId: string) {};}-const TARGETS = ['webflow', 'wordpress', 'framer', 'webhook'] as const;+const TARGETS = ['webflow', 'wordpress', 'framer', 'wix', 'webhook'] as const;/**- * The targets the brand has, when it has Webflow, WordPress or Framer: the- * person picks where pages go. The webhook is always one; a CMS connected+ * The targets the brand has, when it has Webflow, WordPress, Framer or Wix:+ * the person picks where pages go. The webhook is always one; a CMS connected* but not ready shows, off, with what to do. One tab stop, the picked card;* the arrow keys move to the next one and pick it, past one that's off.- * Four cards go two by two.+ * Four cards go two by two; five, three in a row.*/export function CmsTargetPicker({value,webflow,wordpress,framer,+ wix,onChange,disabled,}: {@@ -221,12 +256,13 @@ export function CmsTargetPicker({webflow: CmsWebflow | undefined;wordpress: CmsWordPress | undefined;framer: CmsFramer | undefined;+ wix?: CmsWix | undefined;onChange: (target: CmsTarget) => void;disabled?: boolean;}) {const t = useTranslations('contentEditor.editor.send.target');const cards = useRef<Partial<Record<CmsTarget, HTMLButtonElement | null>>>({});- const connections = { webflow, wordpress, framer };+ const connections = { webflow, wordpress, framer, wix };const shown = TARGETS.filter((target) => target === 'webhook' || connections[target]);const off = (target: CmsTarget) =>disabled || (target !== 'webhook' && !connections[target]?.ready);@@ -257,6 +293,9 @@ export function CmsTargetPicker({? t('wordpress.hint', { site: wordpress.site }): t('wordpress.notReady');}+ if (target === 'wix') {+ return wix?.ready ? t('wix.hint', { site: wix.site }) : t('wix.notReady');+ }return framer?.ready? t('framer.hint', { collection: framer.collection || t('framer.collection') }): t('framer.notReady');@@ -267,7 +306,7 @@ export function CmsTargetPicker({aria-label={t('label')}className={cn('grid gap-2',- shown.length === 3+ shown.length === 3 || shown.length >= 5? 'grid-cols-1 sm:grid-cols-3': shown.length === 4? 'grid-cols-1 sm:grid-cols-2'@@ -329,7 +368,9 @@ export function CmsTargetUnchecked({? 'uncheckedWordPress': target === 'framer'? 'uncheckedFramer'- : 'unchecked',+ : target === 'wix'+ ? 'uncheckedWix'+ : 'unchecked',)}</span><Buttondiff --git a/web/src/components/content/send-to-cms-dialog.test.tsx b/web/src/components/content/send-to-cms-dialog.test.tsxindex 6784483ed..b95dea325 100644--- a/web/src/components/content/send-to-cms-dialog.test.tsx+++ b/web/src/components/content/send-to-cms-dialog.test.tsx@@ -20,6 +20,9 @@ vi.mock('@/lib/wordpress-client', () => ({ readWordPress }));// And its Framer collection (00295): none unless a test gives one.const readFramer = vi.hoisted(() => vi.fn());vi.mock('@/lib/framer-client', () => ({ readFramer }));+// And its Wix site (00372): none unless a test gives one.+const readWix = vi.hoisted(() => vi.fn());+vi.mock('@/lib/wix-client', () => ({ readWix }));const { SendDialog } = await import('./send-to-cms-dialog');@@ -83,6 +86,7 @@ beforeEach(() => {readWebflow.mockReset().mockResolvedValue({ ok: true, configured: false, connection: null });readWordPress.mockReset().mockResolvedValue({ ok: true, configured: true, connection: null });readFramer.mockReset().mockResolvedValue({ ok: true, configured: true, connection: null });+ readWix.mockReset().mockResolvedValue({ ok: true, configured: true, connection: null });// The send target remembered per brand, in this browser.const kept = new Map<string, string>();vi.stubGlobal('localStorage', {@@ -911,6 +915,36 @@ describe('SendDialog', () => {expect(onClose).toHaveBeenCalled();});+ /** Wix (00372): its Blog, a draft post; images counted, as they don't go. */+ it('sends to Wix as a draft post, and says how many images stayed out', async () => {+ readWix.mockResolvedValue({+ ok: true,+ configured: true,+ connection: {+ status: 'connected',+ siteId: '2f8a1c3e-1111-4222-8333-944455556666',+ siteName: 'Acme Coffee',+ connectedAt: '2026-10-28T10:00:00Z',+ updatedAt: '2026-10-28T10:00:00Z',+ },+ });+ await render();+ expect(radios().map((r) => r.textContent)).toEqual([+ "WixA draft post on Acme Coffee's Blog",+ "Your workflowThe brand's webhook (Zapier, Make, n8n)",+ ]);+ expect(radio('Wix')!.getAttribute('aria-checked')).toBe('true');+ expect(dialog().textContent).toContain(+ "The page goes to Acme Coffee's Wix Blog as a draft post",+ );+ sentWith({ updated: false, live: false, changed: { images: 2 } });+ await act(async () => button('Send').click());+ expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', expect.any(Array), 'wix');+ expect(toast.success).toHaveBeenCalledWith('Sent to Wix as a draft post', {+ description: "2 images weren't sent: add them in Wix.",+ });+ });+it('says “your collection” when the collection has no name', async () => {readFramer.mockResolvedValue({...ready,diff --git a/web/src/components/content/send-to-cms-dialog.tsx b/web/src/components/content/send-to-cms-dialog.tsxindex 031f2a2fc..6c7b0ca20 100644--- a/web/src/components/content/send-to-cms-dialog.tsx+++ b/web/src/components/content/send-to-cms-dialog.tsx@@ -114,6 +114,7 @@ export function SendDialog({webflow,wordpress,framer,+ wix,target,pick,sent: keepTarget,@@ -124,6 +125,7 @@ export function SendDialog({const collection = webflow?.ready ? webflow.collection || t('target.webflow.collection') : '';const site = wordpress?.ready ? wordpress.site : '';const framerCollection = framer?.ready ? framer.collection || t('target.framer.collection') : '';+ const wixSite = wix?.ready ? wix.site : '';useEffect(() => {let cancelled = false;@@ -244,6 +246,12 @@ export function SendDialog({toast.success(delivery?.updated ? t('sentFramerUpdated') : t('sentFramer'), {description: notes.length ? notes.join(' ') : undefined,});+ } else if (target === 'wix') {+ // Images don't go to Wix (only its Media Manager's show).+ const images = delivery?.changed?.images ?? 0;+ toast.success(delivery?.updated ? t('sentWixUpdated') : t('sentWix'), {+ description: images ? t('wixImages', { images }) : undefined,+ });} else {toast.success(t('sent'));}@@ -257,6 +265,7 @@ export function SendDialog({webflow: 'errors.webflowFailed',wordpress: 'errors.wordpressFailed',framer: 'errors.framerFailed',+ wix: 'errors.wixFailed',webhook: 'errors.webhookFailed',} as const;return t(failed[shown.target], { reason: shown.failed });@@ -266,10 +275,17 @@ export function SendDialog({return tFailure(code);}// No CMS ready sent the page to the webhook: what to fix is the one connected.- if (code === 'no_webhook' && !webflow?.ready && !wordpress?.ready && !framer?.ready) {+ if (+ code === 'no_webhook' &&+ !webflow?.ready &&+ !wordpress?.ready &&+ !framer?.ready &&+ !wix?.ready+ ) {if (webflow) return t('errors.no_webhookWebflow');if (wordpress) return t('errors.no_webhookWordPress');if (framer) return t('errors.no_webhookFramer');+ if (wix) return t('errors.no_webhookWix');}if (code === 'in_progress' && shown.target === 'wordpress') {return t('errors.in_progressWordPress');@@ -277,6 +293,9 @@ export function SendDialog({if (code === 'in_progress' && shown.target === 'framer') {return t('errors.in_progressFramer');}+ if (code === 'in_progress' && shown.target === 'wix') {+ return t('errors.in_progressWix');+ }// The server names the path ("pages.0.slug"); the field is its last part.if (code === 'invalid' && field) {return t('errors.invalidField', { field: field.split('.').pop() ?? 'other' });@@ -304,16 +323,19 @@ export function SendDialog({? t('descriptionWordPress', { site }): target === 'framer'? t('descriptionFramer', { collection: framerCollection })- : t('description')}+ : target === 'wix'+ ? t('descriptionWix', { site: wixSite })+ : t('description')}</DialogDescription></DialogHeader>- {(webflow || wordpress || framer) && target && (+ {(webflow || wordpress || framer || wix) && target && (<CmsTargetPickervalue={target}webflow={webflow}wordpress={wordpress}framer={framer}+ wix={wix}disabled={sending}onChange={(next) => {pick(next);@@ -431,7 +453,9 @@ export function SendDialog({? `lastWordPress.${last.status}`: last.target === 'framer'? `lastFramer.${last.status}`- : `last.${last.status}`,+ : last.target === 'wix'+ ? `lastWix.${last.status}`+ : `last.${last.status}`,{when: format.dateTime(new Date(last.at), {dateStyle: 'medium',diff --git a/web/src/components/settings/integrations-section.test.tsx b/web/src/components/settings/integrations-section.test.tsxindex c4605486f..6b268372b 100644--- a/web/src/components/settings/integrations-section.test.tsx+++ b/web/src/components/settings/integrations-section.test.tsx@@ -76,6 +76,7 @@ vi.mock('./catalog-category-pages', () => ({),}));vi.mock('./webflow-card', () => ({ WebflowCard: () => <div data-card="webflow">Webflow</div> }));+vi.mock('./wix-card', () => ({ WixCard: () => <div data-card="wix">Wix</div> }));const { IntegrationsSection } = await import('./integrations-section');const { DemoBrandContext } = await import('@/components/providers/demo-brand-provider');@@ -449,13 +450,14 @@ describe('IntegrationsSection on the demo brand', () => {await render(false, true);expect(badges(merchantCenter()!)).toEqual(['Coming soon']);expect(groupOf(row('shopify'))).toBe('Stores and marketplaces');- expect(groupOf(row('wix'))).toBe('Content management systems');expect(row('shopify')!.textContent).toContain('Shopify');- expect(row('wix')!.textContent).toContain('Wix');- expect(badges(row('wix')!)).toEqual(['Coming soon']);// Live now, with cards of their own: no Coming soon row.expect(row('wordpress')).toBeNull();expect(row('framer')).toBeNull();+ expect(row('wix')).toBeNull();+ expect(groupOf(container.querySelector('[data-card="wix"]'))).toBe(+ 'Content management systems',+ );});it('shows none of those rows on another brand', async () => {diff --git a/web/src/components/settings/integrations-section.tsx b/web/src/components/settings/integrations-section.tsxindex eea2b68ea..439179584 100644--- a/web/src/components/settings/integrations-section.tsx+++ b/web/src/components/settings/integrations-section.tsx@@ -52,6 +52,7 @@ import { FramerCard } from './framer-card';import { MerchantCenterAccounts } from './merchant-center-accounts';import { WebflowCard } from './webflow-card';import { SampleDataBadge } from './sample-data-badge';+import { WixCard } from './wix-card';import { WordPressCard } from './wordpress-card';import { useIntegrationConnect } from '@/hooks/use-integration-connect';import { useUpgradeGate } from '@/components/providers/upgrade-gate';@@ -179,6 +180,8 @@ export function IntegrationsSection() {<WordPressCard /><FramerCard />++ <WixCard />{isDemo &&upcomingDemoIntegrations('cms').map((id) => (<UpcomingIntegrationCard key={id} id={id} />diff --git a/web/src/components/settings/wix-card.test.tsx b/web/src/components/settings/wix-card.test.tsxnew file mode 100644index 000000000..5bc661852--- /dev/null+++ b/web/src/components/settings/wix-card.test.tsx@@ -0,0 +1,241 @@+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { NextIntlClientProvider } from 'next-intl';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import messages from '../../../messages/en.json';+import type { WixConnection, WixError } from '@/lib/wix-client';++const client = vi.hoisted(() => ({+ readWix: vi.fn(),+ connectWix: vi.fn(),+ disconnectWix: vi.fn(),+}));+vi.mock('@/lib/wix-client', async (importOriginal) => ({+ ...(await importOriginal<typeof import('@/lib/wix-client')>()),+ ...client,+}));+const role = vi.hoisted(() => ({ canManage: true }));+vi.mock('@/hooks/use-user-role', () => ({ useUserRole: () => role }));+const store = vi.hoisted(() => ({ activeBrandId: 'b1' }));+vi.mock('@/stores/use-brand-store', () => ({+ useBrandStore: () => ({+ activeBrandId: store.activeBrandId,+ brands: [+ { id: 'b1', name: 'Acme' },+ { id: 'b2', name: 'Beta' },+ ],+ }),+}));+const toast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn(), warning: vi.fn() }));+vi.mock('sonner', () => ({ toast }));+// The read-only workspace's upgrade dialog.+const openUpgrade = vi.hoisted(() => vi.fn());+const gate = vi.hoisted(() => ({ isLocked: false }));+vi.mock('@/components/providers/upgrade-gate', () => ({+ useUpgradeGate: () => ({+ isLocked: gate.isLocked,+ openUpgrade,+ guard:+ <Args extends unknown[]>(fn: (...args: Args) => unknown, options: { action?: string } = {}) =>+ (...args: Args) =>+ gate.isLocked ? openUpgrade(options.action) : fn(...args),+ }),+}));++const { WixCard } = await import('./wix-card');++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =+ true;++/** Settings › Integrations › Wix (Send to CMS #1331, phase 2; 00372): a brand's site and API key. */++// Every reason the client names has its words: a missing one fails typecheck. A read-only+// workspace's refusal opens the upgrade dialog instead.+const ERROR_TEXTS: Record<Exclude<WixError, 'subscription'>, string> = messages.settings.wix.errors;++let container: HTMLDivElement;+let root: Root;++const SITE = '2f8a1c3e-1111-4222-8333-944455556666';+const KEY = 'IST.eyJraWQiOiJQb3pIX2FDMiJ9.fake-key';+const CONNECTED: WixConnection = {+ status: 'connected',+ siteId: SITE,+ siteName: 'Acme Coffee',+ connectedAt: '2026-10-27T10:00:00Z',+ updatedAt: '2026-10-27T10:00:00Z',+};++async function render() {+ await act(async () => {+ root.render(+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">+ <WixCard />+ </NextIntlClientProvider>,+ );+ });+}+const button = (label: string, within: ParentNode = container) =>+ [...within.querySelectorAll('button')].find((b) => b.textContent === label);+const click = async (el: Element | undefined) => {+ await act(async () => {+ el!.dispatchEvent(new MouseEvent('pointerdown', { bubbles: true }));+ (el as HTMLElement).click();+ });+};+/** The input a label names. */+const field = (label: string) => {+ const name = [...container.querySelectorAll('label')].find((l) => l.textContent === label);+ return container.querySelector<HTMLInputElement>(`[id="${name!.htmlFor}"]`)!;+};+async function type(label: string, value: string) {+ const input = field(label);+ await act(async () => {+ const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set!;+ setter.call(input, value);+ input.dispatchEvent(new Event('input', { bubbles: true }));+ });+}+const submit = async () => {+ await act(async () => {+ container+ .querySelector('form')!+ .dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));+ });+};++beforeEach(() => {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+ role.canManage = true;+ store.activeBrandId = 'b1';+ gate.isLocked = false;+ openUpgrade.mockReset();+ for (const fn of Object.values(client)) fn.mockReset();+ for (const fn of Object.values(toast)) fn.mockReset();+ client.readWix.mockResolvedValue({ ok: true, configured: true, connection: null });+});++afterEach(() => {+ act(() => root.unmount());+ container.remove();+});++describe('WixCard', () => {+ it('connects the site with its id and an API key, never keeping the key', async () => {+ client.connectWix.mockResolvedValue({ ok: true, connection: CONNECTED });+ await render();+ expect(field('API key').type).toBe('password');+ expect(field('API key').autocomplete).toBe('new-password');+ expect(button('Connect')!.disabled).toBe(true);+ await type('Site id', `https://manage.wix.com/dashboard/${SITE}/home `);+ await type('API key', KEY);+ await submit();+ expect(client.connectWix).toHaveBeenCalledWith('b1', {+ siteId: `https://manage.wix.com/dashboard/${SITE}/home`,+ apiKey: KEY,+ });+ expect(toast.success).toHaveBeenCalledWith('Wix connected');+ expect(container.textContent).toContain('Site: Acme Coffee');+ expect(container.textContent).toContain("Pages go to Acme Coffee's Blog as draft posts.");+ expect(container.querySelector('input[type="password"]')).toBeNull();+ });++ it('says what Wix answered, in our words', async () => {+ client.connectWix.mockResolvedValue({ ok: false, code: 'no_blog' });+ await render();+ await type('Site id', SITE);+ await type('API key', KEY);+ await submit();+ expect(toast.error).toHaveBeenCalledWith(ERROR_TEXTS.no_blog);+ expect(field('API key').value).toBe(KEY);+ });++ it('says the key needs the Ricos permission when Wix’s converter refuses it', async () => {+ client.connectWix.mockResolvedValue({ ok: false, code: 'no_ricos_permission' });+ await render();+ await type('Site id', SITE);+ await type('API key', KEY);+ await submit();+ expect(toast.error).toHaveBeenCalledWith(ERROR_TEXTS.no_ricos_permission);+ expect(ERROR_TEXTS.no_ricos_permission).toContain('Manage Ricos Document');+ });++ it('asks to connect again after a refused key, with the site filled in', async () => {+ client.readWix.mockResolvedValue({+ ok: true,+ configured: true,+ connection: { ...CONNECTED, status: 'auth_failed' },+ });+ await render();+ expect(container.textContent).toContain('API key refused');+ expect(field('Site id').value).toBe(SITE);+ });++ it('disconnects, and says to delete the key in Wix too', async () => {+ client.readWix.mockResolvedValue({ ok: true, configured: true, connection: CONNECTED });+ client.disconnectWix.mockResolvedValue({ ok: true, success: true });+ await render();+ await click(button('Disconnect'));+ const dialog = document.body.querySelector('[role="dialog"]')!;+ await click(button('Disconnect', dialog));+ expect(client.disconnectWix).toHaveBeenCalledWith('b1');+ expect(toast.success).toHaveBeenCalledWith(+ "Wix disconnected. Delete the API key in Wix's API Keys Manager too.",+ );+ });++ it('shows members where pages go, with no form or buttons', async () => {+ role.canManage = false;+ client.readWix.mockResolvedValue({ ok: true, configured: true, connection: CONNECTED });+ await render();+ expect(container.textContent).toContain("Pages go to Acme Coffee's Blog as draft posts.");+ expect(container.querySelector('form')).toBeNull();+ expect(button('Disconnect')).toBeUndefined();+ });++ it('opens the upgrade dialog, not an error, when a read-only workspace’s connect or disconnect is refused', async () => {+ client.connectWix.mockResolvedValue({ ok: false, code: 'subscription' });+ await render();+ await type('Site id', SITE);+ await type('API key', KEY);+ await submit();+ expect(client.connectWix).toHaveBeenCalledTimes(1);+ expect(openUpgrade).toHaveBeenCalledTimes(1);+ expect(toast.error).not.toHaveBeenCalled();++ client.readWix.mockResolvedValue({ ok: true, configured: true, connection: CONNECTED });+ client.disconnectWix.mockResolvedValue({ ok: false, code: 'subscription' });+ act(() => root.unmount());+ root = createRoot(container);+ await render();+ await click(button('Disconnect'));+ await click(button('Disconnect', document.body.querySelector('[role="dialog"]')!));+ expect(client.disconnectWix).toHaveBeenCalledTimes(1);+ expect(openUpgrade).toHaveBeenCalledTimes(2);+ expect(toast.error).not.toHaveBeenCalled();+ });++ it('on a read-only workspace, connects and changes no key, and still disconnects', async () => {+ gate.isLocked = true;+ await render();+ await type('Site id', SITE);+ await type('API key', KEY);+ await submit();+ expect(openUpgrade).toHaveBeenLastCalledWith('Connecting your CMS needs a plan');+ expect(client.connectWix).not.toHaveBeenCalled();++ client.readWix.mockResolvedValue({ ok: true, configured: true, connection: CONNECTED });+ client.disconnectWix.mockResolvedValue({ ok: true, success: true });+ act(() => root.unmount());+ root = createRoot(container);+ await render();+ await click(button('Change API key'));+ expect(openUpgrade).toHaveBeenCalledTimes(2);+ expect(container.querySelector('input[type="password"]')).toBeNull();+ await click(button('Disconnect'));+ await click(button('Disconnect', document.body.querySelector('[role="dialog"]')!));+ expect(client.disconnectWix).toHaveBeenCalledWith('b1');+ });+});diff --git a/web/src/components/settings/wix-card.tsx b/web/src/components/settings/wix-card.tsxnew file mode 100644index 000000000..099262273--- /dev/null+++ b/web/src/components/settings/wix-card.tsx@@ -0,0 +1,317 @@+'use client';++import { useEffect, useState } from 'react';+import { useTranslations } from 'next-intl';+import { toast } from 'sonner';+import { AlertTriangle, Globe, Loader2, Unplug } from 'lucide-react';+import { Badge } from '@/components/ui/badge';+import { Button } from '@/components/ui/button';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';+import { Skeleton } from '@/components/ui/skeleton';+import { useUpgradeGate } from '@/components/providers/upgrade-gate';+import {+ Dialog,+ DialogClose,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ DialogTrigger,+} from '@/components/ui/dialog';+import { useUserRole } from '@/hooks/use-user-role';+import { connectWix, disconnectWix, readWix, type WixConnection } from '@/lib/wix-client';+import { useBrandStore } from '@/stores/use-brand-store';++/**+ * Send to CMS → Wix (#1331, phase 2; 00372): the active brand's Wix site.+ * Admins and managers connect it with an API key its owner made in Wix's+ * API Keys Manager, replace the key and disconnect; members see where pages+ * go. Pages go to the site's Blog as draft posts, published in Wix.+ */+export function WixCard() {+ const t = useTranslations('settings.wix');+ const { activeBrandId, brands } = useBrandStore();+ const { canManage } = useUserRole();+ // A read-only workspace's refusal opens the upgrade dialog, not a toast;+ // while it is read-only, Replace key opens it at once. Disconnect stays+ // open: it ends an access, it starts nothing.+ const { guard, openUpgrade } = useUpgradeGate();+ const tActions = useTranslations('readOnly.actions');+ const brand = brands.find((b) => b.id === activeBrandId) ?? null;++ // The connection as read for a brand: another brand's never shows.+ const [read, setRead] = useState<{+ brandId: string;+ configured: boolean;+ connection: WixConnection | null;+ failed: boolean;+ } | null>(null);+ // Replacing the sign-in, for the brand it was asked for.+ const [replacingFor, setReplacingFor] = useState<string | null>(null);+ const replacing = replacingFor !== null && replacingFor === activeBrandId;+ const [disconnecting, setDisconnecting] = useState(false);++ useEffect(() => {+ if (!activeBrandId) return;+ let cancelled = false;+ readWix(activeBrandId).then((result) => {+ if (cancelled) return;+ setRead(+ result.ok+ ? {+ brandId: activeBrandId,+ configured: result.configured,+ connection: result.connection,+ failed: false,+ }+ : { brandId: activeBrandId, configured: true, connection: null, failed: true },+ );+ });+ return () => {+ cancelled = true;+ };+ }, [activeBrandId]);++ const current = read?.brandId === activeBrandId ? read : null;+ const connection = current?.connection ?? null;+ const setConnection = (next: WixConnection | null) =>+ setRead((r) => (r && r.brandId === activeBrandId ? { ...r, connection: next } : r));+ const site = connection ? (connection.siteName ?? connection.siteId) : '';++ const disconnect = async () => {+ if (!activeBrandId) return;+ setDisconnecting(true);+ const result = await disconnectWix(activeBrandId);+ setDisconnecting(false);+ if (!result.ok) {+ if (result.code === 'subscription') openUpgrade();+ else toast.error(t(`errors.${result.code}`));+ return;+ }+ setConnection(null);+ setReplacingFor(null);+ // The key still works in Wix until its owner deletes it there.+ toast.success(t('disconnected'));+ };++ return (+ <div className="space-y-4 rounded-lg border p-4">+ <div className="flex items-start gap-3">+ <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-md border bg-muted/50">+ <Globe className="h-5 w-5 text-muted-foreground" />+ </div>+ <div className="min-w-0">+ <div className="flex flex-wrap items-center gap-2">+ <p className="text-sm font-medium">{t('title')}</p>+ {connection?.status === 'connected' && (+ <Badge+ variant="outline"+ className="border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400"+ >+ {t('connected')}+ </Badge>+ )}+ {connection?.status === 'auth_failed' && (+ <Badge+ variant="outline"+ className="border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-400"+ >+ {t('refused')}+ </Badge>+ )}+ </div>+ <p className="text-sm text-muted-foreground">+ {brand ? t('description', { brand: brand.name }) : t('noBrand')}+ </p>+ {connection && (+ <p className="mt-1 text-xs text-muted-foreground [overflow-wrap:anywhere]">+ {t('site', { site })}+ </p>+ )}+ {canManage && connection && (+ <div className="mt-3 flex flex-wrap items-center gap-2">+ {!replacing && current?.configured && connection.status === 'connected' && (+ <Button+ variant="outline"+ size="sm"+ onClick={guard(() => setReplacingFor(activeBrandId), {+ action: tActions('connectCms'),+ })}+ >+ {t('replace')}+ </Button>+ )}+ <Dialog>+ <DialogTrigger+ render={+ <Button+ variant="outline"+ size="sm"+ className="gap-2"+ disabled={disconnecting}+ />+ }+ >+ {disconnecting ? (+ <Loader2 className="h-3.5 w-3.5 animate-spin" />+ ) : (+ <Unplug className="h-3.5 w-3.5" />+ )}+ {t('disconnect')}+ </DialogTrigger>+ <DialogContent className="sm:max-w-sm">+ <DialogHeader>+ <DialogTitle>{t('disconnectTitle')}</DialogTitle>+ <DialogDescription>{t('disconnectDescription')}</DialogDescription>+ </DialogHeader>+ <DialogFooter>+ <DialogClose render={<Button variant="outline" />}>{t('cancel')}</DialogClose>+ <DialogClose render={<Button variant="destructive" onClick={disconnect} />}>+ {t('disconnect')}+ </DialogClose>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ </div>+ )}+ </div>+ </div>++ {!activeBrandId ? null : !current ? (+ <Skeleton className="h-16 w-full" />+ ) : current.failed ? (+ <p className="text-sm text-muted-foreground">{t('unavailable')}</p>+ ) : !current.configured ? (+ <p className="text-sm text-muted-foreground">{t('notConfigured')}</p>+ ) : !canManage ? (+ <p className="text-sm text-muted-foreground">+ {!connection+ ? t('notConnectedMember')+ : connection.status === 'auth_failed'+ ? t('refusedMember')+ : t('pagesGoTo', { site })}+ </p>+ ) : !connection || connection.status === 'auth_failed' || replacing ? (+ <div className="space-y-3">+ {connection?.status === 'auth_failed' && (+ <div className="flex items-start gap-2 rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-300">+ <AlertTriangle className="mt-0.5 h-4 w-4 shrink-0" />+ <span>{t('refusedNote')}</span>+ </div>+ )}+ <SignInForm+ brandId={activeBrandId}+ // Connecting again, the site as it was.+ initial={connection}+ onCancel={replacing ? () => setReplacingFor(null) : undefined}+ onConnected={(next) => {+ setReplacingFor(null);+ setConnection(next);+ }}+ />+ </div>+ ) : (+ <p className="text-sm text-muted-foreground">{t('pagesGoTo', { site })}</p>+ )}+ </div>+ );+}++/** The site's id and an API key: the key goes to the API once, never shown again. */+function SignInForm({+ brandId,+ initial,+ onConnected,+ onCancel,+}: {+ brandId: string;+ initial: WixConnection | null;+ onConnected: (connection: WixConnection) => void;+ onCancel?: () => void;+}) {+ const t = useTranslations('settings.wix');+ // Read-only (plan not active): Connect opens the upgrade dialog before anything is sent.+ const { guard, openUpgrade } = useUpgradeGate();+ const tActions = useTranslations('readOnly.actions');+ const [siteId, setSiteId] = useState(initial?.siteId ?? '');+ const [apiKey, setApiKey] = useState('');+ const [connecting, setConnecting] = useState(false);+ const id = (field: string) => `wix-${field}-${brandId}`;+ const ready = siteId.trim() && apiKey.trim().length >= 20;++ const connect = async () => {+ setConnecting(true);+ const result = await connectWix(brandId, { siteId: siteId.trim(), apiKey: apiKey.trim() });+ setConnecting(false);+ if (!result.ok) {+ if (result.code === 'subscription') openUpgrade();+ else toast.error(t(`errors.${result.code}`));+ return;+ }+ setApiKey('');+ toast.success(t('connectedToast'));+ onConnected(result.connection);+ };+ const connectSite = guard(() => void connect(), { action: tActions('connectCms') });++ return (+ <form+ className="space-y-3"+ onSubmit={(e) => {+ e.preventDefault();+ if (ready && !connecting) connectSite();+ }}+ >+ <div className="grid gap-3">+ <div className="space-y-1.5">+ <Label htmlFor={id('site')}>{t('siteLabel')}</Label>+ <Input+ id={id('site')}+ autoComplete="off"+ spellCheck={false}+ value={siteId}+ onChange={(e) => setSiteId(e.target.value)}+ placeholder={t('sitePlaceholder')}+ />+ </div>+ <div className="space-y-1.5">+ <Label htmlFor={id('key')}>{t('keyLabel')}</Label>+ <Input+ id={id('key')}+ aria-describedby={id('hint')}+ type="password"+ // Not a sign-in to Ansvisor: no saved password is offered here.+ autoComplete="new-password"+ spellCheck={false}+ value={apiKey}+ onChange={(e) => setApiKey(e.target.value)}+ placeholder={t('keyPlaceholder')}+ />+ </div>+ </div>+ <p id={id('hint')} className="text-xs text-muted-foreground">+ {t('keyHint')}+ </p>+ <div className="flex flex-wrap gap-2">+ <Button type="submit" size="sm" className="h-9 gap-2" disabled={!ready || connecting}>+ {connecting && <Loader2 className="h-3.5 w-3.5 animate-spin" />}+ {connecting ? t('connecting') : t('connect')}+ </Button>+ {onCancel && (+ <Button+ type="button"+ variant="ghost"+ size="sm"+ className="h-9"+ disabled={connecting}+ onClick={onCancel}+ >+ {t('cancel')}+ </Button>+ )}+ </div>+ </form>+ );+}diff --git a/web/src/lib/content/cms-send-client.test.ts b/web/src/lib/content/cms-send-client.test.tsindex 6c6903b9a..e9c3a8190 100644--- a/web/src/lib/content/cms-send-client.test.ts+++ b/web/src/lib/content/cms-send-client.test.ts@@ -529,6 +529,28 @@ describe('readCmsStatuses', () => {});});+ it('says which sends went to Wix, and one removed there since as failed', async () => {+ statusReads = [+ {+ data: [+ delivery('d1', 'sent', '2026-10-24T10:00:00Z', { target: 'wix' }),+ delivery('d2', 'failed', '2026-10-24T10:00:00Z', {+ target: 'wix',+ error: 'Removed in Wix',+ }),+ ],+ error: null,+ },+ ];+ const statuses = await readCmsStatuses(['d1', 'd2']);+ expect(statuses.get('d1')).toMatchObject({ status: 'sent', target: 'wix' });+ expect(statuses.get('d2')).toMatchObject({+ status: 'failed',+ target: 'wix',+ error: 'Removed in Wix',+ });+ });+it('leaves a read that fails with no sends, as before its table is there', async () => {statusReads = [{ data: null, error: { message: 'relation does not exist' } }];expect((await readCmsStatuses(['d1'])).size).toBe(0);diff --git a/web/src/lib/content/cms-send-client.ts b/web/src/lib/content/cms-send-client.tsindex 160e1c754..5a7a1a08b 100644--- a/web/src/lib/content/cms-send-client.ts+++ b/web/src/lib/content/cms-send-client.ts@@ -12,9 +12,9 @@ import { lastSend } from '@/lib/content/cms-status';/*** Where pages go: the brand's webhook (phase 1), its Webflow collection, its- * WordPress site or its Framer collection (phase 2).+ * WordPress site, its Framer collection or its Wix site's Blog (phase 2).*/-export type CmsTarget = 'webhook' | 'webflow' | 'wordpress' | 'framer';+export type CmsTarget = 'webhook' | 'webflow' | 'wordpress' | 'framer' | 'wix';/** Why a send didn't go, as the server names it. */export type CmsSendError =@@ -36,6 +36,10 @@ export type CmsSendError =| 'no_framer'| 'framer_refused'| 'framer_not_ready'+ // Wix (00372): not on this server, not connected, or its API key refused.+ | 'wix_not_configured'+ | 'no_wix'+ | 'wix_refused'| 'in_progress'| 'daily_limit'| 'forbidden'@@ -94,6 +98,9 @@ const KNOWN: readonly CmsSendError[] = ['no_framer','framer_refused','framer_not_ready',+ 'wix_not_configured',+ 'no_wix',+ 'wix_refused','in_progress','daily_limit','forbidden',diff --git a/web/src/lib/content/cms-status.ts b/web/src/lib/content/cms-status.tsindex 6f57136da..9bc19e65e 100644--- a/web/src/lib/content/cms-status.ts+++ b/web/src/lib/content/cms-status.ts@@ -29,7 +29,10 @@ export function lastSend(row: {return {status: interrupted ? 'failed' : (row.status as CmsDelivery['status']),target:- row.target === 'webflow' || row.target === 'wordpress' || row.target === 'framer'+ row.target === 'webflow' ||+ row.target === 'wordpress' ||+ row.target === 'framer' ||+ row.target === 'wix'? row.target: 'webhook',at: row.published_at ?? row.sent_at ?? row.created_at,diff --git a/web/src/lib/demo/integrations.test.ts b/web/src/lib/demo/integrations.test.tsindex 3a80d11ff..d37d99a0e 100644--- a/web/src/lib/demo/integrations.test.ts+++ b/web/src/lib/demo/integrations.test.ts@@ -6,12 +6,13 @@ describe('the demo brand’s integrations', () => {expect(demoIntegration('google-search-console')).toBe('connected');expect(demoIntegration('google-analytics')).toBe('connected');expect(demoIntegration('webflow')).toBe('connected');- for (const id of ['google-merchant-center', 'shopify', 'wix']) {+ for (const id of ['google-merchant-center', 'shopify']) {expect(demoIntegration(id)).toBe('soon');}// Live with a card of their own, shown as on any brand.expect(demoIntegration('wordpress')).toBeNull();expect(demoIntegration('framer')).toBeNull();+ expect(demoIntegration('wix')).toBeNull();expect(demoIntegration('hubspot')).toBeNull();});@@ -22,6 +23,6 @@ describe('the demo brand’s integrations', () => {it('rows of their own only for those without a card yet, by group', () => {expect(upcomingDemoIntegrations('stores')).toEqual(['shopify']);- expect(upcomingDemoIntegrations('cms')).toEqual(['wix']);+ expect(upcomingDemoIntegrations('cms')).toEqual([]);});});diff --git a/web/src/lib/demo/integrations.ts b/web/src/lib/demo/integrations.tsindex 6aaa22b32..d6bbd0e4c 100644--- a/web/src/lib/demo/integrations.ts+++ b/web/src/lib/demo/integrations.ts@@ -12,7 +12,7 @@* here becomes `{ id, state: 'connected' }` and its new card reads* demoIntegration(id), as the cards below do.*- * One not named here (WordPress, Framer) shows on the demo brand as on any+ * One not named here (WordPress, Framer, Wix) shows on the demo brand as on any* brand, not connected: its buttons open the plan dialog.*/export type DemoIntegrationState = 'connected' | 'soon';@@ -29,7 +29,6 @@ export const DEMO_INTEGRATIONS: readonly DemoIntegration[] = [{ id: 'google-merchant-center', state: 'soon' },{ id: 'shopify', state: 'soon', group: 'stores' },{ id: 'webflow', state: 'connected' },- { id: 'wix', state: 'soon', group: 'cms' },];/** What an integration's card shows on the demo brand; null when the list doesn't name it. */diff --git a/web/src/lib/mcp/content-delivery.test.ts b/web/src/lib/mcp/content-delivery.test.tsindex 2a10c1a6f..d529bee81 100644--- a/web/src/lib/mcp/content-delivery.test.ts+++ b/web/src/lib/mcp/content-delivery.test.ts@@ -132,3 +132,16 @@ describe('the B5 tools', () => {});});});++describe('last_send in the drafts tools', () => {+ it('names every CMS a page can be sent to, Wix included', async () => {+ const server = createMcpServer(auth);+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();+ await server.connect(serverTransport);+ const client = new Client({ name: 'test', version: '1.0.0' });+ await client.connect(clientTransport);+ const { tools } = await client.listTools();+ const description = tools.find((t) => t.name === 'list_content_drafts')?.description ?? '';+ expect(description).toContain('target webhook, webflow, wordpress, framer or wix');+ });+});diff --git a/web/src/lib/mcp/content-delivery.ts b/web/src/lib/mcp/content-delivery.tsindex 7ce352950..8d2612925 100644--- a/web/src/lib/mcp/content-delivery.ts+++ b/web/src/lib/mcp/content-delivery.ts@@ -18,7 +18,7 @@ import { assertSubscriptionActive } from './subscription-gate';export interface McpLastSend {/** queued, sent, failed (a send left queued reads as failed: interrupted) or published. */status: string;- /** webhook, webflow, wordpress or framer: the brand's webhook, Webflow collection, WordPress site or Framer collection. */+ /** webhook, webflow, wordpress, framer or wix: the brand's webhook, Webflow collection, WordPress site, Framer collection or Wix site's Blog. */target: string;/** When it was published, sent or queued. */at: string;diff --git a/web/src/lib/mcp/server.ts b/web/src/lib/mcp/server.tsindex af961c70b..1c9696182 100644--- a/web/src/lib/mcp/server.ts+++ b/web/src/lib/mcp/server.ts@@ -1757,7 +1757,7 @@ export function createMcpServer(auth: McpAuthContext): McpServer {{title: 'Content drafts',description:- "List a brand's Content Editor drafts, the latest changed first (up to 100): title, status (draft, in_review, ready, published), method (create or optimize), page type, author (user or agent), the live page it optimizes, how many agent suggestions wait for review, and the editor path. Also `last_send` (its last Send to CMS: status queued, sent, failed or published, target webhook, webflow, wordpress or framer, when, the webhook's HTTP status, the error, and where the CMS says it went live; null when never sent) and `shopping_links` (on a shop's page with a shopping path: whether its links still sell — state ok or attention, the category pages and products linked, and the linked products that no longer sell: sold out, refused by Merchant Center or gone; none or unchecked otherwise).",+ "List a brand's Content Editor drafts, the latest changed first (up to 100): title, status (draft, in_review, ready, published), method (create or optimize), page type, author (user or agent), the live page it optimizes, how many agent suggestions wait for review, and the editor path. Also `last_send` (its last Send to CMS: status queued, sent, failed or published, target webhook, webflow, wordpress, framer or wix, when, the webhook's HTTP status, the error, and where the CMS says it went live; null when never sent) and `shopping_links` (on a shop's page with a shopping path: whether its links still sell — state ok or attention, the category pages and products linked, and the linked products that no longer sell: sold out, refused by Merchant Center or gone; none or unchecked otherwise).",inputSchema: listDraftsShape,annotations: { readOnlyHint: true, openWorldHint: false },},diff --git a/web/src/lib/wix-client.test.ts b/web/src/lib/wix-client.test.tsnew file mode 100644index 000000000..f40a43a71--- /dev/null+++ b/web/src/lib/wix-client.test.ts@@ -0,0 +1,65 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';++/** Send to CMS › Wix (#1331, phase 2; 00372): a brand's connection from the browser, through the API's proxy. */++vi.mock('@/lib/supabase/client', () => ({+ createClient: () => ({+ auth: { getSession: async () => ({ data: { session: { access_token: 'tok' } } }) },+ }),+}));++const { connectWix, disconnectWix, readWix } = await import('./wix-client');++const fetchMock = vi.fn();+beforeEach(() => {+ fetchMock.mockReset();+ vi.stubGlobal('fetch', fetchMock);+});++const answer = (status: number, body: unknown) =>+ fetchMock.mockResolvedValue(new Response(JSON.stringify(body), { status }));+const BASE = '/api/aeo/api/cms/brands/b1/wix';+const input = { siteId: '2f8a1c3e-1111-4222-8333-944455556666', apiKey: 'IST.fake-key-1234567890' };++describe('wix-client', () => {+ it('reads the connection, sends the key once in the body, and disconnects', async () => {+ answer(200, { configured: true, connection: null });+ expect(await readWix('b1')).toEqual({ ok: true, configured: true, connection: null });+ expect(fetchMock.mock.calls[0]).toEqual([BASE, { headers: { Authorization: 'Bearer tok' } }]);++ answer(200, { connection: { status: 'connected' } });+ expect(await connectWix('b1', input)).toEqual({+ ok: true,+ connection: { status: 'connected' },+ });+ expect(fetchMock.mock.calls[1][1]).toMatchObject({+ method: 'POST',+ body: JSON.stringify(input),+ headers: { 'Content-Type': 'application/json', Authorization: 'Bearer tok' },+ });++ answer(200, { success: true });+ expect(await disconnectWix('b1')).toEqual({ ok: true, success: true });+ expect(fetchMock.mock.calls[2][1]).toMatchObject({ method: 'DELETE' });+ });++ it("names the API's reasons, and the general ones", async () => {+ for (const code of [+ 'no_blog',+ 'no_member',+ 'auth_failed',+ 'no_access',+ 'no_ricos_permission',+ ]) {+ answer(409, { code, error: 'x' });+ expect(await connectWix('b1', input)).toEqual({ ok: false, code });+ }+ answer(401, { error: 'Unauthorized' });+ expect(await readWix('b1')).toEqual({ ok: false, code: 'session' });+ // A read-only workspace: the upgrade dialog's, not a message.+ answer(402, { code: 'subscription_inactive', error: 'x' });+ expect(await connectWix('b1', input)).toEqual({ ok: false, code: 'subscription' });+ answer(500, { code: 'something_else' });+ expect(await readWix('b1')).toEqual({ ok: false, code: 'failed' });+ });+});diff --git a/web/src/lib/wix-client.ts b/web/src/lib/wix-client.tsnew file mode 100644index 000000000..daf0c3593--- /dev/null+++ b/web/src/lib/wix-client.ts@@ -0,0 +1,107 @@+import { BROWSER_API_BASE_URL } from '@/config/api';+import { apiFailure } from '@/lib/api-failure';+import { createClient } from '@/lib/supabase/client';++/**+ * A brand's Wix connection for Send to CMS (#1331, phase 2; 00372), from the+ * browser through the API's same-origin proxy. The API key goes from here+ * to the API once, which checks it with Wix and keeps it encrypted: never+ * through a server action, a log or a response.+ */++export interface WixConnection {+ status: 'connected' | 'auth_failed';+ siteId: string;+ siteName: string | null;+ connectedAt: string;+ updatedAt: string;+}++export type WixError =+ | 'not_configured'+ | 'invalid'+ | 'forbidden'+ | 'auth_failed'+ | 'no_access'+ | 'no_ricos_permission'+ | 'no_blog'+ | 'no_member'+ | 'unreachable'+ | 'session'+ | 'workspace'+ | 'busy'+ /** A read-only workspace (plan not active): the upgrade dialog, not a message. */+ | 'subscription'+ | 'failed';++const KNOWN: readonly WixError[] = [+ 'not_configured',+ 'invalid',+ 'forbidden',+ 'auth_failed',+ 'no_access',+ 'no_ricos_permission',+ 'no_blog',+ 'no_member',+ 'unreachable',+];++export type WixResult<T> = ({ ok: true } & T) | { ok: false; code: WixError };++async function call<T>(brandId: string, init: RequestInit = {}): Promise<WixResult<T>> {+ try {+ const {+ data: { session },+ } = await createClient().auth.getSession();+ if (!session) return { ok: false, code: 'session' };+ const res = await fetch(+ `${BROWSER_API_BASE_URL}/api/cms/brands/${encodeURIComponent(brandId)}/wix`,+ {+ ...init,+ headers: {+ ...(init.body ? { 'Content-Type': 'application/json' } : {}),+ ...init.headers,+ Authorization: `Bearer ${session.access_token}`,+ },+ },+ );+ const body = (await res.json().catch(() => ({}))) as Record<string, unknown>;+ if (!res.ok) {+ const known = KNOWN.find((c) => c === body.code);+ if (known) return { ok: false, code: known };+ const general = apiFailure(res.status, body);+ return {+ ok: false,+ code:+ general === 'session' ||+ general === 'workspace' ||+ general === 'busy' ||+ general === 'subscription'+ ? general+ : 'failed',+ };+ }+ return { ok: true, ...(body as T) };+ } catch (err) {+ console.error('Wix call failed:', err);+ return { ok: false, code: 'failed' };+ }+}++/** The brand's connection, and whether this server can keep a Wix API key. */+export function readWix(brandId: string) {+ return call<{ configured: boolean; connection: WixConnection | null }>(brandId);+}++/** Connects the brand's site, or replaces its key: the API checks it with Wix first. */+export function connectWix(brandId: string, input: { siteId: string; apiKey: string }) {+ return call<{ connection: WixConnection }>(brandId, {+ method: 'POST',+ body: JSON.stringify(input),+ });+}++/** Disconnects the brand's site; its key is deleted with the connection. */+export function disconnectWix(brandId: string) {+ return call<{ success: boolean }>(brandId, { method: 'DELETE' });+}