1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9985],{89985:function(e,t,i){i.r(t),i.d(t,{changes:function(){return c},values:function(){return h}});var s=i(44610),o=i(67462),a=i(85893),n=i(67294),l=i(21606),r=i(83875),d=i(39828);let h=()=>({crm:"the CRM is the venue's customer list, at /manager/crm. Every customer who has ordered or chatted is already on it, and the manager can also add one by hand or bring a list in from a CSV file. Each customer card holds their name, their email addresses, their phone numbers and any notes, and opening one shows what they have spent and how often they come. The search box finds a customer by name, email or phone, and the filters narrow the list to a tag, to the ones with an email, the ones with a phone, the birthdays this month, or hide the ones who have opted out of marketing. The buttons down the side add a customer, email the whole list that is showing, send a Bring Back message to customers who have not been in for a while, and export or import a CSV file. A customer who is on the list twice can be merged into one, and removing a customer takes them off this venue without touching their record on any other"}),c={crm:{run:e=>JSON.stringify(h(e))}};class u extends n.Component{componentDidMount(){this.loadCustomers(),this.loadVenueOrders()}render(){let e=this.props.v;return(0,a.jsx)(r.AdminPanel,{v:e,id:"crm",defaultWidth:400,panelLarge:this.renderPanelLarge({v:e}),main:this.renderMain({v:e}),panelRight:{show:!!this.state.selectedCustomer,close:()=>this.setState({selectedCustomer:null,editedCustomer:null,hasChanges:!1}),save:this.state.hasChanges?this.saveCustomer:null,children:this.renderCustomerDetail({v:e})}})}constructor(){super(),this.loadCustomers=async()=>{let e=this.props.v;this.setState({loading:!0});try{let t=await (0,r.crm)({v:e,type:"get",clientKey:e.clientKey,limit:this.state.fetchLimit||100});this.setState({customersAll:t.customers||[],loading:!1})}catch(e){console.error("Error loading customers:",e),this.setState({loading:!1})}},this.loadVenueOrders=async()=>{let e=this.props.v;try{let t=await (0,r.orders)({v:e,type:"get",queryCustom:[(0,d.Xo)("time","desc")]}).catch(()=>(0,r.orders)({v:e,type:"get"})),i={};(t||[]).forEach(e=>i[e.key]=e),this.setState({ordersByKey:i})}catch(e){console.error("Error loading venue orders:",e)}},this.searchCustomers=async e=>{let t=this.props.v;this.setState({loading:!0});try{let i=await (0,r.crm)({v:t,type:"searchByName",searchText:e,clientKey:t.clientKey});this.setState({customersAll:i.customers||[],loading:!1})}catch(e){console.error("Error searching customers:",e),this.setState({loading:!1})}},this.handleSearch=()=>{let e=this.state.searchText;if(!e){this.loadCustomers();return}this.searchCustomers(e)},this.customerStats=e=>{let t=this.props.v,i=Object.values(e.history||{}).filter(e=>e.clientKey===t.clientKey),s=i.map(e=>{var t;return 1e3*((null===(t=e.time)||void 0===t?void 0:t.seconds)||0)}).filter(Boolean),o=i.filter(e=>e.orderKey),a=o.reduce((e,t)=>{var i,s,o;return e+(Number(null!==(o=t.total)&&void 0!==o?o:null===(s=this.state.ordersByKey)||void 0===s?void 0:null===(i=s[t.orderKey])||void 0===i?void 0:i.total)||0)},0),n=s.length?Math.min(...s):0,l=s.length?Math.max(...s):0,r=Date.now(),d=o.length&&l&&r-l>5184e6?"inactive":o.length>=5?"vip":n&&r-n<=2592e6?"new":"regular";return{ordersN:o.length,visits:i.length,spent:a,first:n,last:l,segment:d}},this.customersFiltered=()=>{let{customersAll:e=[],searchText:t,filterSegment:i,filterTag:s,filterHasEmail:o,filterHasPhone:a,filterBirthdayMonth:n,filterHideOptOut:l}=this.state,r=(t||"").toLowerCase().trim(),d=String(new Date().getMonth()+1).padStart(2,"0");return e.filter(e=>{var t,h,c,u;return(!r||!![e.name,...e.emails||[],...e.phones||[]].join(" ").toLowerCase().includes(r))&&(!i||this.customerStats(e).segment===i)&&(!s||!!(null===(t=e.tags)||void 0===t?void 0:t.includes(s)))&&(!o||!!(null===(h=e.emails)||void 0===h?void 0:h.length))&&(!a||!!(null===(c=e.phones)||void 0===c?void 0:c.length))&&(!n||(null===(u=e.birthday)||void 0===u?void 0:u.slice(5,7))===d)&&(!l||!e.optOut)})},this.timeMs=e=>(null==e?void 0:e.seconds)?1e3*e.seconds:e?new Date(e).getTime():0,this.segments=["new","regular","vip","inactive"],this.segStyle=e=>({new:l.Z.softGreen,regular:this.props.v.div9,vip:l.Z.softOrange,inactive:l.Z.softRed})[e]||l.Z.softGrey,this.segPill=e=>(0,o._)((0,s._)({},this.segStyle(e)),{borderRadius:999,padding:"0.15rem 0.65rem",fontSize:"0.72rem",fontWeight:600,width:"fit-content",letterSpacing:"0.02em"}),this.avatar=e=>{let t=this.props.v,i=e.photo||e.pic;return(0,a.jsx)("div",{style:(0,s._)((0,o._)((0,s._)({width:40,height:40,borderRadius:999},l.Z.flexRow0),{overflow:"hidden",flexShrink:0}),t.div9),children:i?(0,a.jsx)("img",{src:i,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(0,r.getIcon3)({icon:"user",fontSize:"1.25rem",color:t.pc})})},this.emailDialog=e=>{var t;let{recipients:i,subject:s="",message:o=""}=e,a=this.props.v;if(!i.length)return null===(t=a.updateToast)||void 0===t?void 0:t.call(a,{text:"No emailable customers in current list"});a.updateDialog({icon:"email",subject:s,message:o,text:"Sending to ".concat(i.length," customer").concat(i.length>
11?"s":""),fields:[{placeholder:"subject",noIcon:!0},{placeholder:"message",rows:5,noIcon:!0}],okButton:{text:"Send",icon:"email",onClick:async e=>{var t,s,o;let{state:n}=e,l=((null==n?void 0:null===(t=n.dialog)||void 0===t?void 0:t.subject)||"").trim(),d=((null==n?void 0:null===(s=n.dialog)||void 0===s?void 0:s.message)||"").trim();for(let e of(a.updateDialog(""),i))await (0,r.sendEmail3)({v:a,from:"venue",to:e,subject:l,title:l,content:[d.replace(/\n/g,"<br>")]});null===(o=a.updateToast)||void 0===o||o.call(a,{text:"Sent to ".concat(i.length),icon:"tick"})}}})},this.emailCustomer=e=>{var t,i,s;let o=null==e?void 0:null===(t=e.emails)||void 0===t?void 0:t[0];if(!o)return null===(i=(s=this.props.v).updateToast)||void 0===i?void 0:i.call(s,{text:"Customer has no email"});this.emailDialog({recipients:[o]})},this.bulkEmail=()=>{let e=[...new Set(this.customersFiltered().filter(e=>{var t;return(null===(t=e.emails)||void 0===t?void 0:t[0])&&!e.optOut}).map(e=>e.emails[0]))];this.emailDialog({recipients:e})},this.winBack=async()=>{let e=this.props.v;this.setState({loading:!0});let t=(await (0,r.crm)({v:e,type:"get",clientKey:e.clientKey,limit:1e3})).customers||this.state.customersAll||[];this.setState({customersAll:t,fetchLimit:1e3,filterSegment:"inactive",loading:!1});let i=[...new Set(t.filter(e=>{var t;return"inactive"===this.customerStats(e).segment&&(null===(t=e.emails)||void 0===t?void 0:t[0])&&!e.optOut}).map(e=>e.emails[0]))];this.emailDialog({recipients:i,subject:"We miss you at ".concat(e.venueTitle||"our venue","!"),message:"Hi,\n\nIt's been a while since your last visit to ".concat(e.venueTitle||"our venue"," and we'd love to welcome you back.\n\nSee you soon!")})},this.addCustomerDialog=()=>{let e=this.props.v;e.updateDialog({icon:"user",fields:[{placeholder:"name",noIcon:!0},{placeholder:"email",noIcon:!0},{placeholder:"phone",noIcon:!0}],okButton:{text:"Add",icon:"done",onClick:async t=>{let{state:i}=t,s=(null==i?void 0:i.dialog)||{};e.updateDialog(""),await (0,r.crm)({v:e,type:"add",order:{type:"manual",clientKey:e.clientKey,userInfo:{name:s.name||"",email:s.email||"",phone:s.phone||""}}}),this.loadCustomers()}}})},this.importCsv=async e=>{var t,i;let s=this.props.v,o=null===(t=e.target.files)||void 0===t?void 0:t[0];if(e.target.value="",!o)return;let a=(await o.text()).split(/\r?\n/).map(e=>e.trim()).filter(Boolean),n=e=>{let t=[],i="",s=!1;for(let o=0;o<e.length;o++){let a=e[o];s?'"'===a&&'"'===e[o+1]?(i+='"',o++):'"'===a?s=!1:i+=a:'"'===a?s=!0:","===a?(t.push(i),i=""):i+=a}return t.push(i),t.map(e=>e.trim())},l=0,d=0;for(let e of(this.setState({loading:!0}),a)){let[t="",i="",o=""]=n(e);if(!i.includes("@")&&o.replace(/\D/g,"").length<5){d++;continue}let a=await (0,r.crm)({v:s,type:"add",order:{type:"imported",clientKey:s.clientKey,userInfo:{name:t,email:i,phone:o}}});(null==a?void 0:a.success)?l++:d++}null===(i=s.updateToast)||void 0===i||i.call(s,{text:"Imported ".concat(l,", skipped ").concat(d),icon:"tick"}),this.loadCustomers()},this.exportCsv=()=>{let e=[["name","emails","phones","orders","spent","last visit","status","tags","birthday","opt out"],...this.customersFiltered().map(e=>{let t=this.customerStats(e);return[e.name||"",(e.emails||[]).join(";"),(e.phones||[]).join(";"),t.ordersN,t.spent.toFixed(2),t.last?new Date(t.last).toLocaleDateString():"",t.segment,(e.tags||[]).join(";"),e.birthday||"",e.optOut?"yes":""]})].map(e=>e.map(e=>'"'.concat(String(e).replace(/"/g,'""'),'"')).join(",")).join("\n"),t=document.createElement("a");t.href=URL.createObjectURL(new Blob([e],{type:"text/csv"})),t.download="customers.csv",t.click(),URL.revokeObjectURL(t.href)},this.removeCustomer=()=>{let e=this.props.v,t=this.state.selectedCustomer;(null==t?void 0:t.id)&&e.updateDialog({icon:"users",text:"Remove ".concat((0,r.capitalize)(t.name||"this customer")," from your CRM?"),okButton:{text:"Remove",onClick:async()=>{e.updateDialog(""),await (0,r.crm)({v:e,type:"update",customerId:t.id,updates:{clientKeys:(0,d.Ab)(e.clientKey)}}),this.setState({customersAll:(this.state.customersAll||[]).filter(e=>e.id!==t.id),selectedCustomer:null,editedCustomer:null,hasChanges:!1})}}})},this.mergeDialog=()=>{let e=this.props.v,t=this.state.selectedCustomer;(null==t?void 0:t.id)&&e.updateDialog({icon:"users",text:"Find the duplicate to merge into this customer",fields:[{placeholder:"email or phone",noIcon:!0}],okButton:{text:"Find",icon:"search",onClick:async i=>{var s,o,a;let{state:n}=i,l=((null==n?void 0:null===(s=n.dialog)||void 0===s?void 0:s["email or phone"])||"").trim(),h=await (0,r.crm)({v:e,type:"search",email:l,phone:l});if(!(null==h?void 0:h.found)||h.customer.id===t.id||!(null===(o=h.customer.clientKeys)||void 0===o?void 0:o.includes(e.clientKey)))return null===(a=e.updateToast)||void 0===a?void 0:a.call(e,{text:"No other customer found"});let c=h.customer;e.updateDialog({icon:"users",text:"Merge ".concat((0,r.capitalize)(c.name||"unnamed")," into ").concat((0,r.capitalize)(t.name||"unnamed"),"? The duplicate is removed from your CRM."),okButton:{text:"Merge",onClick:async()=>{var i,s,o,a,n,l;e.updateDialog("");let h={updatedAt:new Date};(null===(i=c.emails)||void 0===i?void 0:i.length)&&(h.emails=(0,d.vr)(...c.emails)),(null===(s=c.phones)||void 0===s?void 0:s.length)&&(h.phones=(0,d.vr)(...c.phones)),(null===(o=c.uids)||void 0===o?void 0:o.length)&&(h.uids=(0,d.vr)(...c.uids)),(null===(a=c.tags)||void 0===a?void 0:a.length)&&(h.tags=(0,d.vr)(...c.tags)
1),(null===(n=c.customerNotes)||void 0===n?void 0:n.length)&&(h.customerNotes=(0,d.vr)(...c.customerNotes)),c.name&&!t.name&&(h.name=c.name),c.birthday&&!t.birthday&&(h.birthday=c.birthday),c.preferences&&!t.preferences&&(h.preferences=c.preferences),c.language&&!t.language&&(h.language=c.language),c.optOut&&(h.optOut=!0),c.managerNotes&&(h.managerNotes=[t.managerNotes,c.managerNotes].filter(Boolean).join("\n")),Object.entries(c.history||{}).filter(t=>{let[,i]=t;return i.clientKey===e.clientKey}).forEach(e=>{let[t,i]=e;return h["history.".concat(t)]=i}),await (0,r.crm)({v:e,type:"update",customerId:t.id,updates:h}),await (0,r.crm)({v:e,type:"update",customerId:c.id,updates:{clientKeys:(0,d.Ab)(e.clientKey)}}),null===(l=e.updateToast)||void 0===l||l.call(e,{text:"Merged",icon:"tick"}),this.setState({selectedCustomer:null,editedCustomer:null,hasChanges:!1}),this.loadCustomers()}}})}}})},this.loadChats=async()=>{var e;let t=this.props.v,i=this.state.selectedCustomer,o=((null==i?void 0:i.uids)||[]).filter(Boolean).slice(0,30),a=null==i?void 0:null===(e=i.emails)||void 0===e?void 0:e[0];if(!o.length&&!a)return this.setState({chats:[]});this.setState({chatsLoading:!0});try{let e=(0,d.hJ)(r.fs,"clients",t.clientKey,"orders"),i=o.length?(0,d.IO)(e,(0,d.ar)("type","==","chat"),(0,d.ar)("customerId","in",o),(0,d.b9)(25)):(0,d.IO)(e,(0,d.ar)("type","==","chat"),(0,d.ar)("userInfo.email","==",a),(0,d.b9)(25)),n=await (0,d.PL)(i),l=[];n.forEach(e=>l.push((0,s._)({key:e.id},e.data()))),l.sort((e,t)=>this.timeMs(t.orderTime)-this.timeMs(e.orderTime)),this.setState({chats:l,chatsLoading:!1})}catch(e){console.error("Error loading chats:",e),this.setState({chats:[],chatsLoading:!1})}},this.renderPanelLarge=e=>{let{v:t}=e,i=[...new Set((this.state.customersAll||[]).flatMap(e=>e.tags||[]))],n=(e,i)=>(0,s._)({margin:2,padding:"0.3rem 0.8rem",fontSize:"0.78rem",borderRadius:999},e?(0,o._)((0,s._)({},i||t.div9),{fontWeight:700}):(0,o._)((0,s._)({},l.Z.softGrey),{fontWeight:500}));return(0,a.jsx)("div",{className:"mx-auto md:container",children:(0,a.jsxs)("div",{style:{padding:"1.5rem"},children:[(0,a.jsx)(r.Input2,{v:t,id:"crmSearch",medium:!0,noInstructions:!0,InputType:"input",icon:this.state.loading?"loading":"search",value:this.state.searchText||"",onChange:e=>this.setState({searchText:e.target.value}),button:this.state.searchText?{onClick:()=>this.handleSearch(),icon:"next"}:null,clearPrimary:!0}),this.renderTiles({v:t}),(0,a.jsxs)(r.Card7,{v:t,styleChildren:{padding:"1rem"},twenty:!0,children:[i.length?(0,a.jsx)("div",{style:(0,o._)((0,s._)({},l.Z.flexRowOnly),{flexWrap:"wrap",marginTop:15}),children:i.map(e=>(0,a.jsx)(r.Button5,{v:t,softGrey:!0,text:e,onClick:()=>this.setState({filterTag:this.state.filterTag===e?null:e}),style:n(this.state.filterTag===e)},e))}):null,(0,a.jsx)(r.Switch6,{v:t,icon:"email",text:"Has Email",checked:this.state.filterHasEmail||!1,onChange:()=>this.setState({filterHasEmail:!this.state.filterHasEmail})}),(0,a.jsx)(r.Switch6,{v:t,icon:"phone",text:"Has Phone",checked:this.state.filterHasPhone||!1,onChange:()=>this.setState({filterHasPhone:!this.state.filterHasPhone})}),(0,a.jsx)(r.Switch6,{v:t,icon:"calendar",text:"Birthdays This Month",checked:this.state.filterBirthdayMonth||!1,onChange:()=>this.setState({filterBirthdayMonth:!this.state.filterBirthdayMonth})}),(0,a.jsx)(r.Switch6,{v:t,icon:"hide",text:"Hide Opted-Out",checked:this.state.filterHideOptOut||!1,onChange:()=>this.setState({filterHideOptOut:!this.state.filterHideOptOut})})]}),(0,a.jsxs)("div",{style:(0,o._)((0,s._)({},l.Z.flexColOnly),{gap:6,marginTop:10}),children:[(0,a.jsx)(r.Button5,{v:t,soft:!0,large:!0,fullWidth:!0,icon:"user",text:"Add Customer",onClick:this.addCustomerDialog,style:{marginTop:20}}),(0,a.jsx)(r.Button5,{v:t,soft:!0,large:!0,fullWidth:!0,icon:"email",text:"Email List",onClick:this.bulkEmail,style:{marginTop:10}}),(0,a.jsx)(r.Button5,{v:t,soft:!0,large:!0,fullWidth:!0,icon:"marketing",text:"Bring Back",onClick:this.winBack,style:{marginTop:10}}),(0,a.jsx)(r.Button5,{v:t,softGrey:!0,large:!0,fullWidth:!0,icon:"document",text:"Export CSV",onClick:this.exportCsv,style:{marginTop:10}}),(0,a.jsx)(r.Button5,{v:t,softGrey:!0,large:!0,fullWidth:!0,icon:"uploadImage",text:"Import CSV",onClick:()=>{var e;return null===(e=this.importInput)||void 0===e?void 0:e.click()},style:{marginTop:10}}),(0,a.jsx)("input",{type:"file",accept:".csv,text/csv",style:{display:"none"},ref:e=>this.importInput=e,onChange:this.importCsv})]})]})})},this.viewOrder=e=>{let t=this.props.v;e&&t.updateDialog({renderOrder:!0,orderKey:e,hideOkButton:!0})},this.handleFieldChange=(e,t)=>
1{let i=this.state.editedCustomer||(0,s._)({},this.state.selectedCustomer);i[e]=t,this.setState({editedCustomer:i,hasChanges:!0})},this.handleArrayFieldChange=(e,t)=>{let i=t?t.split(",").map(e=>e.trim()).filter(e=>e):[];this.handleFieldChange(e,i)},this.saveCustomer=async()=>{var e,t;let i=this.props.v,o=this.state.editedCustomer||this.state.selectedCustomer;if(null==o?void 0:o.id)try{let t={name:o.name||"",emails:o.emails||[],phones:o.phones||[],customerNotes:o.customerNotes||[],managerNotes:o.managerNotes||"",birthday:o.birthday||"",tags:o.tags||[],preferences:o.preferences||"",language:o.language||"",optOut:o.optOut||!1};await (0,r.crm)({v:i,type:"update",customerId:o.id,updates:t});let a=this.state.customersAll.map(e=>e.id===o.id?(0,s._)({},e,t):e);this.setState({customersAll:a,selectedCustomer:(0,s._)({},o,t),editedCustomer:null,hasChanges:!1}),null===(e=i.updateToast)||void 0===e||e.call(i,{text:"Saved",icon:"tick"})}catch(e){console.error("Error saving customer:",e),null===(t=i.updateToast)||void 0===t||t.call(i,{text:"Failed to save customer changes"})}},this.renderCustomerDetail=e=>{let{v:t}=e;if(console.log("sss",this.state),!this.state.selectedCustomer)return null;{var i,n,d,h,c;let e=this.state.editedCustomer||this.state.selectedCustomer,u=e.history?Object.entries(e.history):[],m=this.customerStats(this.state.selectedCustomer),g=(null===(i=t.info)||void 0===i?void 0:i.currencySymbol)||"";return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{style:(0,o._)((0,s._)({},l.Z.flexRowOnly),{alignItems:"center",gap:12}),children:[(0,a.jsx)("div",{style:(0,s._)((0,o._)((0,s._)({width:56,height:56,borderRadius:999},l.Z.flexRow0),{flexShrink:0,fontWeight:800,fontSize:"1.1rem",color:t.pc}),t.div9),children:(e.name||"").trim()?e.name.trim().split(/\s+/).map(e=>e[0]).slice(0,2).join("").toUpperCase():(0,r.getIcon3)({icon:"user",fontSize:"1.4rem",color:t.pc})}),(0,a.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,a.jsx)("div",{style:{fontSize:"1.4rem",fontWeight:800,lineHeight:1.15},children:(0,r.capitalize)(e.name||"Unnamed")}),(0,a.jsxs)("div",{style:(0,o._)((0,s._)({},l.Z.flexRowOnly),{alignItems:"center",gap:8,marginTop:5}),children:[(0,a.jsx)(r.Text3,{v:t,text:(0,r.capitalize)(m.segment),style:(0,s._)({color:t.pc},l.Z.heading)}),m.first?(0,a.jsxs)("span",{style:{color:"rgb(107 114 128)",fontSize:"0.8rem"},children:["Guest since ",new Date(m.first).toLocaleDateString(void 0,{month:"short",year:"numeric"})]}):null]})]})]}),(0,a.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10,marginTop:16},children:[["Orders",String(m.ordersN)],["Total Spent",g+m.spent.toFixed(2)],["Visits",String(m.visits)],["Avg / Visit",g+(m.visits?m.spent/m.visits:0).toFixed(2)]].map(e=>{let[i,n]=e;return(0,a.jsxs)("div",{style:(0,o._)((0,s._)({},t.div9,t.style.br),{padding:"0.9rem 1.1rem"}),children:[(0,a.jsx)("div",{style:{fontSize:"0.65rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"rgb(107 114 128)"},children:i}),(0,a.jsx)("div",{style:{fontSize:"1.5rem",fontWeight:800,lineHeight:1.1,marginTop:3},children:n})]},i)})}),(0,a.jsx)(r.Input2,{v:t,icon:"user",placeholder:"Customer Name",value:e.name||"",onChange:e=>this.handleFieldChange("name",e.target.value),twenty:!0}),(0,a.jsx)(r.Input2,{v:t,icon:"email",placeholder:"Email Addresses (comma-separated)",value:(null===(n=e.emails)||void 0===n?void 0:n.join(", "))||"",onChange:e=>this.handleArrayFieldChange("emails",e.target.value),twenty:!0}),(0,a.jsx)(r.Input2,{v:t,icon:"phone",placeholder:"Phone Numbers (comma-separated)",value:(null===(d=e.phones)||void 0===d?void 0:d.join(", "))||"",onChange:e=>this.handleArrayFieldChange("phones",e.target.value),twenty:!0}),(0,a.jsx)(r.Input2,{v:t,noIcon:!0,placeholder:"Customer Notes (comma-separated)",value:(null===(h=e.customerNotes)||void 0===h?void 0:h.join(", "))||"",onChange:e=>this.handleArrayFieldChange("customerNotes",e.target.value),textarea:!0,rows:3,twenty:!0}),(0,a.jsx)(r.Input2,{v:t,noIcon:!0,placeholder:"Manager Notes",value:e.managerNotes||"",onChange:e=>this.handleFieldChange("managerNotes",e.target.value),button:{icon:"save",onClick:()=>this.saveCustomer()},textarea:!0,rows:3,twenty:!0}),(0,a.jsx)(r.Input2,{v:t,icon:"edit",placeholder:"Tags (comma-separated)",value:(null===(c=e.tags)||void 0===c?void 0:c.join(", "))||"",onChange:e=>this.handleArrayFieldChange("tags",e.target.value),twenty:!0}),(0,a.jsx)(r.Input2,{v:t,noIcon:!0,InputType:"input",type:"date",instructions:"Birthday",placeholder:"Birthday",value:e.birthday||"",onChange:e=>this.handleFieldChange("birthday",e.target.value),twenty:!0}),(0,a.jsx)(r.Input2,{v:t,icon:"edit",placeholder:"Preferences (dietary, allergies, roomâ¦)",value:e.preferences||"",onChange:e=>this.handleFieldChange("preferences",e.target.value),rows:2,twenty:!0}),(0,a.jsx)(r.Input2,{v:t,icon:"edit",placeholder:"Language",value:e.language||"",onChange:e=>this.handleFieldChange("language",e.target.value),twenty:!0}),(0,a.jsx)(r.Switch6,{v:t,twenty:!0,icon:"email",text:"Marketing Opt-Out",description:"Excluded from bulk emails",checked:e.optOut||!1,onChange:()=>this.handleFieldChange("optOut",!e.optOut),button:!0}),(0,a.jsx)(r.Card7,{v:t,title:"Chats",icon:"email",twenty:!0,useDropDown2:!0,styleChildren:{padding:"1rem"},children:null==this.state.chats?(0,a.jsx)(r.Button5,{v:t,softest:!0,text:this.state.chatsLoading?"Loadingâ¦":"Load Chats",onClick:this.loadChats}):this.state.chats.length?this.state.chats.map((e,t)=>(0,a.jsxs)("div",{style:(0,s._)({padding:"0.5rem"},t?{borderTop:"1px solid #e5e7eb"}:{}),children:[(0,a.jsxs)("div",{style:{fontWeight:"customer"===e.from?"bold":"normal"},children:["customer"===e.from?"Customer":"Venue",": ",e.message||""]}),(0,a.jsx)("div",{style:{color:"#999",fontSize:"0.8rem"},children:this.timeMs(e.orderTime)?new Date(this.timeMs(e.orderTime)).toLocaleStr
1ing():""})]},e.key)):(0,a.jsx)("div",{style:{fontSize:"0.9rem",color:"#999"},children:"No chats found"})}),(0,a.jsx)(r.Card7,{v:t,title:"Activity History",icon:"calendar",twenty:!0,useDropDown2:!0,styleChildren:{padding:"1rem"},children:u.length?(0,a.jsx)(a.Fragment,{children:u.sort((e,t)=>{var i,s;return((null===(i=t[1].time)||void 0===i?void 0:i.seconds)||0)-((null===(s=e[1].time)||void 0===s?void 0:s.seconds)||0)}).map((e,i)=>{let[o,n]=e;return(0,a.jsxs)("div",{style:(0,s._)({padding:"0.5rem",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},i?{borderTop:"1px solid #e5e7eb"}:{}),children:[(0,a.jsx)("div",{style:{fontWeight:"bold",cursor:n.clientKey===t.clientKey?"pointer":"default"},onClick:()=>n.clientKey===t.clientKey&&this.viewOrder(n.orderKey),children:n.clientKey===t.clientKey?(0,a.jsxs)(a.Fragment,{children:[(0,r.capitalize)(n.name||"")," ",n.orderKey?"#"+n.orderKey.slice(-5):""]}):(0,a.jsx)("span",{style:{color:"#999",fontWeight:"normal"},children:n.venueTitle||"Other Venue"})}),n.time&&(0,a.jsx)("div",{style:{color:"#999",fontSize:"0.8rem"},children:new Date(1e3*n.time.seconds).toLocaleString()})]},o)})}):(0,a.jsx)("div",{style:{fontSize:"0.9rem",color:"#999",marginTop:"0.5rem"},children:"No activity history"})}),(0,a.jsxs)("div",{style:(0,s._)({},l.Z.flexColOnly),children:[(0,a.jsx)(r.Button5,{v:t,soft:!0,large:!0,fullWidth:!0,twenty:!0,icon:"email",text:"Email",onClick:()=>this.emailCustomer(e)}),(0,a.jsx)(r.Button5,{v:t,soft:!0,large:!0,fullWidth:!0,twenty:!0,icon:"users",text:"Merge",onClick:this.mergeDialog}),(0,a.jsx)(r.Button5,{v:t,softGrey:!0,large:!0,fullWidth:!0,twenty:!0,icon:"cleaningBrush",text:"Remove",onClick:this.removeCustomer})]})]})}},this.renderTiles=e=>{let{v:t}=e,i=this.state.customersAll||[],n=new Date;n.setDate(1),n.setHours(0,0,0,0);let d=0,h=0,c=0;i.forEach(e=>{let t=this.customerStats(e);t.first&&t.first>=n.getTime()&&d++,t.ordersN>=2&&h++,"vip"===t.segment&&c++});let u=[{label:"Customers",value:i.length,color:t.pc,icon:"users",onClick:()=>this.setState({filterSegment:null})},{label:"New This Month",value:d,color:l.Z.softGreen.color,icon:"user",onClick:()=>this.setState({filterSegment:"new"})},{label:"Returning",value:i.length?Math.round(h/i.length*100)+"%":"-",color:l.Z.softGrey.color,icon:"thumbsUpDouble"},{label:"VIPs",value:c,color:l.Z.softOrange.color,icon:"starFill",onClick:()=>this.setState({filterSegment:"vip"})}];return(0,a.jsx)("div",{style:(0,o._)((0,s._)({},l.Z.flexRowOnly),{flexWrap:"wrap",margin:"20px -5px 0"}),children:u.map(e=>(0,a.jsx)(r.Button6,{v:t,icon2:e.icon,name:String(e.value),description:e.label,onClick:e.onClick,style:(0,o._)((0,s._)({},l.Z.boxShadowLite),{backgroundColor:"#fff",color:e.color,minWidth:130,minHeight:"5rem",margin:5}),styleName:{fontSize:"1.7rem",fontWeight:800,lineHeight:1.1},styleDescription:{fontSize:"0.68rem",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"rgb(107 114 128)"}},e.label))})},this.renderMain=e=>{var t;let{v:i}=e,s=this.customersFiltered(),o=(null===(t=i.info)||void 0===t?void 0:t.currencySymbol)||"",n=this.state.customersAll?s.map((e,t)=>{var s,n;let l=this.customerStats(e);return{avatar:{value:"",render:this.avatar(e)},name:(0,r.capitalize)(e.name||"")||"-",status:{value:this.segments.indexOf(l.segment),render:(0,a.jsx)(r.Text3,{v:i,text:(0,r.capitalize)(l.segment),style:this.segPill(l.segment)})},orders:l.ordersN,spent:{value:l.spent,render:l.spent?o+l.spent.toFixed(2):"-"},"last visit":{value:l.last,render:l.last?new Date(l.last).toLocaleDateString():"-"},email:(null===(s=e.emails)||void 0===s?void 0:s[0])||"-",phone:(null===(n=e.phones)||void 0===n?void 0:n[0])||"-",index:t}}):null;return(0,a.jsx)("div",{style:{flex:1,display:"flex",flexDirection:"column",height:"100%",overflow:"scroll",padding:"1rem"},children:(0,a.jsxs)("div",{style:{flex:1,minWidth:0,width:"100%"},children:[(0,a.jsx)(r.Table1,{v:i,header:[{name:"avatar",label:""},{name:"name",link:!0,sortable:!0,onClick:e=>{let t=s[e.index];t&&this.setState({selectedCustomer:t,editedCustomer:null,hasChanges:!1,chats:null})}},{name:"status",sortable:!0},{name:"orders",sortable:!0},{name:"spent",sortable:!0},{name:"last visit",sortable:!0},{name:"email",sortable:!0},{name:"phone",sortable:!0}],data:n,empty:{icon:"users",text:"No Customers Found",style:{height:"100%"}}}),(this.state.customersAll||[]).length>=(this.state.fetchLimit||100)?(0,a.jsx)(r.Button5,{v:i,soft:!0,text:"Load More",onClick:()=>this.setState({fetchLimit:(this.state.fetchLimit||100)+200},this.loadCustomers),style:{marginTop:10}}):null]})})},this.state={}}}t.default=u}}]);
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.