PageSourceSearch

https://socialloop.ai/_next/static/chunks/320.c69a7475e05f9259.js

js socialloop.ai collected 2026-10-05 12:45:46 UTC 13,665 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[320],{320:(e,t,s)=>{s.r(t),s.d(t,{WebsiteChooser:()=>d,default:()=>m});var r=s(95155),n=s(12115),a=s(14585),i=s(10639),l=s(78096),o=s(5780),c=s(55619);function d(e){let{value:t,onChange:s,label:l}=e,c=(0,i.G_)("emailExternalSites",a.functions),[d,u]=(0,n.useState)([]),[h,m]=(0,n.useState)("");return(0,n.useEffect)(()=>{let e=!0;return u([]),m(""),c({action:"list"}).then(t=>{if(!Array.isArray(t.sites))throw Error("Website connections could not be loaded.");e&&u(t.sites)}).catch(t=>{e&&m((0,o.Q)(t))}),()=>{e=!1}},[c]),(0,r.jsxs)("div",{className:"text-xs",children:[(0,r.jsxs)("select",{"aria-label":l,className:"max-w-full rounded-lg border border-white/10 bg-white/5 p-2 text-sm",value:t||"",onChange:e=>s(e.target.value),children:[(0,r.jsx)("option",{value:"",children:"Choose connected website"}),t&&!d.some(e=>e.siteId===t)&&(0,r.jsx)("option",{value:t,children:"Unavailable connection"}),d.map(e=>(0,r.jsxs)("option",{value:e.siteId,children:[e.name,e.verified?"":" \xb7 verification needed"]},e.siteId))]}),h&&(0,r.jsx)("p",{role:"alert",className:"text-negative-ink",children:h})]})}let u="text-sm underline disabled:opacity-40",h="/integrations/socialloop-email-woocommerce.zip";function m(){let e=(0,i.G_)("emailExternalSites",a.functions),{role:t}=(0,i.y$)(),s=(0,n.useRef)(0),d=(0,n.useRef)(!1),m=(0,n.useRef)(e),x=(0,n.useRef)(!0);m.current=e;
1let[p,b]=(0,n.useState)([]),[w,v]=(0,n.useState)(""),[y,f]=(0,n.useState)(""),[g,N]=(0,n.useState)(""),[j,k]=(0,n.useState)(""),[C,S]=(0,n.useState)(""),[I,A]=(0,n.useState)(!1),[E,D]=(0,n.useState)(!0),[W,L]=(0,n.useState)(null),[R,T]=(0,n.useState)(null),[K,_]=(0,n.useState)(!1),[F,M]=(0,n.useState)(!1),O=(0,n.useRef)(null);(0,n.useEffect)(()=>(x.current=!0,()=>{x.current=!1}),[]);let U=async()=>{let t=++s.current;D(!0),k("");try{let r=await e({action:"list"});if(!Array.isArray(r.sites))throw Error("Website connections could not be loaded.");x.current&&t===s.current&&b(r.sites)}catch(e){x.current&&t===s.current&&k((0,o.Q)(e))}finally{x.current&&t===s.current&&D(!1)}};(0,n.useEffect)(()=>(b([]),T(null),_(!1),L(null),M(!1),O.current=null,N(""),S(""),v(""),f(""),A(!1),d.current=!1,U(),()=>{s.current++}),[e]),(0,n.useEffect)(()=>{let e=e=>{(R||I)&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[R,I]),(0,l.uq)(e=>{if(d.current)return void S("Wait for the connection update to finish before leaving.");R?(O.current=e,M(!0)):e()});let V=async(s,r)=>{if(!d.current&&"owner"===t){if("rotateKey"===s.action&&R)return void N("Save the key shown below before creating another one.");d.current=!0,A(!0),N(""),S("");try{let t=await e(s);if(!x.current||m.current!==e)return;t.serverKey&&r&&(T({value:t.serverKey,siteId:r.siteId,name:r.name}),_(!1)),"disable"===s.action&&(null==R?void 0:R.siteId)===s.siteId&&T(null),"create"===s.action&&(v(""),f("")),S(t.reason||("disable"===s.action?"Website disconnected. New activity is no longer accepted.":"rotateKey"===s.action?"Key created. Save it in your website server settings.":"create"===s.action?"Website added. Follow the ownership steps below.":"Ownership checked. Review the connection status below.")),L(null),await U()}catch(t){x.current&&m.current===e&&N((0,o.Q)(t))}finally{x.current&&m.current===e&&(d.current=!1,A(!1))}}},q=async e=>{try{await navigator.clipboard.writeText(e),S("Copied.")}catch(e){N("Copy is unavailable. Select the text to copy it manually. For a server key, choose “Show key” first.")}},X=(e,t)=>{N(""),L({action:e,site:t})};return(0,r.jsxs)("section",{className:"space-y-5",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"Connect your website"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-t2 max-w-2xl",children:"See visits and purchases from your website next to your email results."})]}),g&&!W&&(0,r.jsx)("p",{role:"alert",className:"text-sm text-negative-ink",children:g}),C&&(0,r.jsx)("p",{role:"status",className:"text-sm text-t2",children:C}),"owner"===t&&(0,r.jsx)("form",{onSubmit:e=>{e.preventDefault(),V({action:"create",name:w,origin:y})},children:(0,r.jsxs)("fieldset",{disabled:I,className:"grid gap-3 sm:grid-cols-2 rounded-xl border border-white/10 p-5",children:[(0,r.jsxs)("label",{className:"text-sm",children:["Website name",(0,r.jsx)("input",{required:!0,maxLength:100,value:w,onChange:e=>v(e.target.value),className:"w-full mt-2 p-3 rounded-lg border border-white/10 bg-white/5",placeholder:"Our community shop"})]}),(0,r.jsxs)("label",{className:"text-sm",children:["Website address",(0,r.jsx)("input",{required:!0,type:"url",value:y,onChange:e=>f(e.target.value),className:"w-full mt-2 p-3 rounded-lg border border-white/10 bg-white/5",placeholder:"https://shop.example.com"})]}),(0,r.jsx)("button",{className:"justify-self-start rounded-xl px-4 py-3 bg-white text-[rgb(var(--surface-base))] text-sm font-semibold disabled:opacity-40",children:I?"Updating connection…":"Add website"})]})}),R&&(0,r.jsxs)("section",{"aria-label":"New website server key",className:"p-5 rounded-xl border border-amber-300/30 space-y-3",children:[(0,r.jsxs)("h3",{className:"font-semibold",children:["Save the server key for ",R.name]}),(0,r.jsx)("p",{className:"text-sm text-t2",children:"Shown once. Store it only in your website server’s secret settings. It stays here until you confirm you have saved it. Never put it in browser code."}),(0,r.jsx)("input",{type:K?"text":"password",readOnly:!0,"aria-label":"New server key",value:R.value,className:"w-full min-w-0 p-3 bg-white/5 rounded-lg"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-4",children:[(0,r.jsx)("button",{className:u,"aria-pressed":K,onClick:()=>_(e=>!e),children:K?"Hide key":"Show key"}),(0,r.jsx)("button",{className:u,onClick:()=>
1void q(R.value),children:"Copy server key"}),(0,r.jsx)("button",{className:u,onClick:()=>{T(null),_(!1)},children:"I’ve saved it"})]})]}),E&&(0,r.jsx)("p",{role:"status",className:"text-sm text-t2",children:"Loading website connections…"}),j&&(0,r.jsxs)("div",{role:"alert",className:"rounded-xl border border-white/15 p-4 space-y-2",children:[(0,r.jsx)("p",{className:"text-sm",children:"We couldn’t load your website connections. Your saved setup has not changed."}),(0,r.jsx)("p",{className:"text-xs text-t2",children:j}),(0,r.jsx)("button",{disabled:E||I,className:u,onClick:()=>void U(),children:"Try again"})]}),!E&&!j&&!p.length&&(0,r.jsxs)("div",{className:"rounded-xl border border-dashed border-white/20 p-6",children:[(0,r.jsx)("h3",{className:"font-medium",children:"No websites connected yet"}),(0,r.jsx)("p",{className:"mt-2 text-sm text-t2",children:"owner"===t?"Add your website above. Then install our WooCommerce plugin, or share the setup with your website developer.":"Ask your workspace owner to connect a website. Its shared activity will then appear in campaign results."})]}),p.map(e=>{let s=!e.enabled&&!!e.verifiedUntilMs;return(0,r.jsxs)("article",{"aria-label":e.name,className:"rounded-xl border border-white/10 p-5 space-y-4",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("h3",{className:"font-semibold break-words",children:e.name}),(0,r.jsx)("p",{className:"text-sm text-t2 break-all",children:e.origin})]}),s&&(0,r.jsx)("p",{role:"status",className:"text-sm text-t2",children:"Disconnected. New activity is not accepted. Reconnect and create a new server key to resume."}),(0,r.jsxs)("ol",{className:"grid gap-3 sm:grid-cols-3 text-sm",children:[(0,r.jsxs)("li",{className:"rounded-lg bg-white/5 p-3",children:[(0,r.jsx)("strong",{children:"1. Verify ownership"}),(0,r.jsx)("p",{className:"text-xs text-t2 mt-2",children:s?"Connection is disconnected":e.verified?"Verified until ".concat(new Date(e.verifiedUntilMs).toLocaleDateString()):"Not verified yet. See the developer setup below."})]}),(0,r.jsxs)("li",{className:"rounded-lg bg-white/5 p-3",children:[(0,r.jsx)("strong",{children:"2. Connect your website"}),(0,r.jsxs)("p",{className:"text-xs text-t2 mt-2",children:[(0,r.jsx)("a",{className:"underline",href:h,download:!0,children:"Download the WooCommerce plugin"}),", or share the setup below with your website developer."]})]}),(0,r.jsxs)("li",{className:"rounded-lg bg-white/5 p-3",children:[(0,r.jsx)("strong",{children:"3. Confirm activity"}),(0,r.jsx)("p",{className:"text-xs text-t2 mt-2",children:e.lastReceiptAtMs?"Last activity received: ".concat(new Date(e.lastReceiptAtMs).toLocaleString()):"No activity received yet"})]})]}),(0,r.jsxs)("details",{className:"text-sm rounded-lg border border-white/10 p-4",children:[(0,r.jsx)("summary",{className:"cursor-pointer",children:"Setup for your website developer"}),(0,r.jsx)("p",{className:"text-xs text-t2 mt-3",children:"Add this TXT record at your domain provider. No email records need to change."}),[["Website ID",e.siteId],["TXT record name",e.dnsName],["TXT record value",e.dnsValue]].map(t=>{let[s,n]=t;return(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("label",{className:"block text-xs",htmlFor:"".concat(e.siteId,"-").concat(s.toLowerCase().replaceAll(" ","-")),children:s}),(0,r.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,r.jsx)("input",{id:"".concat(e.siteId,"-").concat(s.toLowerCase().replaceAll(" ","-")),readOnly:!0,value:n,className:"min-w-0 flex-1 p-2 bg-white/5 border border-white/10 rounded"}),(0,r.jsx)("button",{"aria-label":"Copy ".concat(s.toLowerCase()," for ").concat(e.name),className:"underline",onClick:()=>void q(n),children:"Copy"})]})]},s)}),(0,r.jsxs)("div",{className:"mt-4 flex flex-wrap gap-4",children:["owner"===t&&(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsx)("button",{disabled:I,className:u,onClick:()=>void V({action:"verify",siteId:e.siteId,revision:e.revision},e),children:"Check ownership"}),e.verified&&(0,r.jsx)("button",{disabled:I||!!R,className:u,onClick:()=>X("rotateKey",e),children:"Create / replace server key"})]}),(0,r.jsx)("button",{className:u,onClick:()=>{q("Connect ".concat(e.name," (").concat(e.origin,") to SocialLoop Email Campaigns.\n1. Add TXT ").concat(e.dnsName," = ").concat(e.dnsValue,". Keep this record for ongoing ownership verification.\n2. Follow https://socialloop.ai/email-website-guide using siteId ").concat(e.siteId,".\n3. Request a server key from the workspace owner through a secure channel. Never put that key in browser code.\n4. Show the optional SocialLoop connection prompt after a campaign visit. It links only a signed-in recipient with a matching recorded email click.\n5. Send consented visits/orders from your server to https://us-central1-").concat(a.functions.app.options.projectId,".cloudfunctions.net/receiveEmailExternalEvent. Confirm a real receipt below.\nThis connection does not grant email/SMS permission. Do not backfill older browsing or transactions."))},children:"Copy setup instructions"}),(0,r.jsx)("a",{className:"underline",href:"/email-website-guide",target:"_blank",rel:"noreferrer",children:"Open setup guide"}),(0,r.jsx)("a",{className:"underline",href:h,download:!0,children:"WooCommerce plugin"})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-4 text-sm",children:["owner"===t&&(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("button",{disabled:I,className:u,onClick:()=>X("verify",e),children:"Reconnect website"}),e.enabled&&(0,r.jsx)("button",{disabled:I,className:u,onClick:()=>X("disable",e),children:"Disconnect website"})]}),(0,r.jsx)("button",{disabled:I||E,className:u,onClick:()=>void U(),children:"Refresh"})]})]},e.siteId)}),W&&(0,r.jsxs)(c.A,{compact:!0,dismissible:!I,title:"disable"===W.action?"Disconnect website?":"verify"===W.action?"Reconnect website?":"Create or replace server key?",onClose:()=>{L(null),N("")},children:[(0,r.jsx)("p",{className:"text-sm font-medium break-words",children:W.site.name}),(0,r.jsx)("p",{className:"text-sm text-t2 mt-3",children:"disable"===W.action?"This stops accepting new activity and disables the current server key. Shared website results become unavailable until the connection is restored. Your website itself is unchanged.":"verify"===W.action?"We’ll check the DNS record and enable this connection again. After reconnecting, create a new server key and update your website server settings.":"If this website already has a key, it stops working immediately when replaced. Save the new key and update your website server settings to keep activity connected."}),g&&(0,r.jsx)("p",{role:"alert",className:"text-sm mt-3 text-negative-ink",children:g}),(0,r.jsxs)("div",{className:"mt-5 flex flex-wrap gap-4",children:[(0,r.jsx)("button",{disabled:I,className:"rounded-lg bg-white text-[rgb(var(--surface-base))] px-4 py-2 text-sm font-semibold disabled:opacity-40",onClick:()=>void V({action:W.action,siteId:W.site.siteId,revision:W.site.revision},W.site),children:I?"Updating…":"disable"===W.action?"Confirm disconnect":"verify"===W.action?"Check DNS and reconnect":"Create new key"}),(0,r.jsx)("button",{disabled:I,className:u,onClick:()=>{L(null),N("")},children:"Cancel"})]})]}),F&&(0,r.jsxs)(c.A,{compact:!0,title:"Have you saved your server key?",onClose:()=>{M(!1),O.current=null},children:[(0,r.jsx)("p",{className:"text-sm text-t2",children:"Leaving this view discards the only visible copy. Save it to your website server’s secret settings first."}),(0,r.jsxs)("div",{className:"mt-5 flex flex-wrap gap-4",children:[(0,r.jsx)("button",{className:u,onClick:()=>{M(!1),O.current=null},children:"Keep key open"}),(0,r.jsx)("button",{className:u,onClick:()=>{let e=O.current;O.current=null,T(null),M(!1),null==e||e()},children:"Discard key and leave"})]})]})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.