PageSourceSearch

https://www.bagchee.com/static/js/2147.41a6ed32.chunk.js

js bagchee.com collected 2026-10-02 11:15:54 UTC 16,202 bytes, 3 lines download raw bytes

1/*! For license information please see 2147.41a6ed32.chunk.js.LICENSE.txt */
2"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[2147],{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"}]])},2580(e,t,r){r.d(t,{A:()=>a});const a=(0,r(7784).A)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]])},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"}]])},4528(e,t,r){r.r(t),r.d(t,{default:()=>v});var a=r(9379),o=r(5043),s=r(2580),n=r(2024),d=r(6533),i=r(9463),l=r(8326),c=r(3356),p=r(7991),x=r(7104),h=r(1360),b=r(2754),m=r(9292),u=r(9855),y=r(7874),g=r(3046),f=r(5003),w=r(3127),j=r(2339),N=r(579);const v=()=>{const e=(0,y.Zp)(),{confirm:t}=(0,f.S)(),r="staff"===(0,w.Gx)(),[v,k]=(0,o.useState)([]),[A,_]=(0,o.useState)(!0),[C,M]=(0,o.useState)(1),[S,z]=(0,o.useState)(1),[D,B]=(0,o.useState)(10),[T,I]=(0,o.useState)(0),[K,P]=(0,o.useState)(""),[E,F]=(0,o.useState)({id:"",title:"",bagchee_id:"",price:"",meta_title:"",isbn10:"",isbn13:"",product_type:""}),H="book",L=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e||_(!0);try{const t="https://www.bagchee.com/api",r=new URLSearchParams;r.append("product_type","book"),r.append("showAll","true"),r.append("page",e?1:C),r.append("limit",e?2e5:D),K&&r.append("keyword",K),Object.keys(E).forEac
2h(e=>{E[e]&&r.append(e,E[e])});const a="".concat(t,"/product/fetch?").concat(r.toString()),o=await g.A.get(a);if(o.data.status){if(e)return o.data.data;k(o.data.data),z(o.data.totalPages||1),I(o.data.total||0)}}catch(t){console.error("Fetch Error:",t),e||k([])}finally{e||_(!1)}};(0,o.useEffect)(()=>{L()},[C,D]),(0,o.useEffect)(()=>{L()},[C,D]);const R=e=>{const{name:t,value:r}=e.target;F(e=>(0,a.A)((0,a.A)({},e),{},{[t]:r}))},V=()=>{L()},q=e=>{"Enter"===e.key&&L()};return(0,N.jsxs)("div",{className:"bg-gray-50 min-h-screen font-body p-4 md:p-6",children:[(0,N.jsx)("style",{dangerouslySetInnerHTML:{__html:"\n        @media print {\n          /* Hide Toolbar, Filters, Pagination, and Action columns */\n          button, input, select, .print\\:hidden, \n          thead.print\\:hidden, th:last-child, td:last-child {\n            display: none !important;\n          }\n          /* Reset background and padding for paper */\n          body { background: white !important; padding: 0 !important; }\n          .bg-white { border: none !important; box-shadow: none !important; }\n          table { width: 100% !important; border-collapse: collapse !important; }\n          th, td { border: 1px solid #ddd !important; padding: 8px !important; font-size: 10px !important; }\n          thead { background-color: #0096cc !important; color: white !important; -webkit-print-color-adjust: exact; }\n          /* Show page title on print */\n          .print-header { display: block !important; text-align: center; margin-bottom: 20px; }\n        }\n        @media screen { .print-header { display: none; } }\n      "}}),(0,N.jsxs)("div",{className:"flex flex-col md:flex-row justify-between items-center gap-4 mb-4",children:[(0,N.jsx)("h1",{className:"text-xl font-bold text-gray-700 uppercase md:hidden",children:"Books list"}),(0,N.jsxs)("button",{onClick:()=>e("/admin/add-book"),className:"bg-[#f8f9fa] border border-gray-300 text-gray-700 hover:bg-white px-4 py-1.5 rounded shadow-sm flex items-center gap-2 font-bold text-xs uppercase transition-all active:scale-95",children:[(0,N.jsx)(h.A,{size:14,className:"text-red-600"})," Add ","book"]}),(0,N.jsxs)("div",{className:"flex flex-wrap gap-2 w-full md:w-auto justify-end",children:[(0,N.jsxs)("button",{onClick:async()=>{const e=j.Ay.loading("Preparing full data for export...");try{const t=await L(!0);if(!t||0===t.length)return void j.Ay.error("No data to export",{id:e});const r=[["ID","Title","Bagchee ID","Price","ISBN 10","ISBN 13","Type"].join(","),...t.map(e=>{const t=e.isbn10?"\t".concat(e.isbn10):"-",r=e.isbn13?"\t".concat(e.isbn13):"-",a='"'.concat((e.title||"").replace(/"/g,'""'),'"'),o='"'.concat((e.metaTitle||e.meta_title||"").replace(/"/g,'""'),'"');return[e.id||e._id,a,e.bagcheeId||e.bagchee_id||"BB".concat(e.id),e.realPrice||e.priceForeign||e.real_price||0,o,t,r,e.productType||e.product_type||"Book"].join(",")})].join("\n"),a=new Blob([r],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(a),s=document.createElement("a");s.href=o,s.setAttribute("download","full_books_report_".concat(Date.now(),".csv")),document.body.appendChild(s),s.click(),document.body.removeChild(s),j.Ay.success("Full data exported! \ud83d\udcca",{id:e})}catch(t){j.Ay.error("Export failed",{id:e})}},className:"bg-[#f8f9fa] border border-gray-300 text-gray-700 px-4 py-1.5 rounded shadow-sm hover:bg-white flex items-center gap-2 text-xs font-bold",children:[(0,N.jsx)(x.A,{size:14,className:"text-yellow-600"})," Export"]}),(0,N.jsxs)("button",{onClick:()=>{0!==v.length?window.print():j.Ay.error("No data to print!")},className:"bg-[#f8f9fa] border border-gray-300 text-gray-700 px-4 py-1.5 rounded shadow-sm hover:bg-white flex items-center gap-2 text-xs font-bold",children:[(0,N.jsx)(b.A,{size:14,className:"text-green-600"})," Print"]}),(0,N.jsx)("button",{onClick:()=>{P(""),F({id:"",title:"",bagchee_id:"",price:"",meta_title:"",isbn10:"",isbn13:"",product_type:""}),setTimeout(()=>{window.location.reload()},100)},className:"bg-[#f8f9fa] border border-gray-300 text-gray-700 px-4 py-1.5 rounded shadow-sm hover:bg-white flex items-center gap-2 text-xs font-bold",children:"Clear filters"}),(0,N.jsxs)("div",{className:"relative",children:[(0,N.jsx)("input",{type:"text",placeholder:"Search title...",value:K,onChange:e=>P(e.target.value),onKeyDown:q,className:"pl-3 pr-10 py-1.5 border border-gray-300 rounded focus:border-primary text-xs w-48 bg-white focus:outline-none focus:ring-1 focus:ring-primary"}),(0,N.jsx)("button",{onClick:V,className:"absolute right-0 top-0 h-full w-8 bg-[#0096cc] text-white rounded-r flex items-center justify-center hover:bg-primary-dark transition-colors",children:(0,N.jsx)(m.A,{size:14})})]})]})]}),(0,N.jsxs)("div",{className:"bg-white rounded border border-gray-200 overflow-hidden shadow-sm",children:[(0,N.jsx)("div",{className:"overflow-x-auto",children:(0,N.jsxs)("table",{className:"w-full min-w-[1200px] border-collapse",children:[(0,N.jsx)("thead",{className:"bg-[#0096cc] text-white",children:(0,N.jsxs)("tr",{children:[(0,N.jsx)("th",{className:"p-3 text-center border-r border-white/20 w-12 text-xs font-bold uppercase",children:"#"}),(0,N.jsx)("th",{className:"p-3 text-left border-r border-white/20 text-xs font-bold uppercase",children:"Title"}),(0,N.jsx)("th",{className:"p-3 text-left border-r border-white/20 text-xs font-bold uppercase",children:"Bagchee id"}),(0,N.jsx)("th",{className:"p-3 text-left border-r border-white/20 text-xs font-bold uppercase",children:"Real price"}),(0,N.jsx)("th",{className:"p-3 text-left border-r border-white/20 text-xs font-bold uppercase",children:"Meta title"}),(0,N.jsx)("th",{className:"p-3 text-left border-r border-white/20 text-xs font-bold uppercase",children:"Isbn 10"}),(0,N.jsx)("th",{className:"p-3 text-left border-r border-white/20 text-xs font-bold uppercase",children:"Isbn 13"}),(0,N.jsx)("th",{className:"p-3 text-left border-r border-white/20 text-xs font-bold uppercase",children:"Product type"}),(0,N.jsx)("th",{className:"p-3 text-center text-xs font-bold uppercase",children:"Actions"})]})}),(0,N.jsx)("thead",{className:"bg-white border-b border-gray-200 print:hidden",children:(0,N.jsxs)("tr",{children:[(0,N.jsx)("th",{className:"p-2 border-r text-center bg-[#f8f9fa]",children:(0,N.jsx)("input",{name:"id",type:"text",placeholder:"#",value:E.id,onChange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary text-center"})}),(0,N.jsx)("th",{className:"p-2 border-r",children:(0,N.jsx)("input",{name:"title",value:E.title,onChange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary"})}),(0,N.jsx)("th",{className:"p-2 border-r",children:(0,N.jsx)("input",{name:"bagchee_id",value:E.bagchee_id,onChange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary"})}),(0,N.jsx)("th",{className:"p-2 border-r",children:(0,N.jsx)("input",{name:"price",value:E.price,onChange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary"})}),(0,N.jsx)("th",{className:"p-2 border-r",children:(0,N.jsx)("input",{name:"meta_title",value:E.meta_title,onChange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary"})}),(0,N.jsx)("th",{className:"p-2 border-r",children:(0,N.jsx)("input",{name:"isbn10",value:E.isbn10,onChange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary"})}),(0,N.jsx)("th",{className:"p-2 border-r",children:(0,N.jsx)("input",{name:"isbn13",value:E.isbn13,onChange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary"})}),(0,N.jsx)("th",{className:"p-2 border-r",children:(0,N.jsx)("input",{name:"product_type",value:E.product_type,onCh
2ange:R,onKeyDown:q,className:"w-full border border-gray-200 p-1 text-[11px] rounded outline-none focus:border-primary"})}),(0,N.jsx)("th",{className:"p-2 text-center bg-[#f8f9fa]",children:(0,N.jsx)("button",{onClick:V,className:"hover:bg-gray-200 p-1 rounded transition cursor-pointer",children:(0,N.jsx)(s.A,{size:14,className:"mx-auto text-gray-500"})})})]})}),(0,N.jsx)("tbody",{className:"divide-y divide-gray-200",children:A?(0,N.jsx)("tr",{children:(0,N.jsx)("td",{colSpan:"9",className:"p-10 text-center text-gray-500",children:(0,N.jsxs)("div",{className:"flex justify-center items-center gap-2",children:[(0,N.jsx)(n.A,{className:"animate-spin text-primary"})," Loading ","book","..."]})})}):v.length>0?v.map((a,o)=>(0,N.jsxs)("tr",{className:"hover:bg-blue-50/30 transition-colors group",children:[(0,N.jsx)("td",{className:"p-2.5 border-r text-center text-sm text-gray-600",children:a.id||a._id}),(0,N.jsx)("td",{className:"p-2.5 border-r text-sm font-bold text-[#333]",children:a.title}),(0,N.jsx)("td",{className:"p-2.5 border-r text-sm text-gray-600 font-semibold",children:a.bagcheeId||a.bagchee_id||"BB".concat(a.id)}),(0,N.jsx)("td",{className:"p-2.5 border-r text-sm text-gray-600 font-bold",children:Number(a.realPrice||a.priceForeign||a.real_price||0).toFixed(2)}),(0,N.jsx)("td",{className:"p-2.5 border-r text-sm text-gray-500 max-w-xs truncate",children:a.metaTitle||a.meta_title||"-"}),(0,N.jsx)("td",{className:"p-2.5 border-r text-sm text-gray-500",children:a.isbn10||"-"}),(0,N.jsx)("td",{className:"p-2.5 border-r text-sm text-gray-500",children:a.isbn13||"-"}),(0,N.jsx)("td",{className:"p-2.5 border-r text-sm font-bold text-[#0096cc] uppercase",children:a.productType||a.product_type||"Books"}),(0,N.jsx)("td",{className:"p-2.5",children:(0,N.jsxs)("div",{className:"flex justify-center gap-1.5",children:[(0,N.jsx)("button",{onClick:()=>e("/admin/edit-book/".concat(a.id||a._id)),className:"p-1.5 bg-gray-100 border rounded text-gray-600 hover:bg-white transition-all shadow-sm",children:(0,N.jsx)(d.A,{size:14})}),!r&&(0,N.jsx)("button",{onClick:()=>(async e=>{if(!await t())return;const r=j.Ay.loading("Deleting...");try{await g.A.delete("".concat("https://www.bagchee.com/api","/product/delete/").concat(e)),j.Ay.success("Deleted",{id:r}),L()}catch(a){j.Ay.error("Failed",{id:r})}})(a.id||a._id),className:"p-1.5 bg-gray-100 border rounded text-red-500 hover:bg-white transition-all shadow-sm",children:(0,N.jsx)(u.A,{size:14})})]})})]},a.id||a._id)):(0,N.jsx)("tr",{children:(0,N.jsxs)("td",{colSpan:"9",className:"p-10 text-center font-bold text-gray-400 italic",children:['No products found in "',H,'".']})})})]})}),(0,N.jsxs)("div",{className:"p-3 bg-white border-t border-cream-200 flex flex-col md:flex-row justify-between items-center gap-4 font-montserrat shadow-sm",children:[(0,N.jsxs)("div",{className:"flex items-center gap-2 text-[12px] font-bold text-text-main",children:[(0,N.jsx)("span",{className:"text-text-muted uppercase text-[10px] tracking-wide",children:"Show"}),(0,N.jsxs)("select",{value:D,onChange:e=>{B(Number(e.target.value)),M(1)},className:"border border-cream-200 rounded px-2 py-1 outline-none focus:border-primary bg-cream-50 text-xs text-primary font-bold transition-all cursor-pointer shadow-sm active:scale-95",children:[(0,N.jsx)("option",{value:10,children:"10"}),(0,N.jsx)("option",{value:25,children:"25"}),(0,N.jsx)("option",{value:50,children:"50"}),(0,N.jsx)("option",{value:100,children:"100"})]}),(0,N.jsx)("span",{className:"text-text-muted uppercase text-[10px] tracking-wide",children:"entries"})]}),(0,N.jsxs)("div",{className:"text-[11px] font-bold text-text-muted uppercase tracking-tighter",children:["Displaying ",T>0?(C-1)*D+1:0," to ",Math.min(C*D,T)," of ",T," items"]}),(0,N.jsxs)("div",{className:"flex items-center gap-1",children:[(0,N.jsx)("button",{onClick:()=>M(1),disabled:1===C,className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary hover:border-primary disabled:opacity-30 disabled:cursor-not-allowed transition-all active:scale-90 bg-white",children:(0,N.jsx)(c.A,{size:16})}),(0,N.jsx)("button",{onClick:()=>M(e=>Math.max(e-1,1)),disabled:1===C,className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary hover:border-primary disabled:opacity-30 disabled:cursor-not-allowed transition-all active:scale-90 bg-white",children:(0,N.jsx)(i.A,{size:16})}),(0,N.jsx)("div",{className:"min-w-[32px] h-8 flex items-center justify-center bg-primary text-white text-xs font-bold rounded shadow-md ring-2 ring-primary/20 mx-1",children:C}),(0,N.jsx)("button",{onClick:()=>M(e=>Math.min(e+1,S)),disabled:C===S,className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary hover:border-primary disabled:opacity-30 disabled:cursor-not-allowed transition-all active:scale-90 bg-white",children:(0,N.jsx)(l.A,{size:16})}),(0,N.jsx)("button",{onClick:()=>M(S),disabled:C===S,className:"p-1.5 border border-cream-200 rounded text-text-muted hover:text-primary hover:border-primary disabled:opacity-30 disabled:cursor-not-allowed transition-all active:scale-90 bg-white",children:(0,N.jsx)(p.A,{size:16})})]})]})]})]})}},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"}]])},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=2147.41a6ed32.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.