PageSourceSearch

https://bridtest.com/_next/static/chunks/pages/categories-b63930799c9e1c32.js

js bridtest.com collected 2026-10-02 01:24:52 UTC 12,630 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3161],{20829:function(e,i,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/categories",function(){return t(93993)}])},93993:function(e,i,t){"use strict";t.r(i),t.d(i,{default:function(){return V}});var n=t(85893),r=t(11163),a=t(33299),s=t(73760),l=t(82729),o=t(53184),c=t(53816),d=t(53252),u=t(15861),x=t(90948),p=t(26447),g=t(34386),m=t(58032),h=t(5616),v=t(10155),_=t(69417),Z=t(64666),j=t(37645),y=t(6514),f=t(86886),b=t(72882),w=t(7906),S=t(295),P=t(45347),C=t(67421),k=t(21942),z=t(74075),N=t(1177),E=t(29061),A=t(55678),W=t(86307),D=t(43034),R=t(67294),I=t(4005),T=t(18972),F=t(12485),L=t(31425),O=t(11711),q=t(67866),G=t(43126),X=t(12002),$=e=>{let{open:i,action:t,category:r,setCategory:a,setRefresh:s,handleClose:l,options:o,discounts:c}=e,{t:d}=(0,C.$G)(),[x,g]=(0,R.useState)(!1),[m,v]=(0,R.useState)(null),[f,b]=(0,R.useState)(!1),[w,S]=(0,R.useState)(""),P=async()=>{var e,i,n,a;try{g(!0);let n="/api/categories/createcategory";"edit"===t&&(n="/api/categories/updatecategory"),await E.Z.post(n,{...r,uploadCheck:f}),v({open:!0,title:d("success"),description:"create"==t?null!==(e=d("category_created_successfully"))&&void 0!==e?e:"":null!==(i=d("category_updated_successfully"))&&void 0!==i?i:"",callback:()=>{v({open:!1}),l(),b(!1),S("")}})}catch(e){A.Am.error((null==e?void 0:null===(a=e.response)||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:n.error)||(null==e?void 0:e.error)||(null==e?void 0:e.message)),l(),b(!1),S("")}finally{g(!1),s(e=>!e)}};return(0,n.jsxs)(Z.Z,{open:i,fullWidth:!0,maxWidth:"xs",children:[(0,n.jsx)(j.Z,{children:"create"===t?d("Add Category"):d("Edit Category")}),(0,n.jsxs)(y.Z,{children:[(0,n.jsx)(I.Z,{alert:m}),(0,n.jsx)(D.Z,{loading:x}),(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(q.Z,{children:[d("section"),"*"]}),(0,n.jsx)(G.Z,{variant:"standard",value:r.item_section_id,onChange:e=>a({...r,item_section_id:e.target.value}),fullWidth:!0,id:"item_section_id",name:"item_section_id",children:o.map((e,i)=>(0,n.jsx)(T.Z,{value:e.item_section_id,children:e.item_section_name},i))})]}),(0,n.jsx)(O.Z,{sx:{marginY:"12px"},variant:"standard",placeholder:"".concat(d("category_name"),"*"),label:"".concat(d("category_name"),"*"),fullWidth:!0,id:"item_category_name",name:"item_category_name",value:r.item_category_name,onChange:e=>a({...r,item_category_name:e.target.value})}),(0,n.jsxs)(h.Z,{sx:{display:"flex",alignItems:"flex-end",gap:1},children:[(0,n.jsx)(X.ZP,{onDrop:e=>{let i=e[0];if(i.size>26624e3){S("file_size_exceeds_2MB_limit");return}let t=i.name.split(".").pop();if(!["jpeg","png","webp","jpg"].includes(t)){console.log("errror"),S("file_type_not_supported");return}let n=new FileReader;n.onload=()=>{let e=n.result;a({...r,item_category_image:e,extension:t}),b(!0),S("")},n.readAsDataURL(i)},children:e=>{let{getRootProps:i,getInputProps:t}=e;return(0,n.jsxs)(p.Z,{...i(),alignItems:"start",sx:{maxWidth:"130px"},children:[(0,n.jsx)("input",{...t()}),(0,n.jsxs)(p.Z,{flexDirection:"column",gap:1,children:[(0,n.jsx)(F.Z,{src:f?r.item_category_image:"https://image.bridtest.com/images/clients/"+r.item_category_image,sx:{width:100,height:100}}),(0,n.jsx)(_.Z,{variant:"contained",className:"responsive_font",children:d("upload")})]})]})}}),(0,n.jsx)(_.Z,{className:"responsive_font",onClick:()=>{a(e=>({...e,item_category_image:"placeholder.png"})),b(!1),S("")},variant:"contained",color:"error",children:d("reset")})]}),w&&(0,n.jsx)(u.Z,{color:"error",padding:1,children:d(w)})]}),(0,n.jsxs)(L.Z,{children:[(0,n.jsx)(_.Z,{className:"responsive_font",color:"primary",variant:"contained",onClick:P,disabled:!r.item_category_name||!r.item_section_id||!!w,children:"create"===t?d("create"):d("update")}),(0,n.jsx)(_.Z,{className:"responsive_font",sx:{marginX:"10px"},color:"error",variant:"contained",type:"button",onClick:()=>{l(),b(!1),S("")},children:d("close")})]})]})},B=t(36963),U=t(49294),M=t(99272),Y=t(28493);function H(){let e=(0,l._)(["\n    cursor: grab;\n  "]);return H=function(){return e},e}let J=[{numeric:!1,disablePadding:!1,label:"no."},{numeric:!1,disablePadding:!1,label:"category_id"},{numeric:!1,disablePadding:!1,label:"name"},{numeric:!1,disablePadding:!1,label:"section_name"},{numeric:!1,disablePadding:!1,label:"actions"}];function K(e){let{hideActions:i=!1}=e,{t}=(0,C.$G)(),r=i?J.filter(e=>"actions"!==e.label):J;return(0,n.jsx)(o.Z,{children:(0,n.jsx)(c.Z,{children:r.map((e,i)=>(0,n.jsx)(d.Z,{align:e.numeric?"right":"left",padding:e.disablePadding?"none":"normal",sx:{border:"0"},children:(0,n.jsx)(u.Z,{variant:"subtitle1",fontWeight:"500",sx:{fontSize:{xs:"12px",sm:"14px"}},children:t(e.label)})},i))})})}var Q=e=>{var i;let{session:t}=e,r=(null==t?void 0:null===(i=t.user)||void 0===i?void 0:i.role)==="SalesPerson",{t:a}=(0,C.$G)(),[s,l]=(0,R.useState)(!1),[o,T]=(0,R.useState)(0),[F,L]=(0,R.useState)(25),[q,G]=(0,R.useState)(""),[X,J]=(0,R.useState)(!1),[Q,V]=(0,R.useState)(!1),[ee,ei]=(0,R.useState)("create"),[et,en]=(0,R.useState)(!1),[er,ea]=(0,R.useState)(null),[es,el]=(0,R.useState)(null),[eo,ec]=(0,R.useState)([]),[ed,eu]=(0,R.useState)([]),[ex,ep]=(0,R.useState)([]),[eg,em]=(0,R.useState)({item_category_name:"",item_section_id:null,item_category_image:"placeholder.png",extension:"",discount_id:null}),[eh,ev]=(0,R.useState)([]),e_=async e=>{em(e),ei("edit"),J(!0)};(0,R.useEffect)(()=>{(async()=>{try{l(!0);let e=await E.Z.post("/api/categories/fetchcategories");ec(e.data),eu(e.data)}catch(t){var e,i;A.Am.error((null==t?void 0:null===(i=t.response)||void 0===i?void 0:null===(e=i.data)||void 0===e?void 0:e.error)||(null==t?void 0:t.error)||(null==t?void 0:t.message))}finally{l(!1)}})()},[Q]),(0,R.useEffect)(()=>{(async()=>{try{l(!0);let e=await E.Z.post("/api/discounts/fetchdiscounts");ep(e.data)}catch(t){var e,i;A.Am.error((null==t?void 0:null===(i=t.response)||void 0===i?void 0:null===(e=i.data)||void 0===e?void 0:e.error)||(null==t?void 0:t.error)||(null==t?void 0:t.message))}finally{l(!1)}})()},[]),(0,R.useEffect)(()=>{(async()=>{try{l(!0);let e=await E.Z.post("/api/sections/fetchsections");ev(e.data)}catch(t){var e,i;A.Am.error((null==t?void 0:null===(i=t.response)||void 0===i?void 0:null===(e=i.data)||void 0===e?void 0:e.error)||(null==t?void 0:t.error)||(null==t?void 0:t.message))}finally{l(!1)}})()},[]);let eZ=async()=>{try{l(!0),en(!1),await E.Z.post("/api/categories/deletecategory",{id:er}),el({open:!0,title:a("Success"),description:a("category_deleted_successfully"),callback:()=>{el({open:!1})}})}catch(t){var e,i;A.Am.error((null==t?void 0:null===(i=t.response)||void 0===i?void 0:null===(e=i.data)||void 0===e?void 0:e.error)||(null==t?void 0:t.error)||(null==t?void 0:t.message))}finally{l(!1),en(!1),V(e=>!e)}},ej=async(e,i)=>{let t=eo[e],n=[...eo];n.splice(e,1),n.splice(i,0,t);try{l(!0);let e=n.map((e,i)=>({item_category_id:e.item_category_id,order_no:i+1}));await E.Z.post("/api/categories/updateOrders",{categories:e})}catch(e){var r,a;A.Am.error((null==e?void 0:null===(a=e.response)||void 0===a?void 0:null===(r=a.data)||void 0===r?void 0:r.error)||(null==e?void 0:e.error))}finally{l(!1),V(e=>!e)}},ey=(0,x.ZP)(c.Z)(H()),ef=e=>{let{index:i,row:t}=e,[{isDragging:s},l]=(0,U.c)({type:"section",item:{index:i},collect:e=>({isDragging:e.isDragging()})}),[,o]=(0,M.L)({accept:"section",drop:async(e,t)=>{let n=e.index;n!==i&&(await ej(n,i),e.index=i)}});return(0,n.jsxs)(ey,{ref:e=>l(o(e)),style:{opacity:s?.5:1},children:[(0,n.jsx)(d.Z,{sx:{border:"0"},children:(0,n.jsx)(p.Z,{spacing:2,direction:"row",children:(0,n.jsx)(u.Z,{sx:{fontSize:{xs:"12px",sm:"14px"}},children:i+1})})}),(0,n.jsx)(d.Z,{sx:{border:"0"},children:(0,n.jsx)(p.Z,{spacing:2,direction:"row",children:(0,n.jsx)(u.Z,{sx:{fontSize:{xs:"12px",sm:"14px"}},children:t.item_category_unique_id})})}),(0,n.jsx)(d.Z,{sx:{border:"0"},children:(0,n.jsx)(p.Z,{spacing:2,direction:"row",children:(0,n.jsx)(u.Z,{sx:{fontSize:{xs:"12px",sm:"14px"}},children:t.item_category_name})})}),(0,n.jsx)(d.Z,{sx:{border:"0"},children:(0,n.jsx)(p.Z,{spacing:2,direction:"row",children:(0,n.jsx)(u.Z,{sx:{fontSize:{xs:"12px",sm:"14px"}},children:t.item_sections.item_section_name})})}),!r&&(0,n.jsx)(d.Z,{sx:{border:"0"},children:(0,n.jsxs)(p.Z,{direction:"row",spacing:1,children:[(0,n.jsx)(g.Z,{title:a("edit"),children:(0,n.jsx)(m.Z,{size:"small",color:"primary",onClick:()=>e_(t),children:(0,n.jsx)(k.Z,{size:18})})}),(0,n.jsx)(g.Z,{title:a("delete"),children:(0,n.jsx)(m.Z,{size:"small",color:"primary",onClick:()=>{ea(t.item_category_id),en(!0)},children:(0,n.jsx)(z.Z,{size:18})})})]})})]})};return(0,n.jsx)(Y.W,{backend:B.PD,children:(0,n.jsxs)(W.Z,{children:[(0,n.jsx)(D.Z,{loading:s}),(0,n.jsx)(I.Z,{alert:es}),(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(h.Z,{sx:{width:"100%",display:"flex",justifyContent:"space-between",alignItems:"flex-start",padding:"10px 20px 10px 0"},children:[(0,n.jsx)(v.Z,{children:(0,n.jsx)(u.Z,{sx:{flex:"1 1 100%"},variant:"h6",id:"tableTitle",component:"div",children:a("categories")})}),(0,n.jsxs)(h.Z,{sx:{display:"flex",gap:1,alignItems:"flex-end",flexDirection:{xs:"column",sm:"row"}},children:[(0,n.jsx)(O.Z,{variant:"standard",placeholder:"".concat(a("search")),label:"".concat(a("search")),id:"search",name:"search",value:q,onChange:e=>{G(e.target.value),""===e.target.value?eu(eo):eu(eo.filter(i=>i.item_category_name.toLowerCase().includes(e.target.value.toLowerCase())))}}),!r&&(0,n.jsx)(_.Z,{sx:{fontSize:{xs:"12px",sm:"14px"},textWrap:"nowrap"},onClick:()=>J(!0),variant:"contained",color:"primary",endIcon:(0,n.jsx)(N.Z,{size:18}),children:a("add_category")})]})]}),(0,n.jsx)($,{open:X,action:ee,category:eg,setCategory:em,setRefresh:V,handleClose:()=>{J(!1),ei("create"),em({item_category_name:"",item_section_id:null,item_category_image:"placeholder.png",extension:""})},options:eh,discounts:ex}),(0,n.jsxs)(Z.Z,{open:et,children:[(0,n.jsxs)(j.Z,{children:[a("are_you_sure_you_want_to_delete_this_category"),"?"]}),(0,n.jsx)(y.Z,{children:(0,n.jsxs)(f.ZP,{display:"flex",flexDirection:"row",justifyContent:"center",padding:2,gap:2,children:[(0,n.jsx)(_.Z,{className:"responsive_font",onClick:()=>{eZ()},variant:"contained",children:a("yes")}),(0,n.jsx)(_.Z,{className:"responsive_font",onClick:()=>{en(!1)},variant:"contained",children:a("no")})]})})]}),(0,n.jsx)(b.Z,{children:(0,n.jsxs)(w.Z,{sx:{width:"100%",borderSpacing:"0 1rem",borderCollapse:"separate",paddingInline:"5px"},"aria-labelledby":"tableTitle",size:"small",children:[(0,n.jsx)(K,{hideActions:r}),(0,n.jsx)(S.Z,{children:(null==ed?void 0:ed.length)>0&&(null==ed?void 0:ed.slice(o*F,o*F+F).map((e,i)=>(0,n.jsx)(ef,{index:i,row:e},i)))})]})}),(0,n.jsx)(P.Z,{rowsPerPageOptions:[25,50,75,{label:a("all"),value:-1}],labelRowsPerPage:a("Rows per page:"),component:"div",count:ed.length,rowsPerPage:F,page:o,onPageChange:(e,i)=>{T(i)},onRowsPerPageChange:e=>{let i=parseInt(e.target.value,10);L(-1===i?ed.length:i),T(0)}})]})]})})},V=()=>{var e,i,t;let{push:l}=(0,r.useRouter)(),{data:o,status:c}=(0,a.useSession)({required:!0,onUnauthenticated(){l("/login")}});return(0,r.useRouter)(),(0,n.jsx)(s.Z,{children:o&&((null==o?void 0:null===(e=o.user)||void 0===e?void 0:e.role)=="Supplier"||(null==o?void 0:null===(i=o.user)||void 0===i?void 0:i.role)=="Employee"||(null==o?void 0:null===(t=o.user)||void 0===t?void 0:t.role)=="SalesPerson")?(0,n.jsx)(Q,{session:null==o?void 0:o.user}):(0,n.jsx)(n.Fragment,{})})}},43034:function(e,i,t){"use strict";var n=t(85893),r=t(98456),a=t(64666),s=t(5616);t(67294),i.Z=function(e){let{loading:i}=e;return(0,n.jsx)(a.Z,{open:i,children:(0,n.jsx)(s.Z,{p:2,children:(0,n.jsx)(r.Z,{})})})}},86307:function(e,i,t){"use strict";var n=t(85893),r=t(66242),a=t(2734),s=t(38359);
1i.Z=e=>{let{children:i,className:t,sx:l}=e;(0,s.v9)(e=>e.customizer);let o=(0,a.Z)().palette.divider;return(0,n.jsx)(r.Z,{sx:{p:0,border:"1px solid ".concat(o),position:"relative",sx:l},className:t,elevation:9,variant:"outlined",children:i})}},67866:function(e,i,t){"use strict";var n=t(85893);t(67294);var r=t(90948),a=t(15861);let s=(0,r.ZP)(e=>(0,n.jsxs)(a.Z,{variant:"subtitle1",fontWeight:600,...e,component:"label",htmlFor:e.htmlFor,children:[e.children,e.required&&(0,n.jsx)("span",{children:" *"})]}))(()=>({marginBottom:"5px",marginTop:"25px",display:"block"}));i.Z=s},43126:function(e,i,t){"use strict";var n=t(85893);t(67294);var r=t(90948),a=t(18360);let s=(0,r.ZP)(e=>(0,n.jsx)(a.Z,{...e}))(e=>{let{}=e;return{}});i.Z=s},73760:function(e,i,t){"use strict";var n=t(85893);i.Z=e=>{let{children:i}=e;return(0,n.jsx)("div",{children:i})}}},function(e){e.O(0,[1535,6886,7866,8779,4779,2002,9774,2888,179],function(){return e(e.s=20829)}),_N_E=e.O()}]);

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.