PageSourceSearch

https://www.bagchee.com/static/js/1278.25a39f69.chunk.js

js bagchee.com collected 2026-10-02 11:16:21 UTC 10,076 bytes, 3 lines download raw bytes

1/*! For license information please see 1278.25a39f69.chunk.js.LICENSE.txt */
2"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[1278],{1278(t,e,s){s.r(e),s.d(e,{default:()=>x});var a=s(9379),i=s(5043),r=s(7874),n=s(2024),o=s(6210),l=s(4805),c=s(614),d=s(3046),h=s(2339),p=s(2532),u=s(7097),m=s(579);const x=()=>{const t=(0,r.Zp)(),[e,s]=(0,i.useState)({title:"",status:"active",category_id:"",order:""}),{data:x=[],isLoading:b}=(0,p.I)({queryKey:["categoriesListDropdown"],queryFn:async()=>{const t=await d.A.get("".concat("https://www.bagchee.com/api","/category/fetch"));return t.data.status&&t.data.data||[]},staleTime:6e5}),g=(0,u.n)({mutationFn:async t=>(await d.A.post("".concat("https://www.bagchee.com/api","/formats/save"),t)).data}),v=(0,i.useCallback)(t=>{s(e=>(0,a.A)((0,a.A)({},e),{},{[t.target.name]:t.target.value}))},[]),y=(a,i)=>{if(a.preventDefault(),!e.title)return h.Ay.error("Title is required!");const r=h.Ay.loading("Saving format...");g.mutate(e,{onSuccess:e=>{e.status?(h.Ay.success("Format added successfully! \ud83c\udfac",{id:r}),"back"===i?t("/admin/formats"):s({title:"",status:"active",category_id:"",order:""})):h.Ay.error(e.msg||"Failed to save",{id:r})},onError:t=>{var e,s;h.Ay.error((null===(e=t.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.msg)||"Failed to save",{id:r})}})};return(0,m.jsxs)("div",{className:"bg-cream-50 min-h-screen font-body text-text-main pb-10",children:[(0,m.jsx)("div",{className:"bg-primary  px-6 py-3 shadow-md flex items-center justify-between",children:(0,m.jsx)("h1",{className:"text-lg font-bold text-white uppercase tracking-slick font-display",children:"Add Formats"})}),(0,m.jsx)("div",{className:"max-w-6xl mx-auto p-6 mt-4",children:(0,m.jsxs)("form",{className:"bg-white rounded border border-cream-200 shadow-sm overflow-hidden",onSubmit:t=>t.preventDefault(),children:[(0,m.jsx)("div",{className:"bg-cream-100 px-6 py-2 border-b border-cream-200",children:(0,m.jsx)("h2",{className:"text-[11px] font-bold uppercase tracking-wider font-montserrat text-text-muted",children:"Format Information"})}),(0,m.jsxs)("div",{className:"p-8 space-y-6",children:[(0,m.jsxs)("div",{className:"grid grid-cols-12 gap-4 items-center",children:[(0,m.jsx)("label",{className:"col-span-3 text-right text-[11px] font-bold text-text-muted uppercase font-montserrat",children:"Title"}),(0,m.jsx)("div",{className:"col-span-9",children:(0,m.jsx)("input",{type:"text",name:"title",value:e.title,onChange:v,placeholder:"Enter format title",className:"w-full border border-gray-300 rounded px-4 py-2 text-[13px] outline-none transition-all focus:border-primary focus:ring-1 focus:ring-primary/20 bg-white"})})]}),(0,m.jsxs)("div",{className:"grid grid-cols-12 gap-4 items-start",children:[(0,m.jsx)("label",{className:"col-span-3 text-right text-[11px] font-bold text-text-muted uppercase font-montserrat pt-1",children:"Active"}),(0,m.jsxs)("div",{className:"col-span-9 space-y-2",children:[(0,m.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,m.jsx)("input",{type:"radio",name:"status",value:"active",checked:"active"===e.status,onChange:v,className:"accent-primary h-4 w-4"}),(0,m.jsx)("span",{className:"text-[13px] text-text-main group-hover:text-primary transition-colors",children:"active"})]}),(0,m.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer group",children:[(0,m.jsx)("input",{type:"radio",name:"status",value:"inactive",checked:"inactive"===e.status,onChange:v,className:"accent-primary h-4 w-4"}),(0,m.jsx)("span",{className:"text-[13px] text-text-main group-hover:text-primary transition-colors",children:"inactive"})]})]})]}),(0,m.jsxs)("div",{className:"grid grid-cols-12 gap-4 items-center",children:[(0,m.jsx)("label",{className:"col-span-3 text-right text-[11px] font-bold text-text-muted uppercase font-montserrat",children:"Category"}),(0,m.jsx)("div",{className:"col-span-9",children:(0,m.jsxs)("select",{name:"category_id",value:e.category_id,onChange:v,disabled:b,className:"w-1/3 border border-gray-300 rounded px-4 py-2 text-[13px] outline-none transition-all focus:border-primary bg-white text-gray-500",children:[(0,m.jsx)("option",{value:"",children:b?"Loading...":"Select Category"}),x.map(t=>(0,m.jsx)("option",{value:t.id||t._id,children:t.title||t.categorytitle},t.id||t._id))]})})]}),(0,m.jsxs)("div",{className:"grid grid-cols-12 gap-4 items-center",children:[(0,m.jsx)("label",{className:"col-span-3 text-right text-[11px] font-bold text-text-muted uppercase font-montserrat",children:"Order"}),(0,m.jsx)("div",{className:"col-span-9",children:(0,m.jsx)("input",{type:"number",name:"order",value:e.order,onChange:v,placeholder:"0",className:"w-full border border-gray-300 rounded px-4 py-2 text-[13px] outline-none transition-all focus:border-primary bg-white"})})]}),(0,m.jsxs)("div",{className:"flex justify-center items-center gap-3 pt-8 border-t mt
2-10 font-montserrat",children:[(0,m.jsxs)("button",{type:"button",onClick:t=>y(t,"stay"),disabled:g.isPending,className:"bg-white border border-gray-300 hover:bg-gray-50 text-text-main px-6 py-2 rounded font-bold text-[11px] uppercase transition-all flex items-center gap-2 shadow-sm disabled:opacity-70",children:[g.isPending?(0,m.jsx)(n.A,{size:14,className:"animate-spin"}):(0,m.jsx)(o.A,{size:16,className:"text-green-600"}),(0,m.jsx)("span",{className:"font-bold",children:"Save"})]}),(0,m.jsxs)("button",{type:"button",onClick:t=>y(t,"back"),disabled:g.isPending,className:"bg-white border border-gray-300 hover:bg-gray-50 text-text-main px-6 py-2 rounded font-bold text-[11px] uppercase transition-all flex items-center gap-2 shadow-sm disabled:opacity-70",children:[g.isPending?(0,m.jsx)(n.A,{size:14,className:"animate-spin"}):(0,m.jsx)(l.A,{size:16,className:"text-primary"}),(0,m.jsx)("span",{className:"font-bold",children:"Save and go back to list"})]}),(0,m.jsxs)("button",{type:"button",onClick:()=>t("/admin/formats"),disabled:g.isPending,className:"bg-white border border-gray-300 hover:bg-gray-50 text-text-main px-6 py-2 rounded font-bold text-[11px] uppercase transition-all flex items-center gap-2 shadow-sm disabled:opacity-70",children:[(0,m.jsx)(c.A,{size:16,className:"text-red-600"}),(0,m.jsx)("span",{className:"font-bold",children:"Cancel"})]})]})]})]})})]})}},2024(t,e,s){s.d(e,{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(t,e,s){s.d(e,{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(t,e,s){s.d(e,{A:()=>a});const a=(0,s(7784).A)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},7097(t,e,s){s.d(e,{n:()=>N});var a,i,r,n,o,l=s(9379),c=s(5043),d=s(9790),h=s(5149),p=s(8458),u=s(6562),m=s(4558),x=s(5239),b=s(1454),g=s(329),v=s(9723),y=(a=new WeakMap,i=new WeakMap,r=new WeakMap,n=new WeakMap,o=new WeakSet,class extends g.Q{constructor(t,e){super(),(0,d.A)(this,o),(0,h.A)(this,a,void 0),(0,h.A)(this,i,void 0),(0,h.A)(this,r,void 0),(0,h.A)(this,n,void 0),(0,m.A)(a,this,t),this.setOptions(e),this.bindMethods(),(0,u.A)(o,this,f).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var e;const s=this.options;this.options=(0,p.A)(a,this).defaultMutationOptions(t),(0,v.f8)(this.options,s)||(0,p.A)(a,this).getMutationCache().notify({type:"observerOptionsUpdated",mutation:(0,p.A)(r,this),observer:this}),null!==s&&void 0!==s&&s.mutationKey&&this.options.mutationKey&&(0,v.EN)(s.mutationKey)!==(0,v.EN)(this.options.mutationKey)?this.reset():"pending"===(null===(e=(0,p.A)(r,this))||void 0===e?void 0:e.state.status)&&(0,p.A)(r,this).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(null===(t=(0,p.A)(r,this))||void 0===t||t.removeObserver(this))}onMutationUpdate(t){(0,u.A)(o,this,f).call(this),(0,u.A)(o,this,A).call(this,t)}getCurrentResult(){return(0,p.A)(i,this)}reset(){var t;null===(t=(0,p.A)(r,this))||void 0===t||t.removeObserver(this),(0,m.A)(r,this,void 0),(0,u.A)(o,this,f).call(this),(0,u.A)(o,this,A).call(this)}mutate(t,e){var s;return(0,m.A)(n,this,e),null===(s=(0,p.A)(r,this))||void 0===s||s.removeObserver(this),(0,m.A)(r,this,(0,p.A)(a,this).getMutationCache().build((0,p.A)(a,this),this.options)),(0,p.A)(r,this).addObserver(this),(0,p.A)(r,this).execute(t)}});function f(){var t,e;const s=null!==(t=null===(e=(0,p.A)(r,this))||void 0===e?void 0:e.state)&&void 0!==t?t:(0,x.$)();(0,m.A)(i,this,(0,l.A)((0,l.A)({},s),{},{isPending:"pending"===s.status,isSuccess:"success"===s.status,isError:"error"===s.status,isIdle:"idle"===s.status,mutate:this.mutate,reset:this.reset}))}function A(t){b.jG.batch(()=>{if((0,p.A)(n,this)&&this.hasListeners()){const m=(0,p.A)(i,this).variables,x=(0,p.A)(i,this).context,b={client:(0,p.A)(a,this),meta:this.options.meta,mutationKey:this.options.mutationKey};if("success"===(null===t||void 0===t?void 0:t.type)){try{var e,s;null===(e=(s=(0,p.A)(n,this)).onSuccess)||void 0===e||e.call(s,t.data,m,x,b)}catch(u){Promise.reject(u)}try{var r,o;null===(r=(o=(0,p.A)(n,this)).onSettled)||void 0===r||r.call(o,t.data,null,m,x,b)}catch(u){Promise.reject(u)}}else if("error"===(null===t||void 0===t?void 0:t.type)){try{var l,c;null===(l=(c=(0,p.A)(n,this)).onError)||void 0===l||l.call(c,t.error,m,x,b)}catch(u){Promise.reject(u)}try{var d,h;null===(d=(h=(0,p.A)(n,this)).onSettled)||void 0===d||d.call(h,void 0,t.error,m,x,b)}catch(u){Promise.reject(u)}}}
2this.listeners.forEach(t=>{t((0,p.A)(i,this))})})}var j=s(3248);function N(t,e){const s=(0,j.jE)(e),[a]=c.useState(()=>new y(s,t));c.useEffect(()=>{a.setOptions(t)},[a,t]);const i=c.useSyncExternalStore(c.useCallback(t=>a.subscribe(b.jG.batchCalls(t)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),r=c.useCallback((t,e)=>{a.mutate(t,e).catch(v.lQ)},[a]);if(i.error&&(0,v.GU)(a.options.throwOnError,[i.error]))throw i.error;return(0,l.A)((0,l.A)({},i),{},{mutate:r,mutateAsync:i.mutate})}}}]);
3//# sourceMappingURL=1278.25a39f69.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.