1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3820],{66505:function(e,i,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/apps/dropship/supply-clients",function(){return t(30202)}])},1636:function(e,i,t){"use strict";t.d(i,{Y7:function(){return y},vx:function(){return b}});var s=t(47568),n=t(828),r=t(70655),a=t(85893),l=t(25941),o=t(5837),d=t(20986),c=t(58571),u=t(96277),p=t(4451),x=t(23837),m=t(43085),h=t(17575),f=t(79072),v=t(13264),j=t(86010),g=t(96486),y=(0,v.Z)(d.nQ)((function(e){return{borderColor:"light"===e.theme.palette.mode?"rgb(22 163 74)":"rgb(187 247 208)",borderWidth:"1px",borderRadius:"0.25rem",backgroundColor:"rgb(74 222 128)",color:"rgb(255 255 255)",pointerEvents:"auto"}})),b=(0,v.Z)(d.Tw)((function(e){return{borderColor:"light"===e.theme.palette.mode?"rgb(153 27 27)":"rgb(248 113 113)",borderWidth:"1px",borderRadius:"0.25rem",backgroundColor:"rgb(220 38 38)",color:"rgb(255 255 255)",pointerEvents:"auto"}})),P=function(e){var i,t=e.dropshipQuantity,s=e.name;return(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("span",{className:"",children:[s,":"]}),(0,a.jsx)("span",{className:"w-10 text-right",children:null!==(i=(0,g.get)(t,s))&&void 0!==i?i:0})]})};i.ZP=function(e){var i=e.dropshipReceive,t=(0,p.a)().user,v=(0,x.b)(t),N=i.dropshipSupplyCompany,Z=i.receiverIsActive,w=i.supplierIsActive,C=i.dropshipPrice,S=i.dropshipQuantity,k=i.fromWareHouse,I=i.id,V=null===v||void 0===v?void 0:v.company.name,D=N.name,Q=(0,g.sum)((0,g.values)((0,g.pick)(S,["damaged","fulfillable","reserved","used"]))),W=(0,n.Z)((0,u.FtM)(),2),O=W[0],R=W[1],F=R.loading,z=R.client,A=function(){var e=(0,s.Z)((function(){var e,t;return(0,r.__generator)(this,(function(s){switch(s.label){case 0:return F?[2]:[4,O({variables:{updateDropshipLinkByReceiverDto:{id:I,isActive:e=!Z}}})];case 1:return(null===(t=s.sent().data)||void 0===t?void 0:t.updateDropshipLinkByReceiver.id)&&((0,m.x9)("Dropship link updated successfully"),z.cache.modify({id:z.cache.identify(i),fields:{receiverIsActive:function(i){return e}}})),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,a.jsxs)("div",{className:"-mt-2 w-full py-2 text-xs",children:[(0,a.jsx)(h.Z,{placement:"left",title:"Supplier is ".concat(w?"active":"NOT active"),children:(0,a.jsxs)("div",{className:(0,j.Z)("flex items-center gap-2",{"text-green-600":w,"text-red-600":!w}),children:[(0,a.jsx)("span",{className:"rounded-lg p-1 text-base",children:w?(0,a.jsx)(d.nQ,{}):(0,a.jsx)(d.Tw,{})}),(0,a.jsx)("span",{className:"w-8 text-left",children:"From: "}),(0,a.jsxs)(f.ZP,{container:!0,spacing:2,children:[(0,a.jsx)(f.ZP,{item:!0,xs:4,children:"Company:"}),(0,a.jsx)(f.ZP,{item:!0,xs:8,children:D}),(0,a.jsx)(f.ZP,{item:!0,xs:4,children:"Warehouse:"}),(0,a.jsx)(f.ZP,{item:!0,xs:8,children:(0,a.jsx)("span",{className:"flex items-center gap-1",children:(null===k||void 0===k?void 0:k.name)||"-"})})]})]})}),(0,a.jsx)(h.Z,{placement:"left",title:"Receiver is ".concat(Z?"active":"NOT active"),children:(0,a.jsxs)("div",{className:(0,j.Z)("flex items-center gap-2",{"text-green-600":Z,"text-red-600":!Z}),children:[(0,a.jsx)("span",{onClick:A,className:"cursor-pointer rounded-lg p-1 text-base hover:bg-slate-400/50",children:F?(0,a.jsx)(d.Ho,{className:"animate-spin"}):Z?(0,a.jsx)(y,{className:"animate-pulse"}):(0,a.jsx)(b,{className:"animate-pulse"})}),(0,a.jsx)("span",{className:"w-8 text-left",children:"To:"})," ",V," (",Z?"Active":"Inactive",")"]})}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{title:"Dropship Price",className:"flex items-center gap-2",children:(0,a.jsx)(o.UP,{color:C?"secondary":"primary",variant:"outlined",label:C?(0,a.jsx)(l.C,{amount:null===C||void 0===C?void 0:C.amount,currency:null===C||void 0===C?void 0:C.currency}):(0,a.jsx)("div",{className:"",children:"~ FIFO Price"})})}),(0,a.jsx)(c._,{title:S?(0,a.jsxs)("div",{children:[(0,a.jsx)(P,{name:"fulfillable",dropshipQuantity:S}),(0,a.jsx)(P,{name:"damaged",dropshipQuantity:S}),(0,a.jsx)(P,{name:"reserved",dropshipQuantity:S}),(0,a.jsx)(P,{name:"used",dropshipQuantity:S})]}):"",children:(0,a.jsxs)("div",{children:["Qty:"," ",(0,a.jsx)("span",{className:"text-base font-bold",children:S?Q:"All"})]})})]})]})}},25665:function(e,i,t){"use strict";t.d(i,{D:function(){return l},w:function(){return a}});var s=t(85893),n=t(67294),r=n.createContext(void 0),a=function(e){var i=(0,n.use
1State)([]),t=i[0],a=i[1],l=e.onSelectProduct,o=e.onSelectProductVariant,d=e.children,c=(0,n.useMemo)((function(){return{onSelectProduct:l,onSelectProductVariant:o,selectedProductVariants:t,setSelectedProductVariants:a}}),[o,l,t]);return(0,s.jsx)(r.Provider,{value:c,children:d})},l=function(){var e=(0,n.useContext)(r);if(void 0===e)throw new Error("useMultiSelectProductVariant can only be used inside MultiSelectProductVariantContext");return e}},30202:function(e,i,t){"use strict";t.r(i),t.d(i,{default:function(){return He}});var s,n=t(85893),r=t(26042),a=t(828),l=t(96277),o=t(4451),d=t(23837),c=t(96486),u=t(11163),p=t.n(u),x=t(67294),m=(0,x.createContext)(void 0),h=function(e){var i=e.children,t=e.defaultFilters,s=e.storeParamsInUrl,h=void 0!==s&&s,f=(0,l.c34)(),v=((0,a.Z)((0,l.VpS)(),1)[0],(0,x.useMemo)((function(){var e;return null===(e=f.data)||void 0===e?void 0:e.myCompany.defaultWarehouse}),[f]),(0,o.a)()),j=v.user,g=v.preferredCurrency,y=(0,d.b)(j),b=null===y||void 0===y?void 0:y.company.id,P=(0,u.useRouter)().query,N=(0,x.useState)((function(){return h&&P.page?Number(P.page):0})),Z=N[0],w=N[1],C=(0,x.useState)((function(){return h&&P.pageSize?Number(P.pageSize):10})),S=C[0],k=C[1],I=(0,x.useState)((function(){return h&&P.filters?JSON.parse(P.filters):(0,r.Z)({},t)})),V=I[0],D=I[1],Q=(0,x.useState)([]),W=Q[0],O=Q[1],R=(0,l.bjh)({variables:{filter:V,page:Z,perPage:S,sortField:"createdAt",sortOrder:l.Asd.Desc,convertCurrency:g||void 0},notifyOnNetworkStatusChange:!1}),F=R.refetch,z=R.loading,A=R.data,_=(0,x.useMemo)((function(){return{rows:(null===A||void 0===A?void 0:A.allSuppliedDropshipProducts.products)||[],totalRows:(null===A||void 0===A?void 0:A.allSuppliedDropshipProducts.total)||0}}),[A]),E=_.rows,M=_.totalRows,U=(0,x.useMemo)((function(){return(0,c.debounce)((function(e){var i=e.filters,t=e.page,s=e.pageSize;p().replace({query:{filters:JSON.stringify(i),page:t,pageSize:s}},void 0,{shallow:!0})}),100)}),[]);(0,x.useEffect)((function(){return h&&U({filters:V,page:Z,pageSize:S}),function(){return U.cancel()}}),[h,Z,V,S,U]),(0,x.useEffect)((function(){f.loading||f.called&&b&&f.refetch()}),[f,b]);var L=(0,x.useMemo)((function(){return{queryResult:R,rows:E,totalRows:M,filters:V,setFilters:D,page:Z,setPage:w,pageSize:S,setPageSize:k,selectedIds:W,setSelectedIds:O,loading:z,refetch:F}}),[R,E,V,M,Z,S,W,z,F]);return(0,n.jsx)(m.Provider,{value:L,children:i})},f=(m.Consumer,function(){var e=(0,x.useContext)(m);if(!e)throw new Error("No Context.Provider found when calling useContext.");return e}),v=t(14924),j=t(69396),g=t(94062),y=t(47018),b=t(79072),P=t(29630),N=t(49837),Z=t(25836),w=t(85518),C=t(31032),S=t(40873),k=t(89479),I=t(26640),V=t(25941),D=t(31753),Q=t(17575),W=t(23378),O=t(86010),R=t(47568),F=t(70655),z=t(5837),A=t(20986),_=t(74098),E=t(58571),M=t(43085),U=t(1636),L=t(45209),H=t(29143),B=t(56302),T=t(44656),q=t(76366),X=t(47533),J=t(19223),K=t(62135),Y=t(54225),G=t(44373),$=t(87536),ee=t(74231),ie={},te=ee.Ry().shape({dropshipPrice:ee.Ry().shape({amount:(0,J.r)(),currency:ee.nK().nullable()}).nullable()});!function(e){e.FIFO="fifo",e.Custom="custom"}(s||(s={}));var se,ne=function(e){var i=e.onSubmit,t=e.defaultValues,r=(0,x.useState)((null===t||void 0===t?void 0:t.dropshipPrice)?s.Custom:s.FIFO),a=r[0],o=r[1],d=(0,c.merge)({},ie,t),u=(0,$.cI)({defaultValues:d,resolver:(0,X.X)(te)}),p=u.handleSubmit,m=u.setValue,h=(u.formState.errors,a!==s.Custom);return(0,n.jsx)("div",{className:"m-1 p-1",children:(0,n.jsx)(q.e,{methods:u,onSubmit:p((function(e){var t={dropshipPrice:a===s.FIFO?null:e.dropshipPrice||null};i(t)})),defaultValues:d,children:(0,n.jsxs)(b.ZP,{container:!0,spacing:6,children:[(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(P.Z,{variant:"body2",sx:{fontWeight:600},children:"1. Dropship Price"})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsxs)(K.Z,{fullWidth:!0,variant:"outlined",size:"medium",children:[(0,n.jsx)(Y.Z,{onClick:function(){o(s.FIFO)},variant:a===s.FIFO?"contained":"outlined",children:s.FIFO}),(0,n.jsx)(Y.Z,{onClick:function(){var e,i,t,n;o(s.Custom),m("dropshipPrice",{amount:null!==(t=null===(e=d.dropshipPrice)||void 0===e?void 0:e.amount)&&void 0!==t?t:0,currency:null!==(n=null===(i=d.dropshipPrice)||void 0===i?void 0:i.currency)&&void 0!==n?n:l.Fa6.Hkd})},variant:a===s.Custom?"contained":"outlined",children:s.Custom})]})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(G.Z,{})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(P.Z,{variant:"body2",sx:{fontWeight:600},children:"2. Custom Price"})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,sm:12,children:(0,n.jsxs)("div",{className:"flex",children:[(0,n.jsx)(T.Z,{label:"Price",name:"dropshipPrice.amount",defaultValues:d,textFieldProps:{disabled:h},formControlProps:{className:"flex-grow"}}),(0,n.jsx)(B.Z,{name:"dropshipPrice.currency",label:null,defaultValue:l.Fa6.Hkd,defaultValues:d,selectProps:{disabled:h},formControlProps:{className:"w-32",size:"small"}})]})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(G.Z,{})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,sx:{pt:function(e){return"".concat(e.spacing(7)," !important")}},children:(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)(Y.Z,{type:"submit",variant:"contained",sx:{mr:4},children:"Submit"})})})]})})})},re=(0,H.Ue)((function(e){var i=e.isOpen,t=e.onResolve,s=(e.onReject,e.dropshipPrice),r=(0,x.useMemo)((function(){return{dropshipPrice:s}}),[s]);return(0,n.jsx)("div",{children:(0,n.jsx)(L.Z,{isOpen:i,setIsOpen:function(e){(0,c.isFunction)(e)?console.log("UpdateDropshipPricePromptDialogBase setIsOpen isFunction: PLEASE DOUBLE CHECK"):!0===e||t(!1)},dialogProps:{maxWidth:"xs"},button:(0,n.jsx)("div",{}),title:"Update Dropship Quantity",children:(0,n.jsx)("div",{onClick:k.UW,children:(0,n.jsx)(ne,{onSubmit:function(e){t(e)},defaultValues:r})})})})})),ae={},le=ee.Ry().shape({dropshipQuantity:ee.Ry().shape({fulfillable:(0,J.r)(),reserved:(0,J.r)(),used:(0,J.r)(),damaged:(0,J.r)()}).nullable()});!function(e){e.All="all",e.Custom="custom"}(se||(se={}));var oe=function(e){var i=e.onSubmit,t=e.defaultValues,s=(0,x.useState)((null===t||void 0===t?void 0:t.dropshipQuantity)?se.Custom:se.All),r=s[0],a=s[1],l=(0,c.merge)({},ae,t),o=(0,$.cI)({defaultValues:l,resolver:(0,X.X)(le)}),d=o.handleSubmit,u=(o.formState.errors,r!==se.Custom);return(0,n.jsx)("div",{className:"m-1 p-1",children:(0,n.jsx)(q.e,{methods:o,onSubmit:d((function(e){var t={dropshipQuantity:r===se.All?null:e.dropshipQuantity||null};i(t)})),defaultValues:l,children:(0,n.jsxs)(b.ZP,{container:!0,spacing:6,children:[(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(P.Z,{variant:"body2",sx:{fontWeight:600},children:"1. Dropship Quantity"})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsxs)(K.Z,{fullWidth:!0,variant:"outlined",size:"medium",children:[(0,n.jsx)(Y.Z,{onClick:function(){a(se.All)},variant:r===se.All?"contained":"outlined",children:se.All}),(0,n.jsx)(Y.Z,{onClick:function(){a(se.Custom)},variant:r===se.Custom?"contained":"outlined",children:se.Custom})]})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(G.Z,{})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(P.Z,{variant:"body2",sx:{fontWeight:600},children:"2. Custom Quantity"})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,sm:12,children:(0,n.jsx)(T.Z,{name:"dropshipQuantity.fulfillable",textFieldProps:{fullWidth:!0,placeholder:"Quantity",disabled:u},label:(0,n.jsx)("div",{children:"Fulfillable"}),defaultValues:l})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,sm:12,children:(0,n.jsx)(T.Z,{name:"dropshipQuantity.damaged",textFieldProps:{fullWidth:!0,placeholder:"Quantity",disabled:u},label:(0,n.jsx)("div",{children:"Damaged"}),defaultValues:l})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,sm:12,children:(0,n.jsx)(T.Z,{name:"dropshipQuantity.used",textFieldProps:{fullWidth:!0,placeholder:"Quantity",disabled:u},label:(0,n.jsx)("div",{children:"Used"}),defaultValues:l})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,sm:12,children:(0,n.jsx)(T.Z,{name:"dropshipQuantity.reserved",textFieldProps:{fullWidth:!0,placeholder:"Quantity",disabled:u},label:(0,n.jsx)("div",{children:"Reserved"}),defaultValues:l})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(G.Z,{})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,sx:{pt:function(e){return"".concat(e.spacing(7)," !important")}},children:(0,n.jsx)("div",{className:"flex items-center gap-2",children:(0,n.jsx)(Y.Z,{type:"submit",variant:"contained",sx:{mr:4},children:"Submit"})})})]})})})},de=(0,H.Ue)((function(e){var i=e.isOpen,t=e.onResolve,s=(e.onReject,e.dropshipQuantity),r=(0,x.useMemo)((function(){return{dropshipQuantity:s}}),[s]);return(0,n.jsx)("div",{children:(0,n.jsx)(L.Z,{isOpen:i,setIsOpen:function(e){(0,c.isFunction)(e)?console.log("UpdateDropshipQuantityPromptDialogBase setIsOpen isFunction: PLEASE DOUBLE CHECK"):!0===e||t(!1)},dialogProps:{maxWidth:"xs"},button:(0,n.jsx)("div",{}),title:"Update Dropship Quantity",children:(0,n.jsx)("div",{onClick:k.UW,children:(0,n.jsx)(oe,{onSubmit:function(e){t(e)},defaultValues:r})})})})})),ce=function(e){var i,t=e.dropshipQuantity,s=e.name;return(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("span",{className:"",children:[s,":"]}),(0,n.jsx)("span",{className:"w-10 text-right",children:null!==(i=(0,c.get)(t,s))&&void 0!==i?i:0})]})};var ue=function(e){var i=e.dropshipSupply,t=i.dropshipReceiveCompany,s=i.receiverIsActive,r=i.supplierIsActive,o=i.dropshipPrice,d=i.dropshipQuantity,u=i.fromWareHouse,p=i.id,x=t.name,m=(0,
1c.sum)((0,c.values)((0,c.pick)(d,["damaged","fulfillable","reserved","used"]))),h=(0,a.Z)((0,l.fQp)(),2),f=h[0],v=h[1],j=v.loading,g=v.client,y=function(){var e=(0,R.Z)((function(){var e,t;return(0,F.__generator)(this,(function(s){switch(s.label){case 0:return j?[2]:[4,f({variables:{updateDropshipLinkDto:{id:p,isActive:e=!r}}})];case 1:return(null===(t=s.sent().data)||void 0===t?void 0:t.updateDropshipLinkBySupplier.id)&&((0,M.x9)("Dropship link updated successfully"),g.cache.modify({id:g.cache.identify(i),fields:{supplierIsActive:function(i){return e}}})),[2]}}))}));return function(){return e.apply(this,arguments)}}(),b=function(){var e=(0,R.Z)((function(){var e,t,s;return(0,F.__generator)(this,(function(n){switch(n.label){case 0:return j?[2]:[4,re({dropshipPrice:o})];case 1:return!1===(e=n.sent())?[2]:(t=e.dropshipPrice,[4,f({variables:{updateDropshipLinkDto:{id:p,dropshipPrice:t}}})]);case 2:return(null===(s=n.sent().data)||void 0===s?void 0:s.updateDropshipLinkBySupplier.id)&&((0,M.x9)("Dropship price updated successfully"),g.cache.modify({id:g.cache.identify(i),fields:{dropshipPrice:function(e){return t}}})),[2]}}))}));return function(){return e.apply(this,arguments)}}(),P=function(){var e=(0,R.Z)((function(){var e,t,s,n,r,a,l;return(0,F.__generator)(this,(function(o){switch(o.label){case 0:return j?[2]:[4,de({dropshipQuantity:d})];case 1:return!1===(e=o.sent())?[2]:(a=e.dropshipQuantity?{fulfillable:null!==(t=e.dropshipQuantity.fulfillable)&&void 0!==t?t:0,reserved:null!==(s=e.dropshipQuantity.reserved)&&void 0!==s?s:0,used:null!==(n=e.dropshipQuantity.used)&&void 0!==n?n:0,damaged:null!==(r=e.dropshipQuantity.damaged)&&void 0!==r?r:0}:e.dropshipQuantity,[4,f({variables:{updateDropshipLinkDto:{id:p,dropshipQuantity:a}}})]);case 2:return(null===(l=o.sent().data)||void 0===l?void 0:l.updateDropshipLinkBySupplier.id)&&((0,M.x9)("Dropship quantity updated successfully"),g.cache.modify({id:g.cache.identify(i),fields:{dropshipQuantity:function(e){return a}}})),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,n.jsxs)("div",{className:"-mt-2 w-full py-2 text-xs",children:[(0,n.jsx)(Q.Z,{placement:"left",title:"Supplier is ".concat(r?"active":"NOT active"),children:(0,n.jsxs)("div",{className:(0,O.Z)("flex items-center gap-2",{"text-green-600":r,"text-red-600":!r}),children:[(0,n.jsx)("span",{onClick:y,className:"cursor-pointer rounded-lg p-1 text-base hover:bg-slate-400/50",children:j?(0,n.jsx)(A.Ho,{className:"animate-spin"}):r?(0,n.jsx)(U.Y7,{className:"animate-pulse"}):(0,n.jsx)(U.vx,{className:"animate-pulse"})}),(0,n.jsx)("span",{className:"w-8 text-left",children:"From:"}),(0,n.jsxs)("span",{className:"flex items-center gap-1",children:[(0,n.jsx)(_.Jj,{})," ",(null===u||void 0===u?void 0:u.name)||"-"]})]})}),(0,n.jsx)(Q.Z,{placement:"left",title:"Receiver is ".concat(s?"active":"NOT active"),children:(0,n.jsxs)("div",{className:(0,O.Z)("flex items-center gap-2",{"text-green-600":s,"text-red-600":!s}),children:[(0,n.jsx)("span",{className:" rounded-lg p-1 text-base",children:s?(0,n.jsx)(A.nQ,{}):(0,n.jsx)(A.Tw,{})}),(0,n.jsx)("span",{className:"w-8 text-left",children:"To:"})," ",x]})}),(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsx)(Q.Z,{className:"cursor-pointer",placement:"top",title:"Click to Edit Dropship Price",followCursor:!0,children:(0,n.jsx)("div",{onClick:b,className:"flex cursor-pointer items-center gap-2",children:(0,n.jsx)(z.UP,{color:o?"secondary":"primary",variant:"outlined",className:"cursor-pointer",label:o?(0,n.jsx)(V.C,{amount:null===o||void 0===o?void 0:o.amount,currency:null===o||void 0===o?void 0:o.currency}):(0,n.jsx)("div",{className:"",children:"~ FIFO Price"})})})}),(0,n.jsx)(Q.Z,{placement:"top",title:"Click to Edit",followCursor:!0,children:(0,n.jsx)("div",{onClick:P,className:"cursor-pointer",children:(0,n.jsx)(E._,{title:d?(0,n.jsxs)("div",{children:[(0,n.jsx)(ce,{name:"fulfillable",dropshipQuantity:d}),(0,n.jsx)(ce,{name:"damaged",dropshipQuantity:d}),(0,n.jsx)(ce,{name:"reserved",dropshipQuantity:d}),(0,n.jsx)(ce,{name:"used",dropshipQuantity:d})]}):"",children:(0,n.jsxs)("div",{children:["Qty:"," ",(0,n.jsx)("span",{className:"text-base font-bold",children:d?m:"All"})]})})})})]})]})};var pe=function(e){var i=e.productVariants;return(0,n.jsx)("div",{className:"-mt-3 flex h-full w-full flex-col justify-start gap-2 divide-y divide-gray-300 dark:divide-gray-800",children:null===i||void 0===i?void 0:i.map((function(e){var t=e.id,s=e.name,r=e.sku,a=e.details,l=(e.type,e.dropshipSupplies
1),o=e.actualImage,d=a.images,c=a.variants,u=a.barcode,p=a.retailPrice;return(0,n.jsxs)("div",{className:"mb-1 flex h-full w-full flex-wrap gap-1 pt-3",children:[(0,n.jsx)("div",{className:"flex w-2/12 items-start justify-start",children:(0,n.jsx)(Q.Z,{arrow:!0,enterDelay:0,color:"white",title:"Name: ".concat(null!==s&&void 0!==s?s:""),placement:"bottom",children:(0,n.jsxs)("div",{className:"flex flex-row gap-y-2",children:[o&&(0,n.jsx)(D.ZP,{imgArray:[o],numOfImages:1}),(0,n.jsx)(D.ZP,{className:"flex-row flex-nowrap",imgArray:d,numOfImages:1})]})})}),(0,n.jsxs)("div",{className:"flex w-4/12 flex-1 flex-col gap-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap gap-1 divide-x divide-gray-500",children:[c.map((function(e){return(0,n.jsx)("div",{children:(0,n.jsxs)("div",{className:"ml-1 text-xs font-bold",children:[e.key," - ",e.value]})},e.id)})),0===c.length&&i.length>1&&(0,n.jsx)("div",{className:"ml-1 text-justify text-xs font-bold",children:(0,n.jsx)("span",{className:"line-clamp-3",children:s||"\u274c Name"})})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start gap-1",children:[(0,n.jsx)("div",{hidden:!p,children:(0,n.jsx)(W.Z,{variant:"outlined",size:"small",label:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:["SRP:",(0,n.jsx)(V.C,{amount:null===p||void 0===p?void 0:p.amount,currency:null===p||void 0===p?void 0:p.currency})]}),color:"secondary"})}),(0,n.jsx)(I.rI,{label:r||"\u274c Sku",copy:r,tooltipProps:{placement:"left"}}),(0,n.jsx)(I.kw,{label:u||"\u274c Barcode",copy:u,tooltipProps:{placement:"left"}})]})]}),(0,n.jsx)("div",{className:(0,O.Z)("flex w-3/12 min-w-[18rem] flex-col items-start justify-start gap-1 divide-y divide-slate-400/50 border-l border-gray-300 pl-3 dark:border-gray-800"),children:null===l||void 0===l?void 0:l.map((function(e){return(0,n.jsx)(ue,{dropshipSupply:e},e.id)}))})]},t)}))})},xe=[{headerName:"Name",field:"name",flex:1,minWidth:320,renderCell:function(e){var i=e.row;return(0,n.jsx)(S.Z,{row:i})}},{headerName:"Product Variants",field:"productVariants",minWidth:500,flex:2,renderCell:function(e){var i=e.row,t=(0,c.get)(i,"productVariants");return(0,n.jsx)("div",{className:"h-full w-full",onClick:k.UW,children:(0,n.jsx)(pe,{productVariants:t})})}},{headerName:"Created",field:"createdAt",minWidth:230,renderCell:function(e){var i=e.row;return(0,n.jsx)(C.Z,{row:i})}}],me=t(73275),he=t(74230),fe=t(66549),ve=t(25665),je=t(94747),ge=t(79506),ye=function(e){var i=e.onSubmit,t=(0,ve.D)(),s=t.selectedProductVariants,r=t.setSelectedProductVariants,a={clientCompanies:[],fromWarehouse:null},l=(0,$.cI)({defaultValues:a}),o=(l.control,l.handleSubmit);l.formState.errors,l.setValue,l.watch,l.reset;return(0,n.jsx)("div",{className:"rounded-xl border border-transparent p-5 hover:border-primary",children:(0,n.jsx)(q.e,{methods:l,onSubmit:o((function(e){var t,s;i({clientCompanyIds:null===(t=e.clientCompanies)||void 0===t?void 0:t.map((function(e){return e.value})),fromWareHouseId:null===(s=e.fromWarehouse)||void 0===s?void 0:s.value})})),defaultValues:a,children:(0,n.jsxs)(b.ZP,{container:!0,spacing:3,sx:{pt:5},children:[(0,n.jsxs)(b.ZP,{item:!0,xs:12,sm:6,className:"space-y-6",children:[(0,n.jsx)(P.Z,{variant:"body2",sx:{fontWeight:600},children:"1. Warehouse (*)"}),(0,n.jsx)(ge.Zu,{methods:l,name:"fromWarehouse",defaultValues:a,label:"Select Warehouse"})]}),(0,n.jsxs)(b.ZP,{item:!0,xs:12,sm:6,className:"space-y-6",children:[(0,n.jsx)(P.Z,{variant:"body2",sx:{fontWeight:600},children:"2. Client Companies (*)"}),(0,n.jsx)(je.L,{methods:l,name:"clientCompanies",defaultValues:a,label:"Select Companies",multiple:!0,disableCloseOnSelect:!1})]}),(0,n.jsxs)(b.ZP,{className:"flex flex-wrap",item:!0,xs:12,sx:{pt:function(e){return"".concat(e.spacing(7)," !important")}},children:[(0,n.jsxs)(Y.Z,{type:"submit",variant:"contained",sx:{mr:4},children:["Create Dropship Link",(0,n.jsxs)("span",{className:"ml-2 font-bold",children:["(",s.length,")"]})]}),(0,n.jsx)(Y.Z,{type:"button",onClick:function(){r([])},color:"error",variant:"outlined",sx:{mr:4},children:"Unselect All"})]})]})})})},be=t(91781),Pe=t(10874),Ne=t(19668),Ze=t(20281),we=t(29815),Ce=t(71246),Se=function(e){var i=e.productVariant,t=(0,ve.D)(),s=t.selectedProductVariants,r=t.setSelectedProductVariants,a=s.some((function(e){return e.id===i.id}));return(0,n.jsx)(Y.Z,{variant:"contained",color:a?"error":"info",onClick:function(){r(a?s.filter((function(e){return e.id!==i.id})):(0,we.Z)(s).concat([i]))},size:"medium",className:a?"":"animate-pulse",children:a?"Unselect":"Select"})};var ke=function(e){var i=e.row,t=(0,c.get)(i,"productVariants");return(0,n.jsx)("div",{className:"h-full w-full",onClick:k.UW,children:(0,n.jsx)("div",{className:"-mt-3 flex h-full w-full flex-col justify-start gap-2 divide-y divide-gray-300 dark:divide-gray-800",children:null===t||void 0===t?void 0:t.map((function(e){var i=e.id,s=e.name,r=e.sku,a=e.details,l=(e.type,e.actualImage),o=a.images,d=a.variants,c=a.barcode,u=a.retailPrice;return(0,n.jsxs)("div",{className:"mb-1 flex h-full w-full flex-wrap gap-1 pt-3",children:[(0,n.jsx)("div",{className:"flex w-2/12 items-start justify-start",children:(0,n.jsx)(Q.Z,{arrow:!0,enterDelay:0,color:"white",title:"Name: ".concat(null!==s&&void 0!==s?s:""),placement:"bottom",children:(0,n.jsxs)("div",{className:"flex flex-row gap-y-2",children:[l&&(0,n.jsx)(D.ZP,{imgArray:[l],numOfImages:1}),(0,n.jsx)(D.ZP,{className:"flex-row flex-nowrap",imgArray:o,numOfImages:1})]})})}),(0,n.jsxs)("div",{className:"flex w-4/12 flex-1 flex-col gap-1",children:[(0,n.jsxs)("div",{className:"flex flex-wrap gap-1 divide-x divide-gray-500",children:[d.map((function(e){return(0,n.jsx)("div",{children:(0,n.jsxs)("div",{className:"ml-1 text-xs font-bold",children:[e.key," - ",e.value]})},e.id)})),0===d.length&&t.length>1&&(0,n.jsx)("div",{className:"ml-1 text-justify text-xs font-bold",children:(0,n.jsx)("span",{className:"line-clamp-3",children:s||"\u274c Name"})})]}),(0,n.jsxs)("div",{className:"flex flex-col items-start gap-1",children:[(0,n.jsx)("div",{hidden:!u,children:(0,n.jsx)(W.Z,{variant:"outlined",size:"small",label:(0,n.jsxs)("div",{className:"flex items-center gap-2",children:["SRP:",(0,n.jsx)(V.C,{amount:null===u||void 0===u?void 0:u.amount,currency:null===u||void 0===u?void 0:u.currency})]}),color:"secondary"})}),(0,n.jsx)(I.rI,{label:r||"\u274c Sku",copy:r,tooltipProps:{placement:"left"}}),(0,n.jsx)(I.kw,{label:c||"\u274c Barcode",copy:c,tooltipProps:{placement:"left"}})]})]}),(0,n.jsxs)("div",{className:(0,O.Z)("flex w-3/12 min-w-[9rem] flex-col items-start justify-start gap-5 border-l border-gray-300 pl-3 dark:border-gray-800"),children:[(0,n.jsx)(Ce.Z,{productVariant:e}),(0,n.jsx)(Se,{productVariant:e})]})]},i)}))})})},Ie=[{headerName:"Name",field:"name",flex:1,minWidth:320,renderCell:function(e){var i=e.row;return(0,n.jsx)(S.Z,{row:i})}},{headerName:"Product Variants",field:"productVariants",minWidth:500,flex:2,renderCell:function(e){var i=e.row;return(0,n.jsx)(ke,{row:i})}},{headerName:"Created",field:"createdAt",minWidth:230,renderCell:function(e){var i=e.row;return(0,n.jsx)(C.Z,{row:i})}},{headerName:"Actions",field:"actions",minWidth:170,renderCell:function(e){var i=e.row;return(0,n.jsx)(Ze.Z,{row:i})}}];var Ve=function(e){var i=(0,fe.iB)(),t=i.page,s=i.pageSize,a=i.selectedIds,l=i.setPage,o=i.setPageSize,d=i.setSelectedIds,c=i.rows,u=i.totalRows,p=i.loading,m=i.filters,h=i.setFilters,f=(0,x.useCallback)((function(){return"auto"}),[]),y=!0;return(0,n.jsx)("div",{children:(0,n.jsx)(b.ZP,{container:!0,spacing:6,children:(0,n.jsxs)(b.ZP,{item:!0,xs:12,children:[(0,n.jsx)(N.Z,{className:"mb-4",children:(0,n.jsx)(be.Z,{filters:m,handleFilter:function(e,i){h((0,j.Z)((0,r.Z)({},m),(0,v.Z)({},e,i)))}})}),(0,n.jsx)(N.Z,{children:(0,n.jsx)("div",{className:"flex h-full w-full",children:(0,n.jsx)("div",{className:"grow",children:(0,n.jsx)(Z.s,{pagination:!0,page:t,pageSize:s,rowCount:u,rows:c,columns:Ie,loading:p,getRowSpacing:Ne.ab,sx:Ne.Dr,paginationMode:"server",onPageSizeChange:o,onPageChange:l,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,getRowHeight:f,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},checkboxSelection:y,disableSelectionOnClick:!1,keepNonExistentRowsSelected:y,onSelectionModelChange:function(e){d(e)},selectionModel:a,components:{Toolbar:Pe.v,Pagination:g.Z},componentsProps:{pagination:{page:t,setPage:l,pageSize:s,setPageSize:o,totalRows:u}}})})})})]})})})};var De=function(e){var i=(0,x.useState)(!1),t=i[0],s=i[1],r=function(){return s(!1)},o=(0,ve.D)(),d=o.selectedProductVariants,c=o.setSelectedProductVariants,u=(0,a.Z)((0,l.ZZc)(),2),p=u[0],m=(u[1].loading,(0,me.H)().drawerContainerRef),h=(0,x.useCallback)(function(){var e=(0,R.Z)((function(e){var i,t,s,n,a;return(0,F.__generator)(this,(function(l){switch(l.label){case 0:return 0===(s=d.map((function(e){return e.id}))).length?((0,M._N)("No product variant selected"),[2]):(null===(i=e.clientCompanyIds)||void 0===i?void 0:i.length)?e.fromWareHouseId?[4,p({variables:{createDropshipLinkDto:{clientCompanyIds:null!==(n=e.clientCompanyIds)&&void 0!==n?n:[],fromWareHouseId:e.fromWareHouseId||"",supplyProdVarIds:s}}})]:((0,M._N)("No warehouse selected"),[2]):((0,M._N)("No client company selected"),[2]);case 1:return(null===(a=l.sent().data)||void 0===a||null===(t=a.bulkCreateDropshipLinks)||void 0===t?void 0:t.length)&&((0,M.x9)("Dropship links created successfully"),c([]),r()),[2]}}))}));return function(i){return e.apply(this,arguments)}}(),[d]);return(0,x.useRef)(null),(0,n.jsx)("div",{children:(0,n.jsx)(L.Z,{isOpen:t,setIsOpen:s,dialogProps:{open:t,onClose:function(){return r()},maxWidth:"xl"},button:(0,n.jsx)(Y.Z,{onClick:function(){s(!0)},size:"small",variant:"contained",color:"primary",children:"New Dropship Linkage"}),title:"New Dropship Linkage",children:(0,n.jsx)("div",{ref:m,onClick:k.UW,className:"relative",style:{height:"calc(100vh - 120px)"},children:(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"sticky -top-2 z-10 ",children:(0,n.jsx)(N.Z,{className:"mb-4 ",children:(0,n.jsx)(ye,{onSubmit:h})})}),(0,n.jsx)("div",{children:(0,n.jsx)(Ve,{})})]})})})})},Qe=function(){var e=f(),i=e.selectedIds,t=e.setSelectedIds,s=(0,x.useCallback)((function(){t([])}),[t]);
1return(0,n.jsx)(he.D,{rightContent:(0,n.jsxs)("div",{className:"flex flex-wrap items-center",children:[(0,n.jsx)(ve.w,{children:(0,n.jsx)(fe.GW,{withProductVariant:!0,children:(0,n.jsx)(me.M,{children:(0,n.jsx)(De,{})})})}),(0,n.jsx)(Y.Z,{color:"error",onClick:s,sx:{m:2},size:"small",variant:"contained",disabled:!(null===i||void 0===i?void 0:i.length),children:"Clear"})]})})},We=t(45408),Oe=t(57412),Re=t(33342),Fe=t(85214),ze=t(81284),Ae=t(51548),_e=t(91359),Ee=function(e){var i,t=e.row,s=t.productVariants,r=t.createdAt,a=t.isReceived,l=t.isScrapped,o=t.createdBy,d=a||l;return(0,n.jsx)(N.Z,{className:"w-full",children:(0,n.jsxs)(_e.Z,{sx:{p:1.5,"&:last-child":{pb:1.5}},children:[(0,n.jsx)(S.Z,{row:t}),(0,n.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 rounded-lg border border-gray-300 px-3 py-2 dark:border-gray-700",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,n.jsx)(P.Z,{variant:"caption",className:"uppercase tracking-wide",sx:{opacity:.7},children:"Created"}),(0,n.jsx)(Ae.Z,{date:r})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,n.jsx)(P.Z,{variant:"caption",className:"uppercase tracking-wide",sx:{opacity:.7},children:"By"}),(0,n.jsx)(P.Z,{variant:"caption",fontWeight:600,children:d?"System":null!==(i=null===o||void 0===o?void 0:o.userName)&&void 0!==i?i:"\u2014"})]})]}),(0,n.jsx)(G.Z,{sx:{my:1.5}}),(0,n.jsx)(pe,{productVariants:s})]})})},Me=function(e){var i=e.rows;return(0,n.jsx)(Fe.Z,{children:i.map((function(e,i){return(0,n.jsx)(ze.ZP,{sx:(0,Re.g)(i),children:(0,n.jsx)(Ee,{row:e})},e.id)}))})},Ue=function(){var e=f(),i=e.rows,t=e.loading,s=e.page,r=e.setPage,a=e.pageSize,l=e.setPageSize,o=e.totalRows;return t&&!i.length?(0,n.jsx)("div",{className:"flex flex-col gap-2 p-2 pb-20",children:Array.from({length:3}).map((function(e,i){return(0,n.jsx)(Oe.Z,{variant:"rounded",height:180},i)}))}):i.length?(0,n.jsxs)("div",{className:"pb-20",children:[(0,n.jsx)(Me,{rows:i}),(0,n.jsx)(g.Z,{page:s,setPage:r,pageSize:a,setPageSize:l,totalRows:o,rowsPerPageOption:[10,25,50,100]})]}):(0,n.jsx)("div",{className:"pb-20",children:(0,n.jsx)(We.u,{compact:!0,variant:"filtered",title:"No drop ship clients found"})})},Le=function(e){var i=f(),t=i.page,s=i.pageSize,a=i.selectedIds,l=i.setPage,o=i.setPageSize,d=i.setSelectedIds,c=i.rows,u=i.totalRows,p=i.loading,m=(i.filters,i.setFilters),h=((0,x.useCallback)((function(e,i){m((function(t){return(0,j.Z)((0,r.Z)({},t),(0,v.Z)({},e,i))}))}),[m]),(0,x.useCallback)((function(){return"auto"}),[]));return(0,n.jsxs)(b.ZP,{container:!0,spacing:6,children:[(0,n.jsx)(y.Z,{title:(0,n.jsx)("div",{className:"flex items-center justify-between",children:(0,n.jsx)(P.Z,{variant:"h5",children:"Drop Ship Clients"})}),subtitle:(0,n.jsx)(P.Z,{variant:"body2",children:"Find all of your clients with dropship service. "})}),(0,n.jsx)(b.ZP,{item:!0,xs:12,children:(0,n.jsx)(b.ZP,{container:!0,spacing:6,children:(0,n.jsxs)(b.ZP,{item:!0,xs:12,children:[(0,n.jsx)(N.Z,{className:"mb-4"}),w.tq?(0,n.jsx)(Ue,{}):(0,n.jsx)(N.Z,{children:(0,n.jsx)(Z.s,{pagination:!0,page:t,pageSize:s,rowCount:u,rows:c,columns:xe,loading:p,paginationMode:"server",onPageSizeChange:o,onPageChange:l,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,autoHeight:!0,getRowHeight:h,initialState:{pinnedColumns:{right:["actions"]}},disableSelectionOnClick:!0,checkboxSelection:!1,keepNonExistentRowsSelected:!0,onSelectionModelChange:function(e){d(e)},selectionModel:a,components:{Toolbar:Qe,Pagination:g.Z},componentsProps:{pagination:{page:t,setPage:l,pageSize:s,setPageSize:o,totalRows:u}}})})]})})})]})},He=function(){return(0,n.jsx)(h,{children:(0,n.jsx)(Le,{})})}}},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,874,9774,2888,179],(function(){return i=66505,e(e.s=i);var i}));var i=e.O();_N_E=i}]);
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.