PageSourceSearch

https://www.bagchee.com/static/js/8029.24957a41.chunk.js

js bagchee.com collected 2026-10-02 11:17:28 UTC 8,378 bytes, 3 lines download raw bytes

1/*! For license information please see 8029.24957a41.chunk.js.LICENSE.txt */
2"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[8029],{2024(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])},4805(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},6210(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},8029(e,t,s){s.r(t),s.d(t,{default:()=>u});var a=s(9379),r=s(5043),c=s(7874),l=s(2024),o=s(6210),d=s(4805),i=s(9292),n=s(614),p=s(3046),m=s(2339),x=s(579);const u=()=>{const e=(0,c.Zp)(),{id:t}=(0,c.g)(),s=Boolean(t),[u,h]=(0,r.useState)(!1),[b,f]=(0,r.useState)(s),[g,y]=(0,r.useState)(""),[v,j]=(0,r.useState)([]),[w,N]=(0,r.useState)(!1),[A,k]=(0,r.useState)(!1),[I,S]=(0,r.useState)({productId:"",isActive:"yes",order:""});(0,r.useEffect)(()=>{if(s){(async()=>{try{const e="https://www.bagchee.com/api",s=await p.A.get("".concat(e,"/home-best-seller/get/").concat(t));if(s.data.status){const e=s.data.data;S({productId:e.productId||"",isActive:e.isActive?"yes":"no",order:e.order||""}),y(e.productId||"")}}catch(s){console.error("Fetch Error:",s),m.Ay.error("Failed to load details"),e("/admin/home-best-seller")}finally{f(!1)}})()}},[t,s,e]),(0,r.useEffect)(()=>{const e=setTimeout(async()=>{if(g.length>2&&w){k(!0);try{const e="https://www.bagchee.com/api",t=await p.A.get("".concat(e,"/home-best-seller/search-inventory?q=").concat(g));t.data.status&&j(t.data.data)}catch(e){console.error("Search Error:",e)}finally{k(!1)}}else j([])},500);return()=>clearTimeout(e)},[g,w]);const C=async(r,c)=>{if(r.preventDefault(),!I.productId)return m.Ay.error("Product ID is required!");if(!I.order)return m.Ay.error("Order is required!");h(!0);const l=m.Ay.loading(s?"Updating...":"Saving...");try{const r="https://www.bagchee.com/api",o=(0,a.A)((0,a.A)({},I),{},{isActive:"yes"===I.isActive});let d;d=s?await p.A.patch("".concat(r,"/home-best-seller/update/").concat(t),o):await p.A.post("".concat(r,"/home-best-seller/save"),o),d.data.status&&(m.Ay.success(s?"Updated successfully!":"Added successfully!",{id:l}),"back"===c?e("/admin/home-best-seller"):s||(S({productId:"",isActive:"yes",order:""}),y("")))}catch(i){var o,d;console.error("Submit Error:",i),m.Ay.error((null===(o=i.response)||void 0===o||null===(d=o.data)||void 0===d?void 0:d.msg)||"Operation failed",{id:l})}finally{h(!1)}},z=e=>{S((0,a.A)((0,a.A)({},I),{},{[e.target.name]:e.target.value}))},B="w-full border border-[#e6decd] rounded-[4px] px-3.5 py-2 text-[13px] outline-none transition-all duration-200 ease-in-out bg-[#fffdf5] focus:bg-white focus:border-primary focus:shadow-[0_0_0_3px_rgba(0,141,218,0.15)] font-body";return b?(0,x.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-cream-50 text-primary",children:(0,x.jsx)(l.A,{className:"animate-spin",size:32})}):(0,x.jsxs)("div",{className:"bg-cream-50 min-h-screen font-body text-text-main pb-10",children:[(0,x.jsx)("div",{className:"bg-primary px-6 py-3 shadow-md flex items-center justify-between",children:(0,x.jsx)("h1",{className:"text-lg font-bold text-white uppercase tracking-slick font-display",children:s?"Edit Best Seller Product":"Add Best Seller Product"})}),(0,x.jsx)("div",{className:"max-w-6xl mx-auto p-6 mt-4",children:(0,x.jsxs)("form",{className:"bg-white rounded border border-cream-200 shadow-sm overflow-hidden",onClick:()=>N(!1),children:[(0,x.jsx)("div",{className:"bg-cream-100 px-6 py-3 border-b border-cream-200 flex justify-between items-center",children:(0,x.jsx)("h2",{className:"text-[11px] font-bold text-text-muted uppercase tracking-wider font-montserrat",children:"Product Information"})}),(0,x.jsxs)("div",{className:"p-8 space-y-6",children:[(0,x.jsxs)("div",{className:"grid grid-cols-12 gap-4 items-center border-b border-cream-50 pb-4 relative z-50",children:[(0,x.jsx)("label",{className:"col-span-12 md:col-span-3 md:text-right text-left text-[11px] font-bold text-text-muted uppercase font-montserrat",children:"Product Id / Title / ISBN"}),(0,x.jsxs)("div",{className:"col-span-12 md:col-span-9 relative",onClick:e=>e.stopPropagation(),children:[(0,x.jsxs)("div",{className:"relative",children:[(0,x.jsx)("input",{type:"text",value:g,onChange:e=>{y(e.target.value),N(!0),s&&S(e=>(0,a.A)((0,a.A)({},e),{},{productId:""}))},onFocus:()=>N(!0),className:"".concat(B," pr-10"),placeholder:"Enter Product ID, Title, ISBN-10 or ISBN-13...",autoComplete:"off"}),(0,x.jsx)("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:A?(0,x.jsx)(l.A,{size:16,className:"animate-spin"}):(0,x.jsx)(i.A,{size:16})})]}),w&&v.length>0&&(0,x.jsx)("div",{className:"absolute top-full left-0 w-full bg-white border border-gray-300 rounded shadow-lg mt-1 max-h-60 overflow-y-auto z-50",children:v.map(e=>(0,x.jsxs)("div",{onClick:()=>{return t=e,S((0,a.A)((0,a.A)({},I),{},{productId:t.bagcheeId||t.bagchee_id})),y("".concat(t.bagcheeId||t.bagchee_id," - ").concat(t.title)),void N(!1);var t},className:"px-4 py-2 hover:bg-blue-50 cursor-pointer border-b border-gray-100 last:border-0 flex flex-col justify-center",children:[(0,x.jsx)("p",{className:"text-xs font-bold text-gray-800 line-clamp-1",children:e.title}),(0,x.jsxs)("div",{className:"text-[10px] text-gray-500 flex flex-wrap gap-x-2",children:[(0,x.jsxs)("span",{children:["ID: ",(0,x.jsx)("strong",{className:"text-primary",children:e.bagcheeId||e.bagchee_id})]}),e.isbn13&&(0,x.jsxs)("span",{children:["| ISBN-13: ",e.isbn13]}),e.isbn10&&(0,x.jsxs)("span",{children:["| ISBN-10: ",e.isbn10]})]})]},e.id||e._id))}),w&&g.length>2&&!A&&0===v.length&&(0,x.jsxs)("div",{className:"absolute top-full left-0 w-full bg-white border border-gray-300 rounded shadow-lg mt-1 p-3 text-xs text-gray-500 text-center z-50",children:['No products found matching "',g,'"']})]})]}),(0,x.jsxs)("div",{className:"grid grid-cols-12 gap-4 items-center border-b border-cream-50 pb-4",children:[(0,x.jsx)("label",{className:"col-span-12 md:col-span-3 md:text-right text-left text-[11px] font-bold text-text-muted uppercase font-montserrat",children:"Active"}),(0,x.jsx)("div",{className:"col-span-12 md:col-span-9",children:(0,x.jsxs)("select",{name:"isActive",value:I.isActive,onChange:z,className:"".concat(B," appearance-none cursor-pointer"),children:[(0,x.jsx)("option",{value:"",disabled:!0,children:"Select Active"}),(0,x.jsx)("option",{value:"yes",children:"Yes"}),(0,x.jsx)("option",{value:"no",children:"No"})]})})]}),(0,x.jsxs)("div",{className:"grid grid-cols-12 gap-4 items-center border-b border-cream-50 pb-4",children:[(0,x.jsx)("label",{className:"col-span-12 md:col-span-3 md:text-right text-left text-[11px] font-bold text-text-muted uppercase font-montserrat",children:"Order"}),(0,x.jsx)("div",{className:"col-span-12 md:col-span-9",children:(0,x.jsx)("input",{type:"number",name:"order",value:I.order,onChange:z,className:B,placeholder:"Enter display order (e.g. 1)"})})]}),(0,x.jsxs)("div",{className:"flex flex-col md:flex-row justify-center items-center gap-4 pt-8 border-t mt
2-4 font-montserrat",children:[(0,x.jsxs)("button",{onClick:e=>C(e,"stay"),disabled:u,className:"w-full md:w-auto bg-primary text-white px-8 py-2.5 rounded font-bold text-[10px] uppercase shadow-md hover:brightness-110 active:scale-95 transition-all flex items-center justify-center gap-2",children:[u?(0,x.jsx)(l.A,{size:14,className:"animate-spin"}):(0,x.jsx)(o.A,{size:14}),s?"Update":"Save"]}),(0,x.jsxs)("button",{onClick:e=>C(e,"back"),disabled:u,className:"w-full md:w-auto bg-text-main text-white px-8 py-2.5 rounded font-bold text-[10px] uppercase shadow-md hover:opacity-90 active:scale-95 transition-all flex items-center justify-center gap-2",children:[(0,x.jsx)(d.A,{size:14}),s?"Update & Go Back":"Save & Go Back"]}),(0,x.jsxs)("button",{type:"button",onClick:()=>e("/admin/home-best-seller"),className:"w-full md:w-auto bg-white border border-cream-200 text-text-main px-8 py-2.5 rounded font-bold text-[10px] uppercase shadow-sm hover:bg-cream-50 active:scale-95 transition-all flex items-center justify-center gap-2",children:[(0,x.jsx)(n.A,{size:14,className:"text-red-600"})," Cancel"]})]})]})]})})]})}}}]);
3//# sourceMappingURL=8029.24957a41.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.