1/*! For license information please see 7707.213f3557.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[7707],{86(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},1360(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},2024(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},2754(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]])},3356(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("chevrons-left",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]])},5815(e,t,r){r.d(t,{b:()=>a});const a=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Sheet1",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"export";const s=await r.e(1238).then(r.bind(r,1238)),o=s.utils.json_to_sheet(e),d=s.utils.book_new();s.utils.book_append_sheet(d,o,t),s.writeFile(d,"".concat(a,"_").concat(Date.now(),".xlsx"))}},6533(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]])},7104(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]])},7707(e,t,r){r.r(t),r.d(t,{default:()=>N});var a=r(9379),s=r(5043),o=r(2024),d=r(6533),n=r(9463),i=r(8326),l=r(3356),c=r(7991),x=r(7104),m=r(1360),p=r(2754),h=r(86),b=r(9292),u=r(9855),g=r(7874),w=r(3046),y=r(2339),j=r(5815),v=r(5003),f=r(579);const N=()=>{const e=(0,g.Zp)(),{confirm:t}=(0,v.S)(),[r,N]=(0,s.useState)([]),[A,k]=(0,s.useState)(!0),[C,M]=(0,s.useState)(!1),[S,z]=(0,s.useState)({productId:"",title:"",active:"",order:""}
2),[_,I]=(0,s.useState)({page:1,limit:25,total:0}),D=async()=>{k(!0);try{const e="https://www.bagchee.com/api",t={page:_.page,limit:_.limit,productId:S.productId,title:S.title,isActive:S.active,order:S.order},r=await w.A.get("".concat(e,"/home-best-seller/list"),{params:t});r.data.status&&N(r.data.data)}catch(e){console.error("Fetch Error:",e),y.Ay.error("Failed to load data")}finally{k(!1)}};(0,s.useEffect)(()=>{D()},[_.page,_.limit]);const E=e=>{z((0,a.A)((0,a.A)({},S),{},{[e.target.name]:e.target.value}))};return(0,f.jsxs)("div",{className:"bg-cream-50 min-h-screen p-4 md:p-6 font-body text-text-main",children:[(0,f.jsxs)("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 mb-4",children:[(0,f.jsxs)("button",{onClick:()=>e("/admin/add-home-best-seller"),className:"bg-white border border-cream-200 text-text-main hover:bg-cream-100 px-4 py-2 rounded shadow-sm flex items-center gap-2 font-montserrat font-bold text-xs uppercase transition-all active:scale-95",children:[(0,f.jsx)(m.A,{size:14,className:"text-red-600"})," Add Best Seller"]}),(0,f.jsxs)("div",{className:"flex flex-wrap gap-2 w-full md:w-auto justify-end",children:[(0,f.jsxs)("button",{onClick:async()=>{M(!0);const e=y.Ay.loading("Exporting all data...");try{const t="https://www.bagchee.com/api",r=await w.A.get("".concat(t,"/home-best-seller/list"),{params:(0,a.A)((0,a.A)({},S),{},{limit:"all"})});if(r.data.status&&r.data.data.length>0){const t=r.data.data.map(e=>{var t,r;return{"Product ID":(null===(t=e.product)||void 0===t?void 0:t.bagchee_id)||e.productId||"N/A",Title:(null===(r=e.product)||void 0===r?void 0:r.title)||e.title||"N/A",Active:e.isActive?"Yes":"No",Order:e.order||0,"Created At":new Date(e.createdAt).toLocaleDateString()}});await(0,j.b)(t,"Best Sellers","home_best_sellers"),y.Ay.success("Export complete!",{id:e})}else y.Ay.error("No data to export",{id:e})}catch(t){console.error("Export Error:",t),y.Ay.error("Export failed",{id:e})}finally{M(!1)}},disabled:C,className:"bg-white border border-cream-200 text-text-main px-4 py-1.5 rounded shadow-sm hover:bg-cream-100 flex items-center gap-2 text-xs font-montserrat font-bold transition-colors disabled:opacity-50",children:[C?(0,f.jsx)(o.A,{size:14,className:"animate-spin"}):(0,f.jsx)(x.A,{size:14,className:"text-accent"}),C?"Exporting...":"Export"]}),(0,f.jsxs)("button",{onClick:()=>{const e=document.getElementById("printable-table-area");if(!e)return;const t=e.style.overflow;e.style.overflow="visible";const r=document.body.innerHTML;document.body.innerHTML='\n <div style="padding: 20px; font-family: sans-serif;">\n <h1 style="text-align:center; margin-bottom: 10px; color: #333;">Home Best Sellers Report</h1>\n <p style="text-align:center; font-size: 12px; color: #666; margin-bottom: 20px; border-bottom: 1px solid #ddd; padding-bottom: 10px;">\n Generated on: '.concat((new Date).toLocaleString(),"\n </p>\n ").concat(e.innerHTML,"\n </div>\n "),window.print(),document.body.innerHTML=r,e.style.overflow=t,window.location.reload()},className:"bg-white border border-cream-200 text-text-main px-4 py-1.5 rounded shadow-sm hover:bg-cream-100 flex items-center gap-2 text-xs font-montserrat font-bold transition-colors",children:[(0,f.jsx)(p.A,{size:14,className:"text-green-600"})," Print"]}),(0,f.jsx)("button",{onClick:()=>{z({productId:"",title:"",active:"",order:""}),setTimeout(()=>D(),100)},className:"bg-white border border-cream-200 text-text-main px-4 py-1.5 rounded shadow-sm hover:text-primary hover:border-primary flex items-center gap-2 text-xs font-montserrat font-bold transition-all",children:"Clear filters"}),(0,f.jsx)("div",{className:"relative flex items-center",children:(0,f.jsx)("button",{onClick:D,className:"bg-primary text-white p-2 rounded hover:bg-primary-hover transition-colors shadow-sm",children:(0,f.jsx)(b.A,{size:16})})})]})]}),(0,f.jsxs)("div",{className:"bg-white rounded border border-cream-200 overflow-hidden shadow-sm",id:"printable-table-area",children:[(0,f.jsx)("div",{className:"overflow-x-auto",children:(0,f.jsxs)("table",{className:"w-full min-w-[800px] border-collapse text-sm",children:[(0,f.jsxs)("thead",{children:[(0,f.jsxs)("tr",{className:"bg-primary text-white border-b border-white/10 font-montserrat font-bold uppercase tracking-wider",children:[(0,f.jsx)("th",{className:"p-3 text-center w-16 border-r border-white/20 hide-on-print",children:(0,f.jsx)("input",{type:"checkbox",className:"h-4 w-4 roun
2ded accent-white cursor-pointer"})}),(0,f.jsx)("th",{className:"p-3 text-left border-r border-white/20",children:"Product Id"}),(0,f.jsx)("th",{className:"p-3 text-left border-r border-white/20",children:"Title"}),(0,f.jsx)("th",{className:"p-3 text-left border-r border-white/20 w-24",children:"Source"}),(0,f.jsx)("th",{className:"p-3 text-left border-r border-white/20 w-32",children:"Active"}),(0,f.jsx)("th",{className:"p-3 text-left border-r border-white/20 w-24",children:"Order"}),(0,f.jsx)("th",{className:"p-3 text-center w-32 hide-on-print",children:"Actions"})]}),(0,f.jsxs)("tr",{className:"bg-primary border-b border-cream-200 hide-on-print",children:[(0,f.jsx)("td",{className:"p-2 border-r border-white/20"}),(0,f.jsx)("td",{className:"p-2 border-r border-white/20",children:(0,f.jsx)("input",{type:"text",name:"productId",value:S.productId,onChange:E,className:"w-full rounded p-1 text-xs outline-none bg-white/90 focus:bg-white text-text-main",placeholder:"Filter ID"})}),(0,f.jsx)("td",{className:"p-2 border-r border-white/20",children:(0,f.jsx)("input",{type:"text",name:"title",value:S.title,onChange:E,className:"w-full rounded p-1 text-xs outline-none bg-white/90 focus:bg-white text-text-main",placeholder:"Filter Title"})}),(0,f.jsx)("td",{className:"p-2 border-r border-white/20"}),(0,f.jsx)("td",{className:"p-2 border-r border-white/20",children:(0,f.jsx)("input",{type:"text",name:"active",value:S.active,onChange:E,className:"w-full rounded p-1 text-xs outline-none bg-white/90 focus:bg-white text-text-main",placeholder:"Yes/No"})}),(0,f.jsx)("td",{className:"p-2 border-r border-white/20",children:(0,f.jsx)("input",{type:"text",name:"order",value:S.order,onChange:E,className:"w-full rounded p-1 text-xs outline-none bg-white/90 focus:bg-white text-text-main",placeholder:"Order"})}),(0,f.jsx)("td",{className:"p-2 text-center",children:(0,f.jsx)("button",{onClick:D,className:"text-white hover:rotate-180 transition-transform duration-500",children:(0,f.jsx)(h.A,{size:16})})})]})]}),(0,f.jsx)("tbody",{className:"divide-y divide-cream-50",children:A?(0,f.jsx)("tr",{children:(0,f.jsx)("td",{colSpan:"7",className:"p-10 text-center text-text-muted font-bold",children:(0,f.jsxs)("div",{className:"flex justify-center items-center gap-2",children:[(0,f.jsx)(o.A,{className:"animate-spin text-primary"})," Loading Data..."]})})}):r.length>0?r.map((r,a)=>{var s,o;const n=(null===(s=r.product)||void 0===s?void 0:s.bagchee_id)||r.productId||"N/A",i=(null===(o=r.product)||void 0===o?void 0:o.title)||r.title||"N/A",l="auto"===r.source;return(0,f.jsxs)("tr",{className:"hover:bg-primary-50 transition-colors",children:[(0,f.jsx)("td",{className:"p-3 border-r border-cream-50 text-center hide-on-print",children:(0,f.jsx)("input",{type:"checkbox",disabled:l,className:"h-4 w-4 rounded accent-primary cursor-pointer disabled:opacity-40"})}),(0,f.jsx)("td",{className:"p-3 border-r border-cream-50 text-text-main font-medium",children:n}),(0,f.jsx)("td",{className:"p-3 border-r border-cream-50 text-text-main font-medium",children:i}),(0,f.jsx)("td",{className:"p-3 border-r border-cream-50 text-text-main",children:(0,f.jsx)("span",{className:"px-2 py-1 rounded text-[10px] font-bold ".concat(l?"bg-blue-100 text-blue-700":"bg-gray-100 text-gray-700"),children:l?"AUTO (".concat(r.soldCount||0," sold)"):"MANUAL"})}),(0,f.jsx)("td",{className:"p-3 border-r border-cream-50 text-text-main",children:(0,f.jsx)("span",{className:"px-2 py-1 rounded text-[10px] font-bold ".concat(r.isActive?"bg-green-100 text-green-700":"bg-red-100 text-red-700"),children:r.isActive?"YES":"NO"})}),(0,f.jsx)("td",{className:"p-3 border-r border-cream-50 text-text-main",children:r.order||0}),(0,f.jsx)("td",{className:"p-3 text-center hide-on-print",children:l?(0,f.jsx)("span",{className:"text-[10px] text-text-muted italic",children:"Auto \u2014 not editable"}):(0,f.jsxs)("div",{className:"flex justify-center gap-2",children:[(0,f.jsx)("button",{onClick:()=>e("/admin/edit-home-best-seller/".concat(r.id||r._id)),className:"p-1.5 bg-cream-50 border border-cream-200 rounded text-text-muted hover:text-primary hover:border-primary transition-all shadow-sm",children:(0,f.jsx)(d.A,{size:14})}),(0,f.jsx)("button",{onClick:()=>(async e=>{if(!await t())return;const r=y.Ay.loading("Deleting...");try{const t="https://www.bagchee.com/api";(await w.A.delete("".concat(t,"/home-best-seller/delete/").concat(e))).data.status&&(y.Ay.success("Deleted successfully!",{id:r}),D())}catch(a){y.Ay.error("Delete failed",{id:r})}})(r.id||r._id),className:"p-1.5 bg-cream-50 border border-cream-200 rounded text-text-muted hover:text-red-600 hover:border-red-600 transition-all shadow-sm",children:(0,f.jsx)(u.A,{size:14})})]})})]},r.id||r._id)}):(0,f.jsx)("tr",{children:(0,f.jsx)("td",{colSpan:"7",className:"p-10 text-center text-text-muted italic",children:"No Best Seller products found."})})})]})}),(0,f.jsxs)("div",{className:"p-4 bg-white border-t border-cream-50 flex flex-col md:flex-row justify-between items-center gap-4",children:[(0,f.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-muted font-montserrat font-bold",children:[(0,f.jsx)("span",{children:"Show"}),(0,f.jsxs)("select",{className:"border border-cream-200 rounded p-1 outline-none focus:border-primary text-xs bg-white text-text-main",value:_.limit,onChange:e=>I((0,a.A)((0,a.A)({},_),{},{limit:Number(e.target.value),page:1})),children:[(0,f.jsx)("option",{value:"25",children:"25"}),(0,f.jsx)("option",{value:"50",children:"50"}),(0,f.jsx)("option",{value:"100",children:"100"})]}),(0,f.jsx)("span",{children:"entries"})]}),(0,f.jsxs)("div",{className:"text-[11px] font-bold text-text-muted uppercase tracking-tighter font-montserrat",children:["Displaying ",r.length," items"]}),(0,f.jsxs)("div",{className:"flex items-center gap-1",children:[(0,f.jsx)("button",{disabled:1===_.page,onClick:()=>I((0,a.A)((0,a.A)({},_),{},{page:1})),className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary disabled:opacity-50 transition-all",children:(0,f.jsx)(l.A,{size:16})}),(0,f.jsx)("button",{disabled:1===_.page,onClick:()=>I((0,a.A)((0,a.A)({},_),{},{page:_.page-1})),className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary disabled:opacity-50 transition-all",children:(0,f.jsx)(n.A,{size:16})}),(0,f.jsx)("div",{className:"flex items-center mx-1 border border-cream-200 rounded overflow-hidden",children:(0,f.jsx)("input",{type:"text",value:_.page,readOnly:!0,className:"w-8 text-center text-xs border-none p-1.5 focus:ring-0 text-text-main font-bold bg-cream-50"})}),(0,f.jsx)("button",{onClick:()=>I((0,a.A)((0,a.A)({},_),{},{page:_.page+1})),className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary transition-all",children:(0,f.jsx)(i.A,{size:16})}),(0,f.jsx)("button",{className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary transition-all",children:(0,f.jsx)(c.A,{size:16})})]})]})]}),(0,f.jsx)("style",{children:"\n @media print {\n .hide-on-print { display: none !important; }\n .bg-cream-50 { background-color: white !important; }\n body { background-color: white !important; }\n #printable-table-area { border: none !important; box-shadow: none !important; }\n }\n "})]})}},7991(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("chevrons-right",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]])},9855(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])}}]); 3//# sourceMappingURL=7707.213f3557.chunk.js.map
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.