PageSourceSearch

https://bro-depot.com/_next/static/chunks/pages/apps/eplatform/system-items-2f825ea563935961.js

js bro-depot.com collected 2026-10-04 02:38:36 UTC 83,908 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[631],{92265:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/apps/eplatform/system-items",function(){return n(44558)}])},61778:function(e,t,n){"use strict";var i=n(26042),l=n(85893),r=n(54275),s=n(30120),a=n(54225),o=n(13264),d=n(15734),c=n(96486),u=n(67294),m=(0,o.Z)(s.Z)((function(e){var t=e.theme;return{width:"100%",backgroundColor:t.palette.primary.main,opacity:"100%",borderTopLeftRadius:t.shape.borderRadius,borderTopRightRadius:t.shape.borderRadius}})),x=(0,o.Z)(a.Z)((function(e){var t=e.theme,n=e.color,i=e.variant;return{height:"100%",backgroundColor:"contained"===i?t.palette.background.paper:t.palette["".concat(n)].main,color:"contained"===i?t.palette["".concat(n)].main:t.palette["".concat(n)].contrastText,borderColor:t.palette["".concat(n)].main,textTransform:"none",fontWeight:600,fontSize:"0.8125rem",letterSpacing:0,transition:"background-color 200ms ease, color 200ms ease, box-shadow 200ms ease",minWidth:"10rem",borderTopLeftRadius:t.shape.borderRadius,borderTopRightRadius:t.shape.borderRadius,borderBottomRightRadius:0,borderBottomLeftRadius:0,"&:hover":"contained"===i?{backgroundColor:t.palette.background.paper,color:t.palette["".concat(n)].main}:{backgroundColor:"".concat(t.palette["".concat(n)].dark," !important"),color:"".concat(t.palette["".concat(n)].light," !important")}}})),h={enter:{y:"25%"},exit:{y:"10%"}};t.ZP=function(e){var t=e.filters,n=e.setFilters,s=e.optionList,a=e.handleClear,o=e.className,f=void 0===o?"":o,v=e.expandOnHover,p=void 0===v||v,j=(0,u.useState)(!p),g=j[0],Z=j[1];return(0,l.jsx)("div",{className:"z-0 ".concat(f),onMouseEnter:p?function(){Z(!0)}:void 0,onMouseLeave:p?function(){return Z(!1)}:void 0,children:(0,l.jsx)(d.E.div,{animate:g?"exit":"enter",variants:h,children:(0,l.jsx)(m,{children:(0,l.jsx)("div",{className:"flex flex-row p-1 pb-0",children:s.map((function(e,s){var o=e.label,d=e.count,u=e.onClick,m=e.conditions,h=function(e){var n=(0,c.pick)(t,Object.keys(e));return(0,c.isEqual)(e,n)}(m);return(0,l.jsxs)(x,{variant:h?"contained":"outlined",color:"primary",onClick:function(){h&&a?a():u?u():n((function(e){return(0,i.Z)({},e,m)}))},children:[o," ",(0,l.jsx)(r.Z,{className:"ml-1",count:d})]},s)}))})})})})}},44558:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return In}});var i,l=n(85893),r=n(82126),s=n(14924),a=n(26042),o=n(69396),d=n(97260),c=n(45408),u=n(61283),m=n(94062),x=n(47018),h=n(4451),f=n(23837),v=n(79072),p=n(29630),j=n(54225),g=n(49837),Z=n(70754),b=n(25836),_=n(67294),P=n(85518),y=n(50922),S=n(47568),N=n(828),C=n(70655),I=n(2417),w=n(54474),k=n(79724),D=n(53273),A=n(87811),B=n(96277),V=n(18377),E=n(15734),M=n(96486),z=n(43085),W=n(81719),T=n(17575),O=n(43963),L=n(45135),R=n(37106),F=(0,W.ZP)(j.Z)((function(e){e.theme;return{root:{"&.Mui-disabled":{pointerEvents:"auto"}},"&.Mui-disabled":{cursor:"not-allowed"}}})),U=function(e){var t=e.ePlatformItemIds,n=e.buttonLabel,i=void 0===n?"Bump":n,r=e.onSuccess,s=(0,_.useState)(null),a=s[0],o=s[1],d=(0,_.useState)(void 0),c=(d[0],d[1],function(){o(null)}),u=Boolean(a),m=u?"bump-shopee-items-popover":void 0,x=(0,N.Z)((0,B.Qw2)({variables:{ePlatformItemIds:t}}),2),h=x[0],f=x[1].loading,v=(0,N.Z)((0,B.Ih$)({variables:{ePlatformItemIds:t}}),2),p=v[0],g=v[1],Z=g.loading,b=g.client,P=(0,N.Z)((0,B.Dgd)({variables:{ePlatformItemIds:t}}),2),y=P[0],I=P[1].loading,w=function(){var e=(0,S.Z)((function(){var e,t,n,i;return(0,C.__generator)(this,(function(l){switch(l.label){case 0:return[4,h()];case 1:return(null===(e=l.sent().data)||void 0===e?void 0:e.bumpShopeeItems)&&(t=e.bumpShopeeItems,n=t.success,i=t.errorMessage,(null===n||void 0===n?void 0:n.length)&&((0,z.x9)("Successfully bumped ".concat(n.length," items")),c(),null===r||void 0===r||r()),(null===i||void 0===i?void 0:i.length)&&((0,z._N)("Failed to bump ".concat(i.length," items")),i.forEach((function(e){(0,z._N)(e)})))),[2]}}))}));return function(){return e.apply(this,arguments)}}(),k=Z||I||f,D=function(){var e=(0,S.Z)((function(e){var t,n,i,l;return(0,C.__generator)(this,(function(r){switch(r.label){case 0:return e?[4,y()]:[3,2];case 1:return(null===(t=r.sent().data)||void 0===t?void 0:t.shopeeBulkEnableAutoBump.length)&&(n=null===t||void 0===t?void 0:t.shopeeBulkEnableAutoBump,(0,z.x9)("Successfully enable auto bump ".concat(n.length," items")),c(),b.cache.evict({fieldName:"allEPlatformItems"})),[3,4];case 2:return[4,p()];case 3:(null===(i=r.sent().data)||void 0===i?void 0:i.shopeeBulkDisableAutoBump.length)&&(l=null===i||void 0===i?void 0:i.shopeeBulkDisableAutoBump,(0,z.x9)("Successfully disable auto bump for ".concat(l.length," items")),c(),b.cache.evict({fieldName:"allEPlatformItems"})),r.label=4;case 4:return[2]}}
1))}));return function(t){return e.apply(this,arguments)}}();return(0,l.jsxs)("div",{children:[(0,l.jsx)(T.Z,{title:"Bump Shopee Items",placement:"top",children:(0,l.jsx)("div",{children:(0,l.jsxs)(F,{onClick:function(e){o(e.currentTarget)},color:"primary",variant:"outlined",sx:{textDecoration:"none",mr:.5,mb:"0.5rem"},disabled:0===t.length,children:[(0,l.jsx)(R.UdJ,{className:"mr-2 text-2xl"})," ",(0,l.jsx)("span",{className:"text-sm",children:i})]})})}),(0,l.jsx)(O.ZP,{id:m,open:u,anchorEl:a,onClose:c,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,l.jsxs)("div",{className:"mx-5 my-2",children:[(0,l.jsx)("div",{className:"flex items-center gap-2",children:(0,l.jsx)(L.Z,{severity:"info",className:"w-full",children:(0,l.jsx)("span",{children:(0,l.jsxs)("span",{className:"text-sm",children:[(0,l.jsx)("span",{className:"font-bold",children:"Bump"})," your items to keep them on top of the search results.",(0,l.jsx)("br",{}),(0,l.jsx)("span",{className:"font-bold",children:"Auto Bump"})," will automatically bump your items periodically.",(0,l.jsx)("br",{}),(0,l.jsx)("span",{className:"font-bold",children:"Bump Now"})," will bump your items once."]})})})}),(0,l.jsxs)("div",{className:"mt-5 flex flex-col justify-end gap-2",children:[(0,l.jsxs)("div",{className:"mb-2 flex flex-row items-center gap-2",children:[(0,l.jsx)(j.Z,{color:"success",variant:"outlined",onClick:function(){return D(!0)},disabled:k,fullWidth:!0,children:"Enable Auto Bump"}),(0,l.jsx)(j.Z,{color:"secondary",variant:"outlined",onClick:function(){return D(!1)},disabled:k,fullWidth:!0,children:"Disable Auto Bump"})]}),(0,l.jsx)(j.Z,{color:"primary",variant:"contained",onClick:w,disabled:k,children:"Bump Now (one-time only)"})]})]})})]})},q=(0,_.createContext)(void 0);!function(e){e.LIST="list",e.CREATE="create",e.ADD_ITEM="add_item",e.VIEW_ITEM="view_item"}(i||(i={}));var H=function(e){var t,n,r,s=e.children,a=e.ePlatformStoreId,o=(0,_.useState)(i.LIST),d=o[0],c=o[1],u=(0,_.useState)(),m=u[0],x=u[1],h=null===(t=(0,B.pct)({variables:{filter:{id:a},page:0,perPage:1}}).data)||void 0===t||null===(n=t.allEPlatformStores)||void 0===n||null===(r=n.ePlatformStores)||void 0===r?void 0:r[0],f=(0,_.useMemo)((function(){return{mode:d,setMode:c,eplatformStore:h,bundleDealId:m,setBundleDealId:x}}),[d,h,m]);return(0,l.jsx)(q.Provider,{value:f,children:s})},J=function(){var e=(0,_.useContext)(q);if(void 0===e)throw new Error("useShopeeBundle can only be used inside ShopeeBundleProvider");return e},X=n(45209),G=n(89479),Y=function(e){var t=e.row,n=J(),i=n.eplatformStore,r=n.bundleDealId,s=(0,N.Z)((0,B.dVG)(),2),a=s[0],o=s[1],d=(o.loading,o.client),c=function(){var e=(0,S.Z)((function(){var e;return(0,C.__generator)(this,(function(n){switch(n.label){case 0:return(null===i||void 0===i?void 0:i.id)?r?[4,a({variables:{ePlatformStoreId:i.id,shopeeAddBundleItemDto:{bundle_deal_id:r,item_list:[{ePlatformItemId:t.id,status:1}]}}})]:((0,z._N)("Please select a bundle deal first"),[2]):((0,z._N)("Please select a store first"),[2]);case 1:return(null===(e=n.sent().data)||void 0===e?void 0:e.shopeeAddBundleItems.length)?((0,z.x9)("Item has been added to bundle"),d.cache.evict({fieldName:"getShopeeBundleItemList"})):0===(null===e||void 0===e?void 0:e.shopeeAddBundleItems.length)&&(0,z._N)("Something went wrong"),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,l.jsx)("div",{onClick:G.UW,className:"flex flex-wrap",children:(0,l.jsx)(j.Z,{variant:"contained",size:"small",onClick:c,children:"Add to Bundle"})})};var K=function(e){var t,n=e.ePlatformStoreId,r=J().setMode,s=(0,_.useState)([]),a=s[0],o=s[1],d=(0,_.useState)({platform:B.NX6.Shopee,ePlatformStoreId:n}),c=d[0],u=(d[1],(0,_.useState)(0)),h=u[0],f=u[1],Z=(0,_.useState)(10),P=Z[0],S=Z[1],N=(0,_.useCallback)((function(){return"auto"}),[]),C=(0,B.c8j)({variables:{filter:c,page:h,perPage:P,sortField:"createdAt",sortOrder:B.Asd.Desc}}),I=C.data,w=C.loading,k=(0,_.useMemo)((function(){var e={headerName:"Actions",field:"actions",minWidth:200,renderCell:function(e){var t=e.row;return(0,l.jsx)(Y,{row:t})}};return y.P.map((function(t){return"actions"===t.field?e:t}))}),[]),D=(null===I||void 0===I?void 0:I.allEPlatformItems.ePlatformItems)||[],V=null!==(t=null===I||void 0===I?void 0:I.allEPlatformItems.total)&&void 0!==t?t:0;return(0,l.jsxs)(v.ZP,{container:!0,spacing:6,children:[(0,l.jsx)(x.Z,{title:(0,l.jsxs)("div",{className:"flex items-center justify-between px-2 pb-2 pt-3",children:[(0,l.jsx)(p.Z,{variant:"h6",children:"Add items into Bundle Deal"}),(0,l.jsxs)("div",{className:"mb-2 flex justify-end gap-5",children:[(0,l.jsxs)(j.Z,{onClick:function(){r(i.LIST)},children:[(0,l.jsx)(A.qg,{className:"mr-2"})," Back to List"]}),(0,l.jsxs)(j.Z,{onClick:function(){r(i.VIEW_ITEM)},variant:"outlined",children:[(0,l.jsx)(A.qg,{className:"mr-2"})," Back to Items"]})]})]})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,children:(0,l.jsx)(v.ZP,{container:!0,spacing:6,children:(0,l.jsx)(v.ZP,{item:!0,xs:12,children:(0,l.jsx)(g.Z,{children:(0,l.jsx)("div",{className:"flex h-full w-full",children:(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(b.s,{pagination:!0,page:h,pageSize:P,rowCount:V,rows:D,columns:k,loading:w,paginationMode:"server",onPageSizeChange:S,onPageChange:f,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,getRowHeight:N,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},checkboxSelection:!1,disableSelectionOnClick:!0,keepNonExistentRowsSelected:!1,onSelectionModelChange:function(e){o(e)},selectionModel:a,components:{Pagination:m.Z},componentsProps:{pagination:{page:h,setPage:f,pageSize:P,setPageSize:S,totalRows:V}}})})})})})})})]})},$=n(20986),Q=n(12508),ee=n(31753),te=n(23378),ne=n(62554);var ie=function(e){var t=e.itemId,n=(0,_.useState)(null),i=n[0],r=n[1],s=Boolean(i),a=s?"delete-bundle-deal-popover":void 0,o=J(),d=o.bundleDealId,c=o.eplatformStore,u=(0,N.Z)((0,B.veG)({variables:{ePlatformStoreId:(null===c||void 0===c?void 0:c.id)||"",shopeeDeleteBundleItemDto:{bundle_deal_id:d||0,item_id_list:[t]}}}),2),m=u[0],x=u[1],h=x.loading,f=x.client,v=function(){var e=(0,S.Z)((function(){var e,t;return(0,C.__generator)(this,(function(n){switch(n.label){case 0:return[4,m()];case 1:return t=n.sent(),(null===(e=t.data)||void 0===e?void 0:e.shopeeDeleteBundleItems)&&((0,z.x9)("Bundle Item has been removed"),f.cache.evict({fieldName:"getShopeeBundleItemList"})),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,l.jsxs)("div",{children:[(0,l.jsx)(ne.Z,{title:"Remove Item from Bundle Deal",iconButtonProps:{color:"error",onClick:function(e){r(e.currentTarget)}},children:(0,l.jsx)($.pJ,{className:"text-red-500"})}),(0,l.jsx)(O.ZP,{id:a,open:s,anchorEl:i,onClose:function(){r(null)},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,l.jsxs)("div",{className:"mx-5 my-2",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-red-500",children:(0,l.jsx)($.zM,{})}),(0,l.jsx)("span",{children:"Are you sure? "})]}),(0,l.jsx)("div",{className:"mt-1 flex justify-end",children:(0,l.jsx)(j.Z,{color:"error",onClick:v,disabled:h,children:"Remove"})})]})})]})},le=[{headerName:"Item Name",field:"name",flex:2,minWidth:240,renderCell:function(e){var t=e.row,n=t.itemId,i=t.itemName,r=t.itemUrl;return(0,l.jsxs)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:[(0,l.jsx)("strong",{onClick:G.UW,children:(0,l.jsx)(T.Z,{title:"View Product",children:(0,l.jsxs)("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-gray-700 hover:text-black hover:underline dark:text-gray-200 dark:hover:text-gray-500",children:[i," ",(0,l.jsx)(Q.h0,{})]})})}),(0,l.jsxs)("div",{className:"text-2xs text-slate-400",children:["ID: ",n]})]})}},{headerName:"Images",field:"images",flex:2,minWidth:200,renderCell:function(e){var t=e.row.images;return(0,l.jsx)("div",{className:"flex w-full flex-col gap-y-1 divide-y divide-slate-400/50",onClick:G.UW,children:(0,l.jsx)(ee.ZP,{imgArray:t.map((function(e){return{content:e,thumbnail:e,type:B.Tv5.Image}})),numOfImages:8})})}},{headerName:"Status",field:"status",flex:1,minWidth:100,renderCell:function(e){var t=e.row.status;return(0,l.jsx)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:(0,l.jsx)("div",{children:(0,l.jsx)(te.Z,{size:"small",label:t,color:"Enable"===t?"success":"secondary"})})})}},{headerName:"Actions",field:"actions",minWidth:100,renderCell:function(e){var t=e.row;return(0,l.jsx)("div",{className:"flex w-full items-center justify-center",children:(0,l.jsx)(ie,{itemId:t.itemId})})}}];var re=function(e){var t=e.bundle_deal_id,n=e.ePlatformStoreId,r=J(),s=r.setMode,a=r.setBundleDealId,o=(0,B.eod)({variables:{bundle_deal_id:t,ePlatformStoreId:n}}),d=o.data,c=o.loading,u=(null===d||void 0===d?void 0:d.getShopeeBundleItemList.item_list)||[],m=null===d||void 0===d?void 0:d.getShopeeBundleItemList.total_count,x=(0,_.useCallback)((function(){return"auto"}),[]),h=(0,_.useCallback)((function(){return(0,l.jsx)(se,{totalCount:m})}),[m]);return(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"mb-2 flex justify-end gap-5",children:[(0,l.jsx)("div",{className:"flex items-center justify-start",children:(0,l.jsxs)(j.Z,{onClick:function(){s(i.ADD_ITEM)},variant:"contained",children:[(0,l.jsx)($.dt,{className:"mr-2"}),"Item to Bundle Deal"]})}),(0,l.jsxs)(j.Z,{onClick:function(){s(i.LIST),a(void 0)},variant:"outlined",children:[(0,l.jsx)(A.qg,{className:"mr-2"})," Back to List"]})]}),(0,l.jsx)("div",{children:(0,l.jsx)("div",{className:"flex h-full w-full",children:(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(b.s,{pagination:!0,pageSize:100,rowCount:m,rows:u,columns:le,loading:c,paginationMode:"client",rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,getRowHeight:x,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},disableSelectionOnClick:!0,components:{Pagination:h}})})})})]})},se=function(e){var t=e.totalCount;return(0,l.jsxs)("div",{className:"",children:["Total : ",t]})},ae=n(29815),oe=n(8089),de=n(44656),ce=n(89886),ue=n(1427),me=n(76366),xe=n(47533),he=n(44373),fe=n(30120),ve=n(87536),pe=function(e){e.defaultValues;
1var t=e.index,n=e.rule_type,i=e.field,r=e.remove,s=(0,ve.Gc)(),a=s.control,o=(s.trigger,s.clearErrors,s.getValues),d=J().eplatformStore,c=null===d||void 0===d?void 0:d.currency,u=((0,ve.cl)({control:a}).errors,"additional_tiers[".concat(t,"]"));return(0,l.jsxs)("div",{className:"flex items-center gap-40 py-5",children:[(0,l.jsxs)("div",{children:["Tier #",t+1]}),(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{children:"Buy"}),(0,l.jsx)("div",{children:(0,l.jsx)(de.Z,{name:"".concat(u,".min_amount"),label:"",defaultValue:i.min_amount,textFieldProps:{className:"w-20"}})}),(0,l.jsx)("div",{hidden:1===n,children:"items & get"}),(0,l.jsx)("div",{hidden:1!==n,children:"items at a Bundle Price of"}),(0,l.jsx)("div",{hidden:1!==n,children:(0,l.jsx)(de.Z,{name:"".concat(u,".fix_price"),label:"",defaultValue:i.fix_price||100,textFieldProps:{className:"w-40",InputProps:{startAdornment:(0,l.jsx)("div",{className:"w-28 text-slate-400",children:c})}}})}),(0,l.jsx)("div",{hidden:2!==n,children:(0,l.jsx)(de.Z,{name:"".concat(u,".discount_percentage"),label:"",defaultValue:i.discount_percentage||5,textFieldProps:{className:"w-40",InputProps:{endAdornment:(0,l.jsx)("div",{className:"w-24 text-slate-400",children:"% OFF"})}}})}),(0,l.jsx)("div",{hidden:3!==n,children:(0,l.jsx)(de.Z,{name:"".concat(u,".discount_value"),label:"",defaultValue:i.discount_value||1,textFieldProps:{className:"w-56",InputProps:{startAdornment:(0,l.jsx)("div",{className:"w-28 text-slate-400",children:c}),endAdornment:(0,l.jsx)("div",{className:"w-24 text-slate-400",children:"OFF"})}}})})]}),(0,l.jsx)("div",{children:(0,l.jsx)(ne.Z,{title:"Delete Tier",iconButtonProps:{color:"error",onClick:function(){var e=o().additional_tiers;(0,M.isNil)(e)||(e.length<=1?(0,z._N)("You must have at least 1 tier"):r(t))}},children:(0,l.jsx)($.pJ,{className:"text-red-500"})})})]})};var je=function(e){var t=e.defaultValues,n=(0,ve.Gc)(),i=n.control,r=(n.trigger,n.clearErrors,n.getValues),s=(0,ve.Dq)({control:i,name:"additional_tiers",keyName:"uid"}),a=s.fields,o=s.remove,d=s.append,c=(0,ve.qo)({control:i,name:"rule_type"}),u=+(null!==c&&void 0!==c?c:1),m=(0,ve.cl)({control:i}).errors;return(0,l.jsxs)("div",{className:"divide-y divide-slate-400/50 rounded-md border border-slate-400/50 px-5",children:[a.map((function(e,n){return(0,l.jsx)("div",{children:(0,l.jsx)(pe,{index:n,rule_type:u,defaultValues:t,remove:o,field:e})},e.uid)})),(0,l.jsx)("div",{className:"py-5",children:(0,l.jsxs)(j.Z,{onClick:function(){var e=r().additional_tiers;if(!(0,M.isNil)(e))if(e.length>=3)(0,z._N)("You can only have up to 3 tiers");else{0===e.length&&d({min_amount:2,discount_percentage:5,discount_value:1,fix_price:1});var t=e[e.length-1];if(!(0,M.isNil)(t))if(t.min_amount)if(1!==u||t.fix_price)if(2!==u||t.discount_percentage)if(3!==u||t.discount_value){var n,i=null!==(n=+t.min_amount)&&void 0!==n?n:2;if(1===u){var l,s=+(null!==(l=t.fix_price)&&void 0!==l?l:1),a=i+1;d({min_amount:a,fix_price:.9*(s/i)*a})}else if(2===u){var o;d({min_amount:i+1,discount_percentage:+(null!==(o=t.discount_percentage)&&void 0!==o?o:0)+1})}else if(3===u){var c;d({min_amount:i+1,discount_value:+(null!==(c=t.discount_value)&&void 0!==c?c:0)+1})}}else(0,z._N)("Please enter discount amount");else(0,z._N)("Please enter discount percentage");else(0,z._N)("Please enter bundle price above");else(0,z._N)("Please enter min amount")}},variant:"outlined",children:[(0,l.jsx)($.dt,{})," Add Tier"]})}),(0,l.jsx)("pre",{children:JSON.stringify(m,null,2)})]})},ge=n(77349),Ze=n(11640),be=n(83894),_e=n(69119),Pe=n(74231),ye=Pe.Ry().shape({name:Pe.Z_().required(),purchase_limit:Pe.Rx().required(),rule_type:Pe.Rx().required(),start_time:Pe.hT().required(),end_time:Pe.hT().required(),min_amount:Pe.Rx().required(),fix_price:Pe.Rx(),discount_value:Pe.Rx(),discount_percentage:Pe.Rx(),additional_tiers:Pe.IX().of(Pe.Ry().shape({min_amount:Pe.Rx().required().min(2,"Please enter a greater amount (>=2)"),fix_price:Pe.Rx(),discount_value:Pe.Rx(),discount_percentage:Pe.Rx()}))}),Se={name:"Bundle Deal",purchase_limit:10,rule_type:2,start_time:(0,_e.default)((0,ge.default)(new Date,1)),end_time:(0,be.default)((0,Ze.default)((0,ge.default)(new Date,1),1)),min_amount:0,fix_price:0,discount_value:0,discount_percentage:0,additional_tiers:[{min_amount:2,discount_percentage:5,discount_value:1,fix_price:100}]};var Ne=function(e){var t=e.ePlatformStoreId,n=J(),r=(n.mode,n.setMode),s=(0,N.Z)((0,B.wZy)(),2),a=s[0],o=s[1],d=o.loading,c=o.client,u=Se,m=(0,ve.cI)({defaultValues:u,resolver:(0,xe.X)(ye)}),x=m.reset,h=m.handleSubmit,f=m.setError,p=function(){r(i.LIST)},g=function(){var e=(0,S.Z)((function(e){var n,i,l,r,s,o,d,u,m,h,v,j,g,Z,b;return(0,C.__generator)(this,(function(_){switch(_.label){case 0:return t?(i=+(null!==(n=e.rule_type)&&void 0!==n?n:1),r=2,e.additional_tiers&&(u=e.additional_tiers[0],r=+(null!==(m=null===u||void 0===u?void 0:u.min_amount)&&void 0!==m?m:2),1===i&&(s=+(null!==(h=null===u||void 0===u?void 0:u.fix_price)&&void 0!==h?h:0)),2===i&&(o=+(null!==(v=null===u||void 0===u?void 0:u.discount_percentage)&&void 0!==v?v:0)),3===i&&(d=+(null!==(j=null===u||void 0===u?void 0:u.discount_value)&&void 0!==j?j:0)),g=e.additional_tiers.slice(1),l=g.map((function(e){var t,n,l,r;return{min_amount:+(null!==(t=null===e||void 0===e?void 0:e.min_amount)&&void 0!==t?t:0),fix_price:1===i?+(null!==(n=null===e||void 0===e?void 0:e.fix_price)&&void 0!==n?n:0):void 0,discount_percentage:2===i?+(null!==(l=null===e||void 0===e?void 0:e.discount_percentage)&&void 0!==l?l:0):void 0,discount_value:3===i?+(null!==(r=null===e||void 0===e?void 0:e.discount_value)&&void 0!==r?r:0):void 0}}))),Z=function(e,t,n){if(!e)return!0;var i=!1;return e.forEach((function(l,r){if(2===t){var s,a=null===l||void 0===l?void 0:l.discount_percentage;0===r&&a<=0&&(n("additional_tiers.".concat(r,".discount_percentage"),{message:"Must be greater than 0",type:"manual"}),i=!0);var o=null===(s=e[r-1])||void 0===s?void 0:s.discount_percentage;o>=a&&(n("additional_tiers.".concat(r,".discount_percentage"),{message:"Must be greater than ".concat(o),type:"manual"}),i=!0)}if(3===t){var d,c=null===l||void 0===l?void 0:l.discount_value;if(0===r)return void(c<=0&&(n("additional_tiers.".concat(r,".discount_value"),{message:"Must be greater than 0",type:"manual"}),i=!0));var u=null===(d=e[r-1])||void 0===d?void 0:d.discount_value;u>=c&&(n("additional_tiers.".concat(r,".discount_value"),{message:"Must be greater than ".concat(u),type:"manual"}),i=!0)}if(1===t){var m=null===l||void 0===l?void 0:l.fix_price;if(0===r&&m<=0&&(n("additional_tiers.".concat(r,".fix_price"),{message:"Must be greater than 0",type:"manual"}),i=!0),r>0){var x,h,f=null===(x=e[r-1])||void 0===x?void 0:x.fix_price,v=null===(h=e[r-1])||void 0===h?void 0:h.min_amount,p=(null===l||void 0===l?void 0:l.min_amount)*(f/v);m>=p&&(n("additional_tiers.".concat(r,".fix_price"),{message:"Must be lower than ".concat(p),type:"manual"}),i=!0)}}})),i}([{fix_price:s,min_amount:r,discount_percentage:o,discount_value:d}].concat((0,ae.Z)(null!==l&&void 0!==l?l:[])),i,f),Z?[2]:[4,a({variables:{ePlatformStoreId:t,shopeeAddBundleDto:{start_time:e.start_time,end_time:e.end_time,name:e.name,purchase_limit:e.purchase_limit,rule_type:e.rule_type,min_amount:r,fix_price:s,discount_percentage:o,discount_value:d,additional_tiers:l}}})]):((0,z._N)("ePlatformStoreId is missing"),[2]);case 1:return(null===(b=_.sent().data)||void 0===b?void 0:b.shopeeAddBundleDeal)&&((0,z.x9)("Bundle deal added"),x(),c.cache.evict({fieldName:"getShopeeBundleList"}),p()),[2]}}))}));return function(t){return e.apply(this,arguments)}}();return t?(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"flex justify-end",children:(0,l.jsxs)(j.Z,{onClick:p,variant:"outlined",children:[(0,l.jsx)(A.qg,{className:"mr-2"})," Back to List"]})}),(0,l.jsx)("div",{className:"p-5",children:(0,l.jsxs)(me.e,{methods:m,onSubmit:h(g),defaultValues:u,children:[(0,l.jsxs)(v.ZP,{container:!0,spacing:6,children:[(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,children:(0,l.jsx)(ue.Z,{name:"name",textFieldProps:{placeholder:"Enter Bundle Deal Name"},defaultValues:u})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:3,children:(0,l.jsx)(oe.Z,{textFieldProps:{size:"small"},name:"start_time",defaultValues:u,reactDatePickerProps:{isClearable:!1}})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:3,children:(0,l.jsx)(oe.Z,{textFieldProps:{size:"small"},name:"end_time",defaultValues:u,reactDatePickerProps:{isClearable:!1}})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:12,children:(0,l.jsx)(ce.Z,{name:"rule_type",options:[{value:"1",label:"Fix Price"},{value:"2",label:"Discount Percentage"},{value:"3",label:"Discount Amount"}],defaultValues:u})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:12,children:(0,l.jsx)(je,{defaultValues:u})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:3,children:(0,l.jsx)(de.Z,{name:"purchase_limit",label:"Purchase Limit",defaultValues:u})})]}),(0,l.jsx)(he.Z,{sx:{my:5}}),(0,l.jsxs)(fe.Z,{sx:{display:"flex",alignItems:"center"},children:[(0,l.jsxs)(j.Z,{disabled:d,className:"flex gap-2",size:"large",type:"submit",variant:"contained",sx:{mr:3},children:[d&&(0,l.jsx)($.Ho,{className:"animate-spin"}
1),(0,l.jsx)("div",{children:"Create new Bundle Deal"})]}),(0,l.jsx)(j.Z,{onClick:p,size:"large",variant:"outlined",color:"secondary",children:"Cancel"})]})]})})]}):(0,l.jsx)("div",{children:"Missing Store ID"})},Ce=n(3021),Ie=n(67062);var we=function(e){var t=e.bundle_deal_id,n=J(),r=n.setMode,s=n.setBundleDealId;return(0,l.jsx)("div",{className:"flex items-center gap-2",children:(0,l.jsx)(ne.Z,{title:"Add Bundle Items",iconButtonProps:{color:"primary",onClick:function(){s(t),r(i.ADD_ITEM)}},children:(0,l.jsx)($.dt,{className:"text-primary"})})})},ke=n(19248);var De=function(e){var t=e.bundle_deal_id,n=J(),r=n.setMode,s=n.setBundleDealId;return(0,l.jsx)("div",{className:"flex items-center gap-2",children:(0,l.jsx)(ne.Z,{title:"View Bundle Items",iconButtonProps:{color:"primary",onClick:function(){s(t),r(i.VIEW_ITEM)}},children:(0,l.jsx)(ke.Z_,{className:"text-primary"})})})};var Ae=function(e){var t=e.bundle_deal_id,n=e.ePlatformStoreId,i=(0,_.useState)(null),r=i[0],s=i[1],a=Boolean(r),o=a?"delete-bundle-deal-popover":void 0,d=(0,N.Z)((0,B.oU3)({variables:{bundle_deal_id:t,ePlatformStoreId:n}}),2),c=d[0],u=d[1],m=u.loading,x=u.client,h=function(){var e=(0,S.Z)((function(){var e,t;return(0,C.__generator)(this,(function(n){switch(n.label){case 0:return[4,c()];case 1:return t=n.sent(),(null===(e=t.data)||void 0===e?void 0:e.shopeeDeleteBundleDeal)&&((0,z.x9)("Bundle Deal has been deleted"),x.cache.evict({fieldName:"getShopeeBundleList"})),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,l.jsxs)("div",{children:[(0,l.jsx)(ne.Z,{title:"Delete Bundle Deal",iconButtonProps:{color:"error",onClick:function(e){s(e.currentTarget)}},children:(0,l.jsx)($.pJ,{className:"text-red-500"})}),(0,l.jsx)(O.ZP,{id:o,open:a,anchorEl:r,onClose:function(){s(null)},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,l.jsxs)("div",{className:"mx-5 my-2",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-red-500",children:(0,l.jsx)($.zM,{})}),(0,l.jsx)("span",{children:"Are you sure? "})]}),(0,l.jsx)("div",{className:"mt-1 flex justify-end",children:(0,l.jsx)(j.Z,{color:"error",onClick:h,disabled:m,children:"Delete Bundle"})})]})})]})};var Be=function(e){var t=e.row.bundle_deal_id,n=J().eplatformStore,i=null===n||void 0===n?void 0:n.id;return(0,l.jsx)("div",{className:"flex flex-wrap items-center gap-1",onClick:G.UW,children:!!i&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(De,{bundle_deal_id:t}),(0,l.jsx)(we,{bundle_deal_id:t}),(0,l.jsx)(Ae,{bundle_deal_id:t,ePlatformStoreId:i})]})})},Ve={Upcoming:"warning",Ongoing:"success",Expired:"error",Unknown:"info"},Ee=[{headerName:"Promotion Name",field:"name",flex:1,minWidth:140,renderCell:function(e){var t=e.row,n=t.name,i=t.bundle_deal_id;return(0,l.jsxs)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:[(0,l.jsx)("div",{children:n}),(0,l.jsx)("div",{className:"text-2xs text-slate-400",children:i})]})}},{headerName:"Bundle Type",field:"bundle_deal_rule",flex:2,minWidth:200,renderCell:function(e){var t=e.row.bundle_deal_rule,n=t.rule_type,i=t.discount_percentage,r=t.discount_value,s=t.min_amount,a=t.fix_price,o=t.additional_tiers,d="";return 1===n?d="Buy ".concat(s," items at a Bundle Price of ").concat(a.toFixed(2)):2===n?d="Buy ".concat(s," items, get ").concat(i,"% off"):3===n&&(d="Buy ".concat(s," items, get ").concat(r.toFixed(2)," off")),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-y-1 divide-y divide-slate-400/50",onClick:G.UW,children:[(0,l.jsx)("div",{className:"py-1",children:d}),null===o||void 0===o?void 0:o.map((function(e,t){var i=e.discount_percentage,r=e.discount_value,s=e.fix_price,a=e.min_amount,o="";return 1===n?o="Buy ".concat(a," items at a Bundle Price of ").concat(s.toFixed(2)):2===n?o="Buy ".concat(a," items, get ").concat(i,"% off"):3===n&&(o="Buy ".concat(a," items, get ").concat(r.toFixed(2)," off")),(0,l.jsx)("div",{className:"py-1",children:o},t)}))]})}},{headerName:"Status",field:"start_time",flex:1,minWidth:100,renderCell:function(e){var t,n=e.row,i=n.end_time,r=n.start_time,s=new Date(1e3*r),a=new Date(1e3*i),o=new Date;return t=o<s?"Upcoming":o>s&&o<a?"Ongoing":o>a?"Expired":"Unknown",(0,l.jsx)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:(0,l.jsx)("div",{children:(0,l.jsx)(te.Z,{size:"small",label:t,color:Ve[t]})})})}},{headerName:"Period",field:"end_time",flex:1,minWidth:140,renderCell:function(e){var t=e.row,n=t.end_time,i=t.start_time,r=new Date(1e3*i),s=new Date(1e3*n);return(0,l.jsxs)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:[(0,l.jsxs)("div",{children:[(0,Ie.o0)(r,"yyyy-MM-dd HH:mm")," - "]}),(0,l.jsx)("div",{children:(0,Ie.o0)(s,"yyyy-MM-dd HH:mm")}
1)]})}},{headerName:"Actions",field:"actions",minWidth:140,renderCell:function(e){var t=e.row;return(0,l.jsx)(Be,{row:t})}}];var Me=function(e){var t,n=e.ePlatformStoreId,r=J().setMode,s=(0,_.useState)(1),a=s[0],o=s[1],d=(0,_.useState)(10),c=d[0],u=d[1],m=(0,_.useState)(1),x=m[0],h=m[1],f=(0,B.AOp)({variables:{ePlatformStoreId:n,page_no:a,page_size:c,time_status:1},onCompleted:function(e){(null===e||void 0===e?void 0:e.getShopeeBundleList.more)&&h((function(e){return Math.max(e,a+1)}))}}),v=f.data,p=f.loading,g=(null===v||void 0===v||null===(t=v.getShopeeBundleList)||void 0===t?void 0:t.bundle_deal_list)||[],Z=x*c,P=(0,_.useCallback)((function(){return"auto"}),[]),y=(0,_.useCallback)((function(){return(0,l.jsx)("div",{className:"my-5 flex justify-center",children:(0,l.jsx)(Ce.Z,{count:x,page:a,onChange:function(e,t){o(t)},variant:"outlined",color:"primary"})})}),[o,a,x]);return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-5 mt-2 flex items-center justify-end",children:(0,l.jsxs)(j.Z,{onClick:function(){r(i.CREATE)},variant:"contained",children:[(0,l.jsx)($.dt,{className:"mr-2"}),"Bundle Deal"]})}),(0,l.jsx)("div",{className:"flex h-full w-full",children:(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(b.s,{pagination:!0,page:a-1,pageSize:c,rowCount:Z,rows:g,columns:Ee,loading:p,paginationMode:"server",onPageSizeChange:u,onPageChange:o,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,getRowHeight:P,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},disableSelectionOnClick:!0,components:{Pagination:y}})})})]})},ze=(0,W.ZP)(j.Z)((function(e){e.theme;return{root:{"&.Mui-disabled":{pointerEvents:"auto"}},"&.Mui-disabled":{cursor:"not-allowed"}}}));var We,Te=function(e){var t=e.ePlatformStoreId,n=e.buttonLabel,r=void 0===n?"Bundle":n,s=J(),a=s.mode,o=(s.setMode,s.bundleDealId),d=(0,_.useState)(!1),c=d[0],u=d[1],m=t?"Shopee Bundle List":"Please select a store";return(0,l.jsx)(X.Z,{isOpen:c,setIsOpen:u,dialogProps:{fullWidth:!0,maxWidth:"lg",onClose:function(){u(!1)}},button:(0,l.jsx)(T.Z,{title:m,placement:"top",children:(0,l.jsx)("div",{className:"",children:(0,l.jsxs)(ze,{onClick:function(){t&&u(!0)},color:"primary",variant:"outlined",sx:{textDecoration:"none",mr:.5,mb:"0.5rem"},disabled:!t,children:[(0,l.jsx)(R.UdJ,{className:"mr-2 text-2xl"})," ",(0,l.jsx)("span",{className:"text-sm",children:r})]})})}),title:m,description:"",children:(0,l.jsxs)("div",{hidden:!c,className:"",children:[a===i.CREATE&&(0,l.jsx)("div",{children:(0,l.jsx)(Ne,{ePlatformStoreId:t})}),t&&o&&a===i.VIEW_ITEM&&(0,l.jsx)(re,{bundle_deal_id:o,ePlatformStoreId:t}),t&&o&&a===i.ADD_ITEM&&(0,l.jsx)(K,{bundle_deal_id:o,ePlatformStoreId:t}),t&&a===i.LIST&&(0,l.jsx)(Me,{ePlatformStoreId:t})]})})},Oe=n(47824),Le=(0,_.createContext)(void 0);!function(e){e.LIST="list",e.CREATE="create",e.ADD_ITEM="add_item",e.VIEW_ITEM="view_item"}(We||(We={}));var Re,Fe,Ue,qe=function(e){var t,n,i,r=e.children,s=e.ePlatformStoreId,a=(0,_.useState)(We.LIST),o=a[0],d=a[1],c=(0,_.useState)(),u=c[0],m=c[1],x=null===(t=(0,B.pct)({variables:{filter:{id:s},page:0,perPage:1}}).data)||void 0===t||null===(n=t.allEPlatformStores)||void 0===n||null===(i=n.ePlatformStores)||void 0===i?void 0:i[0],h=(0,_.useMemo)((function(){return{mode:o,setMode:d,eplatformStore:x,currentVoucher:u,setCurrentVoucher:m}}),[o,x,u]);return(0,l.jsx)(Le.Provider,{value:h,children:r})},He=function(){var e=(0,_.useContext)(Le);if(void 0===e)throw new Error("useShopeeVoucher can only be used inside ShopeeVoucherProvider");return e};!function(e){e.ShopVoucher="Shop Voucher",e.ProductVoucher="Product Voucher"}(Re||(Re={})),function(e){e.Fix_Amount="Fix Amount",e.Discount_Percentage="Discount Percentage",e.Coins_Cashback="Coins Cashback"}(Fe||(Fe={})),function(e){e.Display_All="Display on all pages",e.Hidden="To be shared through voucher code"}(Ue||(Ue={}));var Je=Pe.Ry().shape({voucher_name:Pe.Z_().required("Please enter a voucher name"),voucher_code:Pe.Z_().required("Please enter a voucher code").max(5,"Voucher code must be 5 characters or less"),usage_quantity:Pe.Rx().required("Please enter a usage quantity"),min_basket_price:Pe.Rx().required("Please enter a minimum basket price"),voucher_type:Pe.nK().required("Please select a voucher type"),reward_type:Pe.nK().required("Please select a reward type"),start_time:Pe.hT().required(),end_time:Pe.hT().required(),display_start_time:Pe.hT().nullable(),discount_amount:Pe.Rx().nullable(),percentage:Pe.Rx().nullable(),max_price:Pe.Rx().nullable()}),Xe={voucher_type:Re.ShopVoucher,voucher_name:"Payday Voucher",voucher_code:"CODE",start_time:(0,_e.default)((0,ge.default)(new Date,1)),end_time:(0,be.default)((0,Ze.default)((0,ge.default)(new Date,1),1)),display_start_time:null,reward_type:Fe.Discount_Percentage,display_channel_list:Ue.Display_All,ePlatformItemIds:[],ePlatformItem:[],discount_amount:5,percentage:5,max_price:0,min_basket_price:12,usage_quantity:1},Ge=n(5952),Ye=n(55343),Ke=n(32631),$e=function(e){var t=e.row,n=e.onSelect;return(0,l.jsx)("div",{onClick:G.UW,className:"flex flex-wrap",children:(0,l.jsx)(j.Z,{variant:"contained",size:"small",onClick:function(){n(t)},children:"Add to Voucher"})})};var Qe=function(e){var t,n=e.ePlatformStoreId,i=e.onSelect,r=(0,_.useState)([]),s=r[0],a=r[1],o=(0,_.useState)({platform:B.NX6.Shopee,ePlatformStoreId:n}),d=o[0],c=(o[1],(0,_.useState)(0)),u=c[0],h=c[1],f=(0,_.useState)(10),Z=f[0],P=f[1],S=(0,_.useCallback)((function(){return"auto"}),[]),N=(0,B.c8j)({variables:{filter:d,page:u,perPage:Z,sortField:"createdAt",sortOrder:B.Asd.Desc}}),C=N.data,I=N.loading,w=(0,_.useMemo)((function(){var e={headerName:"Actions",field:"actions",minWidth:200,renderCell:function(e){var t=e.row;return(0,l.jsx)($e,{row:t,onSelect:i})}};return y.P.map((function(t){return"actions"===t.field?e:t}))}),[i]),k=(null===C||void 0===C?void 0:C.allEPlatformItems.ePlatformItems)||[],D=null!==(t=null===C||void 0===C?void 0:C.allEPlatformItems.total)&&void 0!==t?t:0,A=(0,_.useState)(!1),V=A[0],E=A[1],M="Shopee Vouchers";return(0,l.jsx)(X.Z,{isOpen:V,setIsOpen:E,dialogProps:{fullWidth:!0,maxWidth:"lg",onClose:function(){E(!1)}},button:(0,l.jsx)(T.Z,{title:M,placement:"top",children:(0,l.jsx)("div",{children:(0,l.jsxs)(j.Z,{onClick:function(){n&&E(!0)},color:"primary",variant:"outlined",sx:{textDecoration:"none",mr:.5,mb:"0.5rem"},disabled:!n,children:[(0,l.jsx)(R.UdJ,{className:"mr-2 text-2xl"})," ",(0,l.jsx)("span",{className:"text-sm",children:"Add Items to Voucher"})]})})}),title:M,description:"",children:(0,l.jsxs)(v.ZP,{container:!0,spacing:6,children:[(0,l.jsx)(x.Z,{title:(0,l.jsx)("div",{className:"flex items-center justify-between px-2 pb-2 pt-3",children:(0,l.jsx)(p.Z,{variant:"h6",children:"Add items into Shopee Voucher"})})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,children:(0,l.jsx)(v.ZP,{container:!0,spacing:6,children:(0,l.jsx)(v.ZP,{item:!0,xs:12,children:(0,l.jsx)(g.Z,{children:(0,l.jsx)("div",{className:"flex h-full w-full",children:(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(b.s,{pagination:!0,page:u,pageSize:Z,rowCount:D,rows:k,columns:w,loading:I,paginationMode:"server",onPageSizeChange:P,onPageChange:h,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,getRowHeight:S,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},checkboxSelection:!1,disableSelectionOnClick:!0,keepNonExistentRowsSelected:!1,onSelectionModelChange:function(e){a(e)},selectionModel:s,components:{Pagination:m.Z},componentsProps:{pagination:{page:u,setPage:h,pageSize:Z,setPageSize:P,totalRows:D}}})})})})})})})]})})},et=n(13369),tt=n(41664),nt=n.n(tt);var it=function(e){var t,n,i=e.data,r=(e.index,i.itemName),s=i.itemUrl,o=i.ePlatformStore,d=i.images,c=i.sku,u=i.variantItems,m=i.price,x=(0,M.get)(o,"platform"),h=(null===d||void 0===d?void 0:d.map((function(e){return{content:null!==(t=null===e||void 0===e?void 0:e.content)&&void 0!==t?t:"",thumbnail:null!==(n=null===e||void 0===e?void 0:e.thumbnail)&&void 0!==n?n:void 0,type:B.Tv5.Image}})))||[];return(0,l.jsx)("div",{children:(0,l.jsx)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("div",{className:"w-20",children:(0,l.jsx)(ee.ZP,{className:"flex-col",imgArray:h,numOfImages:1})}),(0,l.jsx)("div",{className:"line-clamp-3 w-96",children:s?(0,l.jsx)(T.Z,{title:"Open in ".concat(x),children:(0,l.jsx)(nt(),{href:s,target:"_blank",rel:"noopener",children:(0,l.jsx)("div",{children:r})})}):(0,l.jsx)("div",{children:r})}),(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(et.Z,(0,a.Z)({},{variantItems:u,sku:c||"Missing SKU",price:m}))})]})})})};var lt=function(e){var t=e.defaultValues,n=He().eplatformStore,i=(0,ve.Gc)(),r=i.control,s=(i.getValues,i.setValue,i.formState.errors),a=(0,ve.Dq)({control:r,
1name:"ePlatformItem",keyName:"uid"}),o=a.fields,d=a.append,c=a.remove,u=(0,ve.U2)(s,"ePlatformItem"),m=(0,_.useCallback)((function(e){d({data:e})}),[d]);return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-3 flex",children:(0,l.jsx)(Ye.Z,{error:Boolean(u),children:u&&(0,l.jsx)(Ke.Z,{children:u.message})})}),o.map((function(e,n){var r="ePlatformItem.".concat(n);return(0,l.jsxs)("div",{children:[(0,l.jsx)(Ge.Z,{name:"".concat(r,".data"),defaultValue:e.data,defaultValues:t,methods:i}),(0,l.jsxs)(v.ZP,{container:!0,spacing:6,sx:{pb:5},children:[(0,l.jsx)(v.ZP,{item:!0,xs:11,children:(0,l.jsx)(it,{index:n,data:e.data})}),(0,l.jsx)(v.ZP,{item:!0,xs:1,children:(0,l.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,l.jsx)(ne.Z,{title:"Remove Item",iconButtonProps:{onClick:function(){c(n)}},children:(0,l.jsx)($.pJ,{className:"text-red-500"})})})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,children:(0,l.jsx)(he.Z,{})})]})]},e.uid)})),(null===n||void 0===n?void 0:n.id)&&(0,l.jsx)(Qe,{ePlatformStoreId:n.id,onSelect:m})]})};var rt=function(e){var t=e.defaultValues,n=He(),i=n.setMode,r=n.eplatformStore,s=null===r||void 0===r?void 0:r.currency,a=(0,ve.Gc)(),o=a.control,d=a.formState.isSubmitting,c=(0,ve.qo)({control:o,name:"reward_type"}),u=(0,ve.qo)({control:o,name:"voucher_type"});return(0,l.jsxs)("div",{className:"p-5",children:[(0,l.jsxs)(v.ZP,{container:!0,spacing:6,children:[(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,children:(0,l.jsx)(ue.Z,{name:"voucher_code",textFieldProps:{placeholder:"Enter Voucher Code (BRODCOINS)"},defaultValues:t})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,children:(0,l.jsx)(ue.Z,{name:"voucher_name",textFieldProps:{placeholder:"Enter Voucher Name (Payday Coins)"},defaultValues:t})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:3,children:(0,l.jsx)(oe.Z,{textFieldProps:{size:"small"},name:"start_time",defaultValues:t,reactDatePickerProps:{isClearable:!1}})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:3,children:(0,l.jsx)(oe.Z,{textFieldProps:{size:"small"},name:"end_time",defaultValues:t,reactDatePickerProps:{isClearable:!1}})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:3,children:(0,l.jsx)(oe.Z,{textFieldProps:{size:"small"},name:"display_start_time",label:(0,l.jsx)("div",{children:(0,l.jsx)("span",{children:"Display Start Time (Optional)"})}),defaultValues:t,reactDatePickerProps:{isClearable:!0}})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:12,children:(0,l.jsx)(ce.Z,{name:"voucher_type",options:(0,M.map)(Re,(function(e,t){return{label:e,value:e}})),defaultValues:t})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:12,children:(0,l.jsx)(ce.Z,{name:"reward_type",options:(0,M.map)(Fe,(function(e,t){return{label:e,value:e}})),defaultValues:t})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,hidden:c!==Fe.Fix_Amount,children:(0,l.jsx)(de.Z,{name:"discount_amount",label:"Discount Amount",defaultValues:t,textFieldProps:{InputProps:{startAdornment:(0,l.jsx)("div",{className:"w-24 text-slate-400",children:s})}}})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,hidden:c===Fe.Fix_Amount,children:(0,l.jsx)(de.Z,{name:"percentage",label:"Discount Percentage",defaultValues:t,textFieldProps:{InputProps:{endAdornment:(0,l.jsx)("div",{className:"w-56 whitespace-nowrap text-right text-slate-400",children:c===Fe.Coins_Cashback?"% Coins Cashback":"% OFF"})}}})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,children:(0,l.jsx)(de.Z,{name:"max_price",label:"Maximum Capped Amount (0 for No Limit)",defaultValues:t})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,children:(0,l.jsx)(de.Z,{name:"min_basket_price",label:"Minimum Basket Price",defaultValues:t})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:6,children:(0,l.jsx)(de.Z,{name:"usage_quantity",label:"Usage Quantity (Total usable voucher for all buyers)",defaultValues:t})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:12,children:(0,l.jsx)(ce.Z,{name:"display_channel_list",options:(0,M.map)(Ue,(function(e,t){return{label:e,value:e}})),defaultValues:t})})]}),(0,l.jsx)(he.Z,{sx:{my:5}}),(0,l.jsx)(v.ZP,{item:!0,xs:12,sm:12,hidden:u!==Re.ProductVoucher,children:(0,l.jsx)(lt,{defaultValues:t})}),(0,l.jsx)(he.Z,{sx:{my:5}}),(0,l.jsxs)(V.Z,{sx:{display:"flex",alignItems:"center"},children:[(0,l.jsxs)(j.Z,{disabled:d,className:"flex gap-2",size:"large",type:"submit",variant:"contained",sx:{mr:3},children:[d&&(0,l.jsx)($.Ho,{className:"animate-spin"}),(0,l.jsx)("div",{children:"Create new Voucher"})]}),(0,l.jsx)(j.Z,{onClick:function(){i(We.LIST)},size:"large",variant:"outlined",color:"secondary",children:"Cancel"})]})]})},st=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return Object.values(e).indexOf(t)+n};var at=function(e){var t=e.ePlatformStoreId,n=He().setMode,i=(0,N.Z)((0,B.wW$)(),2),r=i[0],s=i[1],d=s.client,c=(s.loading,Xe),u=(0,ve.cI)({defaultValues:c,resolver:(0,xe.X)(Je)}),m=u.reset,x=u.handleSubmit,h=function(){n(We.LIST)},f=function(){var e=(0,S.Z)((function(e){var n,i,l,s;return(0,C.__generator)(this,(function(c){switch(c.label){case 0:return i=e.voucher_type===Re.ProductVoucher?null===(n=e.ePlatformItem)||void 0===n?void 0:n.map((function(e){return e.data.id})):void 0,l=(0,o.Z)((0,a.Z)({},(0,M.omit)(e,["ePlatformItem"])),{ePlatformItemIds:i,voucher_type:st(Re,e.voucher_type),reward_type:st(Fe,e.reward_type),display_channel_list:[st(Ue,e.display_channel_list)]}),console.log(l,"shopeeAddVoucherDto"),[4,r({variables:{ePlatformStoreId:t,shopeeAddVoucherDto:l}})];case 1:return(null===(s=c.sent().data)||void 0===s?void 0:s.shopeeAddVoucher)&&((0,z.x9)("Shopee voucher added successfully"),d.cache.evict({fieldName:"getShopeeVoucherList"}),m(),h()),[2]}}))}));return function(t){return e.apply(this,arguments)}}();return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"my-2 ml-5 flex justify-start gap-5 ",children:(0,l.jsxs)(j.Z,{onClick:h,variant:"outlined",children:[(0,l.jsx)(A.qg,{className:"mr-2"})," Back to List"]})}),(0,l.jsx)(me.e,{methods:u,onSubmit:x(f),defaultValues:c,children:(0,l.jsx)(rt,{defaultValues:c})})]})};var ot=function(e){var t=e.ePlatformStoreId,n=e.voucher_id,i=He(),r=i.setCurrentVoucher,s=i.setMode,a=(0,B.Hv2)({variables:{ePlatformStoreId:t,voucher_id:n}}),o=a.data,d=(a.loading,null===o||void 0===o?void 0:o.getShopeeVoucherDetails),c=null===d||void 0===d?void 0:d.item_list,u=d||{},m=(u.current_usage,u.end_time),x=u.reward_type,h=u.start_time,f=(u.usage_quantity,u.voucher_code,u.voucher_name,u.voucher_type),v=(u.voucher_purpose,u.discount_amount),p=(u.item_list,u.percentage),g=He().eplatformStore,Z=null===g||void 0===g?void 0:g.currency,b="Unknown";1===x?b="".concat(Z," ").concat(null===v||void 0===v?void 0:v.toFixed(2)," OFF"):2===x?b="".concat(p," % OFF"):3===x&&(b="".concat(p," % Coins"));var _=h?new Date(1e3*h):null,P=m?new Date(1e3*m):null;return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-2 flex justify-start gap-5",children:(0,l.jsxs)(j.Z,{onClick:function(){s(We.LIST),r(void 0)},variant:"outlined",children:[(0,l.jsx)(A.qg,{className:"mr-2"})," Back to List"]})}),(0,l.jsx)("div",{children:(0,l.jsx)("div",{className:"mb-2 flex items-center justify-between p-5",children:(0,l.jsxs)("div",{className:"flex w-full flex-wrap justify-between gap-5",children:[(0,l.jsxs)("div",{className:"line-clamp-3 flex flex-col gap-y-1",children:[(0,l.jsx)("strong",{children:(0,l.jsx)("div",{className:"flex cursor-pointer items-center gap-2 text-gray-700 first-line:
1dark:text-gray-200 dark:hover:text-gray-500",children:(0,l.jsx)("div",{className:"py-1",children:null===d||void 0===d?void 0:d.voucher_code})})}),(0,l.jsx)("div",{className:" line-clamp-2 break-all text-slate-400",children:null===d||void 0===d?void 0:d.voucher_name})]}),(0,l.jsx)("div",{className:"flex flex-col",children:(0,l.jsxs)("div",{className:"textflex items-center gap-2",children:[(0,l.jsx)("div",{className:"flex flex-col",children:(0,l.jsx)("div",{className:"py-1",children:b})}),(0,l.jsxs)("div",{className:"text-slate-400 ",children:["(",1===x?Fe.Fix_Amount:2===x?Fe.Discount_Percentage:Fe.Coins_Cashback,")"]})]})}),(0,l.jsxs)("div",{className:"line-clamp-3 flex flex-wrap gap-y-1",children:[(0,l.jsx)("div",{children:"Period"}),(0,l.jsxs)("div",{children:[_?(0,Ie.p6)(_,"yyyy-MM-dd"):null," ",(0,l.jsx)("span",{className:"text-2xs",children:_?(0,Ie.mr)(_,"HH:mm"):null})," ","- ",P?(0,Ie.p6)(P,"yyyy-MM-dd"):null," ",(0,l.jsx)("span",{className:"text-2xs",children:P?(0,Ie.mr)(P,"HH:mm"):null})," "]})]})]})})}),(0,l.jsx)("div",{className:"px-5 py-1 font-bold",children:1===f?Re.ShopVoucher:Re.ProductVoucher}),(0,l.jsx)("div",{className:"px-5 font-bold",hidden:1!==f,children:"This voucher applies to all products in the store."}),(0,l.jsxs)("div",{className:"px-5 font-bold",hidden:!(null===c||void 0===c?void 0:c.length),children:["This voucher only applies to the products below:"," "]}),(0,l.jsx)("div",{className:"flex flex-col divide-y",children:null===c||void 0===c?void 0:c.map((function(e){var t=e.images,n=(e.itemId,e.itemName),i=e.itemUrl;return(0,l.jsxs)("div",{className:"flex items-center justify-start gap-5 p-5",children:[(0,l.jsx)("div",{className:"flex items-center justify-start",children:(0,l.jsx)(ee.ZP,{imgArray:t.map((function(e){return{content:e,thumbnail:e,type:B.Tv5.Image}})),numOfImages:1})}),(0,l.jsxs)("div",{className:"flex flex-col items-start justify-start",children:[(0,l.jsx)("div",{className:"text-lg",children:n}),(0,l.jsx)("div",{className:"text-sm",children:i})]})]},e.itemId)}))})]})};var dt=function(e){var t=e.voucher_id,n=(0,_.useState)(null),i=n[0],r=n[1],s=Boolean(i),a=s?"delete-voucher-popover":void 0,o=He(),d=(o.currentVoucher,o.eplatformStore),
1c=(0,N.Z)((0,B.AC5)({variables:{ePlatformStoreId:(null===d||void 0===d?void 0:d.id)||"",voucher_id:t}}),2),u=c[0],m=c[1],x=m.loading,h=m.client,f=function(){var e=(0,S.Z)((function(){var e,t;return(0,C.__generator)(this,(function(n){switch(n.label){case 0:return[4,u()];case 1:return t=n.sent(),(null===(e=t.data)||void 0===e?void 0:e.shopeeDeleteVoucher)&&((0,z.x9)("Bundle Item has been removed"),h.cache.evict({fieldName:"getShopeeVoucherList"})),[2]}}))}));return function(){return e.apply(this,arguments)}}();return(0,l.jsxs)("div",{children:[(0,l.jsx)(ne.Z,{title:"Delete Shopee Voucher",iconButtonProps:{color:"error",onClick:function(e){r(e.currentTarget)}},children:(0,l.jsx)($.pJ,{className:"text-red-500"})}),(0,l.jsx)(O.ZP,{id:a,open:s,anchorEl:i,onClose:function(){r(null)},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},children:(0,l.jsxs)("div",{className:"mx-5 my-2",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"text-red-500",children:(0,l.jsx)($.zM,{})}),(0,l.jsx)("span",{children:"Are you sure? "})]}),(0,l.jsx)("div",{className:"mt-1 flex justify-end",children:(0,l.jsx)(j.Z,{color:"error",onClick:f,disabled:x,children:"Delete"})})]})})]})};var ct=function(e){var t=e.row,n=He().eplatformStore,i=null===n||void 0===n?void 0:n.currency,r=t.discount_amount,s=t.reward_type,a=t.percentage,o="Unknown";return 1===s?o="".concat(i," ").concat(null===r||void 0===r?void 0:r.toFixed(2)," OFF"):2===s?o="".concat(a," % OFF"):3===s&&(o="".concat(a," % Coins")),(0,l.jsx)("div",{className:"flex w-full flex-col gap-y-1 divide-y divide-slate-400/50",onClick:G.UW,children:(0,l.jsx)("div",{className:"py-1",children:o})})};var ut=function(e){var t=e.row,n=He(),i=n.setCurrentVoucher,r=n.setMode,s=t.voucher_name,a=t.voucher_code;return t.voucher_purpose,(0,l.jsxs)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:[(0,l.jsx)("strong",{onClick:G.UW,children:(0,l.jsx)(T.Z,{title:"View Voucher",children:(0,l.jsxs)("div",{onClick:function(){i(t),r(We.VIEW_ITEM)},className:"flex cursor-pointer items-center gap-2 text-gray-700 hover:text-black hover:underline dark:text-gray-200 dark:hover:text-gray-500",children:[(0,l.jsx)("div",{className:"py-1",children:a}),(0,l.jsx)(Q.h0,{})]})})}),(0,l.jsx)("div",{className:"line-clamp-2 break-all text-2xs text-slate-400",children:s})]})},mt={Upcoming:"warning",Ongoing:"success",Expired:"error",Unknown:"info"},xt={1:"Shop Voucher",2:"Product Voucher"},ht={1:"Fix Amount",2:"Discount Percentage",3:"Coin Cashback"},ft=[{headerName:"Voucher Name",field:"voucher_name",flex:1,minWidth:140,renderCell:function(e){var t=e.row;return(0,l.jsx)(ut,{row:t})}},{headerName:"Type",field:"voucher_type",minWidth:150,flex:1,renderCell:function(e){var t=e.row,n=t.voucher_type,i=t.reward_type;return(0,l.jsxs)("div",{className:"flex flex-col",onClick:G.UW,children:[(0,l.jsx)("div",{className:"py-1",children:xt["".concat(n)]}),(0,l.jsxs)("div",{className:"text-2xs text-slate-400",children:["(",ht["".concat(i)],")"]})]})}},{headerName:"Discount",field:"reward_type",flex:1,minWidth:150,renderCell:function(e){var t=e.row;return(0,l.jsx)(ct,{row:t})}},{headerName:"Usage Limit",field:"usage_quantity",minWidth:50,renderCell:function(e){var t=e.row.usage_quantity;return(0,l.jsx)("div",{className:"flex w-full flex-col gap-y-1 divide-y divide-slate-400/50",onClick:G.UW,children:(0,l.jsx)("div",{className:"py-1",children:t})})}},{headerName:"Usage",field:"current_usage",minWidth:50,renderCell:function(e){var t=e.row.current_usage;return(0,l.jsx)("div",{className:"flex w-full flex-col gap-y-1 divide-y divide-slate-400/50",onClick:G.UW,children:(0,l.jsx)("div",{className:"py-1",children:t})})}},{headerName:"Status",field:"start_time",flex:1,minWidth:100,renderCell:function(e){var t,n=e.row,i=n.end_time,r=n.start_time,s=new Date(1e3*r),a=new Date(1e3*i),o=new Date;return t=o<s?"Upcoming":o>s&&o<a?"Ongoing":o>a?"Expired":"Unknown",(0,l.jsx)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:(0,l.jsx)("div",{children:(0,l.jsx)(te.Z,{size:"small",label:t,color:mt[t]})})})}},{headerName:"Period",field:"end_time",flex:1,minWidth:180,renderCell:function(e){var t=e.row,n=t.end_time,i=t.start_time,r=new Date(1e3*i),s=new Date(1e3*n);return(0,l.jsxs)("div",{className:"line-clamp-3 flex flex-col gap-y-1",onClick:G.UW,children:[(0,l.jsxs)("div",{children:[(0,Ie.p6)(r,"yyyy-MM-dd")," ",(0,l.jsx)("span",{className:"text-2xs",children:(0,Ie.mr)(r,"HH:mm")}
1)," -"," "]}),(0,l.jsxs)("div",{children:[(0,Ie.p6)(s,"yyyy-MM-dd")," ",(0,l.jsx)("span",{className:"text-2xs",children:(0,Ie.mr)(s,"HH:mm")})," "]})]})}},{headerName:"Actions",field:"actions",minWidth:140,renderCell:function(e){var t=e.row;return(0,l.jsx)("div",{className:"flex w-full items-center justify-center",children:(0,l.jsx)(dt,{voucher_id:t.voucher_id})})}}];var vt=function(e){var t,n=e.ePlatformStoreId,i=He().setMode,r=(0,_.useState)(1),s=r[0],a=r[1],o=(0,_.useState)(10),d=o[0],c=o[1],u=(0,_.useState)(1),m=u[0],x=u[1],h=(0,B.SAJ)({variables:{ePlatformStoreId:n,page_no:s,page_size:d,status:B.JRJ.All},onCompleted:function(e){(null===e||void 0===e?void 0:e.getShopeeVoucherList.more)&&x((function(e){return Math.max(e,s+1)}))}}),f=h.data,v=h.loading,p=(null===f||void 0===f||null===(t=f.getShopeeVoucherList)||void 0===t?void 0:t.voucher_list)||[],g=m*d,Z=(0,_.useCallback)((function(){return"auto"}),[]),P=(0,_.useCallback)((function(){return(0,l.jsx)("div",{className:"my-5 flex justify-center",children:(0,l.jsx)(Ce.Z,{count:m,page:s,onChange:function(e,t){a(t)},variant:"outlined",color:"primary"})})}),[a,s,m]);return(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"mb-5 mt-2 flex items-center justify-end",children:(0,l.jsxs)(j.Z,{onClick:function(){i(We.CREATE)},variant:"contained",children:[(0,l.jsx)($.dt,{className:"mr-2"}),"Voucher"]})}),(0,l.jsx)("div",{className:"flex h-full w-full",children:(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(b.s,{pagination:!0,page:s-1,pageSize:d,rowCount:g,rows:p,columns:ft,loading:v,paginationMode:"server",onPageSizeChange:c,onPageChange:a,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,getRowHeight:Z,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},disableSelectionOnClick:!0,components:{Pagination:P}})})})]})},pt=(0,W.ZP)(j.Z)((function(e){e.theme;return{root:{"&.Mui-disabled":{pointerEvents:"auto"}},"&.Mui-disabled":{cursor:"not-allowed"}}}));var jt=function(e){var t=e.ePlatformStoreId,n=e.buttonLabel,i=void 0===n?"Voucher":n,r=He(),s=r.mode,a=r.currentVoucher,o=(0,_.useState)(!1),d=o[0],c=o[1],u=t?"Shopee Vouchers":"Please select a store";return(0,l.jsx)("div",{children:(0,l.jsx)(X.Z,{isOpen:d,setIsOpen:c,dialogProps:{fullWidth:!0,maxWidth:"lg",onClose:function(){c(!1)}},button:(0,l.jsx)(T.Z,{title:u,placement:"top",children:(0,l.jsx)("div",{children:(0,l.jsxs)(pt,{onClick:function(){t&&c(!0)},color:"primary",variant:"outlined",sx:{textDecoration:"none",mr:.5,mb:"0.5rem"},disabled:!t,children:[(0,l.jsx)(R.UdJ,{className:"mr-2 text-2xl"})," ",(0,l.jsx)("span",{className:"text-sm",children:i})]})})}),title:u,description:"",children:(0,l.jsxs)("div",{hidden:!d,className:"",children:[t&&s===We.CREATE&&(0,l.jsx)(at,{ePlatformStoreId:t}),t&&s===We.LIST&&(0,l.jsx)(vt,{ePlatformStoreId:t}),t&&(null===a||void 0===a?void 0:a.voucher_id)&&s===We.VIEW_ITEM&&(0,l.jsx)(ot,{voucher_id:a.voucher_id,ePlatformStoreId:t})]})})})}
1,gt=n(29620),Zt=n(77745),bt=n(95398),_t=n(62348),Pt=n(18661),yt=n(86777),St=n(70918),Nt=n(90244),Ct=n(93978),It=n(69417),wt=n(5605),kt=n(39807),Dt=n(80562),At=n(86501),Bt=n(67836),Vt=n(76779),Et=function(e){var t=e.ePlatformStoreId,n=e.onCreated,i=(0,_.useState)(!1),r=i[0],s=i[1],o=(0,ve.cI)(),d=o.register,c=o.handleSubmit,u=o.reset,m=(0,N.Z)((0,B.DP4)({onCompleted:function(){At.ZP.success("Collection created"),s(!1),u(),n()},onError:function(e){return At.ZP.error(e.message)}}),2),x=m[0],h=m[1].loading;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(j.Z,{variant:"contained",size:"small",onClick:function(){return s(!0)},children:"Create Collection"}),(0,l.jsx)(gt.Z,{open:r,onClose:function(){return s(!1)},maxWidth:"sm",fullWidth:!0,children:(0,l.jsxs)("form",{onSubmit:c((function(e){x({variables:{dto:{ePlatformStoreId:t,title:e.title,descriptionHtml:e.descriptionHtml||void 0}}})})),children:[(0,l.jsx)(Zt.Z,{children:"Create Collection"}),(0,l.jsxs)(bt.Z,{className:"flex flex-col gap-3 pt-2",children:[(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Title",required:!0,size:"small",fullWidth:!0},d("title",{required:!0}))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Description (HTML)",size:"small",fullWidth:!0,multiline:!0,rows:3},d("descriptionHtml")))]}),(0,l.jsxs)(Vt.Z,{children:[(0,l.jsx)(j.Z,{onClick:function(){return s(!1)},children:"Cancel"}),(0,l.jsx)(j.Z,{type:"submit",variant:"contained",disabled:h,children:h?"Creating...":"Create"})]})]})})]})},Mt=function(e){var t,n,i=e.ePlatformStoreId,r=(0,B.mpq)({variables:{ePlatformStoreId:i,first:50}}),s=r.data,a=r.loading,o=r.refetch,d=(0,N.Z)((0,B.d$O)({onCompleted:function(){At.ZP.success("Collection deleted"),o()},onError:function(e){return At.ZP.error(e.message)}}),1)[0],c=null!==(n=null===s||void 0===s||null===(t=s.getShopifyCollections)||void 0===t?void 0:t.collections)&&void 0!==n?n:[];return(0,l.jsxs)(fe.Z,{children:[(0,l.jsx)(fe.Z,{className:"flex w-full justify-end gap-2 px-1 py-2",children:(0,l.jsx)(Et,{ePlatformStoreId:i,onCreated:function(){return o()}})}),(0,l.jsx)(g.Z,{children:(0,l.jsx)(yt.Z,{component:St.Z,children:(0,l.jsxs)(Nt.Z,{size:"small",children:[(0,l.jsx)(Ct.Z,{children:(0,l.jsxs)(It.Z,{children:[(0,l.jsx)(wt.Z,{children:"Title"}),(0,l.jsx)(wt.Z,{children:"Handle"}),(0,l.jsx)(wt.Z,{children:"Products"}),(0,l.jsx)(wt.Z,{align:"right",children:"Actions"})]})}),(0,l.jsxs)(kt.Z,{children:[a&&(0,l.jsx)(It.Z,{children:(0,l.jsx)(wt.Z,{colSpan:4,align:"center",children:(0,l.jsx)($.Ho,{})})}),!a&&0===c.length&&(0,l.jsx)(It.Z,{children:(0,l.jsx)(wt.Z,{colSpan:4,align:"center",children:(0,l.jsx)(p.Z,{variant:"body2",color:"textSecondary",children:"No collections found"})})}),c.map((function(e){return(0,l.jsxs)(It.Z,{children:[(0,l.jsx)(wt.Z,{children:e.title}),(0,l.jsx)(wt.Z,{children:(0,l.jsx)(te.Z,{label:e.handle,size:"small",variant:"outlined"})}),(0,l.jsx)(wt.Z,{children:e.productsCount}),(0,l.jsx)(wt.Z,{align:"right",children:(0,l.jsx)(T.Z,{title:"Delete",children:(0,l.jsx)(Dt.Z,{size:"small",color:"error",onClick:function(){return d({variables:{ePlatformStoreId:i,collectionGid:e.id}})},children:(0,l.jsx)($.pJ,{className:"text-red-500"})})})})]},e.id)}))]})]})})})]})},zt=n(22841),Wt=n(75158),Tt=function(e){var t=e.ePlatformStoreId,n=e.onCreated,i=(0,_.useState)(!1),r=i[0],s=i[1],o=(0,ve.cI)({defaultValues:{isPercentage:!0,startsAt:(new Date).toISOString().slice(0,16)}}),d=o.register,c=o.handleSubmit,u=o.reset,m=(0,N.Z)((0,B.wqg)({onCompleted:function(){At.ZP.success("Auto discount created"),s(!1),u(),n()},onError:function(e){return At.ZP.error(e.message)}}),2),x=m[0],h=m[1].loading;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(j.Z,{variant:"contained",size:"small",onClick:function(){return s(!0)},children:"Create Auto Discount"}),(0,l.jsx)(gt.Z,{open:r,onClose:function(){return s(!1)},maxWidth:"sm",fullWidth:!0,children:(0,l.jsxs)("form",{onSubmit:c((function(e){x({variables:{dto:{ePlatformStoreId:t,title:e.title,startsAt:new Date(e.startsAt).toISOString(),endsAt:e.endsAt?new Date(e.endsAt).toISOString():void 0,value:Number(e.value),isPercentage:e.isPercentage,minimumSubtotal:e.minimumSubtotal||void 0}}})})),children:[(0,l.jsx)(Zt.Z,{children:"Create Auto Discount"}),(0,l.jsxs)(bt.Z,{className:"flex flex-col gap-3 pt-2",children:[(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Title",required:!0,size:"small",fullWidth:!0},d("title",{required:!0}))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Discount Value",required:!0,size:"small",type:"number",fullWidth:!0},d("value",{required:!0,valueAsNumber:!0}))),(0,l.jsx)(zt.Z,{control:(0,l.jsx)(Wt.Z,(0,a.Z)({defaultChecked:!0},d("isPercentage"))),label:"Percentage off (uncheck for fixed amount)"}),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Starts At",size:"small",type:"datetime-local",fullWidth:!0,InputLabelProps:{shrink:!0}},d("startsAt",{required:!0}))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Ends At (optional)",size:"small",type:"datetime-local",fullWidth:!0,InputLabelProps:{shrink:!0}},d("endsAt"))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Minimum Subtotal (optional)",size:"small",fullWidth:!0},d("minimumSubtotal")))]}),(0,l.jsxs)(Vt.Z,{children:[(0,l.jsx)(j.Z,{onClick:function(){return s(!1)},children:"Cancel"}),(0,l.jsx)(j.Z,{type:"submit",variant:"contained",disabled:h,children:h?"Creating...":"Create"})]})]})})]})},Ot=function(e){var t=e.ePlatformStoreId,n=e.onCreated,i=(0,_.useState)(!1),r=i[0],s=i[1],o=(0,ve.cI)({defaultValues:{isPercentage:!0,startsAt:(new Date).toISOString().slice(0,16)}}),d=o.register,c=o.handleSubmit,u=o.reset,m=(0,N.Z)((0,B.Mf7)({onCompleted:function(){At.ZP.success("Discount created"),s(!1),u(),n()},onError:function(e){return At.ZP.error(e.message)}}),2),x=m[0],h=m[1].loading;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(j.Z,{variant:"contained",size:"small",onClick:function(){return s(!0)},children:"Create Code Discount"}),(0,l.jsx)(gt.Z,{open:r,onClose:function(){return s(!1)},maxWidth:"sm",fullWidth:!0,children:(0,l.jsxs)("form",{onSubmit:c((function(e){x({variables:{dto:{ePlatformStoreId:t,title:e.title,code:e.code,startsAt:new Date(e.startsAt).toISOString(),endsAt:e.endsAt?new Date(e.endsAt).toISOString():void 0,value:Number(e.value),isPercentage:e.isPercentage,usageLimit:e.usageLimit?Number(e.usageLimit):void 0,minimumSubtotal:e.minimumSubtotal||void 0}}})})),children:[(0,l.jsx)(Zt.Z,{children:"Create Code Discount"}),(0,l.jsxs)(bt.Z,{className:"flex flex-col gap-3 pt-2",children:[(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Title",required:!0,size:"small",fullWidth:!0},d("title",{required:!0}))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Discount Code",required:!0,size:"small",fullWidth:!0},d("code",{required:!0}))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Discount Value",required:!0,size:"small",type:"number",fullWidth:!0},d("value",{required:!0,valueAsNumber:!0}))),(0,l.jsx)(zt.Z,{control:(0,l.jsx)(Wt.Z,(0,a.Z)({defaultChecked:!0},d("isPercentage"))),label:"Percentage off (uncheck for fixed amount)"}),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Starts At",size:"small",type:"datetime-local",fullWidth:!0,InputLabelProps:{shrink:!0}},d("startsAt",{required:!0}))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Ends At (optional)",size:"small",type:"datetime-local",fullWidth:!0,InputLabelProps:{shrink:!0}},d("endsAt"))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Usage Limit (optional)",size:"small",type:"number",fullWidth:!0},d("usageLimit"))),(0,l.jsx)(Bt.Z,(0,a.Z)({label:"Minimum Subtotal (optional)",size:"small",fullWidth:!0},d("minimumSubtotal")))]}),(0,l.jsxs)(Vt.Z,{children:[(0,l.jsx)(j.Z,{onClick:function(){return s(!1)},children:"Cancel"}),(0,l.jsx)(j.Z,{type:"submit",variant:"contained",disabled:h,children:h?"Creating...":"Create"})]})]})})]})}
1,Lt={ACTIVE:"success",SCHEDULED:"warning",EXPIRED:"error"},Rt=function(e){var t,n,i,r,s,a,o=e.ePlatformStoreId,d=(0,_.useState)(0),c=d[0],u=d[1],m=(0,B.btV)({variables:{ePlatformStoreId:o,first:50},skip:0!==c}),x=m.data,h=m.loading,f=m.refetch,v=(0,B.FDX)({variables:{ePlatformStoreId:o,first:50},skip:1!==c}),j=v.data,Z=v.loading,b=v.refetch,P=(0,N.Z)((0,B.vCg)({onCompleted:function(){At.ZP.success("Code discount deleted"),f()},onError:function(e){At.ZP.error(e.message)}}),1)[0],y=(0,N.Z)((0,B.U7f)({onCompleted:function(){At.ZP.success("Auto discount deleted"),b()},onError:function(e){At.ZP.error(e.message)}}),1)[0],S=null!==(t=null===x||void 0===x?void 0:x.getShopifyCodeDiscounts)&&void 0!==t?t:[],C=null!==(n=null===j||void 0===j?void 0:j.getShopifyAutoDiscounts)&&void 0!==n?n:[];return(0,l.jsxs)(fe.Z,{children:[(0,l.jsxs)(_t.Z,{value:c,onChange:function(e,t){return u(t)},sx:{mb:2},children:[(0,l.jsx)(Pt.Z,{label:"Code Discounts"}),(0,l.jsx)(Pt.Z,{label:"Auto Discounts"})]}),0===c&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(fe.Z,{className:"flex w-full justify-end gap-2 px-1 py-2",children:(0,l.jsx)(Ot,{ePlatformStoreId:o,onCreated:function(){return f()}})}),(0,l.jsx)(g.Z,{children:(0,l.jsx)(yt.Z,{component:St.Z,children:(0,l.jsxs)(Nt.Z,{size:"small",children:[(0,l.jsx)(Ct.Z,{children:(0,l.jsxs)(It.Z,{children:[(0,l.jsx)(wt.Z,{children:"Title"}),(0,l.jsx)(wt.Z,{children:"Code"}),(0,l.jsx)(wt.Z,{children:"Status"}),(0,l.jsx)(wt.Z,{children:"Value"}),(0,l.jsx)(wt.Z,{children:"Usage"}),(0,l.jsx)(wt.Z,{children:"Start"}),(0,l.jsx)(wt.Z,{children:"End"}),(0,l.jsx)(wt.Z,{align:"right",children:"Actions"})]})}),(0,l.jsxs)(kt.Z,{children:[h&&(0,l.jsx)(It.Z,{children:(0,l.jsx)(wt.Z,{colSpan:8,align:"center",children:(0,l.jsx)($.Ho,{})})}),!h&&0===S.length&&(0,l.jsx)(It.Z,{children:(0,l.jsx)(wt.Z,{colSpan:8,align:"center",children:(0,l.jsx)(p.Z,{variant:"body2",color:"textSecondary",children:"No code discounts found"})})}),S.map((function(e){return(0,l.jsxs)(It.Z,{children:[(0,l.jsx)(wt.Z,{children:e.title}),(0,l.jsx)(wt.Z,{children:(0,l.jsx)(te.Z,{label:e.code,size:"small",variant:"outlined"})}),(0,l.jsx)(wt.Z,{children:(0,l.jsx)(te.Z,{label:e.status,size:"small",color:null!==(i=Lt[e.status])&&void 0!==i?i:"default"})}),(0,l.jsx)(wt.Z,{children:null!==(r=e.value)&&void 0!==r?r:"-"}),(0,l.jsxs)(wt.Z,{children:[e.usageCount,null!=e.usageLimit?" / ".concat(e.usageLimit):""]}),(0,l.jsx)(wt.Z,{children:(0,Ie.o0)(e.startsAt)}),(0,l.jsx)(wt.Z,{children:e.endsAt?(0,Ie.o0)(e.endsAt):"-"}),(0,l.jsx)(wt.Z,{align:"right",children:(0,l.jsx)(T.Z,{title:"Delete",children:(0,l.jsx)(Dt.Z,{size:"small",color:"error",onClick:function(){return P({variables:{ePlatformStoreId:o,discountGid:e.discountId}})},children:(0,l.jsx)($.pJ,{className:"text-red-500"})})})})]},e.discountId)}))]})]})})})]}),1===c&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(fe.Z,{className:"flex w-full justify-end gap-2 px-1 py-2",children:(0,l.jsx)(Tt,{ePlatformStoreId:o,onCreated:function(){return b()}})}),(0,l.jsx)(g.Z,{children:(0,l.jsx)(yt.Z,{component:St.Z,children:(0,l.jsxs)(Nt.Z,{size:"small",children:[(0,l.jsx)(Ct.Z,{children:(0,l.jsxs)(It.Z,{children:[(0,l.jsx)(wt.Z,{children:"Title"}),(0,l.jsx)(wt.Z,{children:"Type"}),(0,l.jsx)(wt.Z,{children:"Status"}),(0,l.jsx)(wt.Z,{children:"Summary"}),(0,l.jsx)(wt.Z,{children:"Start"}),(0,l.jsx)(wt.Z,{children:"End"}),(0,l.jsx)(wt.Z,{align:"right",children:"Actions"})]})}),(0,l.jsxs)(kt.Z,{children:[Z&&(0,l.jsx)(It.Z,{children:(0,l.jsx)(wt.Z,{colSpan:7,align:"center",children:(0,l.jsx)($.Ho,{})})}),!Z&&0===C.length&&(0,l.jsx)(It.Z,{children:(0,l.jsx)(wt.Z,{colSpan:7,align:"center",children:(0,l.jsx)(p.Z,{variant:"body2",color:"textSecondary",children:"No auto discounts found"})})}),C.map((function(e){return(0,l.jsxs)(It.Z,{children:[(0,l.jsx)(wt.Z,{children:e.title}),(0,l.jsx)(wt.Z,{children:(0,l.jsx)(te.Z,{label:e.type,size:"small",variant:"outlined"})}),(0,l.jsx)(wt.Z,{children:(0,l.jsx)(te.Z,{label:e.status,size:"small",color:null!==(s=Lt[e.status])&&void 0!==s?s:"default"})}),(0,l.jsx)(wt.Z,{children:null!==(a=e.summary)&&void 0!==a?a:"-"}),(0,l.jsx)(wt.Z,{children:(0,Ie.o0)(e.startsAt)}),(0,l.jsx)(wt.Z,{children:e.endsAt?(0,Ie.o0)(e.endsAt):"-"}),(0,l.jsx)(wt.Z,{align:"right",children:(0,l.jsx)(T.Z,{title:"Delete",children:(0,l.jsx)(Dt.Z,{size:"small",color:"error",onClick:function(){return y({variables:{ePlatformStoreId:o,discountGid:e.discountId}})},children:(0,l.jsx)($.pJ,{className:"text-red-500"})})})})]},e.discountId)}))]})]})})})]})]})},Ft=function(e){var t=e.ePlatformStoreId,n=(0,_.useState)(!1),i=n[0],r=n[1],s=(0,_.useState)(0),a=s[0],o=s[1];return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(j.Z,{variant:"outlined",size:"small",onClick:function(){return r(!0)},children:"Discounts & Collections"}),(0,l.jsxs)(gt.Z,{open:i,onClose:function(){return r(!1)},maxWidth:"lg",fullWidth:!0,PaperProps:{sx:{minHeight:"60vh"}},children:[(0,l.jsx)(Zt.Z,{children:"Shopify Discounts & Collections"}),(0,l.jsxs)(bt.Z,{children:[(0,l.jsxs)(_t.Z,{value:a,onChange:function(e,t){return o(t)},sx:{mb:2},children:[(0,l.jsx)(Pt.Z,{label:"Discounts"}),(0,l.jsx)(Pt.Z,{label:"Collections"})]}),0===a&&(0,l.jsx)(Rt,{ePlatformStoreId:t}),1===a&&(0,l.jsx)(Mt,{ePlatformStoreId:t})]})]})]})};var Ut,qt=function(e){var t=e.filters,n=null===t||void 0===t?void 0:t.ePlatformStoreId,i=null===t||void 0===t?void 0:t.platform,s=(0,r.RB)(),a=s.selectedIds,o=s.setSelectedIds,d=s.refetch,c=(0,_.useMemo)((function(){return a.map((function(e){return e.toString()}))}),[a]);return(0,l.jsxs)("div",{className:"ml-0 md:ml-2",children:[i===B.NX6.Shopee&&(0,l.jsxs)("div",{className:"flex w-full flex-wrap gap-2",children:[(0,l.jsx)(Oe.Z,{ePlatformStoreId:null!==n&&void 0!==n?n:void 0}),(0,l.jsx)(H,{ePlatformStoreId:null!==n&&void 0!==n?n:void 0,children:(0,l.jsx)(Te,{ePlatformStoreId:null!==n&&void 0!==n?n:void 0})}),(0,l.jsx)(qe,{ePlatformStoreId:null!==n&&void 0!==n?n:void 0,children:(0,l.jsx)(jt,{ePlatformStoreId:null!==n&&void 0!==n?n:void 0})}),(0,l.jsx)(U,{ePlatformItemIds:c,onSuccess:function(){o([]),d()}})]}),i===B.NX6.Shopify&&n&&(0,l.jsx)("div",{className:"flex w-full flex-wrap gap-2",children:(0,l.jsx)(Ft,{ePlatformStoreId:n})})]})},Ht={exit:{opacity:0,y:"100%"},enter:{opacity:1,y:0}};!function(e){e.LISTED="LISTED",e.AUTOLISTINGDRAFT="AUTOLISTINGDRAFT"}(Ut||(Ut={}));var Jt=function(e){var t=e.filters,n=e.handleFilter,i=(0,_.useState)(!P.tq),s=i[0],d=i[1],c=(0,r.RB)().setFilters,u=(0,N.Z)((0,B.eci)(),1)[0],m=function(){var e=(0,S.Z)((function(){var e,n;return(0,C.__generator)(this,(function(i){switch(i.label){case 0:return[4,u({variables:{filter:{platform:t.platform},perPage:100}})];case 1:return e=i.sent(),n=e.data,e.loading,[2,(0,M.get)(n,"allEPlatformStores.ePlatformStores").map((function(e){var t=e.shopRegion;return{label:"".concat(null===e||void 0===e?void 0:e.shopName," (").concat(t,")"),value:null===e||void 0===e?void 0:e.id}}))]}}))}));return function(){return e.apply(this,arguments)}}(),x=[{value:!0,label:"Yes"},{value:!1,label:"No"}],h=function(e,t){"eplatformItemType"===e?t===Ut.LISTED?c((function(e){return(0,o.Z)((0,a.Z)({},e),{isAutoListedDraft:!1})})):t===Ut.AUTOLISTINGDRAFT?c((function(e){return(0,o.Z)((0,a.Z)({},e),{isAutoListedDraft:!0,platform:B.NX6.Woocommerce,ePlatformStoreId:void 0})})):c((function(e){return(0,o.Z)((0,a.Z)({},e),{isAutoListedDraft:void 0})})):n(e,t)},f=(0,_.useState)([]),v=f[0],p=f[1];return(0,l.jsx)(V.Z,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between"},children:(0,l.jsxs)(V.Z,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",width:"100%"},children:[(0,l.jsxs)("div",{className:"flex w-full flex-col pb-1 md:flex-row",children:[(0,l.jsx)(k.Z,{name:"platform",value:null===t||void 0===t?void 0:t.platform,label:"",onChange:h,buttonGroupProps:{size:"medium"},filterOptions:(0,M.map)(B.NX6,(function(e){return{value:e,label:e}})),disableClearAll:!0}),(0,l.jsxs)("div",{className:"flex flex-row flex-wrap items-center gap-2",children:[(0,l.jsx)(k.Z,{name:"isUnmatch",value:null===t||void 0===t?void 0:t.isUnmatch,label:"",onChange:h,filterOptions:[{value:!0,label:"Find Unmatched Items"}],buttonGroupProps:{size:"medium"}}),(0,l.jsx)(w.Z,{name:"ePlatformStoreId",label:"".concat(null===t||void 0===t?void 0:t.platform," store"),value:(null===t||void 0===t?void 0:t.ePlatformStoreId)||"",onChange:h,promiseFn:m,className:"w-64",refetchDependencies:[null===t||void 0===t?void 0:t.platform]})]})]}),(0,l.jsxs)("div",{className:"ml-0 flex w-full md:ml-2",children:[(0,l.jsxs)(E.E.div,{className:"".concat(s?"flex w-full flex-col md:flex-row md:flex-wrap":"hidden"),animate:s?"enter":"exit",variants:Ht,children:[(0,l.jsx)(D.Z,{name:"skuOrListingName",placeholder:"Search (Name / Sku)",value:(null===t||void 0===t?void 0:t.skuOrListingName)||"",onChange:h}),(0,l.jsx)(qt,{filters:t}),(0,l.jsx)("div",{className:v.length?"-ml-7 w-full":" ml-2",children:(0,l.jsx)(I.Z,{filters:t,handleFilter:n,selectedProducts:v,setSelectedProducts:p,autoOpenDialog:!1})}),(0,l.jsxs)("div",{hidden:t.platform!==B.NX6.Shopee,className:"ml-2 flex items-center gap-2",children:[(0,l.jsx)(k.Z,{name:"shopeeIsBumping",value:null===t||void 0===t?void 0:t.shopeeIsBumping,label:"Shopee Bumping Item",onCh
1ange:h,filterOptions:x}),(0,l.jsx)(k.Z,{name:"shopeeAutoBump",value:null===t||void 0===t?void 0:t.shopeeAutoBump,label:"Shopee Auto Bump",onChange:h,filterOptions:x}),(0,l.jsx)(k.Z,{name:"shopeeIsPreOrder",value:null===t||void 0===t?void 0:t.shopeeIsPreOrder,label:"Pre-order Item",onChange:h,filterOptions:x})]}),s&&(0,l.jsx)("div",{className:"flex grow justify-end",children:(0,l.jsxs)(j.Z,{size:"small",color:"secondary",onClick:function(){return d(!1)},children:[(0,l.jsx)(A.Ms,{}),"Minimize"]})})]}),(0,l.jsx)("div",{className:"flex grow justify-end",children:!s&&(0,l.jsxs)(j.Z,{size:"small",color:"secondary",onClick:function(){return d(!0)},children:[(0,l.jsx)(A.G6,{}),"Expand"]})})]})]})})},Xt=n(77501),Gt=n(25425),Yt=n(71241),Kt=n(90896),$t=n(26640),Qt=n(25941),en=n(71959),tn=n(13264),nn=(0,tn.Z)(wt.Z)((function(e){e.theme;return{borderBottom:"0px solid"}})),ln=(0,tn.Z)(It.Z)((function(e){return{borderBottomColor:"light"===e.theme.palette.mode?"#e1e1e5":"rgba(74, 74, 81, 1)",borderBottomStyle:"solid",borderBottomWidth:"1px"}})),rn=function(e){var t=e.ePlatformItem,n=e.hideVariantActions,i=void 0!==n&&n,r=t.id,s=t.sku,a=t.price,o=(t.isMatched,t.hasVariation),d=t.variantItems,c=t.depoBalance,u=t.depoFullPrice,m=(t.itemId,t.productVariant);if(!(null!==o&&void 0!==o&&o)){var x,h="woocommerceItemDetails"===(null===(x=t.itemDetails)||void 0===x?void 0:x.__typename)?t.itemDetails.sale_price:null;return(0,l.jsx)(yt.Z,{className:"w-full",children:(0,l.jsx)(Nt.Z,{children:(0,l.jsx)(kt.Z,{children:(0,l.jsxs)(It.Z,{children:[(0,l.jsxs)(nn,{children:[(0,l.jsx)($t.rI,{label:s||"\u274c sku",copy:s,tooltipProps:{placement:"top-end",followCursor:!0}}),(0,l.jsxs)("div",{className:"flex flex-row justify-start",children:[a?(0,l.jsx)(Qt.C,{amount:null===a||void 0===a?void 0:a.amount,currency:null===a||void 0===a?void 0:a.currency}):(0,l.jsx)("div",{children:"\u274c Price"}),h?(0,l.jsxs)("div",{className:"ml-4 flex flex-row gap-1",children:["Sale :"," ",(0,l.jsx)(Qt.C,{amount:parseFloat(h),currency:null===a||void 0===a?void 0:a.currency})]}):null]}),(0,l.jsx)("div",{className:"mt-0 md:mt-1",children:(0,l.jsx)(en.Z,{depoBalance:c,price:a,depoFullPrice:u})})]}),(0,l.jsx)(nn,{hidden:i,children:(0,l.jsx)("div",{className:"flex flex-row justify-end",children:(0,l.jsx)(Kt.Z,{productVariantId:null===m||void 0===m?void 0:m.id,refetch:function(){},popoverProps:{anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}}})})})]})})})})}return(0,l.jsx)(yt.Z,{className:"w-full",children:(0,l.jsx)(Nt.Z,{children:(0,l.jsx)(kt.Z,{children:null===d||void 0===d?void 0:d.map((function(e,t){var n,s,a=null===e||void 0===e?void 0:e.sku,o=null===e||void 0===e?void 0:e.price,c=null===e||void 0===e?void 0:e.id,u=e.depoBalance,m=e.depoFullPrice,x=null===(n=e.productVariant)||void 0===n?void 0:n.id,h="wcVariantItemDetails"===(null===(s=e.itemDetails)||void 0===s?void 0:s.__typename)?e.itemDetails.sale_price:null,f=t+1===(null===d||void 0===d?void 0:d.length);!!r&&!!c&&e.isMatched,!!r&&!!c&&e.isMatched;return(0,l.jsxs)(ln,{sx:{borderBottom:"".concat(f&&"0px solid white !important")},children:[(0,l.jsxs)(nn,{children:[(0,l.jsx)($t.rI,{label:a||"\u274c Sku",copy:a,tooltipProps:{placement:"top-end",followCursor:!0}}),(0,l.jsxs)("div",{className:"flex flex-row justify-start",children:[o?(0,l.jsx)(Qt.C,{amount:null===o||void 0===o?void 0:o.amount,currency:null===o||void 0===o?void 0:o.currency}):(0,l.jsx)("div",{children:"\u274c Price"}),(0,l.jsx)(he.Z,{orientation:"vertical"}),h?(0,l.jsxs)("div",{className:"flex flex-row gap-2",children:["Sale :"," ",(0,l.jsx)(Qt.C,{amount:parseFloat(h),currency:null===o||void 0===o?void 0:o.currency})]}):null]}),(0,l.jsx)("div",{className:"mt-0 md:mt-1",children:(0,l.jsx)(en.Z,{depoBalance:u,price:o,depoFullPrice:m})})]}),(0,l.jsx)(nn,{hidden:i,children:(0,l.jsx)("div",{className:"flex flex-row justify-end",children:(0,l.jsx)(Kt.Z,{productVariantId:x,refetch:function(){},popoverProps:{anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}}})})})]},null===e||void 0===e?void 0:e.id)}
1))})})})},sn=(0,_.forwardRef)((function(e,t){return(0,l.jsx)(Gt.Z,(0,a.Z)({direction:"up",ref:t},e))}));var an=function(e){var t,n=e.onBulkUpdateSuccess,i=(0,_.useState)(!1),s=i[0],a=i[1],o=function(){return a(!1)},d=(0,r.RB)(),c=d.selectedRows,u=d.selectedIds,m="Bulk Config Stocks",x=((0,_.useCallback)((function(){null===n||void 0===n||n(),o()}),[]),c);return(0,l.jsx)("div",{children:(0,l.jsx)(X.Z,{isOpen:s,setIsOpen:a,dialogProps:{open:s,onClose:function(){return o()},maxWidth:"xl",fullScreen:!0,TransitionComponent:sn},button:(0,l.jsxs)(j.Z,{disabled:0===u.length,title:m,onClick:function(){a(!0)},size:"small",variant:"contained",color:"primary",children:[(0,l.jsx)($.dY,{className:"mr-1"})," Stock Config"]}),title:m,children:(0,l.jsx)("div",{children:(0,l.jsx)(yt.Z,{component:St.Z,children:(0,l.jsxs)(Nt.Z,{sx:{minWidth:650},size:"small","aria-label":"a dense table",children:[(0,l.jsx)(Ct.Z,{children:(0,l.jsxs)(It.Z,{children:[(0,l.jsx)(wt.Z,{children:"Item"}),(0,l.jsx)(wt.Z,{align:"left",children:"Image"}),(0,l.jsx)(wt.Z,{align:"left",children:"Variations"})]})}),(0,l.jsx)(kt.Z,{children:x.map((function(e){var n;return(0,l.jsxs)(It.Z,{sx:{"&:last-child td, &:last-child th":{border:0}},children:[(0,l.jsx)(wt.Z,{component:"th",scope:"row",children:(0,l.jsx)(Yt.Z,{row:e})}),(0,l.jsx)(wt.Z,{align:"left",children:(0,l.jsx)(ee.ZP,{className:"h-full flex-col",imgArray:null!==(t=null===(n=e.images)||void 0===n?void 0:n.map((function(e){return{content:e.content,type:e.type,thumbnail:e.thumbnail}})))&&void 0!==t?t:[],numOfImages:1})}),(0,l.jsx)(wt.Z,{align:"right",children:(0,l.jsx)(rn,{ePlatformItem:e})}),(0,l.jsx)(wt.Z,{children:(0,l.jsx)(Xt.ZP,{ePlatformItem:e,variantItems:e.variantItems,sku:e.sku,price:e.price})})]},e.id)}))})]})})})})})};var on=function(){var e=(0,r.RB)(),t=e.selectedRows,n=e.setSelectedIds,i=(0,_.useMemo)((function(){var e=[];return t.forEach((function(t){t.itemId||e.push(t.id)})),e}),[t]),s=(0,N.Z)((0,B.Ab2)({variables:{ePlatformItemIds:i}}),2),a=s[0],o=s[1],d=o.client,c=o.loading,u=function(){var e=(0,S.Z)((function(){var e,t,l,r,s,o,u,m,x,h;return(0,C.__generator)(this,(function(f){switch(f.label){case 0:return c?[2]:[4,a()];case 1:return r=f.sent(),s=null===(e=r.data)||void 0===e?void 0:e.bulkListToEPlatform,u=null!==(o=null===s||void 0===s||null===(t=s.success)||void 0===t?void 0:t.length)&&void 0!==o?o:0,x=null!==(m=null===s||void 0===s||null===(l=s.errorMessage)||void 0===l?void 0:l.length)&&void 0!==m?m:0,u>0&&((0,z.x9)("Listed ".concat(u," item(s) to e-platform")),d.cache.evict({fieldName:"allEPlatformItems"}),n([])),x>0&&(null===s||void 0===s||null===(h=s.errorMessage)||void 0===h||h.forEach((function(e){(0,z._N)(e)}))),0===u&&0===x&&(0,At.ZP)("Selected ".concat(i.length," item(s) appear to already be listed"),{duration:5e3,icon:"\u2139\ufe0f"}),[2]}}))}));return function(){return e.apply(this,arguments)}}();return 0===i.length?null:(0,l.jsx)("div",{children:(0,l.jsxs)(j.Z,{disabled:c,size:"small",variant:"outlined",onClick:u,children:[c&&(0,l.jsx)($.Ho,{className:"mr-1 animate-spin"})," List to Eplatform (",i.length,")"]})})},dn=n(44162),cn=n(48308),un=n(33342),mn=n(85214),xn=n(81284),hn=n(30062),fn=n(81079),vn=n(91359),pn=n(42057),jn=n(20437),gn=n(96113),Zn=n(86286),bn=n(11304),_n=function(e){var t=e.label,n=e.value;return(0,l.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,l.jsxs)("span",{className:"shrink-0 opacity-60",children:[t,":"]}),(0,l.jsx)("span",{className:"ml-2 min-w-0 text-right font-medium",children:n})]})},Pn=function(e){var t=e.row;return(0,l.jsx)(g.Z,{className:"w-full",children:(0,l.jsxs)(vn.Z,{sx:{p:1.5,"&:last-child":{pb:1.5}},children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,l.jsx)("div",{className:"min-w-0 flex-1",children:(0,l.jsx)(Yt.Z,{row:t})}),(0,l.jsxs)("div",{onClick:G.UW,className:"flex shrink-0 flex-wrap items-center justify-end gap-1",children:[(0,l.jsx)(fn.Z,{row:t}),(0,l.jsx)(hn.Z,{row:t}),(0,l.jsx)(pn.Z,{ePlatformItemId:t.id}),(0,l.jsx)(Zn.Z,{row:t}),(0,l.jsx)(jn.Z,{ePlatformItemId:t.id}),(0,l.jsx)(gn.Z,{ePlatformItemId:t.id})]})]}),(0,l.jsx)(he.Z,{className:"!my-2"}),(0,l.jsxs)("div",{className:"grid grid-cols-1 gap-2 text-sm",children:[(0,l.jsx)("div",{className:"-mx-1",children:(0,l.jsx)(et.Z,{ePlatformItem:t})}
1),(0,l.jsx)(_n,{label:"Listed By",value:(0,l.jsx)(bn.Z,{row:t})})]})]})})},yn=function(e){var t=e.rows;return(0,l.jsx)(mn.Z,{children:null===t||void 0===t?void 0:t.map((function(e,t){return(0,l.jsx)(xn.ZP,{sx:(0,un.g)(t),children:(0,l.jsx)(Pn,{row:e})},e.id)}))})},Sn=n(61778),Nn=function(){var e=(0,r.RB)(),t=e.filters,n=e.setFilters,i=[{label:"Listed",conditions:{isAutoListedDraft:!1},onClick:function(){return n((function(e){return(0,o.Z)((0,a.Z)({},e),{isAutoListedDraft:!1,ePlatformStoreId:void 0})}))}},{label:"Auto Listing Drafts",conditions:{isAutoListedDraft:!0},onClick:function(){return n((function(e){return(0,o.Z)((0,a.Z)({},e),{isAutoListedDraft:!0,platform:B.NX6.Woocommerce,ePlatformStoreId:void 0})}))}}];return(0,l.jsx)(Sn.ZP,{filters:t,setFilters:n,optionList:i})},Cn=function(e){var t=(0,h.a)().user,n=(0,f.b)(t),i=(0,r.RB)(),S=i.selectedRows,N=i.selectedIds,C=i.setSelectedIds,I=i.filters,w=i.setFilters,k=i.rows,D=i.totalRows,A=i.page,B=i.setPage,V=i.pageSize,E=i.setPageSize,M=i.loading,z=(0,dn.e)().setEplatformItems,W=(0,_.useCallback)((function(e,t){w((function(n){return(0,o.Z)((0,a.Z)({},n),(0,s.Z)({},e,t))}))}),[w]),T=(0,_.useCallback)((function(){return"auto"}),[]);(0,_.useEffect)((function(){z(S)}),[S,z]);var O=(0,_.useCallback)((function(){C([])}),[C]);(0,_.useEffect)((function(){(null===n||void 0===n?void 0:n.company.id)&&C([])}),[null===n||void 0===n?void 0:n.company.id]);var L=(0,_.useState)(!0),R=L[0],F=L[1];return R?(0,l.jsxs)(v.ZP,{container:!0,spacing:6,children:[(0,l.jsx)(x.Z,{title:(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)(p.Z,{variant:"h5",onClick:function(){F(!1),setTimeout((function(){F(!0)}),500)},children:"All Eplatform Items"}),(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)(on,{}),(0,l.jsx)(an,{}),(0,l.jsx)(cn.Z,{onBulkUpdateSuccess:O}),(0,l.jsxs)(j.Z,{variant:"outlined",color:"error",size:"small",disabled:0===N.length,onClick:function(){return C([])},children:["Clear (",N.length,")"]}),(0,l.jsx)(d.Z,{color:"primary"})]})]})}),(0,l.jsx)(v.ZP,{item:!0,xs:12,children:(0,l.jsx)(v.ZP,{container:!0,spacing:6,children:(0,l.jsxs)(v.ZP,{item:!0,xs:12,children:[(0,l.jsx)(g.Z,{className:"mb-1 p-5",children:(0,l.jsx)(Jt,{filters:I,handleFilter:W})}),(0,l.jsx)(Nn,{}),P.tq?(0,l.jsxs)("div",{className:"pb-16",children:[M&&!k.length?(0,l.jsx)("div",{className:"flex justify-center py-10",children:(0,l.jsx)(Z.Z,{})}):k.length?(0,l.jsx)(yn,{rows:k}):(0,l.jsx)(c.u,{compact:!0,variant:"filtered",title:"No e-platform items match your filters"}),(0,l.jsx)(m.Z,{page:A,setPage:B,pageSize:V,setPageSize:E,totalRows:D,rowsPerPageOption:[10,25,50,100]})]}):(0,l.jsx)(g.Z,{children:(0,l.jsx)(u.Z,{children:(0,l.jsx)(b.s,{pagination:!0,page:A,pageSize:V,rowCount:D,rows:k,columns:y.P,loading:M,paginationMode:"server",onPageSizeChange:E,onPageChange:B,rowsPerPageOptions:[10,25,50,100],throttleRowsMs:2e3,getRowHeight:T,autoHeight:!0,initialState:{pinnedColumns:{right:["actions"]}},components:{Pagination:m.Z},checkboxSelection:!0,keepNonExistentRowsSelected:!0,disableSelectionOnClick:!1,selectionModel:N,onSelectionModelChange:function(e){C(e)},componentsProps:{pagination:{page:A,setPage:B,pageSize:V,setPageSize:E,totalRows:D}}})})})]})})})]}):null},In=function(){return(0,l.jsx)(r.y5,{storeParamsInUrl:!0,defaultFilters:{platform:B.NX6.Shopee,isAutoListedDraft:!1},children:(0,l.jsx)(dn.OZ,{children:(0,l.jsx)(Cn,{})})})}}},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,6709,9774,2888,179],(function(){return t=92265,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.