1import{j as e}from"./emotion-element-f0de968e.browser.esm-CkAcib9J.js";import{r as h,L as B}from"./chunk-KS7C4IRE-D5dXzlLW.js";import{M as X}from"./react-moment-interop-Cejh4knc.js";import{D as W}from"./DefaultButton-D-2ol00_.js";import{R as Ce}from"./Refresh-DBsKPGNK.js";import{A as N}from"./Add-BMUEcdt_.js";import{S as Z}from"./Save-CQ_ks_us.js";import{D as P}from"./Delete-Bddb6Pmk.js";import{c as ve}from"./useSlotProps-Br-fPZ-p.js";import{P as we}from"./PagingControls-BeFwxpJN.js";import{c as ke,k as ze,bg as Te,bh as De,a6 as We,bi as Me}from"./api-qiY2smlF.js";import{C as Le}from"./ContentCopy-DzcoVcl2.js";import{B as t,T as s}from"./Box-Bu2Z2trI.js";import{C as _,M as $}from"./MenuItem-Cbws_f4j.js";import{S as Ae,a as Ee}from"./Snackbar-Fo0d5dST.js";import{E as q}from"./ExpandMore-BZjfnDlB.js";import{S as _e}from"./Search-DYAWCHnA.js";import{u as ae}from"./useTheme-C_8o6ItC.js";import{I as V}from"./IconButton-C2igLTSk.js";import{A as ee,a as te,b as ne}from"./AccordionSummary-Dv7an5ur.js";import{C as oe}from"./Chip-DBy7n3Mp.js";import{F,S as Be}from"./index-Ba4xS3j9.js";import{I as $e,T as y,F as U}from"./TextField-CwHKLY54.js";import{I as Ve}from"./InputAdornment-DPRfKtOn.js";import{a as Y,R as A}from"./RadioGroup-BoTIMVZt.js";import{F as E}from"./FormControlLabel-BgXUbgq2.js";import"./moment-BLMuvzoS.js";import"./identifier-DCmdaooV.js";import"./imageUtils-BWiJvnWv.js";import"./Drawer-Dxxn1p5J.js";import"./useId-D-VxNTxp.js";import"./Card-C8fRb0iU.js";import"./ArrowRight-CiJ19GP_.js";import"./CustomerWrapper-mJMo-Beg.js";import"./ArrowDropDown-Dc3_CX8Q.js";import"./Favorite-OhcX1HPf.js";import"./Message-b6OAa9gy.js";import"./ColorModeContext-Db2jY2gh.js";import"./Divider-jVf1TKX1.js";import"./AtlasSearchProvider-C0Krahge.js";import"./CustomSearchBox-B1Pjk2eZ.js";import"./appPaths-DLtVD8gm.js";import"./LocationOn-RbsU8tml.js";import"./AnimatedLink-DLgq7h-R.js";import"./index-CaKTCWaW.js";const Fe=ve(e.jsx("path",{d:"M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm-3.06 16L7.4 14.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41zM13 9V3.5L18.5 9z"})),Ne=({storeId:n})=>{const m=ke(ze),[i,{data:c,isLoading:d}]=Te(),[u,p]=h.useState(!1),[l,f]=h.useState("Token copied to clipboard"),[I,M]=h.useState("success.main"),j=async()=>{var S,C,b,r;const g=await i({storeId:n});console.log(g),(C=(S=g.error)==null?void 0:S.data)!=null&&C.error?(f((r=(b=g.error)==null?void 0:b.data)==null?void 0:r.error.message),M("error.main")):(f("Token copied to clipboard"),M("success.main")),p(!0),navigator.clipboard.writeText(g==null?void 0:g.data.tok)};return m?e.jsxs(t,{children:[e.jsx(t,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(W,{variant:"outline",disabled:d,startIcon:d?e.jsx(_,{size:20}):e.jsx(Le,{}),onClick:j,children:e.jsx(s,{sx:{fontSize:"12px"},children:"copy token to clipboard"})})}),e.jsx(Ae,{open:u,autoHideDuration:2e3,onClose:()=>p(!1),children:e.jsx(Ee,{message:l,sx:{backgroundColor:I,fontWeight:700}})})]}):null},se=n=>{if(!n)return"Never synced";const m=new Date(n),c=new Date().getTime()-m.getTime(),d=Math.floor(c/6e4),u=Math.floor(c/36e5),p=Math.floor(c/864e5);return d<1?"Just now":d<60?`${d} minute${d===1?"":"s"} ago`:u<24?`${u} hour${u===1?"":"s"} ago`:p<7?`${p} day${p===1?"":"s"} ago`:m.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})},re=n=>{switch(n){case"connected":return"success";case"disabled":return"warning";case"requested":return"default";default:return"error"}},Pe=({onSearchChange:n})=>{const[m,i]=h.useState("");return h.useEffect(()=>{const c=setTimeout(()=>{n(m)},800);return()=>clearTimeout(c)},[m,n]),e.jsx(y,{size:"small",placeholder:"Search by store name...",value:m,onChange:c=>i(c.target.value),InputProps:{startAdornment:e.jsx(Ve,{position:"start",children:e.jsx(_e,{})})},sx:{minWidth:"300px",backgroundColor:"background.paper"}})},At=()=>{var g,S,C,b;const n=ae(),[m,i]=h.useState(1),[c,d]=h.useState(typeof window<"u"&&localStorage.getItem("completedRequestsLimit")||20),[u,p]=h.useState(""),{data:l,isLoading:f,isFetching:I,refetch:M}=De({page:m,limit:c,search:u}),j=h.useCallback(r=>{p(r)},[]);return e.jsxs(t,{sx:{p:4,color:n.palette.text.primary},children:[e.jsxs(t,{sx:{display:"flex",mb:2},children:[e.jsx(B,{to:"/admin/dashboard",style:{textDecoration:"none"},children:e.jsx(s,{color:"text.secondary",sx:{fontWeight:600,"&:hover":{textDecoration:"underline"}},children:"Admin"})}),"/",e.jsx(B,{to:"/admin/inventory/submit",style:{textDecoration:"none"},children:e.jsx(s,{color:"text.secondary",sx:{fontWeight:600,"&:hover":{textDecoration:"underline"}},children:"Inventory"})}),"/",e.jsx(B,{to:"/admin/inventory/integrations",style:{textDecoration:"none"},children:e.jsx(s,{color:"text.secondary",sx:{fontWeight:600,"&:hover":{textDecoration:"underline"}},children:"Integrations"})}),"/",e.jsx(s,{color:"text.secondary",sx:{fontWeight:600},children:"Shopify Integrations"})]}),e.jsxs(t,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",ga
1p:"15px"},children:[e.jsx(s,{variant:"h1",children:"Shopify Integration"}),e.jsx(V,{onClick:()=>M(),disabled:f,children:e.jsx(Ce,{sx:{fontSize:"20px"},color:"warning"})})]}),e.jsxs(s,{sx:{mt:2},children:["For a step by step guide on how to complete the connection process,"," ",e.jsx(B,{to:"connectionGuide",style:{color:n.palette.primary.main,fontWeight:600},children:"go here"})]}),e.jsx(t,{sx:{my:3},children:e.jsx(Pe,{onSearchChange:j})}),I&&e.jsx(t,{sx:{display:"flex",justifyContent:"center",alignItems:"center",py:4},children:e.jsx(_,{})}),e.jsxs(s,{variant:"h2",sx:{my:2},children:["Connection Requests (",((g=l==null?void 0:l.requests)==null?void 0:g.length)||0,")"]}),e.jsx(t,{sx:{display:"flex",flexDirection:"column",gap:1},children:(S=l==null?void 0:l.requests)==null?void 0:S.map(r=>{var v,w,k,z,T,D;return e.jsxs(ee,{sx:{backgroundColor:n.palette.background.paper,"&:before":{display:"none"}},children:[e.jsxs(te,{expandIcon:e.jsx(q,{}),sx:{"& .MuiAccordionSummary-content":{display:"flex",alignItems:"center",width:"100%",flexWrap:"wrap",gap:1}},children:[e.jsx(s,{variant:"h6",sx:{fontWeight:600,minWidth:200,flex:"0 0 200px"},children:r.name}),e.jsx(s,{variant:"body2",color:"text.secondary",sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",mx:2},children:r.support_email||"No email"}),e.jsx(oe,{label:((w=(v=r.integration)==null?void 0:v.shopify)==null?void 0:w.connectionStatus)||"requested",color:re((z=(k=r.integration)==null?void 0:k.shopify)==null?void 0:z.connectionStatus),size:"small",sx:{minWidth:90}}),e.jsx(s,{variant:"body2",color:"text.secondary",sx:{ml:2,minWidth:150},children:se((D=(T=r.integration)==null?void 0:T.shopify)==null?void 0:D.lastSyncedAt)})]}),e.jsx(ne,{children:e.jsx(ie,{storeRequest:r})})]},r._id)})}),e.jsxs(s,{variant:"h2",sx:{mt:4},children:["Connected Stores (",((C=l==null?void 0:l.recentlyConnected)==null?void 0:C.length)||0,")"]}),e.jsx(t,{sx:{mx:2},children:e.jsxs(t,{sx:{display:"flex",justifyContent:"space-between"},children:[e.jsx(we,{page:m,setPage:i,totalPages:l==null?void 0:l.totalPages}),e.jsxs(F,{sx:{my:1},size:"small",children:[e.jsx($e,{id:"limit-label",children:"Limit"}),e.jsxs(Be,{labelId:"limit-label",id:"limit-select",label:"Limit",value:c,onChange:r=>{r.preventDefault(),i(1),localStorage.setItem("apiEventsLimit",r.target.value),d(r.target.value)},sx:{minWidth:"100px"},children:[e.jsx($,{value:10,children:"10"}),e.jsx($,{value:20,children:"20"}),e.jsx($,{value:50,children:"50"}),e.jsx($,{value:100,children:"100"})]})]})]})}),e.jsx(t,{sx:{display:"flex",flexDirection:"column",gap:1},children:(b=l==null?void 0:l.recentlyConnected)==null?void 0:b.map(r=>{var v,w,k,z,T,D;return e.jsxs(ee,{sx:{backgroundColor:n.palette.background.paper,"&:before":{display:"none"}},children:[e.jsxs(te,{expandIcon:e.jsx(q,{}),sx:{"& .MuiAccordionSummary-content":{display:"flex",alignItems:"center",width:"100%"}},children:[e.jsx(s,{variant:"h6",sx:{fontWeight:600,minWidth:200,flex:"0 0 200px"},children:r.name}),e.jsx(s,{variant:"body2",color:"text.secondary",sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",mx:2},children:r.support_email||"No email"}),e.jsx(oe,{label:((w=(v=r.integration)==null?void 0:v.shopify)==null?void 0:w.connectionStatus)||"unknown",color:re((z=(k=r.integration)==null?void 0:k.shopify)==null?void 0:z.connectionStatus),size:"small",sx:{minWidth:90}}),e.jsx(s,{variant:"body2",color:"text.secondary",sx:{ml:2,minWidth:150},children:se((D=(T=r.integration)==null?void 0:T.shopify)==null?void 0:D.lastSyncedAt)})]}),e.jsx(ne,{children:e.jsx(ie,{storeRequest:r})})]},r._id)})})]})},ie=({storeRequest:n})=>{var H,O,Q,G,R,J,K;const m=ae(),i=n==null?void 0:n.integration,c=i==null?void 0:i.shopify.connectionStatus,[d,u]=h.useState(((H=i==null?void 0:i.shopify)==null?void 0:H.ignoreTags)||[]),[p,l]=h.useState(((O=i==null?void 0:i.shopify)==null?void 0:O.ignoreItemTypes)||[]),[f,I]=h.useState(((Q=i==null?void 0:i.shopify)==null?void 0:Q.ignoreCategories)||[]),[M,{isLoading:j}]=We(),[g,{isError:S,error:C,isLoading:b}]=Me(),r=()=>{const o=[...d];o.push(""),u(o)},v=o=>a=>{const x=[...d];x[o]=a.target.value,u(x)},w=o=>{u(d.filter((a,x)=>x!==o))},k=()=>{const o=[...p];o.push(""),l(o)},z=o=>a=>{const x=[...p];x[o]=a.target.value,l(x)},T=o=>{l(p.filter((a,x)=>x!==o))},D=()=>{const o=[...f];o.push(""),I(o)},le=o=>a=>{const x=[...f];x[o]=a.target.value,I(x)},ce=o=>{I(f.filter((a,x)=>x!==o))},de=o=>{o.preventDefault();const a=new FormData(o.target),x=Array.from(a.entries()).filter(([L,Se])=>Se!==""),{storeUrl:xe,connectionStatus:pe,eventsEnabled:me,ordersEnabled:he,inviteCode:ue,locationName:fe,locationId:ge,accessToken:je}=Object.fromEntries(x),ye=d.map(L=>L),be=p.map(L=>L),Ie=f.map(L=>L);M({storeId:n._id,storeUrl:xe,connectionStatus:pe,eventsEnabled:me,ordersEnabled:he,inviteCode:ue,locationName:fe,locationId:ge,accessToken:je,ignoreTags:ye,ignoreItemTypes:be,ignoreCategories:Ie,triggerEmail:!1})};return e.jsx("form",{onSubmit:de,children:e.jsxs(t,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"1fr 1fr"},gap:2,p:2,border:"1px solid gray",borderRadius:"4px",backgroundColor:m.palette.background.paper},children:[e.jsx(t,{children:e.jsxs(t,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",gap:"9px",width:"100%"},children:[e.jsx(s,{sx:{fontSize:"12px",fontWeight:600,width:"14ch"},children:"Store URL"}),e.jsx(y,{size:"small",name:"storeUrl",defaultValue:(G=i.shopify)==null?void 0:G.storeUrl,placeholder:"yourstore.myshopify.com",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}})]})}),e.jsx(t,{children:e.jsxs(t,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",gap:"9px",width:"100%"},children:[e.jsx(s,{sx:{fontSize:"12px",fontWeight:600,width:"14ch"},children:"Invite Code"}),e.jsx(y,{size:"small",name:"inviteCode",defaultValue:(R=i.shopify)==null?void 0:R.inviteCode,placeholder:"1234",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}})]})}),e.jsx(t,{children:e.jsxs(t,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",gap:"9px",width:"100%"},children:[e.jsx(s,{sx:{fontSize:"12px",fontWeight:600,width:"14ch"},children:"Location Name"}),e.jsx(y,{size:"small",name:"locationName",defaultValue:(J=i.shopify)==null?void 0:J.locationName,placeholder:"123 test street",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}})]})}),e.jsx(t,{children:e.jsxs(t,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",gap:"9px",width:"100%"},children:[e.jsx(s,{sx:{fontSize:"12px",fontWeight:600,width:"14ch"},children:"Location ID"}),e.jsx(y,{size:"small",name:"locationId",defaultValue:(K=i.shopify)==null?void 0:K.locationId,placeholder:"67324112985",autoComplete:"off",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}})]})}),e.jsxs(t,{children:[e.jsxs(t,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-start",alignItems:"center",gap:"9px",width:"100%"},children:[e.jsx(s,{sx:{fontSize:"12px",fontWeight:600,width:"14ch"},children:"Access Token"}),e.jsx(y,{size:"small",name:"accessToken",type:"password",autoComplete:"off",placeholder:"shpat_1234567890abcdefg",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}})]}),e.jsx(Ne,{storeId:n._id})]}),e.jsx(t,{children:c!=="requested"&&e.jsxs(t,{sx:{mt:1},children:[e.jsxs(s,{variant:"body1",sx:{fontSize:"12px"},children:["Conected On:"," ",e.jsx("b",{children:e.jsx(X,{format:"MM/DD/YYYY H:mm a",style:{marginLeft:"5px"},children:n.integration.shopify.connectionDate})})]}),e.jsxs(s,{variant:"body1",sx:{fontSize:"12px"},children:["Last Synced:"," ",e.jsx("b",{children:n.integration.shopify.lastSyncedAt?e.jsx(X,{format:"MM/DD/YYYY H:mm a",style:{marginLeft:"5px"},children:n.integration.shopify.lastSyncedAt}):"N/A"})]})]})}),e.jsx(t,{children:c==="requested"?e.jsxs(t,{children:[e.jsx(s,{sx:{fontSize:"12px"},component:"span",variant:"body2",color:"text.secondary",children:"Connection:"}),e.jsx(s,{sx:{mt:1,fontWeight:800},children:c})]}):e.jsxs(F,{disabled:j,sx:{mt:1},children:[e.jsx(U,{id:"connection-radio-buttons-group-label",sx:{fontSize:"12px"},children:"Connection"}
1),e.jsxs(Y,{row:!0,"aria-labelledby":"connection-radio-buttons-group-label",name:"connectionStatus",defaultValue:c,children:[e.jsx(E,{value:"connected",control:e.jsx(A,{}),label:"Enabled"}),e.jsx(E,{value:"disabled",control:e.jsx(A,{color:"error"}),label:"Disabled"})]})]})}),e.jsx(t,{children:e.jsxs(F,{disabled:j,sx:{mt:1},children:[e.jsx(U,{id:"events-radio-buttons-group-label",sx:{fontSize:"12px"},children:"Events"}),e.jsxs(Y,{row:!0,"aria-labelledby":"events-radio-buttons-group-label",name:"eventsEnabled",defaultValue:n.integration.shopify.eventsEnabled===!0||n.integration.shopify.eventsEnabled==="true"||!1,children:[e.jsx(E,{value:!0,control:e.jsx(A,{}),label:"Enabled"}),e.jsx(E,{value:!1,control:e.jsx(A,{color:"error"}),label:"Disabled"})]})]})}),e.jsx(t,{children:e.jsxs(F,{disabled:j,sx:{mt:1},children:[e.jsx(U,{id:"events-radio-buttons-group-label",sx:{fontSize:"12px"},children:"Orders"}),e.jsxs(Y,{row:!0,"aria-labelledby":"events-radio-buttons-group-label",name:"ordersEnabled",defaultValue:n.integration.shopify.ordersEnabled===!0||n.integration.shopify.ordersEnabled==="true"||!1,children:[e.jsx(E,{value:!0,control:e.jsx(A,{}),label:"Enabled"}),e.jsx(E,{value:!1,control:e.jsx(A,{color:"error"}),label:"Disabled"})]})]})}),e.jsx(t,{children:e.jsxs(t,{sx:{display:"flex",flexDirection:"column",gap:1,mt:2},children:[e.jsxs(s,{variant:"body1",sx:{fontSize:"12px"},color:"text.secondary",children:["Tags to Ignore (",d.length,")"]}),d.map((o,a)=>e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(y,{size:"small",value:o,onChange:v(a),placeholder:"new tag name",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}}),e.jsx(V,{color:"error",onClick:()=>w(a),children:e.jsx(P,{})})]},`store-${n._id}-tags-${a}`)),e.jsx(W,{onClick:r,startIcon:e.jsx(N,{}),variant:"outlined",children:"add new tag"})]})}),e.jsx(t,{children:e.jsxs(t,{sx:{display:"flex",flexDirection:"column",gap:1,mt:2},children:[e.jsxs(s,{variant:"body1",sx:{fontSize:"12px"},color:"text.secondary",children:["Item Types to Ignore (",p.length,")"]}),p.map((o,a)=>e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(y,{size:"small",value:o,onChange:z(a),placeholder:"new item type name",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}}),e.jsx(V,{color:"error",onClick:()=>T(a),children:e.jsx(P,{})})]},`store-${n._id}-itemTypes-${a}`)),e.jsx(W,{onClick:k,startIcon:e.jsx(N,{}),variant:"outlined",children:"add new item type"})]})}),e.jsx(t,{children:e.jsxs(t,{sx:{display:"flex",flexDirection:"column",gap:1,mt:2},children:[e.jsxs(s,{variant:"body1",sx:{fontSize:"12px"},color:"text.secondary",children:["Categories to Ignore (",f.length,")"]}),f.map((o,a)=>e.jsxs(t,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(y,{size:"small",value:o,onChange:le(a),placeholder:"new category name",sx:{backgroundColor:"background.paper","& .MuiInputBase-input":{fontSize:"12px",p:1},width:"100%",maxWidth:"400px"}}),e.jsx(V,{color:"error",onClick:()=>ce(a),children:e.jsx(P,{})})]},`store-${n._id}-categories-${a}`)),e.jsx(W,{onClick:D,startIcon:e.jsx(N,{}),variant:"outlined",children:"add new category"})]})}),e.jsx(t,{sx:{display:"flex",pt:2},children:c==="requested"?e.jsxs(t,{sx:{display:"flex",flexDirection:"column",width:"100%"},children:[e.jsx(s,{color:"error",sx:{mt:"auto",mx:2},children:S&&C.data.error.message}),e.jsxs(t,{sx:{display:"flex",justifyContent:"space-between",mt:1},children:[e.jsx(W,{onClick:()=>{g({storeId:n._id})},endIcon:b?e.jsx(_,{size:20}):e.jsx(Fe,{}),disabled:j||b,sx:{mt:"auto",mr:"auto"},children:"Mark Complete"}),e.jsx(W,{sx:{mt:"auto",ml:"auto"},endIcon:j?e.jsx(_,{size:20}):e.jsx(Z,{}),type:"submit",children:"Update Config"})]})]}):e.jsx(W,{sx:{mt:"auto",ml:"auto"},endIcon:j?e.jsx(_,{size:20}):e.jsx(Z,{}),type:"submit",children:"Update Config"})})]})})};export{At as default};
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.