1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/js/jspdf.es.min-Bdr6jyme.js","assets/js/index-CAG7YFZd.js","assets/css/index-B-wIbh4z.css"])))=>i.map(i=>d[i]); 2import{_ as I,r as p,e as X,t as b,j as e,m as q}from"./index-CAG7YFZd.js";import{D as K,a as ee,b as te,c as se,d as ae,e as T}from"./dropdown-menu-CfBNnlBC.js";import{a as S}from"./index-BTR0BB7t.js";import{D as le,a as re,d as ie,b as ne}from"./dialog-GAffG_et.js";import{S as oe}from"./search-B8wRtotC.js";import{D as de}from"./download-DJSvN6gr.js";import{C as ce}from"./chevron-down-C3dIF40-.js";import{F as xe}from"./file-down-CDwebIUU.js";import{F as me}from"./file-spreadsheet-CLzZZJ2P.js";import{F as he}from"./file-text-7Q36_7-K.js";import{E as pe}from"./eye-D0SP7Wk-.js";import{C as L}from"./circle-check-big-BAIqo4vn.js";import{C as ue}from"./circle-x-CMiMiRa7.js";import{M as fe}from"./mail-CA9foQP_.js";import{P as be}from"./phone-DiNiwgLL.js";import{C as R}from"./calendar-Cj5amzTI.js";import{P as U}from"./package-DNWl5qPR.js";import{I as ge}from"./indian-rupee-CxTvjaab.js";import{M as je}
2from"./map-pin-DAIQP7vC.js";import"./index-QHXycSr2.js";import"./index-CBAjRXir.js";import"./index-CHqH92X0.js";import"./index-r6P5ANRq.js";import"./index-Cf6hN_Fs.js";import"./tslib.es6-CwyXKlH1.js";import"./index-DnCL3ZlK.js";import"./index-Dc0kaaFU.js";import"./index-gW1jScX8.js";import"./chevron-right-DFSfj0ll.js";import"./x-BCVCJpKG.js";const z=(...x)=>{},Ne=(x,v="customers")=>{if(!x||x.length===0){alert("No customers to export");return}const d=["SI","Name","Email","Phone","Total Order","Total Order Amount","Joining Date","Status"],m=x.map((u,N)=>[u.sl||N+1,u.name||"N/A",u.email||"N/A",u.phone||"N/A",u.totalOrder||0,`$${(u.totalOrderAmount||0).toFixed(2)}`,u.joiningDate||"N/A",u.status?"Active":"Inactive"]),f=u=>{if(u==null)return"";const N=String(u);return N.includes(",")||N.includes('"')||N.includes(` 3`)?`"${N.replace(/"/g,'""')}"`:N},j=[d.map(f).join(","),...m.map(u=>u.map(f).join(","))].join(` 4`),o="\uFEFF",g=new Blob([o+j],{type:"text/csv;charset=utf-8;"}),r=document.createElement("a"),i=URL.createObjectURL(g);r.setAttribute("href",i);const h=new Date().toISOString().split("T")[0];r.setAttribute("download",`${v}_${h}.csv`),r.style.visibility="hidden",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)},ve=(x,v="customers")=>{if(!x||x.length===0){alert("No customers to export");return}const d=["SI","Name","Email","Phone","Total Order","Total Order Amount","Joining Date","Status"],m=x.map((i,h)=>[i.sl||h+1,i.name||"N/A",i.email||"N/A",i.phone||"N/A",i.totalOrder||0,(i.totalOrderAmount||0).toFixed(2),i.joiningDate||"N/A",i.status?"Active":"Inactive"]),f=` 5 <html> 6 <head> 7 <meta charset="utf-8"> 8 <style> 9 table { border-collapse: collapse; width: 100%; } 10 th, td { border: 1px solid #ddd; padding: 8px; text-align: left; } 11 th { background-color: #f2f2f2; font-weight: bold; } 12 </style> 13 </head> 14 <body> 15 <table> 16 <thead> 17 <tr> 18 ${d.map(i=>`<th>${i}</th>`).join("")} 19 </tr> 20 </thead> 21 <tbody> 22 ${m.map(i=>`<tr>${i.map(h=>`<td>${h}</td>`).join("")}</tr>`).join("")} 23 </tbody> 24 </table> 25 </body> 26 </html> 27 `,j=new Blob([f],{type:"application/vnd.ms-excel"}),o=document.createElement("a"),g=URL.createObjectURL(j);o.setAttribute("href",g);const r=new Date().toISOString().split("T")[0];o.setAttribute("download",`${v}_${r}.xls`),o.style.visibility="hidden",document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(g)},ye=(x,v="customers")=>{if(!x||x.length===0){alert("No customers to export");return}try{I(async()=>{const{default:d}=await import("./jspdf.es.min-Bdr6jyme.js").then(m=>m.j);return{default:d}},__vite__mapDeps([0,1,2])).then(({default:d})=>{I(async()=>{const{default:m}=await import("./jspdf.plugin.autotable-KFqWVtFs.js");return{default:m}},[]).then(({default:m})=>{const f=new d({orientation:"landscape",unit:"mm",format:"a4"});f.setFontSize(16),f.text("Customers Report",14,15),f.setFontSize(10);const j=new Date().toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"});f.text(`Exported on: ${j} | Total Records: ${x.length}`,14,22);const o=x.map((r,i)=>[r.sl||i+1,r.name||"N/A",r.email||"N/A",r.phone||"N/A",r.totalOrder||0,`$${(r.totalOrderAmount||0).toFixed(2)}`,r.joiningDate||"N/A",r.status?"Active":"Inactive"]);m(f,{head:[["SI","Name","Email","Phone","Total Order","Total Order Amount","Joining Date","Status"]],body:o,startY:28,styles:{fontSize:8,cellPadding:2},headStyles:{fillColor:[241,245,249],textColor:[15,23,42],fontStyle:"bold"},alternateRowStyles:{fillColor:[248,250,252]},columnStyles:{0:{cellWidth:15},1:{cellWidth:35},2:{cellWidth:45},3:{cellWidth:30},4:{cellWidth:25},5:{cellWidth:30},6:{cellWidth:30},7:{cellWidth:25}},margin:{top:28,left:14,right:14}});const g=new Date().toISOString().split("T")[0];f.save(`${v}_${g}.pdf`)}).catch(m=>{z("Error loading jspdf-autotable:",m),alert("Failed to load PDF library. Please try again.")})}).catch(d=>{z("Error loading jsPDF:",d),alert("Failed to load PDF library. Please try again.")})}catch{alert("Failed to export PDF. Please try again.")}};function Ke(){const[x,v]=p.useState(""),[d,m]=p.useState([]),[f,j]=p.useState(!0),[o,g]=p.useState(0),[r,i]=p.useState(1),[h,u]=p.useState(()=>Number(localStorage.getItem("admin_customers_pageSize"))||20),[N,V]=p.useState(null),[c,G]=p.useState(null),[W,P]=p.useState(!1),[J,k]=p.useState(!1),[l,M]=p.useState({orderDate:"",joiningDate:"",status:"",sortBy:"",chooseFirst:""}),[F,H]=p.useState(!0);p.useEffect(()=>{let t=!1;return(async()=>{try{const a=await S.getCustomizationSettings();if(!t&&a?.data?.data){const n=a.data.data;n.cod_blocking_feature_enabled!==void 0&&H(n.cod_blocking_feature_enabled)}}catch{}})(),()=>{t=!0}},[]);const y=p.useMemo(()=>{let t=[...d];return l.joiningDate&&(t=t.filter(s=>{const a=new Date(s.joiningDate),n=new Date(l.joiningDate);return a.toDateString()===n.toDateString()})),l.status&&(l.status==="active"?t=t.filter(s=>s.status===!0):l.status==="inactive"&&(t=t.filter(s=>s.status===!1))),l.sortBy&&(l.sortBy==="name-asc"?t.sort((s,a)=>s.name.localeCompare(a.name)):l.sortBy==="name-desc"?t.sort((s,a)=>a.name.localeCompare(s.name)):l.sortBy==="orders-asc"?t.sort((s,a)=>
27s.totalOrder-a.totalOrder):l.sortBy==="orders-desc"&&t.sort((s,a)=>a.totalOrder-s.totalOrder)),l.chooseFirst&&parseInt(l.chooseFirst)>0&&(t=t.slice(0,parseInt(l.chooseFirst))),t},[d,l]),C=(t,s)=>{M(a=>({...a,[t]:s})),i(1)},_=t=>{if(!t)return"-";try{const s=new Date(t);if(Number.isNaN(s.getTime()))return String(t);const a=String(s.getDate()).padStart(2,"0"),n=s.toLocaleString("en-GB",{month:"short"}),O=s.getFullYear(),D=s.toLocaleString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!0});return`${a} ${n} ${O}, ${D}`}catch{return String(t)}};p.useEffect(()=>{i(1)},[x]),p.useEffect(()=>{let t=!1;const n=setTimeout(async()=>{try{j(!0);const O={limit:h,page:r,...x&&{search:x},...l.status&&{status:l.status},...l.joiningDate&&{joiningDate:l.joiningDate},...l.sortBy&&{sortBy:l.sortBy},...l.chooseFirst&&{chooseFirst:l.chooseFirst}},D=await S.getCustomers(O),w=D?.data?.data||D?.data?.data||D?.data,$=Array.isArray(w?.customers)?w.customers:Array.isArray(w?.users)?w.users:Array.isArray(w)?w:[];!t&&Array.isArray($)?(m($),g(w?.total||$.length)):t||(m([]),g(0))}catch{b.error("Failed to load customers"),t||(m([]),g(0))}finally{t||j(!1)}},x?250:0);return()=>{t=!0,clearTimeout(n)}},[r,h,x,l.status,l.joiningDate,l.sortBy,l.chooseFirst]);const[Q]=X(),A=Q.get("userId");p.useEffect(()=>{if(A&&d.length>0){const t=d.find(s=>s.id===A||s._id===A);t&&E(t.id||t.sl||t._id)}},[A,d]);const Y=async t=>{try{const s=d.find(n=>(n._id||n.id)===t);if(!s)return;const a=!s.status;m(d.map(n=>n.id===t?{...n,status:a}:n)),await S.updateCustomerStatus(t,a),b.success(`User ${a?"activated":"deactivated"} successfully`)}catch{b.error("Failed to update status"),m(d.map(a=>a.id===t?{...a,status:!a.status}:a))}},Z=async t=>{try{const s=d.find(n=>(n._id||n.id)===t);if(!s)return;const a=!s.isCodBlocked;m(d.map(n=>(n.id||n._id)===t?{...n,isCodBlocked:a}:n)),await S.updateCustomerCodStatus(t,a),b.success(`User COD ${a?"blocked":"unblocked"} successfully`)}catch{b.error("Failed to update COD status"),m(d.map(a=>(a.id||a._id)===t?{...a,isCodBlocked:!a.isCodBlocked}:a))}},E=async t=>{try{P(!0),k(!0),V(t);const s=await S.getCustomerById(t),a=s?.data?.data||s?.data;a?.user?G(a.user):(b.error("Failed to load user details"),k(!1))}catch{b.error("Failed to load user details"),k(!1)}finally{P(!1)}},B=t=>{if(y.length===0){b.error("No customers to export");return}const s="customers";try{switch(t){case"csv":Ne(y,s),b.success("CSV export started");break;case"excel":ve(y,s),b.success("Excel export started");break;case"pdf":ye(y,s),b.success("PDF download started");break;default:b.error("Invalid export format");break}}catch{b.error("Failed to export customers")}};return e.jsxs("div",{className:"p-4 lg:p-6 bg-slate-50 min-h-screen",children:[e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-6 mb-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-2",children:"Order Date"}),e.jsx("div",{className:"relative",children:e.jsx("input",{type:"date",value:l.orderDate,onChange:t=>C("orderDate",t.target.value),className:"w-full px-4 py-2.5 border border-slate-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-2",children:"Customer Joining Date"}),e.jsx("div",{className:"relative",children:e.jsx("input",{type:"date",value:l.joiningDate,onChange:t=>C("joiningDate",t.target.value),className:"w-full px-4 py-2.5 border border-slate-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-2",children:"Customer status"}),e.jsxs("select",{value:l.status,onChange:t=>C("status",t.target.value),className:"w-full px-4 py-2.5 border border-slate-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:[e.jsx("option",{value:"",children:"Select Status"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"inactive",children:"Inactive"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-2",children:"Sort By"}),e.jsxs("select",{value:l.sortBy,onChange:t=>C("sortBy",t.target.value),className:"w-full px-4 py-2.5 border border-slate-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:[e.jsx("option",{value:"",children:"Select Customer Sorting Order"}),e.jsx("option",{value:"name-asc",children:"Name (A-Z)"}),e.jsx("option",{value:"name-desc",children:"Name (Z-A)"}),e.jsx("option",{value:"orders-asc",children:"Orders (Low to High)"}),e.jsx("option",{value:"orders-desc",children:"Orders (High to Low)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-2",children:"Choose First"}),e.jsx("input",{type:"number",value:l.chooseFirst,onChange:t=>C("chooseFirst",t.target.value),placeholder:"Ex: 100",className:"w-full px-4 py-2.5 border border-slate-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm"})]})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>{},className:"px-6 py-2.5 text-sm font-medium rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-all",children:"Apply Filters"}),e.jsx("button",{onClick:()=>{M({orderDate:"",joiningDate:"",status:"",sortBy:"",chooseFirst:""})},className:"px-6 py-2.5 text-sm font-medium rounded-lg border border-slate-300 bg-white text-slate-700 hover:bg-slate-50 transition-all",children:"Reset Filters"})]}),e.jsx("div",{className:"text-sm text-slate-600",children:f?"Loading...":`Showing ${y.length} of ${o} customers`})]})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-xl font-bold text-slate-900",children:"Customer list"}),e.jsx("span",{className:"px-3 py-1 rounded-full text-sm font-semibold bg-slate-100 text-slate-700 flex items-center justify-center min-w-[2.5rem] h-7",children:f?e.jsx("span",{className:"w-5 h-3 rounded bg-slate-300/80 animate-pulse"}):o})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-initial min-w-[200px]",children:[e.jsx("input",{type:"text",placeholder:"Ex: Search by name",value:x,onChange:t=>{v(t.target.value),i(1)},className:"pl-10 pr-4 py-2.5 w-full text-sm rounded-lg border border-slate-300 bg-white focus:outline-none focus:ring-2 focus:ring-slate-400 focus:border-slate-400"}),e.jsx(oe,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-slate-400"})]}),e.jsxs(K,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("button",{className:"px-4 py-2.5 text-sm font-medium rounded-lg border border-slate-300 bg-white hover:bg-slate-50 text-slate-700 flex items-center gap-2 transition-all",children:[e.jsx(de,{className:"w-4 h-4"}),e.jsx("span",{className:"text-black font-bold",children:"Export"}),e.jsx(ce,{className:"w-3 h-3"})]})}),e.jsxs(te,{align:"end",className:"w-56 bg-white border border-slate-200 rounded-lg shadow-lg z-50",children:[e.jsx(se,{children:"Export Format"}),e.jsx(ae,{}),e.jsxs(T,{onClick:()=>B("csv"),className:"cursor-pointer",children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),"Export as CSV"]}),e.jsxs(T,{onClick:()=>B("excel"),className:"cursor-pointer",children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),"Export as Excel"]}),e.jsxs(T,{onClick:()=>B("pdf"),className:"cursor-pointer",children:[e.jsx(he,{className:"w-4 h-4 mr-2"}),"Export as PDF"]})]})]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-full",children:[e.jsx("thead",{className:"bg-slate-50 border-b border-slate-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Sl"}),e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Name"}),e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Contact Info"}),e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Total Order"}),e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Total Amount"}),e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Joining Date"}),e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Active/Inactive"}),F&&e.jsx("th",{className:"px-3 py-4 text-left text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"COD Blocked"}),e.jsx("th",{className:"px-3 py-4 text-center text-[10px] font-bold text-slate-700 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-slate-100",children:f?e.jsx("tr",{children:e.jsx("td",{colSpan:F?9:8,className:"px-6 py-8 text-center",children:e.jsx("div",{className:"text-sm text-slate-500",children:"Loading customers..."})})}):y.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:F?9:8,className:"px-6 py-8 text-center",children:e.jsx("div",{className:"text-sm text-slate-500",children:"No customers found"})})}):y.map((t,s)=>e.jsxs("tr",{className:"hover:bg-slate-50 transition-colors",children:[e.jsx("td",{className:"px-3 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm font-medium text-slate-700",children:(r-1)*h+s+1})}),e.jsx("td",{className:"px-3 py-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center shrink-0 overflow-hidden cursor-pointer hover:opacity-80 transition-all border border-slate-200",style:{background:"linear-gradient(135deg, #E8EEF7 0%, #C5D3E5 100%)"},onClick:()=>E(t._id||t.id||t.sl),children:e.jsx("img",{src:t.profileImage||"/profile_avatar.webp",alt:t.name,className:"w-full h-full object-cover",style:{mixBlendMode:"multiply"},onError:a=>{a.currentTarget.src="/profile_avatar.webp"}})}),e.jsx("span",{className:"text-sm font-medium text-slate-900 cursor-pointer hover:text-blue-600 transition-colors",onClick:()=>E(t._id||t.id||t.sl),children:t.name})]})}),e.jsx("td",{className:"px-3 py-4",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm text-slate-700",children:t.email||"NA"}),e.jsx("span",{className:"text-xs text-slate-500",children:t.phone})]})}),e.jsx("td",{className:"px-3 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-slate-700",children:t.totalOrder||0})}),e.jsx("td",{className:"px-3 py-4 whitespace-nowrap",children:e.jsxs("span",{className:"text-sm font-medium text-slate-900",children:["â¹"," ",(t.totalOrderAmount||0).toLocaleStr
27ing("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})]})}),e.jsx("td",{className:"px-3 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-slate-700",children:_(t.joiningDate)})}),e.jsx("td",{className:"px-3 py-4 whitespace-nowrap",children:e.jsx("button",{onClick:()=>Y(t.id||t.sl),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2 ${t.status?"bg-green-600":"bg-slate-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t.status?"translate-x-6":"translate-x-1"}`})})}),F&&e.jsx("td",{className:"px-3 py-4 whitespace-nowrap",children:e.jsx("button",{onClick:()=>Z(t.id||t.sl||t._id),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 ${t.isCodBlocked?"bg-red-600":"bg-slate-300"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t.isCodBlocked?"translate-x-6":"translate-x-1"}`})})}),e.jsx("td",{className:"px-3 py-4 whitespace-nowrap text-center",children:e.jsx("button",{onClick:()=>E(t._id||t.id||t.sl),className:"p-1.5 rounded text-blue-600 hover:bg-blue-50 transition-colors",children:e.jsx(pe,{className:"w-4 h-4"})})})]},t.id||t.sl))})]})}),o>0&&e.jsxs("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-4 border-t border-slate-100 bg-white px-4 py-4 sm:px-6 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-slate-500 font-medium",children:"Rows per page:"}),e.jsxs("select",{value:h,onChange:t=>{const s=Number(t.target.value);u(s),localStorage.setItem("admin_customers_pageSize",s),i(1)},className:"rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-sm font-semibold text-slate-700 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:border-slate-400 cursor-pointer shadow-sm",children:[e.jsx("option",{value:10,children:"10"}),e.jsx("option",{value:20,children:"20"}),e.jsx("option",{value:50,children:"50"}),e.jsx("option",{value:100,children:"100"})]})]}),e.jsxs("div",{className:"flex flex-1 justify-between sm:hidden w-full",children:[e.jsx("button",{onClick:()=>i(t=>Math.max(t-1,1)),disabled:r===1,className:"relative inline-flex items-center rounded-md border border-slate-300 bg-white px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-50 transition-colors",children:"Previous"}),e.jsx("button",{onClick:()=>i(t=>Math.min(t+1,Math.ceil(o/h))),disabled:r>=Math.ceil(o/h),className:"relative ml-3 inline-flex items-center rounded-md border border-slate-300 bg-white px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-50 transition-colors",children:"Next"})]}),e.jsxs("div",{className:"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between w-full",children:[e.jsx("div",{className:"pl-4",children:e.jsxs("p",{className:"text-sm text-slate-600",children:["Showing ",e.jsx("span",{className:"font-semibold text-slate-900",children:Math.min(o,(r-1)*h+1)})," to"," ",e.jsx("span",{className:"font-semibold text-slate-900",children:Math.min(o,r*h)})," of"," ",e.jsx("span",{className:"font-semibold text-slate-900",children:o})," customers"]})}),e.jsx("div",{children:e.jsxs("nav",{className:"isolate inline-flex -space-x-px rounded-md shadow-sm gap-1","aria-label":"Pagination",children:[e.jsx("button",{onClick:()=>i(t=>Math.max(t-1,1)),disabled:r===1,className:"relative inline-flex items-center rounded-md px-2.5 py-1.5 text-slate-500 border border-slate-200 hover:bg-slate-50 disabled:opacity-50 transition-colors",children:"<"}),Array.from({length:Math.ceil(o/h)},(t,s)=>s+1).filter(t=>t===1||t===Math.ceil(o/h)||t>=r-2&&t<=r+2).map((t,s,a)=>{const n=s>0&&t-a[s-1]>1;return e.jsxs(q.Fragment,{children:[n&&e.jsx("span",{className:"px-3 py-1.5 text-slate-400 text-sm",children:"..."}),e.jsx("button",{onClick:()=>i(t),className:`relative inline-flex items-center px-3.5 py-1.5 text-sm font-semibold rounded-md transition-colors ${r===t?"bg-slate-900 text-white":"text-slate-700 border border-slate-200 hover:bg-slate-50"}`,children:t})]},t)}),e.jsx("button",{onClick:()=>i(t=>Math.min(t+1,Math.ceil(o/h))),disabled:r>=Math.ceil(o/h),className:"relative inline-flex items-center rounded-md px-2.5 py-1.5 text-slate-500 border border-slate-200 hover:bg-slate-50 disabled:opacity-50 transition-colors",children:">"})]})})]})]})]})]}),e.jsx(le,{open:J,onOpenChange:k,children:e.jsxs(re,{className:"max-w-2xl max-h-[85vh] overflow-y-auto mx-auto p-0 gap-0",children:[e.jsx(ie,{className:"px-6 pt-6 pb-4 border-b border-slate-200",children:e.jsx(ne,{className:"pr-12 text-xl font-bold text-slate-900",children:"User Details"})}),W?e.jsx("div",{className:"px-6 py-8 text-center",children:e.jsx("div",{className:"text-sm text-slate-500",children:"Loading user details..."})}):c?e.jsxs("div",{className:"space-y-4 px-6 py-5",children:[e.jsx("div",{className:"bg-slate-50 rounded-xl p-4 sm:p-5",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center flex-shrink-0 overflow-hidden border border-slate-200",style:{background:"linear-gradient(135deg, #E8EEF7 0%, #C5D3E5 100%)"},children:e.jsx("img",{src:c.profileImage||"/profile_avatar.webp",alt:c.name,className:"w-full h-full rounded-full object-cover",style:{mixBlendMode:"multiply"},onError:t=>{t.currentTarget.src="/profile_avatar.webp"}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-lg font-bold text-slate-900",children:c.name}),c.isActive?e.jsxs("span",{className:"px-2 py-1 rounded-full text-xs font-semibold bg-green-100 text-green-700 flex items-center gap-1",children:[e.jsx(L,{className:"w-3 h-3"}),"Active"]}):e.jsxs("span",{className:"px-2 py-1 rounded-full text-xs font-semibold bg-red-100 text-red-700 flex items-center gap-1",children:[e.jsx(ue,{className:"w-3 h-3"}),"Inactive"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-600 min-w-0",children:[e.jsx(fe,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:c.email||"NA"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-600 min-w-0",children:[e.jsx(be,{className:"w-4 h-4"}),e.jsx("span",{children:c.phone}),c.phoneVerified&&e.jsx(L,{className:"w-3 h-3 text-green-600"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-600",children:[e.jsx(R,{className:"w-4 h-4"}),e.jsxs("span",{children:["Joined: ",_(c.joiningDate)]})]})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"bg-blue-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(U,{className:"w-4 h-4 text-blue-600"}),e.jsx("span",{className:"text-xs font-semibold text-slate-700",children:"Total Orders"})]}),e.jsx("p",{className:"text-xl font-bold text-blue-600",children:c.totalOrders||0})]}),e.jsxs("div",{className:"bg-green-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ge,{className:"w-4 h-4 text-green-600"}),e.jsx("span",{className:"text-xs font-semibold text-slate-700",children:"Total Spent"})]}),e.jsxs("p",{className:"text-xl font-bold text-green-600",children:["â¹",(c.totalOrderAmount||0).toLocaleStr
27ing("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),e.jsxs("div",{className:"bg-purple-50 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(R,{className:"w-4 h-4 text-purple-600"}),e.jsx("span",{className:"text-xs font-semibold text-slate-700",children:"Member Since"})]}),e.jsx("p",{className:"text-base font-bold text-purple-600",children:_(c.joiningDate)})]})]}),c.addresses&&c.addresses.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-base font-bold text-slate-900 mb-2 flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),"Addresses"]}),e.jsx("div",{className:"space-y-2",children:c.addresses.map((t,s)=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 border border-slate-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700",children:t.label||"Address"}),t.isDefault&&e.jsx("span",{className:"px-2 py-1 rounded-full text-xs font-semibold bg-blue-100 text-blue-700",children:"Default"})]}),e.jsxs("p",{className:"text-sm text-slate-600",children:[t.street,t.additionalDetails&&`, ${t.additionalDetails}`,t.city&&`, ${t.city}`,t.state&&`, ${t.state}`,t.zipCode&&` - ${t.zipCode}`]})]},s))})]}),c.orders&&c.orders.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-base font-bold text-slate-900 mb-2 flex items-center gap-2",children:[e.jsx(U,{className:"w-4 h-4"}),"Recent Orders"]}),e.jsx("div",{className:"space-y-2",children:c.orders.slice(0,5).map((t,s)=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 border border-slate-200 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:t.orderId}),e.jsx("p",{className:"text-xs text-slate-600",children:t.restaurantName})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-semibold text-slate-900",children:["â¹",(t.total||0).toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})]}),e.jsx("p",{className:"text-xs text-slate-600 capitalize",children:t.status})]})]},s))})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[c.gender&&e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-700 mb-1",children:"Gender"}),e.jsx("p",{className:"text-sm text-slate-600 capitalize",children:c.gender})]}),c.dateOfBirth&&e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-700 mb-1",children:"Date of Birth"}),e.jsx("p",{className:"text-sm text-slate-600",children:new Date(c.dateOfBirth).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})]})]})]}):e.jsx("div",{className:"py-8 text-center",children:e.jsx("div",{className:"text-sm text-slate-500",children:"No user details available"})})]})})]})}export{Ke 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.