1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4464],{61899:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/catalog/admin/catalog-product",function(){return r(18595)}])},25665:function(e,t,r){"use strict";r.d(t,{D:function(){return o},w:function(){return s}});var n=r(85893),a=r(67294),i=a.createContext(void 0),s=function(e){var t=(0,a.useState)([]),r=t[0],s=t[1],o=e.onSelectProduct,l=e.onSelectProductVariant,d=e.children,c=(0,a.useMemo)((function(){return{onSelectProduct:o,onSelectProductVariant:l,selectedProductVariants:r,setSelectedProductVariants:s}}),[l,o,r]);return(0,n.jsx)(i.Provider,{value:c,children:d})},o=function(){var e=(0,a.useContext)(i);if(void 0===e)throw new Error("useMultiSelectProductVariant can only be used inside MultiSelectProductVariantContext");return e}},33251:function(e,t,r){"use strict";r.d(t,{L:function(){return l},X:function(){return o}});var n=r(29815),a=r(85893),i=r(67294),s=i.createContext(void 0),o=function(e){var t=e.children,r=e.renderActions,o=e.newColumns,l=e.newExpandedColumns,d=e.renderExpandedColumns,c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(!t||0===t.length)return e;var r=(0,n.Z)(e);return t.forEach((function(t){var n;-1===(n=e.findIndex((function(e){return e.field===t.field})))&&(n=e.findIndex((function(e){return e.headerName===t.headerName}))),r[n]=t})),r},u=(0,i.useMemo)((function(){return{renderActions:r,newColumns:o,newExpandedColumns:l,renderExpandedColumns:d,replaceColumns:c}}),[r,o,l,d]);return(0,a.jsx)(s.Provider,{value:u,children:t})},l=function(){var e=(0,i.useContext)(s);if(void 0===e)throw new Error("useSelect can only be used inside SelectProvider");return e}},75097:function(e,t,r){"use strict";var n=r(14924),a=r(26042),i=r(69396),s=r(85893),o=r(91781),l=r(19668),d=r(94062),c=r(49837),u=r(39410),f=r(25836),v=r(67294),p=r(3105),m=r(66549),x=r(33251);t.Z=function(e){var t=(0,m.iB)(),r=t.page,h=t.pageSize,g=(t.selectedIds,t.setPage),j=t.setPageSize,b=(t.setSelectedIds,t.rows),C=t.totalRows,P=t.loading,y=t.filters,S=t.setFilters,w=t.sortType,N=t.setSortType,Z=(0,x.L)(),I=Z.replaceColumns,V=Z.newColumns,k=(Z.newExpandedColumns,(0,v.useCallback)((function(){return"auto"}),[])),O=V&&I?I(p.E,V):p.E;return(0,s.jsxs)("div",{className:"flex flex-col gap-2",onClick:function(e){e.stopPropagation()},children:[(0,s.jsx)(c.Z,{className:"mb-4",children:(0,s.jsx)(o.Z,{filters:y,handleFilter:function(e,t){S((0,i.Z)((0,a.Z)({},y),(0,n.Z)({},e,t)))},sortType:w,setSortType:N})}),(0,s.jsx)(f.s,{pagination:!0,page:r,pageSize:h,rowCount:C,columns:O,rows:b,loading:P,getRowSpacing:l.ab,sx:l.Dr,paginationMode:"server",onPageSizeChange:function(e){return j(e)},onPageChange:function(e){return g(e)},getRowHeight:k,getDetailPanelHeight:k,autoHeight:!0,components:{Pagination:d.Z},componentsProps:{pagination:{page:r,setPage:g,pageSize:h,setPageSize:j,totalRows:C}},rowsPerPageOptions:[10,25,50,100],initialState:{pinnedColumns:{left:[u.n.field],right:["actions"]}},disableSelectionOnClick:!0})]})}},57951:function(e,t,r){"use strict";r.d(t,{u:function(){return s}});var n=r(85893),a=r(20986),i=r(54225),s=(r(96486),function(e){return[{headerName:"Actions",field:"actions",minWidth:150,renderCell:function(t){var r=t.row;return(0,n.jsx)("div",{className:"mx-auto flex flex-wrap gap-2",children:(0,n.jsxs)(i.Z,{variant:"outlined",size:"small",onClick:function(){return e({product:r})},children:["Select",(0,n.jsx)(a.sG,{className:"ml-1 text-lg",id:"click-me"})]})})}}]})},48942:function(e,t,r){"use strict";r.d(t,{L:function(){return s}});var n=r(85893),a=r(20986),i=r(30120),s=function(e){var t=e.value,r=e.trueLabel,s=e.falseLabel,o=e.size,l=!!t,d=l?"#2e7d32":"#9e9e9e",c=l?r:s,u="small"===(void 0===o?"small":o)?"0.95rem":"1.2rem";return(0,n.jsxs)(i.Z,{component:"span",sx:{display:"inline-flex",alignItems:"center",gap:.5,px:c?1:.5,py:.25,borderRadius:"999px",border:"1.5px solid ".concat(d,"66"),backgroundColor:"".concat(d,"1f"),color:d,fontSize:"0.72rem",fontWeight:600,lineHeight:1,userSelect:"none"},children:[l?(0,n.jsx)(a.Ye,{style:{fontSize:u}}):(0,n.jsx)(a.lY,{style:{fontSize:u}}),c&&(0,n.jsx)("span",{children:c})]})}},17603:function(e,t,r){"use strict";r.d(t,{Z:function(){return s}});var n=r(85893),a=r(86010),i=r(96486);function s(e){var t=e.currentTab,r=e.setCurrentTab,s=e.tabs;return(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"sm:hidden",children:(0,n.jsx)("select",{id:"tabs",name:"tabs",className:"block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500",value:t,onChange:function(e){return r(e.target.value)},children:s.map((function(e){return(0,n.jsx)("option",{children:(0,i.isString)(e.label)?e.label:e.value},e.value)}))})}),(0,n.jsx)("div",{className:"hidden rounded-md border-y py-1 sm:block",children:(0,n.jsx)("nav",{className:"flex space-x-4","aria-label":"Tabs",children:s.map((function(e){var i=e.value===t;return(0,n.jsx)("div",{className:(0,a.Z)(i?"bg-indigo-100 text-indigo-700":"text-gray-500 hover:text-gray-700","grow cursor-pointer rounded-md px-3 py-2 text-center text-sm font-medium"),"aria-current":i?"page":void 0,onClick:function(){return r(e.value)},children:e.label},e.value)}))})})]})}},18595:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return Xe}});var n=r(85893),a=r(14924),i=r(26042),s=r(69396),o=r(29815),l=r(25665),d=r(3105),c=r(91781),u=r(45408),f=r(61283),v=r(19668),p=r(73275),m=r(76891),x=r(94062),h=r(47018),g=r(79072),j=r(29630),b=r(70754),C=r(49837),P=r(25836),y=r(67294),S=r(85518),w=r(54225),N=r(6798),Z=r(96277),I=r(4451),V=r(23837),k=r(4232),O=r(60747),E=r(96486),z=r(11163),R=(0,y.createContext)(void 0),_=new Set(Object.values(Z.Pte)),M=new Set(Object.values(Z.kvN)),F=new Set(Object.values(Z.SNS)),W=function(e){var t=e;return null==e.status||_.has(e.status)||(t=(0,s.Z)((0,i.Z)({},t),{status:void 0})),null==e.type||M.has(e.type)||(t=(0,s.Z)((0,i.Z)({},t),{type:void 0})),null==e.receivedOfferSpecificEvent||F.has(e.receivedOfferSpecificEvent)||(t=(0,s.Z)((0,i.Z)({},t),{receivedOfferSpecificEvent:void 0})),t},A=function(e){var t=e.children,r=e.defaultFilters,a=e.storeParamsInUrl,s=void 0!==a&&a,o=e.withProductVariant,l=void 0===o||o,d=(0,z.useRouter)(),c=(d.query,(0,I.a)()),u=c.user,f=c.preferredCurrency,v=(0,O.A)(),p=(0,y.useMemo)((function(){var e=(0,V.b)(u);return(0,N.yC)(null===e||void 0===e?void 0:e.company.id)}),[u]),m=(0,y.useState)((function(){if(s){var e,t=(0,k.W)(d);if(null===t||void 0===t?void 0:t.page)return t.page;var r=null!==(e=(0,N.E$)("page",p))&&void 0!==e?e:0;return Number(r)}return 0})),x=m[0],h=m[1],g=(0,y.useState)((function(){if(s){var e,t=(0,k.W)(d);if(null===t||void 0===t?void 0:t.pageSize)return t.pageSize;var r=null!==(e=(0,N.E$)("pageSize",p))&&void 0!==e?e:10;return Number(r)}return 10})),j=g[0],b=g[1],C=(0,y.useState)((function(){if(s){var e=(0,k.W)(d);if(null===e||void 0===e?void 0:e.filters)return W(e.filters);var t=(0,N.E$)("filters",p);if(t)return W((0,i.Z)({},t))}return(0,i.Z)({},r)})),P=C[0],S=C[1],w=(0,y.useState)((function(){if(s){var e=(0,N.E$)("sortField",p);return(null===e||void 0===e?void 0:e.toString())||"createdAt"}return"createdAt"})),_=w[0],M=w[1],F=(0,y.useState)(Z.Asd.Desc),A=F[0],T=F[1],H=(0,y.useState)(null),D=H[0],q=H[1],L=(0,y.useState)([]),U=L[0],X=L[1],B=(0,y.useState)([]),G=B[0],$=B[1],K=(0,y.useMemo)((function(){return W(P)}),[P]),Y=(0,y.useMemo)((function(){return{page:x,perPage:j,filter:K,sortField:_,sortOrder:A,sortType:D,limit:3,convertCurrency:f||void 0}}),[x,j,K,_,A,D,f]),J=(0,Z.USI)({variables:Y,skip:l}),Q=J.refetch,ee=J.loading,te=J.data,re=(0,y.useMemo)((function(){return{rows:(null===te||void 0===te?void 0:te.allProducts.products)||[],totalRows:(null===te||void 0===te?void 0:te.allProducts.total)||0}}),[te]),ne=re.rows,ae=re.totalRows,ie=(0,y.useMemo)((function(){return(0,E.debounce)((function(e){var t=e.filters,r=e.page,n=e.pageSize,a={page:r,pageSize:n,filters:t};p&&(0,N.lj)(a,p),d.replace({query:{filters:JSON.stringify(t),page:r,pageSize:n}},void 0,{shallow:!0})}),500)}),[p]);(0,y.useEffect)((function(){return s&&ie({filters:P,page:x,pageSize:j}),function(){return ie.cancel()}}),[s,x,P,j,ie]),(0,y.useEffect)((function(){var e=null!==G&&void 0!==G?G:[],t=ne.filter((function(e){return U.includes(e.id)}
1)),r=e.concat(t).filter((function(e){return U.includes(e.id)})),n=(0,E.uniqBy)(r,"id");$(n)}),[U]),(0,y.useEffect)((function(){var e,t;null===(e=v.current)||void 0===e||null===(t=e.resetRowHeights)||void 0===t||t.call(e)}),[v,te]);var se=(0,y.useMemo)((function(){return{queryResult:J,rows:ne,totalRows:ae,filters:P,setFilters:S,page:x,setPage:h,pageSize:j,setPageSize:b,selectedIds:U,setSelectedIds:X,selectedRows:G,loading:ee,refetch:Q,sortField:_,setSortField:M,sortOrder:A,setSortOrder:T,sortType:D,setSortType:q,dataGridRef:v}}),[J,ne,P,ae,x,j,U,G,ee,Q,_,A,D,v]);return(0,n.jsx)(R.Provider,{value:se,children:t})},T=(R.Consumer,function(){var e=(0,y.useContext)(R);if(!e)throw new Error("No Context.Provider found when calling useContext.");return e}),H=r(47568),D=r(828),q=r(70655),L=r(43085);var U=function(e){var t=e.selectedIds,r=e.onSuccess,a=(0,D.Z)((0,Z.HKZ)(),2),i=a[0],s=a[1],o=(s.loading,s.client),l=function(){var e=(0,H.Z)((function(){var e,n,a,s,l;return(0,q.__generator)(this,(function(d){switch(d.label){case 0:return t.length?[4,i({variables:{productIds:t}})]:[2];case 1:return n=d.sent(),(a=null===(e=n.data)||void 0===e?void 0:e.bulkRemoveProductCatalogs)&&((null===(s=a.success)||void 0===s?void 0:s.length)&&((0,L.x9)("Successfully removed ".concat(a.success.length," products from catalog")),o.cache.evict({fieldName:"allProductsForCatalogView"}),r()),(null===(l=a.errorMessage)||void 0===l?void 0:l.length)&&a.errorMessage.forEach((function(e){(0,L._N)(e)}))),[2]}}))}));return function(){return e.apply(this,arguments)}}();return t.length?(0,n.jsx)("div",{children:(0,n.jsx)(w.Z,{onClick:l,size:"small",variant:"outlined",color:"error",children:"Unlist"})}):null};var X=function(e){var t=T(),r=t.selectedIds,a=t.setSelectedIds,i=t.refetch,s=function(){return a([])},o=r.map((function(e){return e.toString()}));return(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)(w.Z,{color:"error",onClick:s,sx:{m:2},size:"small",variant:"contained",disabled:!(null===r||void 0===r?void 0:r.length),children:["Clear",(0,n.jsx)("span",{hidden:!r.length,className:"mx-1",children:r.length})]}),(0,n.jsx)(U,{selectedIds:o,onSuccess:function(){s(),i()}})]})},B=r(20986),G=r(43963),$=r(89479),K=r(45209),Y=r(78525),J=r(5952),Q=r(8132),ee=r(56302),te=r(44656),re=r(89886),ne=r(1427),ae=r(76366),ie=r(79506),se=r(17603),oe=r(47533),le=r(67062),de=r(31812),ce=r(17575),ue=r(91359),fe=r(45135),ve=r(87536),pe=r(74231),me=r(57891),xe={fromWarehouse:null},he=pe.Ry().shape({prodVarsCatalog:pe.IX().of(pe.Ry().shape({productVariantId:pe.Z_().required(),offerPrice:pe.Ry().shape({amount:pe.Rx().required("Required"),currency:pe.nK().required("Required")}).nullable()}))}),ge=function(e){var t=e.defaultValues,r=e.currentOfferOptions,a=e.PREFIX,i=(0,ve.Gc)(),s=i.control,o=i.setValue,l=(0,ve.qo)({control:s,name:"".concat(a,".offerId")});return(0,y.useEffect)((function(){if(l){var e,t,n,i,s=r.find((function(e){return e.value===l}));if(s)o("".concat(a,".offerPrice"),{amount:null!==(n=null===(e=s.offerSupplyPrice)||void 0===e?void 0:e.amount)&&void 0!==n?n:0,currency:null!==(i=null===(t=s.offerSupplyPrice)||void 0===t?void 0:t.currency)&&void 0!==i?i:Z.Fa6.Hkd})}}),[l]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"my-2 text-2xs",children:[0===r.length?"Create new offer with Price":"Update existing offer with this Price",":"]}),(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(te.Z,{label:"Price",name:"".concat(a,".offerPrice.amount"),defaultValues:t,formControlProps:{className:"flex-grow"}}),(0,n.jsx)(ee.Z,{name:"".concat(a,".offerPrice.currency"),label:null,defaultValues:t,selectProps:{disabled:!0},formControlProps:{className:"w-32",size:"small"}})]})]})},je=function(e){var t,r=e.defaultValues,a=e.onSubmit,i=e.onCancel,s=e.productId,o=function(){var e,t=(0,Z.c34)(),r=(0,y.useMemo)((function(){var e;return null===(e=t.data)||void 0===e?void 0:e.myCompany.defaultWarehouse}),[t]),n=(0,Z.DKt)({variables:{filter:void 0,sortField:"name",sortOrder:Z.Asd.Asc}}),a=null===(e=n.data)||void 0===e?void 0:e.allWarehouses.total,i=(0,y.useMemo)((function(){var e;return(null===(e=n.data)||void 0===e?void 0:e.allWarehouses.warehouses)||[]}),[n.data]);return{suggestedOption:(0,y.useMemo)((function(){return 1===a?i[0]:r&&!(0,me.Q)(r)?{value:r.
1id,label:r.name}:null}),[r,a,i]),defaultWarehouse:r,total:a,options:i}}().suggestedOption,l=(0,y.useMemo)((function(){return(0,E.merge)({},xe,r,{fromWarehouse:o})}),[r,o]),d=(0,ve.cI)({defaultValues:l,resolver:(0,oe.X)(he)}),c=function(){var e=(0,H.Z)((function(e){return(0,q.__generator)(this,(function(t){switch(t.label){case 0:return[4,a(e)];case 1:return t.sent(),[2]}}))}));return function(t){return e.apply(this,arguments)}}(),u=d.reset,f=d.handleSubmit,v=d.watch,p=d.setValue,m=d.formState.isSubmitting,x=(0,I.a)().preferredCurrency,h=(0,Z.$pn)({variables:{filter:{selfOffer:!0,productId:s},page:0,perPage:0,sortField:"createdAt",sortOrder:Z.Asd.Desc,convertCurrency:x||void 0}}),j=h.data,b=(h.loading,(0,y.useMemo)((function(){var e,t;return null===j||void 0===j||null===(e=j.allOffers)||void 0===e?void 0:e.offers.map((function(e){var r,a,i;return{value:e.id,label:(0,n.jsx)("div",{children:(0,n.jsx)(ce.Z,{title:(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"text-sm text-gray-500",children:["Release Date:",(0,n.jsx)("div",{className:"text-gray-300",children:(0,le.p6)(e.releaseDate)})]}),(0,n.jsxs)("div",{className:"text-sm text-gray-500",children:["Order Deadline:",(0,n.jsx)("div",{className:"text-gray-300",children:(0,le.p6)(e.orderDeadline)})]})]}),children:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsxs)("div",{className:"text-sm font-bold",children:[(0,n.jsxs)("span",{hidden:!e.version,children:["[",e.version,"]"]})," ",e.itemNumber]}),(0,n.jsx)("div",{className:"text-sm text-gray-500",children:e.remark})]})}),(0,n.jsxs)("div",{className:"text-sm text-gray-500",children:[null===(r=e.supplyPrice)||void 0===r?void 0:r.currency," ",null===(a=e.supplyPrice)||void 0===a?void 0:a.amount]})]})})}),productVariantId:null!==(t=null===(i=e.productVariant)||void 0===i?void 0:i.id)&&void 0!==t?t:"",offerSupplyPrice:e.supplyPrice}}))}),[j])),C=[{label:"Enabled",value:"false"},{label:"Disabled",value:"true"}];return(0,y.useEffect)((function(){u(l)}),[l]),(0,n.jsx)(ae.e,{methods:d,onSubmit:f(c),defaultValues:l,children:(0,n.jsx)(ue.Z,{children:(0,n.jsxs)(g.ZP,{container:!0,spacing:2,children:[(0,n.jsxs)(g.ZP,{item:!0,xs:12,mb:10,children:[(0,n.jsxs)(fe.Z,{severity:"warning",children:[(0,n.jsxs)("div",{children:["Please map each product variant to ",(0,n.jsx)("span",{className:"font-bold",children:"own offer"})]}),(0,n.jsxs)("div",{className:"mt-2",children:[(0,n.jsx)("span",{className:"font-bold",children:"Note 1 :"})," If you do not have any"," ",(0,n.jsx)("span",{className:"font-bold",children:"own offer"})," for this product yet, please create one first."]}),(0,n.jsxs)("div",{className:"mt-2",children:[(0,n.jsx)("span",{className:"font-bold",children:"Note 2 :"})," The price for"," ",(0,n.jsx)("span",{className:"font-bold",children:"own offer"})," should be marked up"]})]}),(0,n.jsx)("div",{className:"mt-4 grid gap-4 sm:grid-cols-2 md:grid-cols-3",children:null===(t=l.prodVarsCatalog)||void 0===t?void 0:t.map((function(e,t){var r,a,i="prodVarsCatalog.".concat(t),s=null===(r=l.productVariants)||void 0===r?void 0:r.find((function(t){return t.id===e.productVariantId})),o=null!==(a=null===b||void 0===b?void 0:b.filter((function(t){return t.productVariantId===e.productVariantId})))&&void 0!==a?a:[],c=v("".concat(i,".disableCatalog"));return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-transparent p-3 transition-colors duration-500 hover:border-slate-400/75 hover:bg-slate-50/50",children:[(0,n.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,n.jsx)("div",{children:(0,n.jsx)(Y.Z,{productVariants:s?[s]:[],hasActions:!1})})}),(0,n.jsxs)("div",{className:"flex w-full items-center gap-3",children:[(0,n.jsxs)("span",{className:"text-xs font-bold",children:[t+1,"."]}),(0,n.jsx)(J.Z,{name:"".concat(i,".productVariantId"),defaultValues:l,methods:d}),(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,n.jsx)(se.Z,{tabs:C,currentTab:c?"true":"false",setCurrentTab:function(e){p("".concat(i,".disableCatalog"),"true"===e)}}),0===o.length?(0,n.jsx)(fe.Z,{hidden:!!c,severity:"error",className:"grow",children:"Missing Own Offer"}):(0,n.jsx)(re.Z,{name:"".concat(i,".offerId"),label:"Select Offer",options:o,defaultValues:l,selectProps:{}}),(0,n.jsx)(ge,{currentOfferOptions:o,defaultValues:l,PREFIX:i})]})]})]},e.productVariantId)}))})]}),(0,n.jsx)(g.ZP,{item:!0,xs:12,sm:6,className:"space-y-6",children:(0,n.jsx)(ie.Zu,{methods:d,name:"fromWarehouse",defaultValues:l,label:"Select Warehouse",autoCompleteProps:{disableClearable:!0},enableAutofillWarehouse:!0})}),(0,n.jsx)(g.ZP,{item:!0,xs:12,sm:4,children:(0,n.jsx)(ne.Z,{name:"remarks",textFieldProps:{fullWidth:!0,placeholder:"Remarks"},label:"Remarks",defaultValues:l})}),(0,n.jsx)(g.ZP,{item:!0,xs:12,sm:2,children:(0,n.jsx)(Q.Z,{name:"hidePrice",defaultValues:l,hasLabel:!0,formControlProps:{sx:{width:"auto"}},label:"Hide Price ?"})}),(0,n.jsxs)(g.ZP,{item:!0,xs:12,sx:{pt:function(e){return"".concat(e.spacing(7)," !important")}},children:[(0,n.jsx)(de.Z,{type:"submit",variant:"contained",loading:m,sx:{mr:2},children:"Save"}),(0,n.jsx)(de.Z,{hidden:!i,type:"submit",variant:"text",loading:m,sx:{mr:2},color:"error",onClick:i,children:"Back"})]})]})})})};var be=function(e){var t=e.productId,r=(0,y.useState)(!1),a=r[0],i=r[1],s=function(){return i(!1)},o=(0,I.a)().user,l=(0,V.b)(o),d=(0,Z.tZY)({variables:{filter:{productId:t,companyId:null===l||void 0===l?void 0:l.company.id},userCompanyId:null===l||void 0===l?void 0:l.id},skip:!a||!(null===l||void 0===l?void 0:l.company.id)}),c=(0,y.useMemo)((function(){var e,t=null===(e=d.data)||void 0===e?void 0:e.allProductCatalogs.productCatalogs[0];if(!t)return{};var r=t.product.productVariants,n={productVariants:r,prodVarsCatalog:null===r||void 0===r?void 0:r.map((function(e){var t,r,n=null===(t=e.catalogOffer)||void 0===t?void 0:t.supplyPrice;return{productVariantId:e.id,offerId:null===(r=e.catalogOffer)||void 0===r?void 0:r.id,disableCatalog:e.disableCatalog,offerPrice:n?{amount:n.amount,currency:n.currency}:null}}
1)),hidePrice:t.hidePrice,fromWarehouse:t.fromWarehouse?{label:t.fromWarehouse.name,value:t.fromWarehouse.id}:null};return n}),[d]),u=(0,D.Z)((0,Z.jCf)(),2),f=u[0],v=u[1],p=(v.loading,v.client),m=function(){var e=(0,H.Z)((function(e){var t,r,n,a,i,o,l;return(0,q.__generator)(this,(function(c){switch(c.label){case 0:return e.fromWarehouse,n=e.prodVarsCatalog,a=e.remarks,i=e.hidePrice,(null===n||void 0===n?void 0:n.length)?(o=null===(r=null===(t=d.data)||void 0===t?void 0:t.allProductCatalogs.productCatalogs[0])||void 0===r?void 0:r.id)?[4,f({variables:{dto:{remarks:a,hidePrice:i,prodVarsCatalog:n.map((function(e){return{productVariantId:e.productVariantId,disableCatalog:e.disableCatalog,offerId:e.offerId,offerPrice:e.offerPrice}}))},productCatalogId:o}})]:((0,L._N)("Product Catalog not found"),[2]):((0,L._N)("Please select a product"),(0,L._N)("This feature is still under development. "),[2]);case 1:return(null===(l=c.sent().data)||void 0===l?void 0:l.updateProductCatalog.id)&&((0,L.x9)("Product Catalog Updated"),s(),p.cache.evict({fieldName:"fullProductCatalogsWithOfferId"}),p.cache.evict({fieldName:"allProductsForCatalogView"})),[2]}}))}));return function(t){return e.apply(this,arguments)}}();return(0,n.jsx)("div",{children:(0,n.jsx)(K.Z,{isOpen:a,setIsOpen:i,dialogProps:{open:a,maxWidth:"lg"},button:(0,n.jsx)(w.Z,{onClick:function(){i(!0)},size:"medium",variant:"outlined",children:(0,n.jsx)(B.dY,{})}),title:"Update Product Catalog",description:(0,n.jsx)("span",{className:"font-bold"}),children:(0,n.jsx)("div",{onClick:$.UW,className:"mx-2",children:(0,n.jsx)(je,{defaultValues:c,onSubmit:m,onCancel:function(){s()},productId:t})})})})},Ce=function(e){e.productId;var t=e.productCatalog,r=(0,y.useState)(null),a=r[0],i=r[1],s=function(){i(null)},o=Boolean(a),l=o?"toggle-product-catalog-active-status-popover":void 0,d=!!(null===t||void 0===t?void 0:t.isActive),c=(0,D.Z)((0,Z.jCf)(),2),u=c[0],f=c[1],v=f.loading,p=f.client,m=function(){var e=(0,H.Z)((function(){var e,r;return(0,q.__generator)(this,(function(n){switch(n.label){case 0:return(e=null===t||void 0===t?void 0:t.id)?[4,u({variables:{dto:{isActive:!d},productCatalogId:e}})]:((0,L._N)("Product Catalog not found"),[2]);case 1:return(null===(r=n.sent().data)||void 0===r?void 0:r.updateProductCatalog.id)&&((0,L.x9)("Catalog status updated"),s()),p.cache.modify({id:p.cache.identify(t),fields:{isActive:function(e){return!e}}}),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,n.jsxs)("div",{children:[(0,n.jsxs)(w.Z,{size:"small",variant:"outlined",title:"Toggle Active/Inactive",onClick:function(e){i(e.currentTarget)},color:d?"error":"success",className:"!text-2xs",children:["Set as ",d?"Inactive":"Active"]}),(0,n.jsx)(G.ZP,{id:l,open:o,anchorEl:a,onClose:s,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,n.jsxs)("div",{className:"mx-5 my-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:d?"text-green-500":"text-red-500",children:(0,n.jsx)(B.zM,{})}),(0,n.jsxs)("span",{children:["Status: ",d?"Active":"Inactive"," "]})]}),(0,n.jsx)("div",{className:"mt-1 flex justify-end",children:(0,n.jsx)(w.Z,{color:d?"error":"success",onClick:m,disabled:v,children:d?"Set as Inactive":"Set as Active"})})]})})]})};var Pe=function(e){var t=e.row;return(0,n.jsxs)("div",{className:"grid gap-2",children:[(0,n.jsx)(be,{productId:t.id}),(0,n.jsx)(Ce,{productId:t.id,productCatalog:t.catalog})]})},ye=r(66549),Se=r(57951),we=r(75097),Ne=r(33251),Ze=r(3032);var Ie,Ve=function(e){var t=(0,p.H)().drawerContainerRef,r=(0,y.useState)(null),a=r[0],i=r[1],s=(0,Ze.k)(),o=s.isOpen,l=s.setIsOpen,d=(s.closeModal,s.openModal),c=(0,I.a)().user,u=(0,V.b)(c),f=null===u||void 0===u?void 0:u.company.baseCurrency,v="Create Product Catalog",m=(0,y.useMemo)((function(){if(a){var e=a.productVariants;return{productVariants:e,prodVarsCatalog:null===e||void 0===e?void 0:e.map((function(e){var t=e.details.retailPrice,r=(null===t||void 0===t?void 0:t.currency)===f;return{productVariantId:e.id,disableCatalog:!1,offerPrice:r?e.details.retailPrice:{amount:0,currency:null!==f&&void 0!==f?f:Z.Fa6.Hkd}}}))}}return{}}),[a]),x=(0,D.Z)((0,Z.WSh)(),2),h=x[0],g=x[1],j=(g.loading,g.client),b=function(){var e=(0,H.Z)((function(e){var t,r,n,s,o;return(0,q.__generator)(this,(function(l){switch(l.label){case 0:return t=e.fromWarehouse,r=e.prodVarsCatalog,n=e.remarks,s=e.hidePrice,(null===a||void 0===a?void 0:a.id)&&(null===r||void 0===r?void 0:r.length)?(null===t||void 0===t?void 0:t.value)?[4,h({variables:{dto:{remarks:n,fromWarehouseId:t.value,productId:null===a||void 0===a?void 0:a.id,hidePrice
1:s,prodVarsCatalog:r.map((function(e){return{disableCatalog:e.disableCatalog,productVariantId:e.productVariantId,offerId:e.offerId,offerPrice:e.offerPrice}}))}}})]:((0,L._N)("Please select a warehouse"),[2]):((0,L._N)("Please select a product"),[2]);case 1:return(null===(o=l.sent().data)||void 0===o?void 0:o.createProductCatalog.id)&&((0,L.x9)("Product Catalog Created"),i(null),j.cache.evict({fieldName:"allProductCatalogs"}),j.cache.evict({fieldName:"allProducts"})),[2]}}))}));return function(t){return e.apply(this,arguments)}}();return(0,n.jsx)("div",{children:(0,n.jsx)(K.Z,{isOpen:o,setIsOpen:l,dialogProps:{open:o,maxWidth:"lg"},button:(0,n.jsx)(w.Z,{onClick:d,sx:{m:2},size:"small",variant:"contained",children:v}),title:v,description:(0,n.jsx)("span",{className:"font-bold"}),children:(0,n.jsx)(Ne.X,{newColumns:(0,Se.u)((function(e){var t=e.product;i(t)})),children:(0,n.jsx)(ye.GW,{defaultFilters:{isOnCatalog:!1},children:(0,n.jsxs)("div",{ref:t,onClick:$.UW,className:"mx-2",children:[a&&(0,n.jsx)("div",{hidden:!a,children:(0,n.jsx)(je,{defaultValues:m,onSubmit:b,onCancel:function(){i(null)},productId:a.id})}),!a&&(0,n.jsx)("div",{hidden:!!a,children:(0,n.jsx)(we.Z,{})})]})})})})})},ke=r(33342),Oe=r(85214),Ee=r(81284),ze=r(57427),Re=r(48942),_e=r(94138),Me=r(51548),Fe=r(44373),We=function(e){var t=e.label,r=e.value;return(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,n.jsxs)("span",{className:"shrink-0 opacity-60",children:[t,":"]}),(0,n.jsx)("span",{className:"ml-2 truncate text-right font-medium",children:r||"-"})]})},Ae=(Ie={},(0,a.Z)(Ie,Z.Pte.Approved,"success"),(0,a.Z)(Ie,Z.Pte.Archived,"error"),(0,a.Z)(Ie,Z.Pte.Pending,"warning"),Ie),Te=function(e){var t,r,a,i,s,o,l=e.row,d=(null===(t=l.categories)||void 0===t?void 0:t.map((function(e){return e.name})).join(", "))||null,c=null===(r=l.createdBy)||void 0===r?void 0:r.userName,u=l.isReceived||l.isScrapped,f=(null===(a=l.details)||void 0===a?void 0:a.version)?String(l.details.version):null;return(0,n.jsx)(C.Z,{className:"w-full",children:(0,n.jsxs)(ue.Z,{sx:{p:1.5,"&:last-child":{pb:1.5}},children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsx)(ze.Z,{id:l.id,name:l.name}),(0,n.jsx)(_e.I,{label:String(l.status),color:null!==(o=Ae[l.status])&&void 0!==o?o:"info"}),l.type!==Z.kvN.Normal?(0,n.jsx)(_e.I,{label:String(l.type),color:"secondary"}):null]})}),(0,n.jsx)("div",{className:"flex shrink-0 items-center gap-1",children:(0,n.jsx)(Pe,{row:l})})]}),(0,n.jsx)(Fe.Z,{className:"!my-2"}),(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-1 text-sm",children:[(0,n.jsx)(We,{label:"In Catalog",value:(0,n.jsx)(Re.L,{value:!!(null===(i=l.catalog)||void 0===i?void 0:i.isActive),trueLabel:"Active",falseLabel:"Inactive"})}),(0,n.jsx)(We,{label:"Category",value:d}),(0,n.jsx)(We,{label:"Version",value:f}),(0,n.jsx)(We,{label:"Company",value:(null===(s=l.company)||void 0===s?void 0:s.name)||null}),(0,n.jsx)(We,{label:"Created",value:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,n.jsx)(Me.Z,{date:l.createdAt}),c||u?(0,n.jsxs)("span",{className:"text-xs opacity-70",children:["by ",u?"System":c]}):null]})})]})]})})},He=function(e){var t=e.rows;return(0,n.jsx)(Oe.Z,{children:null===t||void 0===t?void 0:t.map((function(e,t){return(0,n.jsx)(Ee.ZP,{sx:(0,ke.g)(t),children:(0,n.jsx)(Te,{row:e})},e.id)}))})},De=r(35886),qe=r(62135);var Le=function(e){var t=(0,I.a)().user,r=(0,V.b)(t),a=null===r||void 0===r?void 0:r.company.name,i="".concat(window.location.origin,"/catalog/").concat(a),s=function(){var e=(0,H.Z)((function(e){var t;return(0,q.__generator)(this,(function(r){switch(r.label){case 0:if("string"!==typeof e)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,navigator.clipboard.writeText(e)];case 2:return r.sent(),(0,L.x9)("Content copied.",{icon:(0,n.jsx)(B.Km,{})}),[3,4];case 3:return t=r.sent(),console.error("Failed to copy:",t),[3,4];case 4:return[2]}}
1))}));return function(t){return e.apply(this,arguments)}}();return(0,n.jsx)("div",{children:(0,n.jsxs)(qe.Z,{size:"small",children:[(0,n.jsx)(w.Z,{onClick:function(){window.open(i,"_blank")},variant:"contained",children:"View Catalog"}),(0,n.jsx)(w.Z,{onClick:function(){s(i)},variant:"outlined",children:(0,n.jsx)(De.aA,{className:""})})]})})};var Ue=function(e){var t=e.hasHeader,r=void 0===t||t,w=T(),N=w.page,Z=w.pageSize,I=w.selectedIds,V=w.setPage,k=w.setPageSize,O=w.setSelectedIds,E=w.rows,z=w.totalRows,R=w.loading,_=w.filters,M=w.setFilters,F=w.sortField,W=w.setSortField,A=w.sortOrder,H=w.setSortOrder,D=w.sortType,q=w.setSortType,L=w.dataGridRef,U=(0,y.useCallback)((function(e,t){M((function(r){return(0,s.Z)((0,i.Z)({},r),(0,a.Z)({},e,t))}))}),[M]),B=(0,y.useCallback)((function(){return"auto"}),[]),G=(0,y.useMemo)((function(){var e=d.E.findIndex((function(e){return"actions"===e.field})),t=d.E[e];if(!t)return d.E;var r=(0,o.Z)(d.E);return r.splice(e,1,(0,s.Z)((0,i.Z)({},t),{width:120,renderCell:function(e){var t=e.row;return(0,n.jsx)(Pe,{row:t})}})),r}),[]);return(0,n.jsxs)(g.ZP,{container:!0,spacing:6,children:[r?(0,n.jsx)(h.Z,{title:(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)(j.Z,{variant:"h5",children:"Catalog products"}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)(X,{}),(0,n.jsx)(l.w,{children:(0,n.jsx)(p.M,{children:(0,n.jsx)(Ve,{})})}),(0,n.jsx)(Le,{})]})]}),subtitle:(0,n.jsx)(j.Z,{variant:"body2",children:"Find all of your products displayed in company catalog"})}):null,(0,n.jsx)(g.ZP,{item:!0,xs:12,children:(0,n.jsx)(g.ZP,{container:!0,spacing:6,children:(0,n.jsxs)(g.ZP,{item:!0,xs:12,children:[(0,n.jsx)(m.Z,{children:(0,n.jsx)(c.Z,{filters:_,handleFilter:U,sortField:F,setSortField:W,sortOrder:A,setSortOrder:H,sortType:D,setSortType:q,isCatalogFilter:!0})}),S.tq?(0,n.jsxs)("div",{className:"pb-16",children:[R&&!E.length?(0,n.jsx)("div",{className:"flex justify-center py-10",children:(0,n.jsx)(b.Z,{})}):E.length?(0,n.jsx)(He,{rows:E}):(0,n.jsx)(u.u,{compact:!0,variant:"filtered",title:"No catalog products match your filters"}),(0,n.jsx)(x.Z,{page:N,setPage:V,pageSize:Z,setPageSize:k,totalRows:z,rowsPerPageOption:[10,25,50,100]})]}):(0,n.jsx)(C.Z,{children:(0,n.jsx)(f.Z,{children:(0,n.jsx)(P.s,{apiRef:L,pagination:!0,page:N,pageSize:Z,rowCount:z,rows:E,columns:G,loading:R,getRowSpacing:v.ab,sx:v.Dr,paginationMode:"server",onPageSizeChange:k,onPageChange:V,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:1e3,getEstimatedRowHeight:function(){return 600},getRowHeight:B,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},checkboxSelection:!0,disableSelectionOnClick:!1,keepNonExistentRowsSelected:!0,onSelectionModelChange:function(e){O(e)},selectionModel:I,components:{Pagination:x.Z},componentsProps:{pagination:{page:N,setPage:V,pageSize:Z,setPageSize:k,totalRows:z}}})})})]})})})]})},Xe=function(){return(0,n.jsx)(A,{withProductVariant:!1,defaultFilters:{isOnCatalog:!0},children:(0,n.jsx)(Ue,{})})}}},function(e){e.O(0,[2876,630,4980,7536,1524,4231,5428,1718,5836,5734,3747,1717,2268,9591,2512,1090,7247,5780,1280,2020,8507,3021,1115,7384,4738,5686,5646,9714,2068,6778,1039,4503,6446,2180,7297,309,7545,9329,9721,1197,7302,3105,9774,2888,179],(function(){return t=61899,e(e.s=t);var t}));var t=e.O();_N_E=t}]);
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.