shopify-chatbot-widget 0.8.6 → 0.8.7
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.
|
@@ -683,4 +683,4 @@ html body {
|
|
|
683
683
|
userAgent: `).concat(navigator.userAgent,`
|
|
684
684
|
timeBetweenLoadAndGet: `).concat(o-a,`
|
|
685
685
|
visitorId: `).concat(f.visitorId,`
|
|
686
|
-
components: `).concat(T2(u),"\n```")),[2,f]}})})}}}function lie(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(e2,"/npm-monitoring"),!0),e.send()}catch(t){console.error(t)}}function sie(e){var t;return e===void 0&&(e={}),nc(this,void 0,void 0,function(){var a,r,o;return ac(this,function(u){switch(u.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&lie(),a=e.delayFallback,r=e.debug,[4,iie(a)];case 1:return u.sent(),o=Qre({cache:{},debug:r}),[2,oie(o,r)]}})})}var cie={load:sie,hashComponents:O2,componentsToDebugString:T2};const uie=()=>{const[e,t]=S.useState(!
|
|
686
|
+
components: `).concat(T2(u),"\n```")),[2,f]}})})}}}function lie(){if(!(window.__fpjs_d_m||Math.random()>=.001))try{var e=new XMLHttpRequest;e.open("get","https://m1.openfpcdn.io/fingerprintjs/v".concat(e2,"/npm-monitoring"),!0),e.send()}catch(t){console.error(t)}}function sie(e){var t;return e===void 0&&(e={}),nc(this,void 0,void 0,function(){var a,r,o;return ac(this,function(u){switch(u.label){case 0:return(!((t=e.monitoring)!==null&&t!==void 0)||t)&&lie(),a=e.delayFallback,r=e.debug,[4,iie(a)];case 1:return u.sent(),o=Qre({cache:{},debug:r}),[2,oie(o,r)]}})})}var cie={load:sie,hashComponents:O2,componentsToDebugString:T2};const uie=()=>{const[e,t]=S.useState(!1),[a,r]=S.useState("sessions"),[o,u]=S.useState(null),[f,m]=S.useState(!1),[g,p]=S.useState(""),[v,x]=S.useState(""),[C,T]=S.useState(!1),{chatbotLogo:O,colorCode:M,messagesSuggestions:A,disableForm:_,merchantPhone:N,userType:j,isFetchingDetails:L,calendly:z,disbleCheckout:V,chatbotName:P}=Y7(),[$,B]=S.useState(null),H=J.jsx(Ks,{style:{fontSize:24,color:M||"#7F28F8"},spin:!0}),ee=()=>{if(!_&&!f){r("create");return}else{const ie=crypto.randomUUID();u(ie),x(O),p(P),T(!0),r("messenger")}};S.useEffect(()=>{(async()=>{try{let G=localStorage.getItem("visitor_id");G||(G=(await(await cie.load()).get()).visitorId,localStorage.setItem("visitor_id",G));const K=await(await fetch(`${ii.apiUrl}register-ip/`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({visitor_id:G})})).json();K.visitor&&K.country?(localStorage.setItem("country",K.country),B({visitorId:K.visitor,country:K.country}),m(K.has_user_info||!1)):console.warn("Backend did not return country")}catch(G){console.error("Failed to fetch or send visitor info",G)}})()},[]);const Y=(ie,G,q)=>{u(ie),p(G),x(q),T(!1),r("messenger")};S.useEffect(()=>{const ie=G=>{const q=G.data||{};q.type==="JAWEB_CHAT"&&(q.action==="open-ready"?t(!0):q.action==="closed"&&t(!1))};return window.addEventListener("message",ie),()=>window.removeEventListener("message",ie)},[]);const W=()=>{window.parent?.postMessage({type:"JAWEB_CHAT",action:"open"},"*")},Z=()=>{window.parent?.postMessage({type:"JAWEB_CHAT",action:"close"},"*")};return S.useEffect(()=>{L||window.parent?.postMessage({type:"JAWEB_CHAT",action:"ready-confirm"},"*")},[L]),J.jsx("div",{children:e&&J.jsx("div",{className:"chatbot-box",children:L?J.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:300},children:J.jsx(Zc,{indicator:H,tip:"..."})}):J.jsxs(fj,{mode:"sync",children:[a==="sessions"&&J.jsx(Yi.div,{initial:{opacity:0,x:-30},animate:{opacity:1,x:0},exit:{opacity:0,x:30},transition:{duration:.3},style:{height:"100%"},children:J.jsx(RK,{chatbotLogo:O,Phone:N||"",colorCode:M,visitorId:$?.visitorId||"",Opened:e,setOpen:ie=>ie?W():Z(),onNewSession:ee,onSessionSelect:Y})},"sessions"),a==="create"&&J.jsx(Yi.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},exit:{opacity:0,y:-30},transition:{duration:.3},children:J.jsx(fne,{colorCode:M,visitorId:$?.visitorId||"",country:$?.country||"",onBack:()=>r("sessions"),onCreate:ie=>{u(ie.session_id),m(ie.hasInfo),r("messenger")}})},"create"),a==="messenger"&&o&&J.jsx(Yi.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},transition:{duration:.3},children:J.jsx(Qne,{sessionId:o,chatbotLogo:v||O,agentName:g||P||"Ai Assistant",colorCode:M,messagesSuggestions:A,newSession:C,disableForm:_,calendly:z??"",setOpen:ie=>ie?W():Z(),setNewSession:T,Opened:e,setView:()=>r("sessions"),userType:j,disbleCheckout:V})},"messenger")]})})})},R2="jaweb-chatbot-container";if(!document.getElementById(R2)){const e=document.createElement("div");e.id=R2,document.body.appendChild(e),PL.createRoot(e).render(J.jsx(uie,{}))}})();
|
package/package.json
CHANGED
package/src/Chatbot/Chatbot.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { Spin } from 'antd';
|
|
|
11
11
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
12
12
|
|
|
13
13
|
const Chatbot: React.FC = () => {
|
|
14
|
-
const [open, setOpen] = useState(
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
15
|
const [viewMode, setViewMode] = useState<'sessions' | 'create' | 'messenger'>('sessions');
|
|
16
16
|
const [activeSessionId, setActiveSessionId] = useState<string | null>(null);
|
|
17
17
|
const [HasInfo, setHasInfo] = useState(false);
|