1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6486],{5609:(e,s,t)=>{"use strict";t.r(s),t.d(s,{__N_SSP:()=>eQ,default:()=>eY});var r=t(37876),l=t(87966),a=t(78394);let i=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 16 16",fill:"none",...l,children:(0,r.jsx)("path",{d:"M13.125 9.65625V12.9375C13.125 13.1861 13.0262 13.4246 12.8504 13.6004C12.6746 13.7762 12.4361 13.875 12.1875 13.875H2.8125C2.56386 13.875 2.3254 13.7762 2.14959 13.6004C1.97377 13.4246 1.875 13.1861 1.875 12.9375V9.65625C1.875 9.53193 1.92439 9.4127 2.01229 9.32479C2.1002 9.23689 2.21943 9.1875 2.34375 9.1875C2.46807 9.1875 2.5873 9.23689 2.67521 9.32479C2.76311 9.4127 2.8125 9.53193 2.8125 9.65625V12.9375H12.1875V9.65625C12.1875 9.53193 12.2369 9.4127 12.3248 9.32479C12.4127 9.23689 12.5319 9.1875 12.6562 9.1875C12.7806 9.1875 12.8998 9.23689 12.9877 9.32479C13.0756 9.4127 13.125 9.53193 13.125 9.65625ZM7.16836 9.98789C7.21189 10.0315 7.26359 10.066 7.3205 10.0896C7.3774 10.1132 7.4384 10.1254 7.5 10.1254C7.5616 10.1254 7.6226 10.1132 7.6795 10.0896C7.73641 10.066 7.78811 10.0315 7.83164 9.98789L10.1754 7.64414C10.2189 7.60059 10.2535 7.54889 10.2771 7.49198C10.3006 7.43508 10.3128 7.37409 10.3128 7.3125C10.3128 7.25091 10.3006 7.18992 10.2771 7.13302C10.2535 7.07611 10.2189 7.02441 10.1754 6.98086C10.1318 6.93731 10.0801 6.90276 10.0232 6.87919C9.96633 6.85562 9.90534 6.84349 9.84375 6.84349C9.78216 6.84349 9.72117 6.85562 9.66427 6.87919C9.60736 6.90276 9.55566 6.93731 9.51211 6.98086L7.96875 8.52481V3.09375C7.96875 2.96943 7.91936 2.8502 7.83146 2.76229C7.74355 2.67439 7.62432 2.625 7.5 2.625C7.37568 2.625 7.25645 2.67439 7.16854 2.76229C7.08064 2.8502 7.03125 2.96943 7.03125 3.09375V8.52481L5.48789 6.98086C5.39993 6.8929 5.28064 6.84349 5.15625 6.84349C5.03186 6.84349 4.91257 6.8929 4.82461 6.98086C4.73665 7.06882 4.68724 7.18811 4.68724 7.3125C4.68724 7.43689 4.73665 7.55618 4.82461 7.64414L7.16836 9.98789Z",fill:t})})};var d=t(49995);let n=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 25 27",fill:"none",...l,children:[(0,r.jsx)("path",{d:"M19.1665 5H6.1665C5.61422 5 5.1665 5.4757 5.1665 6.0625V23.0625C5.1665 23.6493 5.61422 24.125 6.1665 24.125H19.1665C19.7188 24.125 20.1665 23.6493 20.1665 23.0625V6.0625C20.1665 5.4757 19.7188 5 19.1665 5Z",stroke:t,strokeWidth:"1.5",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M9.66748 2.875V6.0625M15.6675 2.875V6.0625M8.66748 10.8438H16.6675M8.66748 15.0938H14.6675M8.66748 19.3438H12.6675",stroke:t,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})},o=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{width:s,height:s,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l,children:(0,r.jsx)("path",{id:"Vector",d:"M12 6V14M12.0498 18V18.1L11.9502 18.1002V18H12.0498Z",stroke:t,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})};var c=t(32625),u=t(54611),m=t(99712),x=t(14232);let p=(0,x.createContext)(null),h={sortKey:"created_at",sortType:"desc"},v={expand:"outlet,outlet.geographicalLocations,items,items.variant,items.variant.product,fulfillments,invoices,customer,depot",fields:"id,status,display_id,created_at,email,fulfillment_status,payment_status,total,currency_code,metadata,tax_rate,depot_id,outlet_id,credit_checked,inventory_checked,promotion_checked,customer_id,is_processing,region,extended_status",offset:0,limit:20,order:(0,m.E8)(h)},f=e=>{let{children:s}=e,{depot:t,setDepot:l}=(0,u.X)(),[a,i]=(0,x.useState)(null),[d,n]=(0,x.useState)(null),[o,c]=(0,x.useState)([]),[m,h]=(0,x.useState)(null),[f,b]=(0,x.useState)(null),[j,g]=(0,x.useState)(0),[C,N]=(0,x.useState)(0),[y,_]=(0,x.useState)(0),[w,k]=(0,x.useState)(!0),[A,S]=(0,x.useState)({...v,...t?{depot_id:t}:{}}),[L,O]=(0,x.useState)(!1),[V,M]=(0,x.useState)(!1);(0,x.useEffect)(()=>{if(w)k(!1),l(null);else{let e={...A,offset:0};t?e.depot_id=t:delete e.depot_id,S(e)}},[t,w]);let F=(0,x.useMemo)(()=>({clickedOrder:a,setClickedOrder:i,stockLocation:d,setStockLocation:n,orders:o,setOrders:c,orderExtended:m,setOrderExtended:h,queryOrdersObject:A,setQueryOrdersObject:S,orderFilterType:f,setOrderFilterType:b,numberOrderReadyInvoiced:j,setNumberOrderReadyInvoiced:g,numberOrderActive:C,setNumberOrderActive:N,numberOrderNeedReview:y,setNumberOrderNeedReview:_,isInitState:w,preventPageChangeTable:L,setPreventPageChangeTable:O,isRefetchOrderDetail
1:V,setIsRefetchOrderDetail:M}),[a,d,o,m,A,f,j,C,y,V]);return(0,r.jsx)(p.Provider,{value:F,children:s})},b=()=>(0,x.useContext)(p);var j=t(71422),g=t(97685),C=t(85780),N=t(9843),y=t(64050);let _=e=>{var s;let{orders:t,setOrders:r,orderExtended:l,setOrderExtended:a,setNumberOrderReadyInvoiced:i,setNumberOrderActive:d,setNumberOrderNeedReview:n}=b(),{isFeatureEnabled:o}=(0,C.u)(),[c,u]=(0,x.useState)(null),[p,h]=(0,x.useState)([]),[v,f]=(0,x.useState)(!1),[_,w]=(0,x.useState)(!1),[k,A]=(0,x.useState)(!1),[S,L]=(0,x.useState)(!1),[O,V]=(0,x.useState)(!1),[M,F]=(0,x.useState)(!1),[H,E]=(0,x.useState)(!1),[q,z]=(0,x.useState)(!1),[B,Z]=(0,x.useState)(!1),[P,T]=(0,x.useState)(!1),[I,D]=(0,x.useState)(!1),[R,G]=(0,x.useState)(!1),[K,X]=(0,x.useState)(!1),J=o("inventoryService")&&o("stockLocationService"),{stock_locations:U,refetch:W}=(0,j.rFV)({name:null==e||null==(s=e.depot)?void 0:s.external_id},{enabled:!1}),{mutate:$,isLoading:Q}=(0,j.p53)(null==e?void 0:e.id),{mutate:Y,isLoading:ee}=(0,j.udj)(null==e?void 0:e.id),{mutate:es,isLoading:et}=(0,j.b6G)(null==e?void 0:e.id),er=(0,x.useMemo)(()=>(null==e?void 0:e.credit_checked)&&(null==e?void 0:e.inventory_checked)&&(null==e?void 0:e.promotion_checked)&&"cancelled"!==(0,m.ih)(e),[e,null==e?void 0:e.credit_checked,null==e?void 0:e.inventory_checked,null==e?void 0:e.promotion_checked]);(0,x.useEffect)(()=>{e&&(W(),h(e.items))},[e]),(0,x.useEffect)(()=>{var s,t;(null==U?void 0:U.length)&&(null==e||null==(s=e.depot)?void 0:s.external_id)===(null==(t=U[0])?void 0:t.name)?u(U[0]):u(null)},[U]);let el=(s,l)=>{let i={...e},d=[...t],n=d.findIndex(e=>e.id===i.id);for(let e of l){var o,c;i[e.key]=null!=(o=e.value)?o:s[e.key],d[n][e.key]=null!=(c=e.value)?c:s[e.key]}s.id===e.id&&a(i),r(d)},ea=(s,t)=>{let r=s||e,l={order_ids:[null==r?void 0:r.id]};f(!0),y.A.invoices.generate(l).then(e=>{var l,a,i,d;let{data:n}=e;if(null==n||null==(l=n.downloaded)?void 0:l.length){if(!(null==r||null==(a=r.invoices)?void 0:a.length)){let e=[{key:"invoices",value:[null==n||null==(d=n.downloaded)||null==(i=d[0])?void 0:i.invoice]}];s&&(e.push({key:"fulfillment_status"}),e.push({key:"fulfillments"})),e.push({key:"extended_status",value:"invoiced"}),el(r,e),g.Ay.success("Order is generated invoice successfully")}null==t||t(n)}else g.Ay.error("Failed to generate invoice")}).catch(e=>{g.Ay.error("Failed to generate invoice")}).finally(()=>{f(!1)})};return{isLoadingCreateOrderFulfillment:Q,isLoadingUpdateOrder:ee,isLoadingGenerateInvoice:v,isLoadingCancelOrder:et,isLoadingDownloadInvoice:_,isAllowAction:er,isLoadingInventoryCheck:k,isLoadingCreditCheck:S,isLoadingPromotionCheck:O,isLoadingOrderActive:q,isLoadingOrderNeedReview:P,isLoadingOrderReadyInvoiced:M,isLoadingNumberOrderReadyInvoiced:H,isLoadingNumberOrderActive:B,isLoadingNumberOrderNeedReview:I,isLoadingEditOrder:R,isLoadingUpdateStatus:K,changeProcessingStatus:()=>{Y({is_processing:!0},{onSuccess:e=>{let{order:s}=e;el(s,[{key:"is_processing",value:!0},{key:"extended_status",value:"processing"}]),g.Ay.success("Order is updated successfully to Processing")},onError:e=>g.Ay.error("Failed to mark Processing")})},changeCancelStatus:e=>{es(void 0,{onSuccess:s=>{let{order:t}=s;el(t,[{key:"status"},{key:"extended_status",value:"cancelled"}]),g.Ay.success("Successfully cancelled order"),null==e||e()},onError:e=>g.Ay.error((0,N.u)(e))})},handleGenerateInvoice:s=>{(null==e?void 0:e.fulfillment_status)==="not_fulfilled"||(null==e?void 0:e.fulfillment_status)==="canceled"?(s=>{let t;t={metadata:{},no_notification:!1};if(!p.length)return g.Ay.error("Order has no item");t.items=Object.entries(e.items.reduce((e,s)=>({...e,[s.id]:(e=>e.quantity-(e.fulfilled_quantity||0))(s)}),{})).filter(e=>{let[,s]=e;return!!s}).map(e=>{let[s,t]=e;return{item_id:s,quantity:t}}),J&&(t.location_id=null==c?void 0:c.id),$(t,{onSuccess:e=>{let{order:t}=e;el(t,[{key:"fulfillment_status"},{key:"fulfillments"}]),g.Ay.success("Successfully fulfilled order"),null==s||s(t)},onError:e=>g.Ay.error((0,N.u)(e))})})(e=>{ea(e,t=>{null==s||s(e,t)})}):ea(void 0,e=>{null==s||s(null,e)})}
1,handleDownloadInvoice:(e,s)=>{w(!0),y.A.invoices.download(e).then(e=>{let{data:t}=e,r=window.URL.createObjectURL(new Blob([t],{type:"application/pdf"}));null==s||s(r)}).catch(e=>{g.Ay.error("Something is wrong")}).finally(()=>{w(!1)})},handleInventoryCheck:(s,t)=>{A(!0),y.A.orders.inventoryChecked(null==e?void 0:e.id).then(e=>{let{data:t}=e;el(t,[{key:"inventory_checked"}]),g.Ay.success("Inventory check is updated successfully"),null==s||s()}).catch(e=>{g.Ay.error("Something is wrong"),null==t||t()}).finally(()=>{A(!1)})},handleCreditCheck:(s,t)=>{L(!0),y.A.orders.creditChecked(null==e?void 0:e.id).then(e=>{let{data:t}=e;el(t,[{key:"credit_checked"}]),g.Ay.success("Credit check is updated successfully"),null==s||s()}).catch(e=>{g.Ay.error("Something is wrong"),null==t||t()}).finally(()=>{L(!1)})},handlePromotionCheck:(s,t)=>{V(!0),y.A.orders.promotionChecked(null==e?void 0:e.id).then(e=>{let{data:t}=e;el(t,[{key:"promotion_checked"}]),g.Ay.success("Promotion check is updated successfully"),null==s||s()}).catch(e=>{g.Ay.error("Something is wrong"),null==t||t()}).finally(()=>{V(!1)})},getOrderReadyInvoiced:(e,s)=>{F(!0),y.A.orders.orderActive().then(s=>{let{data:t}=s;null==e||e(t)}).catch(e=>{g.Ay.error("Failed to load orders ready invoiced"),null==s||s()}).finally(()=>{F(!1)})},getOrderActive:(e,s,t)=>{z(!0),y.A.orders.orderActive(e).then(e=>{let{data:t}=e;null==s||s(t)}).catch(e=>{g.Ay.error("Failed to load orders active"),null==t||t()}).finally(()=>{z(!1)})},getOrderNeedReview:(e,s,t)=>{T(!0),y.A.orders.orderNeedReview(e).then(e=>{let{data:t}=e;null==s||s(t)}).catch(e=>{g.Ay.error("Failed to load orders need review"),null==t||t()}).finally(()=>{T(!1)})},getNumberOrderReadyInvoiced:(e,s,t)=>{E(!0),y.A.orders.numberOrderReadyInvoiced(e).then(e=>{let{data:{count:t}}=e;i(t),null==s||s(t)}).catch(e=>{g.Ay.error("Failed to load number of orders ready invoiced"),null==t||t()}).finally(()=>{E(!1)})},getNumberOrderActive:(e,s,t)=>{Z(!0),y.A.orders.numberOrderActive(e).then(e=>{let{data:{count:t}}=e;d(t),null==s||s(t)}).catch(e=>{g.Ay.error("Failed to load number of orders active"),null==t||t()}).finally(()=>{Z(!1)})},getNumberOrderNeedReview:(e,s,t)=>{D(!0),y.A.orders.numberOrderNeedReview(e).then(e=>{let{data:{count:t}}=e;n(t),null==s||s(t)}).catch(e=>{g.Ay.error("Failed to load number of orders new review"),null==t||t()}).finally(()=>{D(!1)})},getOrderEvents:(s,t)=>{y.A.orders.events(null==e?void 0:e.id).then(e=>{let{data:t}=e;null==s||s(null==t?void 0:t.order_events)}).catch(e=>{g.Ay.error("Cannot get order events"),null==t||t()})},editOrder:(s,t,r)=>{G(!0),y.A.orders.editOrder(null==e?void 0:e.id,s).then(e=>{let{order:s}=e.data;el(s,[{key:"is_processing",value:!0},{key:"extended_status",value:"processing"},{key:"invoices",value:[]}]),null==t||t()}).catch(e=>{g.Ay.error((0,N.u)(e))}).finally(()=>{G(!1),null==r||r()})},isAllowMultipleUpdateStatus:e=>{let s={...e[0]};return!e.some(e=>!((e=>e.credit_checked&&e.inventory_checked&&e.promotion_checked&&"cancelled"!==(0,m.ih)(e))(e)&&s.extended_status===e.extended_status))},updateExtendedStatus:(e,s,i)=>{X(!0),y.A.orderExtendStatus.update({order_ids:e.map(e=>e.id),status:s}).then(e=>{let{data:{errors:d,saved:n}}=e;if(((e,s)=>{let i={...l},d=[...t];e.forEach(e=>{let t=d.findIndex(s=>s.id===e.id);for(let a of s){var r,l;e.id===i.id&&(i[a.key]=null!=(r=a.value)?r:e[a.key]),t>=0&&(d[t][a.key]=null!=(l=a.value)?l:e[a.key])}}),a(i),r(d)})(n,[{key:"fulfillment_status"},{key:"fulfillments"},{key:"extended_status"},{key:"actual_delivery_date"},{key:"invoices"}]),null==d?void 0:d.length){let e=[];for(let s of d){var o;e.push("Order ".concat(s.order_id,": ").concat(null==(o=s.error)?void 0:o.message))}g.Ay.error('Fail update to "'.concat(s,'"\n').concat(e.join("\n"))),(null==n?void 0:n.length)&&g.Ay.success('Success update to "'.concat(s,'"\n').concat(n.map(e=>"".concat(e.order_id)).join(", ")))}else g.Ay.success('Success update to "'.concat(s,'"'));null==i||i()}).catch(e=>{g.Ay.error((0,N.u)(e))}).finally(()=>{X(!1)})},getGMTTimeFromExternalId:(e,s)=>{let t="";if(e){let r=null==s?void 0:s.find(s=>s.id===e);t=(null==r?void 0:r.external_id)||""}else{var r;t=(null==s||null==(r=s[1])?void 0:r.external_id)||""}return 60*(t.toUpperCase().includes("BBI")?8:7*!!t.toUpperCase().includes("BSR"))}}};var w=t(43406),k=t(57368);let A=[{label:"distributors.orders.create-order-panel.steps.choose-order-type.point-title"},{label:"distributors.orders.create-order-panel.steps.select-customer.point-title"},{label:"distributors.orders.create-order-panel.steps.add-products.point-title"},{label:"distributors.orders.create-order-panel.steps.confirm.point-title"}],S={selectedIndex:0,steps:{type:{isCustomer:!1,isHeineken:!1},customer:{shipping_address:{outlet_name:"",area:"",address:"",contact_name:"",contact_number:""},billing_address:{address:"",contact_name:"",contact_number:""},selectedOutlet:{}},products:{values:[]},confirm:{value:{}},success:""}},L=(0,x.createContext)({createOrderState:S,setCreateOrderState:e=>{}}),O=e=>{let{children:s}=e,[t,l]=(0,x.useState)(S);return(0,r.jsx)(L.Provider,{value:{createOrderState:t,setCreateOrderState:l},children:s})};var V=t(38227),M=t(2193),F=t(9519),H=t(31515);let E=e=>{let{size:s="100",color:t="currentColor",...l}=e;return(0,r.jsxs)("svg",{width:s,height:s,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l,children:[(0,r.jsx)("path",{id:"Vector",d:"M50.2002 84C31.4002 84 16.2002 68.8 16.2002 50C16.2002 31.2 31.4002 16 50.2002 16C69.0002 16 84.2002 31.2 84.2002 50C84.2002 68.8 68.8002 84 50.2002 84ZM50.2002 20C33.6002 20 20.2002 33.4 20.2002 50C20.2002 66.6 33.6002 80 50.2002 80C66.8002 80 80.2002 66.6 80.2002 50C80.2002 33.4 66.6002 20 50.2002 20Z",fill:t}),(0,r.jsx)("path",{id:"Vector_2",d:"M30.6 74.6L27 73C28 70.6 31.2 69.2 34.6 67.6C38 66 42.2 64.2 42.2 62V59C41 58 39 55.8 38.6 52.6C37.6 51.6 36 49.8 36 47.4C36 46 36.6 44.8 37 44C36.6 42.4 36.2 39.4 36.2 37C36.2 29.2 41.6 24 50.2 24C52.6 24 55.6 24.6 57.2 26.4C61 27.2 64.2 31.6 64.2 37C64.2 40.4 63.6 43.2 63.2 44.6C63.6 45.2 64 46.2 64 47.4C64 50 62.6 51.8 61.4 52.6C61 55.8 59.2 57.8 58 58.8V62C58 63.8 61.6 65.2 64.8 66.4C68.6 67.8 72.6 69.4 74 72.6L70.2 74C69.6 72.4 66.4 71.2 63.4 70.2C59 68.6 54 66.8 54 62.2V57L55 56.4C55 56.4 57.4 54.8 57.4 51.6V50.2L58.6 49.6C58.8 49.6 59.8 49 59.8 47.4C59.8 47 59.4 46.4 59.2 46.2L58.4 45.4L58.8 44.4C58.8 44.4 59.8 41.2 59.8 37.2C59.8 33.4 57.6 30.6 55.8 30.6H54.6L54 29.6C54 28.8 52.6 28 50.2 28C44 28 40.2 31.4 40.2 37C40.2 39.6 41.2 44 41.2 44L41.4 45L40.6 46C40.4 46 40 46.6 40 47.4C40 48.4 41.2 49.6 41.8 50L42.6 50.6V51.6C42.6 54.6 45.2 56.2 45.2 56.4L46.2 57V62.2C46.2 67 41 69.4 36.2 71.4C34 72.2 31 73.6 30.6 74.6Z",fill:t})]})},q=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{width:s,height:s,viewBox:"0 0 146 34",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l,children:(0,r.jsxs)("g",{id:"Group",children:[(0,r.jsx)("path",{id:"Vector",d:"M0.00219216 8.49699C0.122758 8.2947 0.317856 8.2881 0.521723 8.2903C3.1676 8.2925 5.81348 8.2881 8.45937 8.2991C8.72461 8.2991 8.83641 8.22433 8.91971 7.96706C9.73079 5.42953 10.5572 2.89859 11.3771 0.365457C11.4341 0.191743 11.4757 0.0114327 11.7059 0.000438213C11.9602 -0.0105563 12.0106 0.187344 12.0698 0.367654C12.8962 2.90959 13.7248 5.45372 14.5381 8.00004C14.6126 8.23533 14.7113 8.30129 14.9524 8.30129C17.5676 8.2925 20.1806 8.2947 22.7958 8.2947C22.8791 8.2947 22.9646 8.2969 23.0479 8.2947C23.2057 8.2925 23.346 8.32328 23.403 8.4948C23.4622 8.67511 23.3745 8.79605 23.2342 8.8972C22.8002 9.21164 22.3661 9.53048 21.9321 9.84712C21.0969 10.4562 20.2595 11.0609 19.4287 11.6722C19.2774 11.7844 19.1262 11.8349 18.9355 11.8349C17.5435 11.8283 16.1515 11.8173 14.7617 11.8415C14.4307 11.8481 14.3189 11.7316 14.2268 11.4369C13.8213 10.1308 13.3894 8.83123 12.9664 7.52948C12.94 7.45252 12.9094 7.37556 12.8611 7.24362C12.5893 8.07481 12.3372 8.85322 12.0829 9.63163C11.8747 10.2715 11.6555 10.9092 11.4648 11.5557C11.399 11.7822 11.2894 11.8371 11.068 11.8349C9.70887 11.8239 8.34757 11.8283 6.98846 11.8305C6.87885 11.8305 6.76267 11.7997 6.62018 11.8767C6.75609 11.9801 6.87228 12.0768 6.99503 12.1648C8.06917 12.9454 9.13892 13.7304 10.2196 14.5022C10.3906 14.6231 10.4432 14.7243 10.3731 14.9332C9.91493 16.3119 9.46993 17.695 9.02274 19.0759C8.97451 19.2232 8.89779 19.331 8.77065 19.4211C7.51457 20.3293 6.26287 21.2418 5.01117 22.1544C4.85553 22.2687 4.69989 22.4007 4.50041 22.2687C4.27462 22.1192 4.38203 21.9103 4.44341 21.7256C5.24792 19.243 6.04585 16.7561 6.87008 14.2801C6.98188 13.9437 6.94023 13.7744 6.64649 13.5633C4.53987 12.0526 2.44859 10.5222 0.350738 8.99615C0.223596 8.90379
10.0920688 8.81584 0 8.6861C0.00219211 8.62453 0.00219216 8.56076 0.00219216 8.49699Z",fill:t}),(0,r.jsx)("path",{id:"Vector_2",d:"M29.1048 24.7715C29.1048 27.7378 29.1004 30.7064 29.1113 33.6727C29.1113 33.9453 29.0346 33.9959 28.7781 33.9937C27.3335 33.9805 25.8889 33.9805 24.4443 33.9937C24.2032 33.9959 24.1506 33.9299 24.1528 33.6969C24.1615 31.2363 24.155 28.7757 24.1637 26.3151C24.1637 26.0623 24.1177 25.9765 23.8437 25.9787C22.6095 25.9941 21.3776 25.9919 20.1434 25.9809C19.9001 25.9787 19.8277 26.0381 19.8299 26.291C19.8409 28.7405 19.8321 31.1901 19.8409 33.6397C19.8409 33.9058 19.7949 33.9981 19.5011 33.9959C18.0565 33.9783 16.6119 33.9805 15.1673 33.9937C14.9152 33.9959 14.8604 33.9255 14.8604 33.6815C14.867 28.3909 14.8626 23.1004 14.8714 17.8098C14.8714 17.1897 14.742 16.6774 14.1787 16.3189C13.9507 16.1738 14.0822 15.8682 14.0997 15.6417C14.1107 15.4724 14.308 15.5537 14.4176 15.5537C16.1143 15.5471 17.8132 15.5559 19.5099 15.5449C19.7686 15.5427 19.8453 15.6109 19.8431 15.8748C19.8321 18.0187 19.8431 20.1626 19.8299 22.3066C19.8277 22.577 19.9045 22.6342 20.1631 22.632C21.3863 22.6166 22.6095 22.6144 23.8327 22.6342C24.1309 22.6386 24.1681 22.5396 24.1659 22.278C24.155 20.145 24.1637 18.0121 24.155 15.8792C24.1528 15.6241 24.2076 15.5405 24.4794 15.5449C25.913 15.5603 27.3467 15.5581 28.7803 15.5449C29.0412 15.5427 29.1135 15.6065 29.1113 15.8704C29.1004 18.8367 29.1048 21.8052 29.1048 24.7715Z",fill:t}),(0,r.jsx)("path",{id:"Vector_3",d:"M134.539 23.6033C134.563 23.8914 134.598 24.1794 134.607 24.4675C134.694 27.5591 134.622 30.653 134.651 33.7468C134.653 33.9491 134.583 33.9931 134.396 33.9909C133.322 33.9821 132.246 33.9799 131.172 33.9931C130.961 33.9953 130.937 33.9162 130.937 33.7381C130.941 27.7636 130.939 21.787 130.942 15.8126C130.942 15.7005 130.88 15.5465 131.099 15.5487C131.943 15.5575 132.787 15.5355 133.627 15.5729C134.747 15.6213 135.554 16.2062 136.143 17.1429C137.546 19.3726 138.962 21.5935 140.372 23.8166C140.775 24.4543 141.181 25.0898 141.584 25.723C141.42 22.4445 141.545 19.1769 141.499 15.9115C141.494 15.6345 141.549 15.5377 141.852 15.5421C143.127 15.5619 144.403 15.5553 145.677 15.5443C145.914 15.5421 146.01 15.5861 145.999 15.85C145.99 16.1138 145.973 16.3139 145.708 16.4745C145.388 16.668 145.236 17.0044 145.217 17.3848C145.21 17.5211 145.206 17.6597 145.206 17.796C145.208 22.7897 145.208 27.7834 145.212 32.7771C145.212 33.1026 145.175 33.4082 144.945 33.6611C144.741 33.8832 144.487 33.9865 144.186 33.9865C143.248 33.9865 142.31 33.9777 141.372 33.9931C141.163 33.9975 141.1 33.8722 141.019 33.7403C139.116 30.7322 137.211 27.7241 135.308 24.7138C135.069 24.3355 134.828 23.9573 134.589 23.5813C134.574 23.5901 134.556 23.5967 134.539 23.6033Z",fill:t}),(0,r.jsx)("path",{id:"Vector_4",d:"M64.2488 23.5441C64.3978 24.958 64.3189 26.3543 64.3255 27.7462C64.3365 29.7318 64.3233 31.7152 64.3343 33.7008C64.3365 33.9383 64.2751 33.9999 64.0383 33.9977C62.9839 33.9845 61.9295 33.9867 60.8773 33.9955C60.6712 33.9977 60.6099 33.9405 60.6099 33.7294C60.6164 27.755 60.6142 21.7784 60.6142 15.804C60.6142 15.6787 60.5879 15.5445 60.7918 15.5489C61.6555 15.5665 62.5192 15.5159 63.3829 15.5775C64.4417 15.6523 65.2177 16.1888 65.7789 17.0706C66.75 18.601 67.7233 20.1292 68.6922 21.6597C69.4879 22.913 70.2815 24.1686 71.0772 25.422C71.132 25.5077 71.189 25.5913 71.2723 25.7144C71.3271 25.4462 71.2372 25.2395 71.2307 25.0284C71.132 21.9455 71.2131 18.8627 71.1824 15.782C71.1802 15.5995 71.2416 15.5467 71.4192 15.5489C72.5043 15.5555 73.5894 15.5621 74.6767 15.5467C74.9485 15.5423 74.8959 15.7006 74.8959 15.8502C74.8959 19.0913 74.8959 22.3325 74.8959 25.5737C74.8959 28.0013 74.8959 30.4289 74.8959 32.8587C74.8959 33.6041 74.5166 33.9889 73.7713 33.9933C72.8967 33.9977 72.022 33.9867 71.1474 33.9999C70.9238 34.0043 70.812 33.9163 70.7002 33.7382C68.622 30.4421 66.5351 27.1503 64.4526 23.8564C64.3869 23.7486 64.3167 23.6475 64.2488 23.5441ZM71.3227 25.743L71.3118 25.7628L71.3271 25.765L71.3227 25.743Z",fill:t}),(0,r.jsx)("path",{id:"Vector_5",d:"M101.059 22.3674C102.547 20.6501 103.968 19.0075 105.39 17.3671C105.653 17.0637 105.919 16.7646 106.182 16.4612C106.695 15.8697 107.348 15.564 108.124 15.5552C109.345 15.5421 110.566 15.553 111.809 15.553C111.796 15.6894 111.693 15.7553 111.622 15.8367C109.586 18.1895 107.552 20.5446 105.506 22.8886C105.351 23.0667 105.357 23.1788 105.476 23.3635C107.67 26.7872 109.858 30.2175 112.045 33.6456C112.107 33.7402 112.164 33.8369 112.232 33.9447C112.181 33.9645 112.155 33.9842 112.129 33.9842C110.695 33.982 109.262 33.9842 107.828 33.9689C106.861 33.9579 106.105 33.5269 105.581 32.7177C104.579 31.1696 103.591 29.6128 102.597 28.0604C102.106 27.2908 101.615 26.5234 101.076 25.6812C101.067 25.8703 101.059 25.9802 101.059 26.088C101.059 28.6123 101.054 31.1345 101.063 33.6588C101.063 33.9183 101.002 33.9974 100.736 33.9952C99.5768 33.9798 98.4171 33.9908 97.2575 33.9886C96.4749 33.9864 96.0913 33.6038 96.0913 32.8254C96.0913 27.1764 96.0935 21.5275 96.0847 15.8785C96.0847 15.6234 96.1395 15.5399 9
16.4091 15.5421C97.8428 15.5552 99.2764 15.5552 100.71 15.5421C100.982 15.5399 101.067 15.597 101.065 15.8873C101.052 17.9037 101.059 19.9201 101.059 21.9365C101.059 22.0508 101.059 22.1629 101.059 22.3674Z",fill:t}),(0,r.jsx)("path",{id:"Vector_6",d:"M34.1006 24.1008C34.1006 21.3566 34.1028 18.6102 34.0962 15.866C34.0962 15.6285 34.14 15.5449 34.4009 15.5449C37.9324 15.5537 41.4639 15.5515 44.9954 15.5515C45.7319 15.5515 46.1199 15.9451 46.1221 16.6884C46.1243 17.3436 46.109 17.9989 46.1287 18.652C46.1353 18.9004 46.0542 18.9444 45.8262 18.9422C43.6757 18.9334 41.5253 18.94 39.3748 18.9334C39.1402 18.9334 39.0504 18.9752 39.0548 19.2391C39.0723 20.2638 39.0723 21.2885 39.0548 22.3109C39.0504 22.588 39.1424 22.632 39.3945 22.632C41.0605 22.621 42.7265 22.6298 44.3904 22.621C44.6249 22.6188 44.717 22.6628 44.7104 22.9266C44.6929 23.8546 44.6973 24.7847 44.7082 25.7148C44.7104 25.9347 44.6534 25.9985 44.4298 25.9963C42.7441 25.9875 41.0562 25.9963 39.3704 25.9853C39.1249 25.9831 39.0526 26.0447 39.0548 26.2976C39.0679 27.4278 39.0591 28.558 39.0613 29.6861C39.0635 30.3633 39.3222 30.6162 40.0017 30.6162C41.9418 30.6162 43.8818 30.6206 45.8196 30.6096C46.0739 30.60
174 46.1331 30.68 46.1265 30.924C46.109 31.5881 46.1243 32.2544 46.1199 32.9184C46.1156 33.5671 45.7297 33.9871 45.0918 33.9871C42.0448 33.9937 38.9999 33.9981 35.9529 33.9849C35.0147 33.9805 34.2979 33.4176 34.1313 32.6194C34.1006 32.4765 34.1006 32.3269 34.1006 32.1796C34.0984 29.486 34.1006 26.7923 34.1006 24.1008Z",fill:t}),(0,r.jsx)("path",{id:"Vector_7",d:"M79.8938 24.1052C79.8938 21.3588 79.8982 18.6146 79.8872 15.8704C79.8872 15.6043 79.9595 15.5449 80.2182 15.5449C83.7278 15.5537 87.2396 15.5515 90.7491 15.5515C91.5273 15.5515 91.9088 15.9363 91.911 16.7191C91.911 17.3634 91.8978 18.0077 91.9175 18.652C91.9241 18.896 91.8518 18.9466 91.6194 18.9444C89.4799 18.9356 87.3404 18.9444 85.1987 18.9312C84.9115 18.929 84.8304 19.0016 84.8348 19.2941C84.8545 20.3077 84.8501 21.3214 84.837 22.3351C84.8326 22.5748 84.8984 22.632 85.1351 22.632C86.8121 22.621 88.4869 22.632 90.1638 22.6188C90.4291 22.6166 90.4948 22.6848 90.4905 22.9464C90.4729 23.8744 90.4773 24.8045 90.4883 25.7346C90.4905 25.9457 90.4269 25.9963 90.223 25.9941C88.5373 25.9853 86.8494 25.9963 85.1636 25.9831C84.9006 25.9809 84.8326 26.0535 84.837 26.3151C84.8523 27.4344 84.8414 28.5536 84.8436 29.6729C84.8436 30.3479 85.111 30.6162 85.7774 30.6162C87.7174 30.6162 89.6575 30.6228 91.5953 30.6096C91.8649 30.6074 91.9241 30.6822 91.9175 30.9416C91.8978 31.6057 91.9131 32.272 91.911 32.936C91.9088 33.5605 91.5186 33.9871 90.8982 33.9871C87.8402 33.9937 84.7844 34.0025 81.7264 33.9827C80.5931 33.9739 79.8938 33.2153 79.8938 32.0917C79.8938 29.4266 79.8938 26.7659 79.8938 24.1052Z",fill:t}),(0,r.jsx)("path",{id:"Vector_8",d:"M114.727 24.1089C114.727 21.3625 114.731 18.6183 114.72 15.8718C114.72 15.608 114.792 15.542 115.053 15.542C118.563 15.5508 122.075 15.5486 125.584 15.5486C126.351 15.5486 126.748 15.9488 126.75 16.7206C126.752 17.3539 126.739 17.9872 126.757 18.6205C126.763 18.8667 126.702 18.9415 126.446 18.9393C124.295 18.9283 122.145 18.9393 119.994 18.9261C119.725 18.9239 119.668 19.0009 119.672 19.2581C119.687 20.2828 119.685 21.3075 119.672 22.33C119.67 22.5631 119.725 22.6269 119.964 22.6269C121.649 22.6159 123.337 22.6269 125.023 22.6137C125.262 22.6115 125.319 22.673 125.314 22.9083C125.299 23.8384 125.299 24.7664 125.314 25.6965C125.319 25.9318 125.262 25.9934 125.023 25.9912C123.337 25.9802 121.649 25.9912 119.964 25.978C119.722 25.9758 119.67 26.0395 119.672 26.2748C119.685 27.4359 119.676 28.5991 119.679 29.7601C119.681 30.323 119.97 30.6089 120.54 30.6111C122.511 30.6133 124.484 30.6155 126.454 30.6067C126.682 30.6067 126.766 30.6506 126.759 30.8969C126.739 31.561 126.757 32.2273 126.752 32.8935C126.748 33.5708 126.347 33.9842 125.672 33.9864C122.658 33.9908 119.641 33.9886 116.627 33.9886C116.002 33.9886 115.478 33.7577 115.073 33.2761C114.801 32.9529 114.724 32.5703 114.727 32.1569C114.731 29.4742 114.727 26.7916 114.727 24.1089Z",fill:t}),(0,r.jsx)("path",{id:"Vector_9",d:"M55.5899 24.7883C55.5899 27.7459 55.5855 30.7012 55.5964 33.6587C55.5964 33.916 55.5394 33.9995 55.2698 33.9951C54.1102 33.9797 52.9506 33.9907 51.7909 33.9885C50.9974 33.9863 50.6203 33.6015 50.6203 32.7967C50.6203 27.1675 50.6225 21.5406 50.6138 15.9114C50.6138 15.6277 50.6751 15.5398 50.9733 15.5442C52.385 15.5617 53.7989 15.5595 55.2106 15.5442C55.5066 15.5398 55.5986 15.6035 55.5986 15.9202C55.5833 18.8755 55.5899 21.8308 55.5899 24.7883Z",fill:t})]})})};var z=t(70455);let B=e=>{let{onNext:s}=e,{t}=(0,z.Bd)(),{createOrderState:l,setCreateOrderState:a}=(0,x.useContext)(L);return(0,r.jsxs)("div",{className:"flex flex-col items-center text-black-1",children:[(0,r.jsx)("h2",{className:"text-xl",children:t("distributors.orders.create-order-panel.steps.choose-order-type.title")}),(0,r.jsx)("p",{className:"text-sm font-light mt-2",children:t("distributors.orders.create-order-panel.steps.choose-order-type.description")}),(0,r.jsxs)("div",{className:"flex mt-12 gap-12",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{a({...l,steps:{...l.steps,type:{...l.steps.type,isCustomer:!0}}})},className:(0,d.A)(l.steps.type.isCustomer?"bg-[#00A551] shadow-[0_10px_0_0_#008943] text-white active:shadow-[0_6px_0_0_#006643]":"bg-[#F1F1F1] cursor-no-drop shadow-[0_10px_0_0_#E2E2E2] text-black-1 active:shadow-[0_6px_0_0_#E2E2E2]","active:translate-y-1 cursor-pointer rounded-[20px] w-[230px] h-[230px] flex flex-col items-center px-10 pt-2 pb-5 text-center transition-all duration-300"),children:[(0,r.jsx)(E,{}),(0,r.jsx)("h3",{className:"text-base font-bold select-none",children:t("distributors.orders.create-order-panel.steps.choose-order-type.order-for-customer.title")}),(0,r.jsx)("p",{className:"text-[13px] font-light mt-2.5 select-none",children:t("distributors.orders.create-order-panel.steps.choose-order-type.order-for-customer.description")}),(0,r.jsx)("div",{className:"mt-auto",children:l.steps.type.isCustomer&&(0,r.jsx)(H.lC,{})})]}),(0,r.jsxs)("div",{className:"bg-[#F1F1F1] cursor-no-drop shadow-[0_10px_0_0_#E2E2E2] rounded-[20px] w-[230px] h-[230px] flex flex-col items-center px-10 pt-2 pb-5 text-center",children:[(0,r.jsx)("div",{className:"w-[100px] h-[100px] flex justify-center items-center",children:(0,r.jsx)(q,{size:146})}),(0,r.jsx)("h3",{className:"text-medium font-bold text-black-1",children:t("distributors.orders.create-order-panel.steps.choose-order-type.order-to-heineken.title")}),(0,r.jsx)("p",{className:"text-[13px] font-light text-black-1 mt-2.5",children:t("distributors.orders.create-order-panel.steps.choose-order-type.order-to-heineken.description")}),(0,r.jsx)("div",{className:"mt-auto text-[13px] text-black-1",children:t("distributors.orders.create-order-panel.steps.choose-order-type.order-to-heineken.comming-soon")})]})]}),(0,r.jsx)(F.A,{title:t("distributors.orders.create-order-panel.steps.choose-order-type.continue"),variant:"primary",className:"mt-24 whitespace-nowrap",handleClick:s,disabled:!l.steps.type.isCustomer})]})};var Z=t(75306),P=t(17201),T=t(97259);let I=e=>{let{className:s,disable:t}=e;return(0,r.jsx)("input",{className:(0,d.A)("w-5 h-5",s),type:"checkbox",disabled:t})};var D=t(88992);let R=()=>{let[e,s]=(0,x.useState)(!1),[t,r]=(0,x.useState)(!1);return{onGetOutletsByIds:(e,t,r)=>{s(!0),y.A.outlets.getOutletsByIds(e,t).then(e=>{let{data:s}=e;null==r||r(s)}).catch(e=>{g.oR.error((0,N.u)(e))}).finally(()=>{s(!1)})},onPlaceOrder:(e,s)=>{r(!0),y.A.orders.createOrder(e).then(e=>{e.data.order&&(null==s||s(e.data.order.display_id))}).catch(e=>{g.oR.error((0,N.u)(e))}).finally(()=>{r(!1)})},isLoadingOutlets:e,isLoadingPlaceOrder:t}},G={sortKey:"created_at",sortType:"desc"},K=e=>{let{onNext:s,onPrev:t}=e,{t:l}=(0,z.Bd)(),{createOrderState:a,setCreateOrderState:i}=(0,x.useContext)(L),[n,o]=(0,x.useState)([]),[c,m]=(0,x.useState)(a.steps.customer.selectedOutlet),[p,h]=(0,x.useState)(!0),[v,f]=(0,x.useState)(0),{depot:b,depots:j}=(0,u.X)(),{onGetOutletsByIds:g,isLoadingOutlets:C}=R(),{register:N,handleSubmit:y,setValue:_,getValues:w}=(0,D.mN)({shouldUseNativeValidation:!0,defaultValues:{shipping_address:{...a.steps.customer.shipping_address},billing_address:{...a.steps.customer.billing_address}}}),[k,A]=(0,x.useState)({include_address:!0,offset:0,limit:20,q:""});(0,x.useEffect)(()=>{(null==c?void 0:c.id)||m(n[0])},[n]),(0,x.useEffect)(()=>{b?g({depot:b},k,e=>{let{outlets:s,count:t}=e;S(s,t)}):g({...j.filter(e=>!!e.id).map(e=>e.id)},k,e=>{let{outlets:s,count:t}=e;S(s,t)})},[k]);let S=(e,s)=>{k.offset>0?o(n.concat(e)):(o(e),f(s))};return(0,x.useEffect)(()=>{p&&_("billing_address",w("shipping_address"))},[p]),(0,x.useEffect)(()=>{(null==c?void 0:c.id)&&h(!0)},[c]),(0,x.useEffect)(()=>
1{if(c){var e,s,t;_("shipping_address.outlet_name",c.legal_name),_("shipping_address.area",c.sale_area),_("shipping_address.address",function(){var e;let s=null==c||null==(e=c.geographicalLocations)?void 0:e.find(e=>{var s;return(null==(s=e.location_type)?void 0:s.toLowerCase())==="shipping"});return(null==s?void 0:s.address_line)||""}()),_("shipping_address.contact_name",function(){var e,s,t,r,l,a,i,d,n,o,u,m;return(null==c||null==(t=c.outletContacts)||null==(s=t[0])||null==(e=s.contact)?void 0:e.customer.first_name)&&(null==c||null==(a=c.outletContacts)||null==(l=a[0])||null==(r=l.contact)?void 0:r.customer.last_name)?"".concat(null==c||null==(n=c.outletContacts)||null==(d=n[0])||null==(i=d.contact)?void 0:i.customer.first_name," ").concat(null==(m=c.outletContacts)||null==(u=m[0])||null==(o=u.contact)?void 0:o.customer.last_name):""}()),_("shipping_address.contact_number",null==c||null==(t=c.outletContacts)||null==(s=t[0])||null==(e=s.contact)?void 0:e.customer.phone),_("billing_address",w("shipping_address"))}},[c]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)(F.A,{className:"whitespace-nowrap",title:l("distributors.orders.create-order-panel.steps.select-customer.back"),variant:"secondary",handleClick:t}),(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("h3",{className:"text-xl text-black-1",children:l("distributors.orders.create-order-panel.steps.select-customer.title")}),(0,r.jsx)("p",{className:"text-sm font-light text-black-1 mt-2",children:l("distributors.orders.create-order-panel.steps.select-customer.description")})]}),(0,r.jsx)(F.A,{className:"whitespace-nowrap",title:l("distributors.orders.create-order-panel.steps.select-customer.continue"),variant:"primary",handleClick:y(e=>{i({...a,selectedIndex:2,steps:{...a.steps,customer:{shipping_address:e.shipping_address,billing_address:e.billing_address,selectedOutlet:c}}})}),disabled:!(null==c?void 0:c.id)})]}),(0,r.jsx)("div",{className:"my-5",children:(0,r.jsx)(P.A,{size:"full",placeholder:l("distributors.orders.create-order-panel.steps.select-customer.search-customer-placeholder"),onHandleSubmit:e=>{let{q:s}=e;A({...k,offset:0,q:s||""})}})}),(0,r.jsxs)("div",{className:"grid grid-cols-12 gap-6",children:[(0,r.jsx)("div",{className:"col-span-8",children:(0,r.jsx)(T.A,{className:"text-sm",contentClassName:"max-h-[calc(100vh-80px-40px-48px-32px-56px-80px-44px-44px)] min-h-[640px]",columns:[{label:l("distributors.orders.create-order-panel.steps.select-customer.columns.id"),header:{className:"col-span-5"},content:{className:"col-span-5",formatter:e=>(0,r.jsx)("div",{className:"truncate",title:e.external_id,children:e.external_id})}},{label:l("distributors.orders.create-order-panel.steps.select-customer.columns.customer"),header:{className:"col-span-10",sortKey:"customer",sortAction:e=>{}},content:{className:"col-span-10",formatter:e=>{let s=e.legal_name||e.trading_name||"";return(0,r.jsxs)("div",{className:(0,d.A)({"font-bold":(null==c?void 0:c.id)===e.id},"flex items-center gap-3"),title:s,children:[(0,r.jsx)(Z.A,{user:{first_name:s,last_name:s},size:"small"}),s]})}}},{label:l("distributors.orders.create-order-panel.steps.select-customer.columns.address"),header:{className:"col-span-12",sortKey:"address",sortAction:e=>{}},content:{className:"col-span-12",formatter:e=>{var s,t;return(0,r.jsx)("div",{className:(0,d.A)({"font-bold":(null==c?void 0:c.id)===e.id},"line-clamp-2"),children:null==(t=e.geographicalLocations)||null==(s=t[0])?void 0:s.address_line})}}},{label:l("distributors.orders.create-order-panel.steps.select-customer.columns.email"),header:{className:"col-span-9",sortKey:"email",sortAction:e=>{}},content:{className:"col-span-9",formatter:e=>(0,r.jsx)("div",{className:(0,d.A)({"font-bold":(null==c?void 0:c.id)===e.id},"underline text-oms-green truncate"),children:e.email_address})}},{label:l("distributors.orders.create-order-panel.steps.select-customer.columns.phone"),header:{className:"col-span-5",sortKey:"phone"},content:{className:"col-span-5",formatter:e=>(0,r.jsx)("div",{className:(0,d.A)({"font-bold":(null==c?void 0:c.id)===e.id},"underline text-oms-green"),children:e.phone_number})}},{label:"",header:{className:"col-span-6"},content:{className:"col-span-6",formatter:e=>(0,r.jsx)("div",{className:"flex justify-center items-center",children:(0,r.jsx)(F.A,{variant:(null==c?void 0:c.id)===e.id?"primary":"secondary",title:l((null==c?void 0:c.id)===e.id?"distributors.orders.create-order-panel.steps.select-customer.selected":"distributors.orders.create-order-panel.steps.select-customer.select"),size:"small",handleClick:()=>(e=>{e.id!==c.id&&(m(e),i({...a,steps:{...a.steps,products:{...a.steps.products,values:[]}}}))})(e),className:"text-sm w-[86px] px-2 whitespace-nowrap"})})}}],row:{header:{className:"grid-cols-48",selectClassName:"col-span-4"},content:{className:"grid-cols-48",selectClassName:"col-span-4"}},loading:C,data:n||[],totalCount:v,pageSize:20,onPageChange:e=>{A({...k,offset:(e-1)*20})},infinite:!0,currentPage:k.offset/20+1,defaultSort:[G],allowSelect:!1,allowClick:!1,scrollId:"scrollOutlets"})}),(0,r.jsxs)("div",{className:"col-span-4",children:[(0,r.jsxs)("div",{className:"text-oms-gray",children:[(0,r.jsx)("h3",{className:"text-xl font-bold",children:null==c?void 0:c.legal_name}),(0,r.jsx)("p",{className:"text-sm font-light mb-5",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.description")})]}),(0,r.jsx)("div",{className:"p-5 shadow-section rounded-xl divide-y h-[calc(100%-68px)]",children:(0,r.jsxs)("form",{children:[(0,r.jsxs)("div",{className:"pb-6",children:[(0,r.jsx)("h4",{className:"text-xl font-bold",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.shipping-address")}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm ",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.outlet-name")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8",type:"text",...N("shipping_address.outlet_name")}
1)]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.area")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8",...N("shipping_address.area")})]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.address")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8",...N("shipping_address.address")})]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.contact-name")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8",...N("shipping_address.contact_name")})]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.contact-number")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8",...N("shipping_address.contact_number")})]})]}),(0,r.jsxs)("div",{className:"pt-6",children:[(0,r.jsx)("h4",{className:"text-xl font-bold",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.billing-address")}),(0,r.jsxs)("div",{className:"flex items-center gap-2 cursor-pointer mt-4 text-sm",onClick:()=>{h(!p),p&&_("billing_address",{address:"",contact_name:"",contact_number:""},{shouldValidate:!0})},children:[p?(0,r.jsx)(H.Dj,{size:20,className:"group-peer-checked:block text-oms-green flex-shrink-0"}):(0,r.jsx)(I,{className:"flex-shrink-0"}),l("distributors.orders.create-order-panel.steps.select-customer.address-review.same-shipping-address-label")]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm ",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.address")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8 bg-[#ECEFF2] text-[#767676]",...N("billing_address.address")})]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm ",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.contact-name")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8 bg-[#ECEFF2] text-[#767676]",...N("billing_address.contact_name")})]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 items-center mt-4",children:[(0,r.jsx)("label",{className:"col-span-4 text-sm ",children:l("distributors.orders.create-order-panel.steps.select-customer.address-review.contact-number")}),(0,r.jsx)("input",{readOnly:!0,className:"oms-input focus:outline-none text-sm p-3 col-span-8 bg-[#ECEFF2] text-[#767676]",...N("billing_address.contact_number")})]})]})]})})]})]})]})};var X=t(79822),J=t(10270),U=t(12931);let W={sortKey:"created_at",sortType:"desc"},$=e=>{let{onNext:s,onPrev:t}=e,{t:l}=(0,z.Bd)(),[a,i]=(0,x.useState)(0),{createOrderState:d,setCreateOrderState:n}=(0,x.useContext)(L),[o,c]=(0,x.useState)(d.steps.products.values),[u,m]=(0,x.useState)([]),[p,h]=(0,x.useState)({region_id:d.steps.customer.selectedOutlet.outletDepots[0].depot.region_id,depot_id:d.steps.customer.selectedOutlet.outletDepots[0].depot_id,outlet_id:d.steps.customer.selectedOutlet.outletDepots[0].outlet_id,include_empties_deposit:!0,limit:20,offset:0,q:""}),{variants:v,isLoading:f,count:b,isPreviousData:g,isRefetching:C,refetch:N}=(0,j.RAl)(p,{enabled:!1,keepPreviousData:!0});(0,x.useEffect)(()=>{!v||g||C||y(v,b)},[v,C,g]),(0,x.useEffect)(()=>{N()},[p]);let y=(e,s)=>{p.offset>0?m(u.concat(e)):(m(e),i(s))},_=()=>null==o?void 0:o.reduce((e,s)=>e+Number(s.quantity),0),w=e=>e.filter(e=>Number(e.quantity)>0),k=(e,s,t)=>{let r=o.find(e=>e.id===s.id&&e.is_foc),l=null,a=e.target.value;l=r?{...r,is_foc:!0,[t]:a}:"quantity"===t?{...s,is_foc:!0,quantity:a}:{...s,is_foc:!0,[t]:a,quantity:0},c([...o.filter(e=>
1e.id===s.id&&!e.is_foc||e.id!==s.id),l])},A=(e,s)=>{let t=o.find(s=>s.id===e&&s.is_foc);return(null==t?void 0:t[s])||""};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex flex-1 gap-3",children:(0,r.jsx)(F.A,{title:l("distributors.orders.create-order-panel.steps.add-products.back"),variant:"secondary",handleClick:t})}),(0,r.jsxs)("div",{className:"text-center flex-1",children:[(0,r.jsx)("h3",{className:"text-xl text-black-1",children:l("distributors.orders.create-order-panel.steps.add-products.title")}),(0,r.jsx)("p",{className:"text-sm font-light text-black-1 mt-2",children:l("distributors.orders.create-order-panel.steps.add-products.description")})]}),(0,r.jsxs)("div",{className:"flex-1 justify-end flex items-center gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-oms-green font-bold",children:_()})," ",l("distributors.orders.create-order-panel.steps.add-products.item".concat(_()>1?"s":"","-added"))]}),(0,r.jsx)(F.A,{title:l("distributors.orders.create-order-panel.steps.add-products.proceed"),variant:"primary",handleClick:()=>{n({...d,selectedIndex:3,steps:{...d.steps,products:{...d.steps.products,values:w(o)}}})},disabled:0===_()})]})]}),(0,r.jsx)("div",{className:"my-5",children:(0,r.jsx)(P.A,{size:"full",placeholder:l("distributors.orders.create-order-panel.steps.add-products.search-product-placeholder"),onHandleSubmit:e=>{let{q:s}=e;h({...p,offset:0,q:s||void 0})}})}),(0,r.jsx)("div",{children:(0,r.jsx)(T.A,{className:"text-sm",contentClassName:"max-h-[calc(100vh-80px-40px-48px-32px-56px-80px-44px-44px)] min-h-[520px]",columns:[{label:l("distributors.orders.create-order-panel.steps.add-products.columns.product"),header:{className:"col-span-12"},content:{className:"col-span-12",formatter:e=>(0,r.jsxs)("div",{className:"flex items-center font-bold tracking-wide",title:e.product.title,children:[(0,r.jsx)(X.A,{thumbnail:e.product.thumbnail||"",border:!0}),e.product.title]})}},{id:"sku",label:l("distributors.orders.create-order-panel.steps.add-products.columns.sku"),header:{className:"col-span-4"},content:{className:"col-span-4",formatter:e=>(0,r.jsx)("div",{className:"flex items-center gap-3",title:e.sku,children:e.sku})}},{label:l("distributors.orders.create-order-panel.steps.add-products.columns.price"),header:{className:"col-span-8"},content:{className:"col-span-8",formatter:e=>{var s,t;return(0,r.jsxs)("div",{className:"",children:[e.calculated_price&&(null==(s=d.steps.customer.selectedOutlet)?void 0:s.currency_key)," ",(0,J.PJ)({amount:e.calculated_price,currency:null==(t=d.steps.customer.selectedOutlet)?void 0:t.currency_key})]})}}},{label:l("distributors.orders.create-order-panel.steps.add-products.columns.empties-deposit"),header:{className:"col-span-8"},content:{className:"col-span-8",formatter:e=>{var s,t;return(0,r.jsxs)("div",{children:[e.empties_deposit&&(null==(s=d.steps.customer.selectedOutlet)?void 0:s.currency_key)," ",(0,J.PJ)({amount:e.empties_deposit,currency:null==(t=d.steps.customer.selectedOutlet)?void 0:t.currency_key})]})}}},{label:"FOC",header:{className:"col-span-4"},content:{className:"col-span-4",formatter:e=>e.calculated_price?(0,r.jsx)("div",{className:"cursor-pointer",onClick:()=>(e=>{let s=[...o],t=null==s?void 0:s.findIndex(s=>s.id===e.id&&s.is_foc);t>-1?s.splice(t,1):s.push({...e,is_foc:!0,quantity:0}),c(s)})(e),children:A(e.id,"is_foc")?(0,r.jsx)(H.Dj,{size:20,className:"group-peer-checked:block text-oms-green flex-shrink-0 cursor-pointer"}):(0,r.jsx)(I,{className:"flex-shrink-0"})}):(0,r.jsx)(I,{className:"flex-shrink-0",disable:!0})}},{label:"Promotion code",header:{className:"col-span-8"},content:{className:"col-span-8",formatter:e=>(0,r.jsx)("div",{})}},{label:l("distributors.orders.create-order-panel.steps.add-products.columns.quantity"),header:{className:"col-span-4 justify-center"},content:{className:"col-span-4",formatter:e=>(0,r.jsx)("div",{className:"flex justify-center items-center mr-1",children:(0,r.jsx)("input",{className:"border disabled:bg-oms-gray-2 border-oms-gray-2 max-w-[88px] rounded-lg p-2 outline-none text-sm text-oms-green text-center font-bold placeholder:font-normal",type:"text",placeholder:l("distributors.orders.create-order-panel.steps.add-products.quantity-placeholder"),value:((e,s)=>
1{let t=o.find(s=>s.id===e&&!s.is_foc);return(null==t?void 0:t[s])||""})(e.id,"quantity"),onChange:s=>((e,s,t)=>{let r=o.find(e=>e.id===s.id&&!e.is_foc),l=null,a=e.target.value;l=r?{...r,[t]:a}:"quantity"===t?{...s,quantity:a}:{...s,[t]:a,quantity:0},c([...o.filter(e=>e.id!==s.id||e.id===s.id&&e.is_foc),l])})(s,e,"quantity"),disabled:!e.calculated_price,onKeyDown:e=>{/[0-9]/.test(e.key)||"Backspace"===e.key||e.preventDefault()}})})}}],row:{header:{className:"grid-cols-48",selectClassName:"col-span-4"},content:{className:"grid-cols-48",selectClassName:"col-span-4",formatter:e=>{var s,t,l,a;let{item:i,htmlContent:n,columns:o,index:c}=e,u=o.find(e=>"sku"===e.id);return(0,r.jsxs)("div",{children:[n,A(i.id,"is_foc")&&(0,r.jsx)("div",{className:"pl-10 border-b py-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-48 items-center",children:[(0,r.jsx)("div",{className:"p-3 col-span-12",children:(0,r.jsxs)("div",{className:"flex items-center font-bold tracking-wide text-oms-red-2",title:i.product.title,children:[(0,r.jsx)(X.A,{thumbnail:i.product.thumbnail||"",border:!0,isGift:!0}),i.product.title]})}),(0,r.jsx)("div",{className:"p-3 col-span-4",children:null==u||null==(t=u.content)||null==(s=t.formatter)?void 0:s.call(t,i)}),(0,r.jsxs)("div",{className:"p-3 col-span-8",children:[null==(l=d.steps.customer.selectedOutlet)?void 0:l.currency_key," ","0.00",(0,r.jsx)("span",{className:"ml-1 italic line-through text-oms-gray",children:(0,J.PJ)({amount:i.calculated_price,currency:null==(a=d.steps.customer.selectedOutlet)?void 0:a.currency_key})})]}),(0,r.jsx)("div",{className:"p-3 col-span-8"}),(0,r.jsx)("div",{className:"p-3 col-span-4"}),(0,r.jsx)("div",{className:"p-3 col-span-8",children:(0,r.jsx)("input",{type:"text",placeholder:"Enter QAP",value:A(i.id,"promotionCodes"),onChange:e=>k(e,i,"promotionCodes"),disabled:!i.calculated_price,className:"border border-oms-gray-2 disabled:bg-oms-gray-2 w-full rounded-lg p-2 outline-none text-sm text-oms-red-2 text-center font-bold placeholder:font-normal"})}),(0,r.jsx)("div",{className:"flex justify-center items-center p-3 col-span-4",children:(0,r.jsxs)("div",{className:"flex items-center px-2 max-w-[88px] border border-oms-gray-2 w-full rounded-lg text-oms-red-2",children:[(0,r.jsx)(U.A,{size:20}),(0,r.jsx)("input",{className:"w-full p-2 outline-none text-sm font-bold placeholder:font-normal",type:"text",placeholder:"QTY",value:A(i.id,"quantity"),onChange:e=>k(e,i,"quantity"),onKeyDown:e=>{/[0-9]/.test(e.key)||"Backspace"===e.key||e.preventDefault()}})]})})]})})]},c)}}},loading:f||C,data:u||[],totalCount:a,pageSize:20,onPageChange:e=>{h({...p,offset:(e-1)*20})},infinite:!0,currentPage:p.offset/20+1,defaultSort:[W],allowSelect:!1,allowClick:!1,scrollId:"scrollProduct",highLightItems:(()=>{let e=w(o);return null==e?void 0:e.map(e=>e.id)})()||[]})})]})},Q=e=>{var s;let{onPrev:t,onNext:l}=e,{t:a}=(0,z.Bd)(),{createOrderState:i,setCreateOrderState:n}=(0,x.useContext)(L),[o,c]=(0,x.useState)({}),{depot:m}=(0,u.X)(),{queryOrdersObject:p,setQueryOrdersObject:h,setPreventPageChangeTable:v}=b(),{getNumberOrderActive:f,getNumberOrderNeedReview:g}=_(),{onPlaceOrder:C,isLoadingPlaceOrder:N}=R(),{shipping_options:y}=(0,j.Ddq)({region_id:i.steps.customer.selectedOutlet.outletDepots[0].depot.region_id}),w=i.steps.products.values.map(e=>({variant_id:e.id,quantity:Number(e.quantity),metadata:{promotionCodes:e.promotionCodes,is_foc:e.is_foc}}));(0,x.useEffect)(()=>{var e,s,t,r,l,a,d,n,o,u,m,x,p,h,v,f,b,j,g,C,N,_,k,A,S,L,O,V;c({email:null==(l=i.steps.customer.selectedOutlet)||null==(r=l.outletContacts)||null==(t=r[0])||null==(s=t.contact)||null==(e=s.customer)?void 0:e.email,items:w,region_id:i.steps.customer.selectedOutlet.outletDepots[0].depot.region_id,shipping_methods:[{option_id:null==y||null==(a=y[0])?void 0:a.id}],shipping_address:{address_1:i.steps.customer.shipping_address.address,country_code:i.steps.customer.selectedOutlet.shipping_address.country_code,first_name:null==(u=i.steps.customer.selectedOutlet)||null==(o=u.outletContacts)||null==(n=o[0])||null==(d=n.contact)?void 0:d.customer.first_name,last_name:null==(h=i.steps.customer.selectedOutlet)||null==(p=h.outletContacts)||null==(x=p[0])||null==(m
1=x.contact)?void 0:m.customer.last_name},billing_address:{address_1:i.steps.customer.billing_address.address,country_code:i.steps.customer.selectedOutlet.shipping_address.country_code,first_name:null==(j=i.steps.customer.selectedOutlet)||null==(b=j.outletContacts)||null==(f=b[0])||null==(v=f.contact)?void 0:v.customer.first_name,last_name:null==(_=i.steps.customer.selectedOutlet)||null==(N=_.outletContacts)||null==(C=N[0])||null==(g=C.contact)?void 0:g.customer.last_name},customer_id:null==(A=i.steps.customer.selectedOutlet.outletContacts)||null==(k=A[0])?void 0:k.contact.customer_id,depot_id:null==(L=i.steps.customer.selectedOutlet.outletDepots)||null==(S=L[0])?void 0:S.depot_id,outlet_id:null==(V=i.steps.customer.selectedOutlet.outletDepots)||null==(O=V[0])?void 0:O.outlet_id,metadata:{source_system:"OMS"}})},[y,i]);let k=null==(s=i.steps.customer.selectedOutlet)?void 0:s.currency_key;return(0,r.jsxs)("div",{className:"flex flex-col text-sm",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex flex-1 gap-3",children:(0,r.jsx)(F.A,{title:a("distributors.orders.create-order-panel.steps.confirm.back"),variant:"secondary",handleClick:t})}),(0,r.jsxs)("div",{className:"text-center flex-1",children:[(0,r.jsx)("h3",{className:"text-xl text-black-1",children:a("distributors.orders.create-order-panel.steps.confirm.title")}),(0,r.jsx)("p",{className:"text-sm font-light text-black-1 mt-2",children:a("distributors.orders.create-order-panel.steps.confirm.description")})]}),(0,r.jsx)("div",{className:"flex-1 justify-end flex",children:(0,r.jsx)(F.A,{title:N?(0,r.jsx)(H.y$,{}):a("distributors.orders.create-order-panel.steps.confirm.place-order"),variant:"primary",handleClick:()=>{C(o,e=>{let s={};m&&(s.depot_id=m),f(s),g(s),v(!0),h({...p,offset:0}),n({...i,selectedIndex:4,steps:{...i.steps,success:e}})})}})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-12 mt-12 font-bold gap-2",children:[(0,r.jsx)("div",{className:"col-span-2",children:a("distributors.orders.create-order-panel.steps.confirm.columns.product")}),(0,r.jsx)("div",{className:"col-span-1",children:a("distributors.orders.create-order-panel.steps.confirm.columns.sku")}),(0,r.jsx)("div",{className:"col-span-2",children:a("distributors.orders.create-order-panel.steps.confirm.columns.price")}),(0,r.jsx)("div",{className:"col-span-2",children:a("distributors.orders.create-order-panel.steps.confirm.columns.total-price")}),(0,r.jsx)("div",{className:"col-span-1",children:a("distributors.orders.create-order-panel.steps.confirm.columns.empties-deposit")}),(0,r.jsx)("div",{className:"col-span-1 text-center",children:"FOC"}),(0,r.jsx)("div",{className:"col-span-2",children:"Promotion code"}),(0,r.jsx)("div",{className:"col-span-1 text-right",children:a("distributors.orders.create-order-panel.steps.confirm.columns.quantity")})]}),(0,r.jsx)("div",{className:"max-h-[500px] overflow-hidden overflow-y-scroll",children:i.steps.products.values.map((e,s)=>(0,r.jsxs)("div",{className:(0,d.A)({"border-none bg-gradient-to-r from-[#F9FAFE] to-[#FAF6FF]":e.promotionCodes},"grid grid-cols-12 items-center mt-5 border-y border-oms-gray-3 py-2 gap-2"),children:[(0,r.jsxs)("div",{className:"col-span-2 flex items-center font-bold tracking-wide",children:[(0,r.jsx)("div",{children:(0,r.jsx)(X.A,{thumbnail:e.product.thumbnail||"",border:!0,isPromo:!e.is_foc&&!!e.promotionCodes,isGift:!!e.is_foc})}),(0,r.jsx)("span",{className:(0,d.A)({"text-oms-red-2":!!e.promotionCodes||!!e.is_foc}),children:null==e?void 0:e.product.title})]}),(0,r.jsx)("div",{className:"col-span-1",children:e.sku}),(0,r.jsxs)("div",{className:"col-span-2",children:[k," ",(0,J.PJ)({amount:e.is_foc?0:e.calculated_price,currency:k}),e.is_foc&&(0,r.jsxs)("span",{className:"ml-1 italic line-through text-oms-gray",children:[" ",(0,J.PJ)({amount:e.calculated_price,currency:k})]})]}),(0,r.jsxs)("div",{className:"col-span-2",children:[k," ",(0,J.PJ)({amount:e.is_foc?0:e.calculated_price*Number(e.quantity),currency:k})]}),(0,r.jsxs)("div",{className:"col-span-1",children:[e.empties_deposit&&k," ",(0,J.PJ)({amount:e.empties_deposit,currency:k})]}),(0,r.jsx)("div",{className:"col-span-1 mx-auto text-oms-red-2",children:e.is_foc&&(0,r.jsx)(U.A,{size:24})}),(0,r.jsx)("div",{className:"col-span-2",children:e.promotionCodes}),(0,r.jsx)("div",{className:"col-span-1 font-bold text-right mr-4",children:e.quantity})]},s))}),(0,r.jsxs)("div",{className:"mt-10 border-t border-oms-gray-2 pt-5 space-y-2 text-sm",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:a("distributors.orders.create-order-panel.steps.confirm.summary.ship-to")}),(0,r.jsxs)("div",{className:"font-bold divide-x-2 flex space-x-2",children:[i.steps.customer.shipping_address.address&&(0,r.jsx)("span",{children:i.steps.customer.shipping_address.address}),i.steps.customer.shipping_address.contact_name&&(0,r.jsx)("span",{className:"pl-2",children:i.steps.customer.shipping_address.contact_name}),i.steps.customer.shipping_address.contact_number&&(0,r.jsx)("span",{className:"pl-2",children:i.steps.customer.shipping_address.contact_number})]})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:a("distributors.orders.create-order-panel.steps.confirm.summary.bill-to")}),(0,r.jsxs)("div",{className:"font-bold divide-x-2 flex space-x-2",children:[i.steps.customer.billing_address.address&&(0,r.jsx)("span",{children:i.steps.customer.billing_address.address}),i.steps.customer.billing_address.contact_name&&(0,r.jsx)("span",{className:"pl-2",children:i.steps.customer.billing_address.contact_name}),i.steps.customer.billing_address.contact_number&&(0,r.jsx)("span",{className:"pl-2",children:i.steps.customer.billing_address.contact_number})]})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:a("distributors.orders.create-order-panel.steps.confirm.summary.total-quanity")}),(0,r.jsx)("span",{className:"font-bold",children:i.steps.products.values.reduce((e,s)=>e+Number(s.quantity),0)})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:a("distributors.orders.create-order-panel.steps.confirm.summary.subtotal")}),(0,r.jsx)("span",{className:"font-bold"})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:a("distributors.orders.create-order-panel.steps.confirm.summary.promotion-discount")}
1),(0,r.jsx)("span",{className:"font-bold text-oms-green"})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:a("distributors.orders.create-order-panel.steps.confirm.summary.empties-deposit")}),(0,r.jsx)("span",{className:"font-bold"})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{children:a("distributors.orders.create-order-panel.steps.confirm.summary.vat")}),(0,r.jsx)("span",{className:"font-bold"})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("span",{className:"font-bold",children:a("distributors.orders.create-order-panel.steps.confirm.summary.total-due")}),(0,r.jsx)("span",{className:"font-bold text-xl"})]})]})]})};var Y=t(54587),ee=t.n(Y);let es=e=>{let{onClose:s}=e,{t}=(0,z.Bd)(),{createOrderState:l}=(0,x.useContext)(L);return(0,r.jsxs)("div",{className:"flex flex-col items-center max-w-xl mx-auto",children:[(0,r.jsx)("h3",{className:"text-black font-bold text-xl tracking-wide mt-8",children:t("distributors.orders.create-order-panel.steps.create-success.title",{orderId:l.steps.success})}),(0,r.jsx)("p",{className:"text-sm text-oms-gray mt-2 mb-20",children:t("distributors.orders.create-order-panel.steps.create-success.description")}),(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)(ee(),{src:"/distributor/image-success.png",width:162,height:162,alt:"Congratulation"}),(0,r.jsx)("p",{className:"text-center text-oms-gray font-bold text-base mt-8 mb-5",children:t("distributors.orders.create-order-panel.steps.create-success.congratulation",{orderId:l.steps.success})}),(0,r.jsx)(F.A,{className:"whitespace-nowrap",variant:"secondary",title:t("distributors.orders.create-order-panel.steps.create-success.back-to-home"),handleClick:s})]})]})},et=e=>{let{onClose:s}=e,{t}=(0,z.Bd)(),{createOrderState:l,setCreateOrderState:a}=(0,x.useContext)(L),i=()=>{4!==l.selectedIndex&&a({...l,selectedIndex:l.selectedIndex+1})},n=()=>{a({...l,selectedIndex:l.selectedIndex-1})},o=l.selectedIndex;return(0,r.jsxs)(V.o.Group,{defaultIndex:0,selectedIndex:o,manual:!0,children:[(0,r.jsxs)(V.o.List,{className:"flex justify-between items-center w-full",children:[(0,r.jsx)(k.l.Title,{className:"text-xl font-medium text-oms-gray",children:t("distributors.orders.create-order-panel.title")}),(0,r.jsx)("div",{className:"mt-6",children:A.map((e,s)=>(0,r.jsx)(V.o,{className:(0,d.A)(s!==A.length-1?"pr-48":"","relative"),children:s<o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"absolute inset-0 flex items-center","aria-hidden":"true",children:(0,r.jsx)("div",{className:"h-0.5 w-full bg-oms-green"})}),(0,r.jsx)("a",{href:"#",className:"relative flex h-4 w-4 items-center justify-center rounded-full border-2 border-oms-green bg-oms-green",children:(0,r.jsx)("span",{className:"absolute bottom-6 w-40 max-w-[200px] inline-block text-sm text-oms-gray-2",children:t(e.label)})})]}):s===o?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"absolute inset-0 flex items-center","aria-hidden":"true",children:(0,r.jsx)("div",{className:"h-0.5 w-full bg-oms-gray-3"})}),(0,r.jsx)("a",{href:"#",className:"relative flex h-4 w-4 items-center justify-center rounded-full border-2 border-oms-green bg-white","aria-current":"step",children:(0,r.jsx)("span",{className:"absolute bottom-6 w-40 max-w-[200px] inline-block text-sm font-bold text-oms-green",children:t(e.label)})})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"absolute inset-0 flex items-center","aria-hidden":"true",children:(0,r.jsx)("div",{className:"h-0.5 w-full bg-oms-gray-3"})}),(0,r.jsx)("a",{href:"#",className:"group relative flex h-4 w-4 items-center justify-center rounded-full border-2 border-oms-gray-2 bg-white hover:border-oms-gray-2",children:(0,r.jsx)("span",{className:"absolute bottom-6 w-40 max-w-[200px] inline-block text-sm text-[#989898]",children:t(e.label)})})]})},e.label))}),(0,r.jsx)("div",{className:"ml-3 flex h-7 items-center",children:(0,r.jsxs)("button",{type:"button",className:"relative rounded-md bg-white text-gray-400 hover:text-gray-500 focus:ring-2 focus:ring-indigo-500",onClick:s,children:[(0,r.jsx)("span",{className:"absolute -inset-2.5"}),(0,r.jsx)(M.A,{className:"h-6 w-6","aria-hidden":"true"})]})})]}),o<A.length?(0,r.jsxs)(V.o.Panels,{className:"mt-8",children:[(0,r.jsx)(V.o.Panel,{children:(0,r.jsx)(B,{onNext:i})}),(0,r.jsx)(V.o.Panel,{children:(0,r.jsx)(K,{onNext:i,onPrev:n})}),(0,r.jsx)(V.o.Panel,{children:(0,r.jsx)($,{onNext:i,onPrev:n})}),(0,r.jsx)(V.o.Panel,{children:(0,r.jsx)(Q,{onNext:i,onPrev:n})})]}):(0,r.jsx)(V.o.Panel,{children:(0,r.jsx)(es,{onClose:s})})]})},er=e=>{let{onClose:s,isOpen:t}=e;return(0,r.jsx)(w.e.Root,{appear:!0,show:t,as:x.Fragment,children:(0,r.jsxs)(k.l,{as:"div",className:"relative z-10 font-roboto",onClose:s,children:[(0,r.jsx)(w.e.Child,{as:x.Fragment,enter:"ease-out duration-100",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,r.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm"})}),(0,r.jsx)("div",{className:"fixed inset-0 overflow-hidden",children:(0,r.jsx)("div",{className:"absolute inset-0 overflow-hidden",children:(0,r.jsx)("div",{className:"pointer-events-none fixed top-20 bottom-0 inset-x-0 flex w-full",children:(0,r.jsx)(w.e.Child,{as:x.Fragment,enter:"ease-out duration-100",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,r.jsx)(k.l.Panel,{className:"pointer-events-auto w-screen",children:(0,r.jsx)("div",{className:"flex h-full flex-col overflow-y-scroll bg-white rounded-t-3xl",children:(0,r.jsx)("div",{className:"p-10",children:(0,r.jsx)(O,{children:(0,r.jsx)(et,{onClose:s})})})})})})})})})]})})},el=()=>{let{t:e}=(0,z.Bd)(),{depot:s}=(0,u.X)(),{orderFilterType:t,setOrderFilterType:l,numberOrderReadyInvoiced:a,numberOrderActive:m,numberOrderNeedReview:p,isInitState:h}=b(),{isLoadingOrderActive:v,isLoadingOrderNeedReview:f,getNumberOrderReadyInvoiced:j,getNumberOrderActive:g,getNumberOrderNeedReview:C}=_(),[N,y]=(0,x.useState)(!1);return(0,x.useEffect)(()=>
1{if(!h){let e={};s&&(e.depot_id=s),j(e),g(e),C(e)}},[s,h]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"grid grid-cols-4 gap-[30px]",children:[(0,r.jsxs)("div",{className:(0,d.A)("font-bold px-[30px] py-5 border border-oms-gray-2 rounded-[10px] bg-white transition-all duration-300 hover:border-oms-green-3 hover:bg-oms-green-4 group"),children:[(0,r.jsx)("div",{className:"flex justify-between items-center",children:(0,r.jsx)("div",{className:"w-10 h-10 rounded-[10px] flex justify-center items-center bg-oms-green-2 text-oms-green transition-all duration-300 group-hover:bg-oms-green-2 group-hover:text-oms-green-5 flex-shrink-0",children:(0,r.jsx)(i,{size:20})})}),(0,r.jsx)("h3",{className:"text-[19px] leading-[30px] mt-3 mb-1 text-oms-gray",children:e("distributors.orders.kpi-blocks.orders-ready-to-be-invoiced.title")}),(0,r.jsx)("span",{className:"text-[40px] font-extrabold leading-[40px]",children:a})]}),(0,r.jsxs)("div",{className:(0,d.A)("font-bold px-[30px] py-5 border border-oms-gray-2 rounded-[10px] bg-white transition-all duration-300 hover:border-oms-green-3 hover:bg-oms-green-4 group",{"!border-oms-green-3 !bg-oms-green-4 is-active":"order-active"===t}),children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-[10px] flex justify-center items-center bg-oms-green-2 text-oms-green transition-all duration-300 group-hover:bg-oms-green-2 group-hover:text-oms-green-5 group-[.is-active]:bg-oms-green-2 group-[.is-active]:text-oms-green-5 flex-shrink-0",children:(0,r.jsx)(n,{size:24})}),(0,r.jsx)("button",{type:"button",onClick:()=>{l("order-active"===t?"order":"order-active")},disabled:v||f,children:(0,r.jsx)("span",{className:"underline text-oms-green uppercase text-sm",children:e("order-active"===t?"distributors.orders.kpi-blocks.pending-orders.cta-activated":"distributors.orders.kpi-blocks.pending-orders.cta")})})]}),(0,r.jsx)("h3",{className:"text-[19px] leading-[30px] mt-3 mb-1 text-oms-gray",children:e("distributors.orders.kpi-blocks.pending-orders.title")}),(0,r.jsx)("span",{className:"text-[40px] font-extrabold leading-[40px]",children:m})]}),(0,r.jsxs)("div",{className:(0,d.A)("font-bold px-[30px] py-5 border border-oms-gray-2 rounded-[10px] bg-white transition-all duration-300 hover:border-oms-orange-3 hover:bg-oms-orange-4 group",{"!border-oms-orange-3 !bg-oms-orange-4 is-active":"order-need-review"===t}),children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-[10px] flex justify-center items-center bg-oms-orange-4 text-oms-orange transition-all duration-300 group-hover:bg-oms-orange group-hover:text-oms-orange-4 group-[.is-active]:bg-oms-orange group-[.is-active]:text-oms-orange-4 flex-shrink-0",children:(0,r.jsx)(o,{size:28})}),(0,r.jsx)("button",{type:"button",onClick:()=>{l("order-need-review"===t?"order":"order-need-review")},disabled:v||f,children:(0,r.jsx)("span",{className:"underline text-oms-green uppercase text-sm",children:e("order-need-review"===t?"distributors.orders.kpi-blocks.orders-need-reviews.cta-activated":"distributors.orders.kpi-blocks.orders-need-reviews.cta")})})]}),(0,r.jsx)("h3",{className:"text-[19px] leading-[30px] mt-3 mb-1 text-oms-gray",children:e("distributors.orders.kpi-blocks.orders-need-reviews.title")}),(0,r.jsx)("span",{className:"text-[40px] font-extrabold leading-[40px]",children:p})]}),(0,r.jsxs)("div",{className:(0,d.A)("font-bold px-[30px] py-5 border border-oms-gray-2 rounded-[10px] bg-white transition-all duration-300 hover:border-oms-purple-3 hover:bg-oms-purple-4 group"),children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-[10px] flex justify-center items-center bg-oms-purple-4 text-oms-purple transition-all duration-300 group-hover:bg-oms-purple group-hover:text-oms-purple-4 cursor-pointer flex-shrink-0",onClick:()=>{y(!0)},children:(0,r.jsx)(c.A,{size:20})}),(0,r.jsx)("button",{type:"button",onClick:()=>{y(!0)},children:(0,r.jsx)("span",{className:"underline text-oms-green uppercase text-sm",children:e("distributors.orders.kpi-blocks.create-new-order.cta")})})]}),(0,r.jsx)("h3",{className:"text-[19px] leading-[30px] mt-3 mb-1 text-oms-gray",children:e("distributors.orders.kpi-blocks.create-new-order.title")})]})]}),(0,r.jsx)(er,{onClose:()=>y(!1),isOpen:N})]})};var ea=t(12427);let ei=e=>{let{checked:s,disabled:t=!1,onSwitch:l,readOnly:a=!1}=e;return(0,r.jsxs)(ea.d,{checked:s,onChange:e=>{a||null==l||l(e)},disabled:t,className:(0,d.A)(s?"bg-oms-green border-transparent":"bg-white border-oms-orange",{"cursor-no-drop":a},"relative items-center inline-flex h-[22px] w-10 flex-shrink-0 rounded-full border-[1.5px] transition-colors duration-200 ease-in-out focus:outline-none"),children:[(0,r.jsx)("span",{className:"sr-only",children:"Use setting"}),(0,r.jsx)("span",{"aria-hidden":"true",className:(0,d.A)(s?"translate-x-5 bg-white":"translate-x-1 bg-oms-orange","pointer-events-none inline-block h-3.5 w-3.5 transform rounded-full transition duration-200 ease-in-out")})]})},ed=e=>{let{content:s,status:t,disabled:l=!1,onSwitch:a}=e,{t:i}=(0,z.Bd)();return(0,r.jsxs)("div",{className:(0,d.A)(t?"border-transparent":"border-oms-orange","rounded-[20px] shadow-card p-2.5 text-black-1 border-2 flex-1 flex flex-col"),children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)("h3",{className:"font-medium text-[15px] min-w-0",children:i(s.title)}),(0,r.jsx)("div",{className:(0,d.A)(t?"bg-oms-gray-3":"bg-oms-orange","w-[36px] h-[36px] rounded-full flex justify-center items-center flex-shrink-0"),children:s.icon})]}),(0,r.jsx)("p",{className:"font-normal text-xs my-[15px] text-oms-gray",children:i(t?s.descriptionSuccess:s.descriptionFail)}),(0,r.jsxs)("div",{className:"flex justify-between mt-auto",children:[(0,r.jsx)("span",{className:"font-medium text-[15px] min-w-0",children:i(t?s.statusSuccess:s.statusFail)}),(0,r.jsx)(ei,{checked:!!t,onSwitch:a,disabled:l,readOnly:!!t})]})]})},en=e=>{var s,t,l,a,i;let{view:n,item:o,index:c=0,region:u}=e,{t:m}=(0,z.Bd)(),x=null==(l=o.variant)||null==(t=l.product)||null==(s=t.metadata)?void 0:s.packType,p=(null==(a=o.metadata)?void 0:a.promotionCodes)||(null==(i=o.metadata)?void 0:i.promotion_codes);return(0,r.jsx)(()=>{var e,s,t,l,a,i,h,v,f,b,g,C,N,y,_;return"modal"===n?(0,r.jsxs)("div",{className:"grid grid-cols-12 py-2 items-center",children:[(0,r.jsx)("div",{children:c+1}),(0,r.jsx)("div",{children:(0,r.jsx)(X.A,{thumbnail:o.thumbnail||""})}),(0,r.jsx)("div",{children:null==o||null==(e=o.variant)?void 0:e.sku}),(0,r.jsxs)("div",{className:(0,d.A)({"text-oms-red-2 font-bold":!!p||
1(null==(s=o.metadata)?void 0:s.is_foc),"text-oms-orange-5 font-bold":!!(null==(t=o.metadata)?void 0:t.is_returned_empties)},"col-span-3 ml-5"),children:[(0,r.jsx)("p",{children:null==o?void 0:o.title}),!!p&&!(null==(l=o.metadata)?void 0:l.is_foc)&&(0,r.jsx)("span",{className:"inline-block is-promo",children:m("distributors.orders.order-details.products.line-item.promo")}),!!(null==(a=o.metadata)?void 0:a.is_foc)&&(0,r.jsx)("span",{className:"inline-block is-promo",children:(0,r.jsx)(U.A,{size:14})}),!!(null==(i=o.metadata)?void 0:i.is_returned_empties)&&(0,r.jsx)("span",{className:"inline-block is-promo bg-oms-orange-5 font-semibold",children:"Return"})]}),(0,r.jsx)("div",{className:"col-span-2 text-right mr-2",children:(0,j.ejx)({amount:(null==(h=o.metadata)?void 0:h.is_foc)?0:null==o?void 0:o.unit_price,region:u,includeTaxes:!1})}),(0,r.jsx)("div",{className:"ml-4 text-right",children:null==o?void 0:o.quantity}),(0,r.jsx)("div",{className:"text-right",children:x}),(0,r.jsx)("div",{className:"col-span-2 text-right pr-2",children:(0,j.ejx)({amount:(null==(v=o.metadata)?void 0:v.is_foc)?0:(null==o?void 0:o.unit_price)*(null==o?void 0:o.quantity),region:u,includeTaxes:!1})})]}):(0,r.jsxs)("div",{className:"grid grid-cols-12 mb-[15px]",children:[(0,r.jsxs)("div",{className:"flex col-span-8",children:[(0,r.jsx)(X.A,{border:!0,thumbnail:o.thumbnail||"",isPromo:!!p&&!(null==(f=o.metadata)?void 0:f.is_foc),isGift:!!(null==(b=o.metadata)?void 0:b.is_foc),isReturnEmpty:!!(null==(g=o.metadata)?void 0:g.is_returned_empties)}),(0,r.jsxs)("div",{className:"flex flex-col text-oms-gray",children:[(0,r.jsx)("h4",{className:(0,d.A)({"text-oms-red-2":!!(null==(C=o.metadata)?void 0:C.is_foc)||!!p,"text-oms-orange-5":!!(null==(N=o.metadata)?void 0:N.is_returned_empties)},"font-bold uppercase xlarge:w-[300px] w-[200px] truncate mr-3 mt-0.5"),children:null==o?void 0:o.title}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 items-center mt-1",children:[(0,r.jsxs)("span",{children:[m("distributors.orders.order-details.products.line-item.sku")," ",null==o||null==(y=o.variant)?void 0:y.sku]}),(0,r.jsx)("span",{children:x})]})]})]}),(0,r.jsxs)("div",{className:"flex-col col-span-4",children:[p?(0,r.jsx)("div",{className:"flex text-oms-red-2 font-bold",children:(0,r.jsxs)("p",{className:"truncate ...",title:p,children:[m("distributors.orders.order-details.products.line-item.qap")," ",p]})}):(0,r.jsx)("div",{className:"min-h-[20px]"}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsx)("div",{className:"font-medium mt-0.5 col-span-2",children:m("distributors.orders.order-details.products.line-item.unit".concat((null==o?void 0:o.quantity)>1?"s":""),{quantity:null==o?void 0:o.quantity})}),(0,r.jsx)("div",{className:"font-medium mt-0.5 col-span-2 text-right",children:(0,j.ejx)({amount:(null==(_=o.metadata)?void 0:_.is_foc)?0:null==o?void 0:o.unit_price,region:u,includeTaxes:!1})})]})]})]})},{})},eo=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 16 15",fill:"none",...l,children:(0,r.jsx)("path",{d:"M7.91846 1.25C7.79346 1.25 7.66846 1.3125 7.54346 1.375L2.60596 4.125C2.41846 4.25 2.29346 4.4375 2.29346 4.6875V10.3125C2.29346 10.5625 2.41846 10.75 2.60596 10.875L7.54346 13.625C7.66846 13.6875 7.79346 13.75 7.91846 13.75C8.04346 13.75 8.16846 13.6875 8.29346 13.625L8.85596 13.3125C8.66846 12.9375 8.60596 12.5 8.54346 12.0625V7.875L12.2935 5.75V8.125C12.731 8.125 13.1685 8.1875 13.5435 8.3125V4.6875C13.5435 4.4375 13.4185 4.25 13.231 4.125L8.29346 1.375C8.16846 1.3125 8.04346 1.25 7.91846 1.25ZM7.91846 2.625L11.6685 4.6875L10.4185 5.375L6.73096 3.25L7.91846 2.625ZM5.48096 3.9375L9.16846 6.125L7.91846 6.8125L4.16846 4.6875L5.48096 3.9375ZM3.54346 5.75L7.29346 7.875V12.0625L3.54346 9.9375V5.75ZM13.731 9.875L11.481 12.125L10.481 11.125L9.79346 11.875L11.5435 13.75L14.5435 10.75L13.731 9.875Z",fill:t})})},ec=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 14 14",fill:"none",...l,children:(0,r.jsx)("path",{d:"M2.57766 12.2667C2.27211 12.2667 2.01044 12.1578 1.79266 11.94C1.57489 11.7222 1.46618 11.4608 1.46655 11.1556V3.37781C1.46655 3.07225 1.57544 2.81058 1.79322 2.59281C2.011 2.37503 2.27248 2.26632 2.57766 2.26669H11.4666C11.7721 2.26669 12.0338 2.37558 12.2516 2.59336C12.4693 2.81114 12.578 3.07262 12.5777 3.37781V11.1556C12.5777 11.4611 12.4688 11.7228 12.251 11.9406C12.0332 12.1584 11.7717 12.2671 11.4666 12.2667H2.57766ZM2.57766 11.1556H11.4666V3.37781H2.57766V11.1556ZM3.13322 10.0445H5.911V8.93336H3.13322V10.0445ZM8.43878 8.93336L11.1888 6.18336L10.3971 5.39169L8.43878 7.36392L7.64711 6.57225L6.86933 7.36392L8.43878 8.93336ZM3.13322 7.82225H5.911V6.71114H3.13322V7.82225ZM3.13322 5.60003H5.911V4.48892H3.13322V5.60003Z",fill:t})})},eu=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 16 15",fill:"none",...l,children:(0,r.jsx)("path",{d:"M5.73096 3.75H4.60596C5.54346 2.9375 6.66846 2.5 7.91846 2.5C8.10596 2.5 8.29346 2.5 8.48096 2.5625C8.79346 2.625 9.10596 2.375 9.16846 2C9.23096 1.6875 8.98096 1.375 8.60596 1.3125C8.35596 1.25 8.16846 1.25 7.91846 1.25C6.41846 1.25 4.98096 1.8125 3.85596 2.75V1.875C3.85596 1.5 3.60596 1.25 3.23096 1.25C2.85596 1.25 2.60596 1.5 2.60596 1.875V4.375C2.60596 4.75 2.85596 5 3.23096 5H5.73096C6.10596 5 6.35596 4.75 6.35596 4.375C6.35596 4 6.10596 3.75 5.73096 3.75ZM4.79346 9.0625C4.41846 9.0625 4.16846 9.3125 4.16846 9.6875V10.8125C3.35596 9.875 2.91846 8.75 2.91846 7.5C2.91846 7.3125 2.91846 7.125 2.98096 6.9375C3.04346 6.625 2.79346 6.3125 2.41846 6.25C2.10596 6.1875 1.79346 6.4375 1.73096 6.8125C1.66846 7.0625 1.66846 7.25 1.66846 7.5C1.66846 9 2.23096 10.4375 3.16846 11.5625H2.29346C1.91846 11.5625 1.66846 11.8125 1.66846 12.1875C1.
166846 12.5625 1.91846 12.8125 2.29346 12.8125H4.79346C4.98096 12.8125 5.16846 12.6875 5.29346 12.5625C5.29346 12.5 5.35596 12.4375 5.35596 12.375V9.6875C5.41846 9.3125 5.16846 9.0625 4.79346 9.0625ZM13.5435 3.4375C13.9185 3.4375 14.1685 3.1875 14.1685 2.8125C14.1685 2.4375 13.9185 2.1875 13.5435 2.1875H10.9185C10.856 2.1875 10.7935 2.25 10.731 2.25C10.6685 2.3125 10.606 2.3125 10.606 2.375C10.606 2.4375 10.5435 2.5 10.5435 2.5V5.1875C10.5435 5.5625 10.7935 5.8125 11.1685 5.8125C11.5435 5.8125 11.7935 5.5625 11.7935 5.1875V4.1875C12.606 5.0625 13.0435 6.25 13.0435 7.5C13.0435 7.6875 13.0435 7.875 12.981 8.0625C12.9185 8.375 13.1685 8.6875 13.5435 8.75H13.606C13.9185 8.75 14.1685 8.5 14.231 8.1875C14.231 7.9375 14.2935 7.75 14.2935 7.5C14.2935 6 13.731 4.5625 12.7935 3.4375H13.5435ZM13.106 10.3125L12.9185 10.125C12.856 10.0625 12.7935 10.0625 12.731 10.0625H10.106C9.73096 10.0625 9.48096 10.3125 9.48096 10.6875C9.48096 11.0625 9.73096 11.3125 10.106 11.3125H11.231C10.356 12.125 9.16846 12.5625 7.91846 12.5625C7.73096 12.5625 7.54346 12.5625 7.35596 12.5C7.04346 12.4375 6.73096 12.6875 6.66846 13.0625C6.60596 13.4375 6.85596 13.6875 7.23096 13.75C7.48096 13.75 7.66846 13.8125 7.91846 13.8125C9.41846 13.8125 10.856 13.25 11.981 12.3125V13.125C11.981 13.5 12.231 13.75 12.606 13.75C12.981 13.75 13.231 13.5 13.231 13.125V10.625C13.231 10.5 13.1685 10.375 13.106 10.3125Z",fill:t})})},em=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 17 16",fill:"none",...l,children:(0,r.jsx)("path",{d:"M0.918457 3V4H10.4185V11.5H7.34046C7.11746 10.6405 6.34446 10 5.41846 10C4.49246 10 3.71946 10.6405 3.49646 11.5H2.91846V9H1.91846V12.5H3.49646C3.71946 13.3595 4.49246 14 5.41846 14C6.34446 14 7.11746 13.3595 7.34046 12.5H11.4965C11.7195 13.3595 12.4925 14 13.4185 14C14.3445 14 15.1175 13.3595 15.3405 12.5H16.9185V8.422L16.887 8.3435L15.887 5.3435L15.7785 5H11.4185V3H0.918457ZM1.41846 5V6H5.91846V5H1.41846ZM11.4185 6H15.059L15.9185 8.5625V11.5H15.3405C15.1175 10.6405 14.3445 10 13.4185 10C12.4925 10 11.7195 10.6405 11.4965 11.5H11.4185V6ZM1.91846 7V8H4.91846V7H1.91846ZM5.41846 11C5.97696 11 6.41846 11.4415 6.41846 12C6.41846 12.5585 5.97696 13 5.41846 13C4.85996 13 4.41846 12.5585 4.41846 12C4.41846 11.4415 4.85996 11 5.41846 11ZM13.4185 11C13.977 11 14.4185 11.4415 14.4185 12C14.4185 12.5585 13.977 13 13.4185 13C12.86 13 12.4185 12.5585 12.4185 12C12.4185 11.4415 12.86 11 13.4185 11Z",fill:t})})};var ex=t(10841),ep=t.n(ex),eh=t(34846);let ev=e=>{var s,t,l,a,i,n,o,c,u,m,x,p,h,v,f,b,j,g,C,N,y,_,w,k,A,S,L,O,V,M,F,H,E,q,z,B,Z,P,T,I,D,R,G,K,X,J,U,W;let{event:$,subEventOpened:Q,subEventInventory:Y,subEventCredit:ee,subEventPromo:es,icon:et,label:er,timeGMT:el=0}=e,{t:ea}=(0,eh.useTranslation)();return(0,r.jsx)("li",{children:(0,r.jsxs)("div",{className:"relative pb-8 font-normal text-sm",children:[$&&(null==$?void 0:$.event_name)!=="Cancelled"&&(null==$?void 0:$.event_name)!=="Paid"?(0,r.jsx)("span",{className:"absolute left-[16.5px] top-4 -ml-px h-full border border-l-[3px] border-oms-green","aria-hidden":"true"}):er!==ea("distributors.orders.order-details.order-history.paid")?(0,r.jsx)("span",{className:"absolute left-[16.5px] top-4 -ml-px h-full border-dotted border-l-[3px] border-l-[#D9D9D9]","aria-hidden":"true"}):null,(0,r.jsxs)("div",{className:"relative flex space-x-3",children:[(0,r.jsx)("div",{children:(0,r.jsx)("span",{className:(0,d.A)({"ring-2 ring-oms-green bg-white text-oms-green":$,"ring-2 ring-oms-red bg-white text-oms-red":(null==$?void 0:$.event_name)==="Cancelled","bg-oms-gray-3 color-black":!$},"h-9 w-9 rounded-full flex items-center justify-center"),children:et})}),(0,r.jsxs)("div",{className:"flex flex-col justify-center",children:[(0,r.jsx)("p",{className:(0,d.A)({"text-oms-green":$,"text-oms-red":(null==$?void 0:$.event_name)==="Cancelled","text-black":!$},"font-bold"),children:er}),(null==$?void 0:$.event_date)&&(0,r.jsx)("div",{className:"text-xs text-gray-500",children:ep()(null==$?void 0:$.event_date).utcOffset(el).format("DD MMM, HH:mm")}
1),Q&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"italic font-bold text-xs mt-1",children:Q.event_name}),(0,r.jsxs)("span",{className:"text-xs",children:[ep()(Q.event_date).fromNow()," by"," ",(null==(l=Q.event_created_by)||null==(t=l.contact)||null==(s=t.user)?void 0:s.first_name)&&(null==(n=Q.event_created_by)||null==(i=n.contact)||null==(a=i.user)?void 0:a.last_name)?"".concat(Q.event_created_by.contact.user.first_name," ").concat(Q.event_created_by.contact.user.last_name):"".concat((null==(u=Q.event_created_by)||null==(c=u.contact)||null==(o=c.user)?void 0:o.first_name)||(null==(p=Q.event_created_by)||null==(x=p.contact)||null==(m=x.user)?void 0:m.last_name)||"OMS System")]})]}),Y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("hr",{className:"border-t border-t-light-oms-gray mt-1"}),(0,r.jsx)("div",{className:"italic font-bold text-xs mt-1",children:Y.event_name}),(0,r.jsxs)("span",{className:"text-xs",children:[ep()(Y.event_date).fromNow()," by"," ",(null==(f=Y.event_created_by)||null==(v=f.contact)||null==(h=v.user)?void 0:h.first_name)&&(null==(g=Y.event_created_by)||null==(j=g.contact)||null==(b=j.user)?void 0:b.last_name)?"".concat(Y.event_created_by.contact.user.first_name," ").concat(Y.event_created_by.contact.user.last_name):"".concat((null==(y=Y.event_created_by)||null==(N=y.contact)||null==(C=N.user)?void 0:C.first_name)||(null==(k=Y.event_created_by)||null==(w=k.contact)||null==(_=w.user)?void 0:_.last_name)||"OMS System")]})]}),ee&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("hr",{className:"border-t border-t-light-oms-gray mt-1"}),(0,r.jsx)("div",{className:"italic font-bold text-xs mt-1",children:ee.event_name}),(0,r.jsxs)("span",{className:"text-xs",children:[ep()(ee.event_date).fromNow()," by"," ",(null==(L=ee.event_created_by)||null==(S=L.contact)||null==(A=S.user)?void 0:A.first_name)&&(null==(M=ee.event_created_by)||null==(V=M.contact)||null==(O=V.user)?void 0:O.last_name)?"".concat(ee.event_created_by.contact.user.first_name," ").concat(ee.event_created_by.contact.user.last_name):"".concat((null==(E=ee.event_created_by)||null==(H=E.contact)||null==(F=H.user)?void 0:F.first_name)||(null==(B=ee.event_created_by)||null==(z=B.contact)||null==(q=z.user)?void 0:q.last_name)||"OMS System")]})]}),es&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("hr",{className:"border-t border-t-light-oms-gray mt-1"}),(0,r.jsx)("div",{className:"italic font-bold text-xs mt-1",children:es.event_name}),(0,r.jsxs)("span",{className:"text-xs",children:[ep()(es.event_date).fromNow()," by"," ",(null==(T=es.event_created_by)||null==(P=T.contact)||null==(Z=P.user)?void 0:Z.first_name)&&(null==(R=es.event_created_by)||null==(D=R.contact)||null==(I=D.user)?void 0:I.last_name)?"".concat(es.event_created_by.contact.user.first_name," ").concat(es.event_created_by.contact.user.last_name):"".concat((null==(X=es.event_created_by)||null==(K=X.contact)||null==(G=K.user)?void 0:G.first_name)||(null==(W=es.event_created_by)||null==(U=W.contact)||null==(J=U.user)?void 0:J.last_name)||"OMS System")]})]})]})]})]})})},ef=e=>{let{size:s="19",color:t="currentColor",...l}=e;return(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 19 18",fill:"none",...l,children:[(0,r.jsx)("path",{d:"M14.7778 2.25H3.52783C3.22946 2.25 2.94332 2.36853 2.73234 2.5795C2.52136 2.79048 2.40283 3.07663 2.40283 3.375V14.625C2.40283 14.9234 2.52136 15.2095 2.73234 15.4205C2.94332 15.6315 3.22946 15.75 3.52783 15.75H14.7778C15.0762 15.75 15.3623 15.6315 15.5733 15.4205C15.7843 15.2095 15.9028 14.9234 15.9028 14.625V3.375C15.9028 3.07663 15.7843 2.79048 15.5733 2.5795C15.3623 2.36853 15.0762 2.25 14.7778 2.25Z",stroke:t,strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("path",{d:"M8.02783 11.625L9.90283 13.125L12.9028 9.375M5.40283 5.625H12.9028M5.40283 8.625H8.40283",stroke:t,strokeLinecap:"round",strokeLinejoin:"round"})]})},eb=e=>{let{order:s}=e,{depot:t,depots:l}=(0,u.X)(),{t:a}=(0,z.Bd)(),{getOrderEvents:i,getGMTTimeFromExternalId:d}=_(s),[o,c]=(0,x.useState)([]),[m,p]=(0,x.useState)(0);(0,x.useEffect)(()=>{(null==l?void 0:l.length)&&p(d(t,l))},[t,l]),(0,x.useEffect)(()=>{s&&i(e=>{c(e)})},[s]);let h=e=>o.find(s=>(null==s?void 0:s.event_name)===e);return(0,r.jsx)("div",{className:"flow-root mb-[18px]",children:(0,r.jsxs)("ul",{role:"list",className:"-mb-8",children:[(0,r.jsx)(ev,{event:h("Placed"),icon:(0,r.jsx)(n,{size:20}),label:a("distributors.orders.order-details.order-history.order-placed"),timeGMT:m}),(0,r.jsx)(ev,{event:h("Opened"),subEventOpened:h("Opened"),subEventInventory:h("Inventory Confirmed"),subEventCredit:h("Credit Confirmed"),subEventPromo:h("Promo Confirmed"),icon:(0,r.jsx)(eu,{size:18}),label:a("distributors.orders.order-details.order-history.processing"),timeGMT:m}),h("Cancelled")?(0,r.jsx)(ev,{event:h("Cancelled"),icon:(0,r.jsx)(M.A,{size:20}),label:a("distributors.orders.order-details.order-history.cancelled"),timeGMT:m}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ev,{event:h("Invoiced"),icon:(0,r.jsx)(ef,{size:19}),label:a("distributors.orders.order-details.order-history.invoiced"),timeGMT:m}),(0,r.jsx)(ev,{event:h("Shipped"),icon:(0,r.jsx)(em,{size:20}),label:a("distributors.orders.order-details.order-history.shipped"),timeGMT:m})]}),(0,r.jsx)(ev,{event:h("Delivered"),icon:(0,r.jsx)(eo,{size:20}),label:a("distributors.orders.order-details.order-history.delivered"),timeGMT:m}),(0,r.jsx)(ev,{event:h("Paid"),icon:(0,r.jsx)(ec,{size:20}),label:a("distributors.orders.order-details.order-history.paid"),timeGMT:m})]})})};var ej=t(63315);let eg=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 3 13",fill:"none",...l,children:[(0,r.jsx)("ellipse",{cx:"1.51144",cy:"1.5",rx:"1.42941",ry:"1.5",fill:t}),(0,r.jsx)("ellipse",{cx:"1.51144",cy:"6.5",rx:"1.42941",ry:"1.5",fill:t}),(0,r.jsx)("ellipse",{cx:"1.51144",cy:"11.5",rx:"1.42941",ry:"1.5",fill:t})]})};var eC=t(50073),eN=t(99959);function ey(e){let{selected:s,handleChange:t,selectList:l,size:a="small"}=e,{t:i}=(0,z.Bd)(),n=l.find(e=>e.value===s);return(0,r.jsx)(eC.W,{value:s,onChange:t,children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsxs)(eC.W.Button,{className:(0,d.A)("relative h-8 border border-oms-green-5 cursor-pointer rounded-lg bg-white font-bold focus:outline-none flex items-center",{"w-[164px] text-sm":"small"===a}),children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-2 py-2 pl-3 pr-10 truncate",children:[(null==n?void 0:n.icon)&&(0,r.jsx)("span",{className:"text-oms-green-5",children:null==n?void 0:n.icon}),(0,r.jsx)("span",{className:"truncate",title:i(null==n?void 0:n.name),children:i(null==n?void 0:n.name)})]}),(0,r.jsx)("span",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2",children:(0,r.jsx)(eN.A,{size:16})})]}),(0,r.jsx)(w.e,{as:x.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,r.jsx)(eC.W.Options,{className:(0,d.A)("absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"),children:l.map((e,s)=>!e.hidden&&(0,r.jsx)(eC.W.Option,{className:e=>{let{active:s,selected:t}=e;return(0,d.A)("relative cursor-pointer select-none p-2",s||t?"bg-oms-green-2":"bg-white")},value:e.value,children:s=>{let{selected:t}=s;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("span",{className:(0,d.A)(t?"font-bold":"font-normal","flex items-center gap-2 truncate hover:text-clip"),title:i(e.name),children:[e.icon&&(0,r.jsx)("span",{className:"text-oms-green-5",children:e.icon}),(0,r.jsx)("span",{className:"truncate",children:i(e.name)})]})})}},s))})})]})})}let e_=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 24 25",fill:"none",...l,children:(0,r.jsx)("path",{d:"M4.83407 18.8883L7.82573 15.8967H17.3341C17.7761 15.8967 18.2 15.7211 18.5126 15.4085C18.8251 15.096 19.0007 14.672 19.0007 14.23V6.73001C19.0007 6.28798 18.8251 5.86406 18.5126 5.5515C18.2 5.23894 17.7761 5.06334 17.3341 5.06334H6.50073C6.0587 5.06334 5.63478 5.23894 5.32222 5.5515C5.00966 5.86406 4.83407 6.28798 4.83407 6.73001V18.8883ZM4.83407 20.0633H4.00073V6.73001C4.00073 6.06697 4.26412 5.43108 4.73297 4.96224C5.20181 4.4934 5.83769 4.23001 6.50073 4.23001H17.3341C17.9971 4.23001 18.633 4.4934 19.1018 4.96224C19.5707 5.43108 19.8341 6.06697 19.8341 6.73001V14.23C19.8341 14.8931 19.5707 15.5289 19.1018 15.9978C18.633 16.4666 17.9971 16.73 17.3341 16.73H8.1674L4.83407 20.0633ZM7.33407 7.56334H16.5007V8.39668H7.33407V7.56334ZM7.33407 10.0633H16.5007V10.8967H7.33407V10.0633ZM7.33407 12.5633H14.0007V13.3967H7.33407V12.5633Z",fill:t})})},ew=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 25 25",fill:"none",...l,children:(0,r.jsx)("path",{d:"M18.8569 14.6758L15.2414 13.0556C15.0776 12.9854 14.8989 12.9572 14.7214 12.9735C14.544 12.9898 14.3734 13.0501 14.2251 13.149C14.21 13.1587 14.1957 13.1694 14.1822 13.1811L12.2926 14.7883C12.273 14.799 12.2512 14.805 12.2289 14.8058C12.2066 14.8066 12.1844 14.8022 12.164 14.7929C10.9495 14.2067 9.69125 12.9561 9.10271 11.7584C9.09291 11.7384 9.08782 11.7164 9.08782 11.6941C9.08782 11.6718 9.09291 11.6498 9.10271 11.6298L10.7153 9.71648C10.7268 9.70232 10.7376 9.6875 10.7474 9.67209C10.8449 9.52324 10.9038 9.35245 10.9188 9.17514C10.9337 8.99783 10.9043 8.81959 10.8331 8.6565L9.2244 5.04719C9.13304 4.83413 8.97505 4.65645 8.77413 4.54081C8.57321 4.42517 8.3402 4.37781 8.11008 4.40584C7.10996 4.53733 6.19194 5.02847 5.52756 5.7875C4.86318 6.54653 4.49791 7.5215 4.50001 8.53022C4.50001 14.5228 9.37517 19.3979 15.3677 19.3979C16.3764 19.3999 17.3513 19.0345 18.1103 18.3702C18.8693 17.7058 19.3605 16.7879 19.4921 15.7879C19.5201 15.5588 19.4734 15.3269 19.3589 15.1265C19.2445 14.9261 19.0684 14.7681 18.8569 14.6758ZM15.3677 18.4795C9.88182 18.4795 5.41841 14.0161 5.41841 8.53022C5.41585 7.74493 5.69929 6.98558 6.21576 6.39403C6.73224 5.80248 7.44643 5.41921 8.22488 5.31582H8.24248C8.27332 5.3164 8.30327 5.32628 8.3284 5.34417C8.35353 5.36206 8.37267 5.38713 8.3833 5.41608L9.99815 9.02156C10.0074 9.04161 10.0121 9.06341 10.0121 9.08547C10.0121 9.10753 10.0074 9.12932 9.99815 9.14937L8.38254 11.0673C8.37048 11.081 8.35948 11.0956 8.34963 11.1109C8.24853 11.2653 8.189 11.4431 8.1768 11.6272C8.1646 11.8113 8.20014 11.9954 8.27998 12.1617C8.95883 13.5516 10.3594 14.9414 11.7645 15.6203C11.9318 15.6997 12.1169 15.7343 12.3016 15.7209C12.4863 15.7075 12.6643 15.6465 12.8184 15.5437C12.8329 15.5338 12.8475 15.5231 12.8613 15.5116L14.7501 13.9044C14.7688 13.8944 14.7894 13.8885 14.8105 13.8872C14.8316 13.8858 14.8528 13.8891 14.8726 13.8967L18.4887 15.5169C18.5183 15.5295 18.5431 15.5511 18.5597 15.5785C18.5764 15.606 18.5839 15.638 18.5814 15.67C18.4785 16.4488 18.0956 17.1635 17.5042 17.6806C16.9
1128 18.1976 16.1533 18.4816 15.3677 18.4795Z",fill:t})})},ek=e=>{var s,t;let{customer:l,saleRep:a,type:i="customer"}=e,{t:d}=(0,z.Bd)();return(0,r.jsxs)(r.Fragment,{children:["customer"===i&&(0,r.jsxs)("div",{className:"text-sm text-[#666666]",children:[(0,r.jsx)("h4",{className:"font-bold mb-3 text-sm text-oms-gray",children:d("distributors.orders.order-details.order-modal.customer.label")}),(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"bg-white border border-oms-gray-2 w-8 h-8 rounded-full flex justify-center items-center",children:(0,r.jsx)(Z.A,{user:{email:(null==l?void 0:l.legal_name)||(null==l?void 0:l.trading_name)},size:"small"})}),(0,r.jsxs)("div",{className:"flex items-center gap-x-3 ml-3",children:[!!(null==l?void 0:l.legal_name)&&(0,r.jsx)("span",{className:"text-black font-medium",children:null==l?void 0:l.legal_name}),!!(null==l?void 0:l.legal_name)&&!!(null==l?void 0:l.trading_name)&&(0,r.jsx)("span",{className:"font-bold pb-2",children:"."}),!!(null==l?void 0:l.trading_name)&&(0,r.jsx)("span",{children:null==l?void 0:l.trading_name})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 mt-3 gap-y-2 gap-x-5 text-[0.7578rem]",children:[(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{children:d("distributors.orders.order-details.order-modal.customer.email")}),(0,r.jsx)("span",{className:"text-oms-green underline",children:null==l?void 0:l.email_address})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("span",{children:d("distributors.orders.order-details.order-modal.customer.address")}),(0,r.jsx)("span",{className:"text-black",children:null==l||null==(t=l.geographicalLocations)||null==(s=t[0])?void 0:s.address_line})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{children:d("distributors.orders.order-details.order-modal.customer.phone")}),(0,r.jsx)("span",{className:"text-oms-green underline",children:null==l?void 0:l.phone_number})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"mr-2",children:d("distributors.orders.order-details.order-modal.customer.sales-rep")}),(0,r.jsxs)("span",{className:"text-black",children:[null==a?void 0:a.first_name," ",null==a?void 0:a.last_name]})]})]})]}),"saleRep"===i&&(0,r.jsxs)("div",{className:"text-sm text-[#666666]",children:[(0,r.jsx)("h4",{className:"font-bold mb-3 text-sm text-oms-gray",children:d("distributors.orders.order-details.order-modal.sales-rep.label")}),(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"bg-white border border-oms-gray-2 w-8 h-8 rounded-full flex justify-center items-center",children:(0,r.jsx)(Z.A,{user:a,size:"small"})}),(0,r.jsxs)("span",{className:"ml-3 text-black font-medium",children:[null==a?void 0:a.first_name," ",null==a?void 0:a.last_name]})]}),(0,r.jsx)("div",{className:"grid grid-cols-2 mt-3 gap-y-2 gap-x-5",children:(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)(ew,{size:22}),(0,r.jsx)("span",{className:"mr-2 ml-2",children:d("distributors.orders.order-details.order-modal.sales-rep.phone")}),(0,r.jsx)("span",{className:"text-oms-green underline",children:null==a?void 0:a.phone})]})}),(0,r.jsxs)("div",{className:"flex items-center mt-1",children:[(0,r.jsx)(e_,{size:22}),(0,r.jsxs)("span",{className:"text-oms-green underline flex items-center cursor-no-drop ml-2",children:[d("distributors.orders.order-details.order-modal.sales-rep.notify-in-dsr")," ",(0,r.jsx)(ej.A,{size:12})]})]})]})]})};var eA=t(96394);let eS={sortKey:"created_at",sortType:"desc"},eL=e=>{let{onClose:s,isOpen:t,order:l,closeOrderModal:a}=e,{t:i}=(0,z.Bd)(),{depot:d}=(0,u.X)(),{setIsRefetchOrderDetail:n}=b(),[o,c]=(0,x.useState)(0),[m,p]=(0,x.useState)(()=>l.items.map(e=>{var s,t,r;let l={};return l.variant_id=null==(s=e.variant)?void 0:s.id,l.quantity=e.quantity,l.metadata={promotionCodes:null==(t=e.metadata)?void 0:t.promotionCodes,is_foc:!!(null==(r=e.metadata)?void 0:r.is_foc)},l})),[h,v]=(0,x.useState)([]),[f,C]=(0,x.useState)({region_id:l.region.id,depot_id:l.depot.id,outlet_id:l.outlet.id,include_empties_deposit:!0,limit:20,offset:0,q:""}),[N,y]=(0,x.useState)(!0),[A,S]=(0,x.useState)(!1),{editOrder:L,isLoadingEditOrder:O,getNumberOrderNeedReview:V,getNumberOrderReadyInvoiced:E}=_(l),{variants:q,isLoading:B,count:Z,isPreviousData:D,isRefetching:R,refetch:G}=(0,j.RAl)(f,{enabled:!1});(0,x.useEffect)(()=>{let e=l.items.map(e=>{var s,t,r;let l={};return l.variant_id=null==(s=e.variant)?void 0:s.id,l.quantity=e.quantity,l.metadata={promotionCodes:null==(t=e.metadata)?void 0:t.promotionCodes,is_foc:!!(null==(r=e.metadata)?void 0:r.is_foc)},l}),s=m.filter(e=>e.quantity>0),t=!1;e.length===s.length&&(t=e.every(e=>s.some(s=>s.variant_id===e.variant_id&&s.quantity===e.quantity&&s.metadata.promotionCodes===e.metadata.promotionCodes))),y(t)},[m]),(0,x.useEffect)(()=>{!q||D||R||K(q,Z)},[q,R,D]),(0,x.useEffect)(()=>{G()},[f]),(0,x.useEffect)(()=>{h.length>
10&&h.length===o?S(!0):S(!1)},[o,h.length,f]);let K=(e,s)=>{f.offset>0?v(h.concat(e)):(v(e),c(s))},J=(0,x.useMemo)(()=>(e=>null==e?void 0:e.reduce((e,s)=>e+Number(s.quantity),0))(m),[m]);(0,x.useEffect)(()=>{0===J&&y(!0)},[J]);let W=(e,s)=>{var t;let r=m.find(s=>{var t;return s.variant_id===e&&(null==(t=s.metadata)?void 0:t.is_foc)});return"quantity"===s?(null==r?void 0:r.quantity)||"":(null==r||null==(t=r.metadata)?void 0:t[s])||""},$=(e,s,t)=>{let r=m.find(e=>{var t;return e.variant_id===s.id&&(null==(t=e.metadata)?void 0:t.is_foc)}),l=null,a=e.target.value;l=r?"quantity"===t?{...r,quantity:Number(a)}:{...r,metadata:{is_foc:!0,[t]:a}}:"quantity"===t?{variant_id:s.id,quantity:Number(a),metadata:{is_foc:!0}}:{variant_id:s.id,quantity:0,metadata:{is_foc:!0,[t]:a}},p([...m.filter(e=>{var t;return e.variant_id===s.id&&!(null==(t=e.metadata)?void 0:t.is_foc)||e.variant_id!==s.id}),l])};return(0,r.jsx)(w.e.Root,{appear:!0,show:t,as:x.Fragment,children:(0,r.jsxs)(k.l,{as:"div",className:"relative z-[100] font-roboto",onClose:s,children:[(0,r.jsx)(w.e.Child,{as:x.Fragment,enter:"ease-out duration-100",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,r.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-60 backdrop-blur-sm"})}),(0,r.jsx)("div",{className:"fixed inset-0 overflow-hidden",children:(0,r.jsx)("div",{className:"absolute inset-0 overflow-hidden",children:(0,r.jsx)("div",{className:"pointer-events-none fixed top-20 bottom-0 inset-x-0 flex w-full",children:(0,r.jsx)(w.e.Child,{as:x.Fragment,enter:"ease-out duration-100",enterFrom:"opacity-0",enterTo:"opacity-100",leave:"ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,r.jsx)(k.l.Panel,{className:"pointer-events-auto w-screen",children:(0,r.jsxs)("div",{className:"flex h-full flex-col overflow-y-scroll bg-white rounded-t-3xl",children:[(0,r.jsxs)("div",{className:"p-10 flex items-center justify-between",children:[(0,r.jsx)(k.l.Title,{className:"text-xl font-medium text-oms-gray",children:i("distributors.orders.edit-order-panel.title")}),(0,r.jsx)("div",{className:"ml-3 flex h-7 items-center justify-between",children:(0,r.jsx)("button",{type:"button",className:"relative bg-white",onClick:s,children:(0,r.jsx)(M.A,{className:"h-6 w-6","aria-hidden":"true"})})})]}),(0,r.jsxs)("div",{className:"px-10",children:[(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsx)("div",{className:"flex flex-1 gap-3",children:(0,r.jsx)(F.A,{title:i("distributors.orders.create-order-panel.steps.add-products.back"),variant:"secondary",handleClick:s})}),(0,r.jsxs)("div",{className:"text-center flex-1",children:[(0,r.jsx)("h3",{className:"text-xl text-black-1",children:i("distributors.orders.create-order-panel.steps.add-products.title")}),(0,r.jsx)("p",{className:"text-sm font-light text-black-1 mt-2",children:i("distributors.orders.create-order-panel.steps.add-products.description")})]}),(0,r.jsxs)("div",{className:"flex-1 justify-end flex items-center gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-oms-green font-bold",children:J})," ",i("distributors.orders.create-order-panel.steps.add-products.item".concat(J>1?"s":"","-added"))]}),(0,r.jsx)(F.A,{title:O?(0,r.jsx)(H.y$,{}):i("distributors.orders.create-order-panel.steps.add-products.proceed"),variant:"primary",handleClick:()=>{L({items:m},()=>{let e={};d&&(e.depot_id=d),E(e),V(e),n(!0)},()=>{g.oR.success("Order updated successfully"),s(),a()})},disabled:N})]})]}),(0,r.jsx)("div",{className:"my-5",children:(0,r.jsx)(P.A,{size:"full",placeholder:i("distributors.orders.create-order-panel.steps.add-products.search-product-placeholder"),onHandleSubmit:e=>{let{q:s}=e;C({...f,offset:0,q:s||void 0})}})}),(0,r.jsx)(T.A,{className:"text-sm",contentClassName:"max-h-[calc(100vh-80px-40px-48px-32px-56px-80px-44px-44px)] min-h-[520px]",columns:[{label:i("distributors.orders.create-order-panel.steps.add-products.columns.product"),header:{className:"col-span-12"},content:{className:"col-span-12",formatter:e=>(0,r.jsxs)("div",{className:"flex items-center font-bold tracking-wide",title:e.product.title,children:[(0,r.jsx)(X.A,{thumbnail:e.product.thumbnail||"",border:!0}),e.product.title]})}},{label:i("distributors.orders.create-order-panel.steps.add-products.columns.sku"),header:{className:"col-span-4"},content:{className:"col-span-4",formatter:e=>(0,r.jsx)("div",{className:"flex items-center gap-3",title:e.sku,children:e.sku})}},{label:i("distributors.orders.create-order-panel.steps.add-products.columns.price"),header:{className:"col-span-8"}
1,content:{className:"col-span-8",formatter:e=>(0,r.jsx)("div",{className:"",children:(null==e?void 0:e.calculated_price)&&(0,j.ejx)({amount:null==e?void 0:e.calculated_price,region:l.region,includeTaxes:!1})})}},{label:i("distributors.orders.create-order-panel.steps.add-products.columns.empties-deposit"),header:{className:"col-span-8"},content:{className:"col-span-8",formatter:e=>(0,r.jsx)("div",{children:e.empties_deposit&&(0,j.ejx)({amount:e.empties_deposit,region:l.region,includeTaxes:!1})})}},{label:"FOC",header:{className:"col-span-4"},content:{className:"col-span-4",formatter:e=>e.calculated_price?(0,r.jsx)("div",{className:"cursor-pointer",onClick:()=>(e=>{let s=[...m],t=null==s?void 0:s.findIndex(s=>{var t;return s.variant_id===e.id&&(null==(t=s.metadata)?void 0:t.is_foc)});if(t>-1)s.splice(t,1);else{let t={variant_id:e.id,quantity:0,metadata:{is_foc:!0}};s.push(t)}p(s)})(e),children:W(e.id,"is_foc")?(0,r.jsx)(H.Dj,{size:20,className:"group-peer-checked:block text-oms-green flex-shrink-0 cursor-pointer"}):(0,r.jsx)(I,{className:"flex-shrink-0"})}):(0,r.jsx)(I,{className:"flex-shrink-0",disable:!0})}},{label:"Promotion code",header:{className:"col-span-8"},content:{className:"col-span-8",formatter:e=>(0,r.jsx)("div",{})}},{label:i("distributors.orders.create-order-panel.steps.add-products.columns.quantity"),header:{className:"col-span-4 justify-center"},content:{className:"col-span-4",formatter:e=>(0,r.jsx)("div",{className:"flex justify-center items-center mr-1",children:(0,r.jsx)("input",{className:"border disabled:bg-oms-gray-2 border-oms-gray-2 max-w-[88px] rounded-lg p-2 outline-none text-sm text-oms-green text-center font-bold placeholder:font-normal",type:"text",placeholder:i("distributors.orders.create-order-panel.steps.add-products.quantity-placeholder"),value:((e,s)=>{var t;let r=m.find(s=>{var t;return s.variant_id===e&&!(null==(t=s.metadata)?void 0:t.is_foc)});return"quantity"===s?(null==r?void 0:r.quantity)||"":(null==r||null==(t=r.metadata)?void 0:t[s])||""})(e.id,"quantity"),onChange:s=>((e,s,t)=>{let r=m.find(e=>{var t;return e.variant_id===s.id&&!(null==(t=e.metadata)?void 0:t.is_foc)}),l=null,a=e.target.value;l=r?"quantity"===t?{...r,quantity:Number(a)}:{...r,metadata:{[t]:a}}:"quantity"===t?{variant_id:s.id,quantity:Number(a)}:{variant_id:s.id,quantity:0,metadata:{[t]:a}},p([...m.filter(e=>{var t;return e.variant_id===s.id&&(null==(t=e.metadata)?void 0:t.is_foc)||e.variant_id!==s.id}),l])})(s,e,"quantity"),disabled:!e.calculated_price,onKeyDown:e=>{/[0-9]/.test(e.key)||"Backspace"===e.key||e.preventDefault()}})})}}],row:{header:{className:"grid-cols-48",selectClassName:"col-span-4"},content:{className:"grid-cols-48",selectClassName:"col-span-4",formatter:e=>{var s,t;let{item:a,htmlContent:i,columns:d,index:n}=e,o=d.find(e=>"sku"===e.id);return(0,r.jsxs)("div",{children:[i,W(a.id,"is_foc")&&(0,r.jsx)("div",{className:"pl-10 border-b py-4",children:(0,r.jsxs)("div",{className:"grid grid-cols-48 items-center",children:[(0,r.jsx)("div",{className:"p-3 col-span-12",children:(0,r.jsxs)("div",{className:"flex items-center font-bold tracking-wide text-oms-red-2",title:a.product.title,children:[(0,r.jsx)(X.A,{thumbnail:a.product.thumbnail||"",border:!0,isGift:!0}),a.product.title]})}),(0,r.jsx)("div",{className:"p-3 col-span-4",children:null==o||null==(t=o.content)||null==(s=t.formatter)?void 0:s.call(t,a)}),(0,r.jsxs)("div",{className:"p-3 col-span-8",children:[(0,j.ejx)({amount:0,region:l.region,includeTaxes:!1}),(0,r.jsx)("span",{className:"ml-1 italic line-through text-oms-gray",children:(null==a?void 0:a.calculated_price)&&(0,j.ejx)({amount:null==a?void 0:a.calculated_price,region:l.region,includeTaxes:!1})})]}),(0,r.jsx)("div",{className:"p-3 col-span-8"}),(0,r.jsx)("div",{className:"p-3 col-span-4"}),(0,r.jsx)("div",{className:"p-3 col-span-8",children:(0,r.jsx)("input",{type:"text",placeholder:"Enter QAP",value:W(a.id,"promotionCodes"),onChange:e=>$(e,a,"promotionCodes"),disabled:!a.calculated_price,className:"border border-oms-gray-2 disabled:bg-oms-gray-2 w-full rounded-lg p-2 outline-none text-sm text-oms-red-2 text-center font-bold placeholder:font-normal"})}),(0,r.jsx)("div",{className:"flex justify-center items-center p-3 col-span-4",children:(0,r.jsxs)("div",{className:"flex items-center px-2 max-w-[88px] border border-oms-gray-2 w-full rounded-lg text-oms-red-2",children:[(0,r.jsx)(U.A,{size:20}),(0,r.jsx)("input",{className:"w-full p-2 outline-none text-sm font-bold placeholder:font-normal",type:"text",placeholder:"QTY",value:W(a.id,"quantity"),onChange:e=>$(e,a,"quantity"),onKeyDown:e=>{/[0-9]/.test(e.key)||"Backspace"===e.key||e.preventDefault()}})]})})]})})]},n)}}},loading:B||R,data:h,totalCount:o,pageSize:20,onPageChange:e=>{C({...f,offset:(e-1)*20})},infinite:!0,currentPage:f.offset/20+1,defaultSort:[eS],allowSelect:!1,allowClick:!1,scrollId:"scrollVariantsEdit",highLightItems:(null==m?void 0:m.map(e=>e.variant_id))||[]}),(0,r.jsx)(F.A,{variant:"secondary",title:B?(0,r.jsx)(H.y$,{}):"Load more",handleClick:()=>{B||C({...f,offset:(f.offset/20+1)*20})},className:"block mx-auto mt-2",disabled:A})]})]})})})})})})]})})},eO=[{id:1,name:"distributors.orders.order-details.order-modal.status.processing",icon:(0,r.jsx)(eu,{size:20}),value:"processing"},{id:2,name:"distributors.orders.order-details.order-modal.status.shipped",icon:(0,r.jsx)(em,{size:20}),value:"shipped"},{id:3,name:"distributors.orders.order-details.order-modal.status.delivered",icon:(0,r.jsx)(eo,{size:20}),value:"delivered"},{id:4,name:"distributors.orders.order-details.order-modal.status.paid",icon:(0,r.jsx)(ec,{size:20}),value:"paid"},{id:5,name:"distributors.orders.order-details.order-modal.status.invoiced",icon:(0,r.jsx)(ef,{size:19}),value:"invoiced",hidden:!0}];function eV(e){var s,t;let{onClose:l,isOpen:a,order:i}=e,{t:d}=(0,z.Bd)(),[n,o]=(0,x.useState)((0,m.ih)(i)),[c,u]=(0,x.useState)(!1),{isLoadingUpdateOrder:p,isLoadingCreateOrderFulfillment:h,isAllowAction:v,updateExtendedStatus:f,isLoadingUpdateStatus:b}=_(i),C=(0,m.dy)(i),N=null==(s=i.metadata)?void 0:s.promotion_codes,y=null==N?void 0:N.split(",").map(e=>(0,r.jsx)("p",{className:"mt-1",children:e},e)),w=(0,m.OM)(i);return(0,r.jsx)(r.Fragment,{children:c?(0,r.jsx)(eL,{isOpen:c,onClose:()=>{u(!1)},order:i,closeOrderModal:()=>{l()}}):(0,r.jsxs)(eA.A,{isOpen:a,close:l,size:"xlarge",children:[(0,r.jsx)(eA.A.Title,{showCloseIcon:!1,children:(0,r.jsxs)("div",{className:"flex justify-between items-center pt-6 px-9",children:[(0,r.jsxs)("h3",{className:"font-bold text-xl uppercase whitespace-nowrap",children:[d("distributors.orders.order-details.order-modal.title")," #",i.display_id]}),(0,r.jsxs)("div",{className:"flex items-center",children:[(0,r.jsxs)("span",{className:"text-sm font-medium mr-2",children:[d("distributors.orders.order-details.order-modal.status.title")," "]}),(0,r.jsx)(ey,{selectList:eO,selected:n,handleChange:e=>{v?o(e):g.oR.error("Please check inventory/promotion/credits")}}),(0,r.jsx)("button",{onClick:()=>
1{n!==(0,m.ih)(i)?f([i],n,()=>l()):l()},className:"flex justify-center items-center min-w-[115px] text-sm max-h-8 border border-oms-gray rounded-[10px] text-oms-gray px-4 py-2 ml-6",disabled:b||h||p,children:b||h||p?(0,r.jsx)(H.y$,{}):d("distributors.orders.order-details.order-modal.save-close")})]})]})}),(0,r.jsxs)(eA.A.Body,{children:[(0,r.jsx)("div",{className:"mt-8 px-9",children:(0,r.jsxs)("div",{className:" flex gap-10",children:[(0,r.jsx)("div",{className:"w-6/12",children:(0,r.jsx)(ek,{customer:i.outlet,saleRep:w})}),(0,r.jsx)("div",{className:"w-6/12",children:(0,r.jsx)(ek,{saleRep:w,type:"saleRep"})})]})}),(0,r.jsxs)("div",{className:"pl-9 pr-8 mt-9",children:[(0,r.jsxs)("div",{className:"grid grid-cols-12 border-b text-sm font-bold py-4 border-black",children:[(0,r.jsx)("div",{children:d("distributors.orders.order-details.order-modal.columns.no")}),(0,r.jsx)("div",{children:d("distributors.orders.order-details.order-modal.columns.image")}),(0,r.jsx)("div",{children:d("distributors.orders.order-details.order-modal.columns.sku")}),(0,r.jsx)("div",{className:"col-span-3 ml-5",children:d("distributors.orders.order-details.order-modal.columns.name-of-goods")}),(0,r.jsx)("div",{className:"col-span-2 text-right mr-2",children:d("distributors.orders.order-details.order-modal.columns.price")}),(0,r.jsx)("div",{className:"text-right",children:d("distributors.orders.order-details.order-modal.columns.quantity")}),(0,r.jsx)("div",{className:"text-right",children:d("distributors.orders.order-details.order-modal.columns.unit")}),(0,r.jsx)("div",{className:"col-span-2 text-right pr-1",children:d("distributors.orders.order-details.order-modal.columns.total-price")})]}),(0,r.jsx)("div",{className:"divide-y divide-oms-gray-3 text-sm max-h-60 overflow-y-scroll",children:i.items.map((e,s)=>(0,r.jsx)(en,{item:e,view:"modal",index:s,region:i.region},e.id))})]}),(0,r.jsx)("div",{className:"flex justify-center mt-4",children:(0,r.jsx)(F.A,{className:"whitespace-nowrap",title:d("distributors.orders.order-details.order-modal.edit-order"),variant:"primary",size:"large",handleClick:()=>u(!0),disabled:!["processing","invoiced"].includes((0,m.ih)(i))})})]}),(0,r.jsx)(eA.A.Footer,{children:(0,r.jsxs)("div",{className:"flex gap-9 bg-oms-gray-3 px-9 pb-6 pt-4 mt-5",children:[(0,r.jsx)("div",{className:"w-6/12",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-bold text-sm text-oms-gray",children:d("distributors.orders.order-details.order-modal.customers-notes.title")}),(0,r.jsx)("div",{className:"bg-black/[.08] rounded-[10px] p-2 mt-2 text-xs text-oms-gray relative min-h-[5rem]",children:C.length?(0,r.jsx)(r.Fragment,{children:(0,r.jsx)("p",{className:"text-xs line-clamp-3",children:C})}):(0,r.jsx)("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm",children:d("distributors.orders.order-details.order-modal.customers-notes.empty-view")})}),(0,r.jsxs)("div",{className:"text-sm",children:[(0,r.jsx)("h4",{className:"font-bold text-oms-gray mt-3",children:d("distributors.orders.order-details.order-modal.qap")}),(0,r.jsx)("div",{className:"flex gap-4 flex-wrap",children:y})]})]})}),(0,r.jsxs)("div",{className:"w-6/12 text-base flex flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-semibold",children:d("distributors.orders.order-details.order-modal.summary.disc")}),(null==(t=i.items)?void 0:t.some(e=>{var s;return!!(null==(s=e.metadata)?void 0:s.is_returned_empties)}))&&(0,r.jsx)("div",{className:"text-[10px] italic leading-normal pr-8",children:"(Empties Return - This amount will be deducted in the calculation of the order total.)"})]}),(0,r.jsx)("span",{children:(0,j.ejx)({amount:i.discount_total,region:i.region,includeTaxes:!1})})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("span",{className:"font-semibold",children:[d("distributors.orders.order-details.order-modal.summary.dpp")," "]}),(0,r.jsx)("span",{children:(0,j.ejx)({amount:i.subtotal,region:i.region,includeTaxes:!1})})]}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("span",{className:"font-semibold",children:[d("distributors.orders.order-details.order-modal.summary.ppn")," "]}),(0,r.jsx)("span",{children:(0,j.ejx)({amount:i.tax_total||0,region:i.region,includeTaxes:!1})})]}),(0,r.jsx)("hr",{className:"border-t border-t-oms-gray-2"}),(0,r.jsxs)("div",{className:"flex justify-between",children:[(0,r.jsxs)("span",{className:"font-semibold",children:[d("distributors.orders.order-details.order-modal.summary.total-due")," "]}),(0,r.jsx)("span",{className:"font-semibold text-xl",children:(0,j.ejx)({amount:i.total,region:i.region,includeTaxes:!1})})]}),(0,r.jsx)("div",{className:"text-right italic",children:d("distributors.orders.order-details.order-modal.summary.total-payment-due-time",{numberDays:30})})]})]})})]})})}let eM={stock:{title:"distributors.orders.order-details.checks-list.stock.title",icon:(0,r.jsx)(e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 14 14",fill:"none",...l,children:(0,r.jsx)("path",{d:"M12.6 0H1.4C0.7 0 0 0.63 0 1.4V3.507C0 4.011 0.301 4.445 0.7 4.69V12.6C0.7 13.37 1.47 14 2.1 14H11.9C12.53 14 13.3 13.37 13.3 12.6V4.69C13.699 4.445 14 4.011 14 3.507V1.4C14 0.63
113.3 0 12.6 0ZM9.1 8.4H4.9V7H9.1V8.4ZM12.6 3.5H1.4V1.4L12.6 1.386V3.5Z",fill:t})})},{size:14}),descriptionFail:"distributors.orders.order-details.checks-list.stock.description-fail",descriptionSuccess:"distributors.orders.order-details.checks-list.stock.description-good",statusSuccess:"distributors.orders.order-details.checks-list.stock.status-good",statusFail:"distributors.orders.order-details.checks-list.stock.status-fail"},credit:{title:"distributors.orders.order-details.checks-list.credit.title",icon:(0,r.jsx)(e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 24 24",fill:"none",...l,children:(0,r.jsx)("path",{d:"M3 6H21V18H3V6ZM12 9C12.7956 9 13.5587 9.31607 14.1213 9.87868C14.6839 10.4413 15 11.2044 15 12C15 12.7956 14.6839 13.5587 14.1213 14.1213C13.5587 14.6839 12.7956 15 12 15C11.2044 15 10.4413 14.6839 9.87868 14.1213C9.31607 13.5587 9 12.7956 9 12C9 11.2044 9.31607 10.4413 9.87868 9.87868C10.4413 9.31607 11.2044 9 12 9ZM7 8C7 8.53043 6.78929 9.03914 6.41421 9.41421C6.03914 9.78929 5.53043 10 5 10V14C5.53043 14 6.03914 14.2107 6.41421 14.5858C6.78929 14.9609 7 15.4696 7 16H17C17 15.4696 17.2107 14.9609 17.5858 14.5858C17.9609 14.2107 18.4696 14 19 14V10C18.4696 10 17.9609 9.78929 17.5858 9.41421C17.2107 9.03914 17 8.53043 17 8H7Z",fill:t})})},{size:26}),descriptionFail:"distributors.orders.order-details.checks-list.credit.description-fail",descriptionSuccess:"distributors.orders.order-details.checks-list.credit.description-good",statusSuccess:"distributors.orders.order-details.checks-list.credit.status-good",statusFail:"distributors.orders.order-details.checks-list.credit.status-fail"},promotion:{title:"distributors.orders.order-details.checks-list.promotion.title",icon:(0,r.jsx)(U.A,{size:16}),descriptionFail:"distributors.orders.order-details.checks-list.promotion.description-fail",descriptionSuccess:"distributors.orders.order-details.checks-list.promotion.description-good",statusSuccess:"distributors.orders.order-details.checks-list.promotion.status-good",statusFail:"distributors.orders.order-details.checks-list.promotion.status-fail"}},eF=e=>{var s,t;let{disabled:l=!1}=e,{t:a}=(0,z.Bd)(),{depot:i}=(0,u.X)(),{orderExtended:d}=b(),[n,o]=(0,x.useState)(!1),[c,m]=(0,x.useState)(!1),[p,h]=(0,x.useState)(!1),[v,f]=(0,x.useState)(!1),{handleInventoryCheck:j,handleCreditCheck:g,handlePromotionCheck:C,getNumberOrderNeedReview:N,getNumberOrderActive:y,getNumberOrderReadyInvoiced:w}=_(d);return(0,x.useEffect)(()=>{d&&(m(!!d.inventory_checked),h(!!d.credit_checked),f(!!d.promotion_checked))},[JSON.stringify(d)]),(0,x.useEffect)(()=>{if(d&&c&&p&&v){let e={};i&&(e.depot_id=i),N(e),w(e),y(e)}},[d,c,p,v]),(0,r.jsxs)(r.Fragment,{children:[l&&(0,r.jsx)("div",{className:"absolute inset-0 z-50"}),(0,r.jsx)("div",{className:"absolute top-5 right-5 cursor-pointer",children:(0,r.jsx)(eg,{size:16})}),(0,r.jsxs)("div",{className:"grid grid-cols-12 h-full",children:[(0,r.jsxs)("div",{className:"col-span-9 p-5 bg-white rounded-l-[10px]",children:[(0,r.jsxs)("div",{className:"grid grid-cols-3 gap-5 mb-4",children:[(0,r.jsx)(ed,{content:eM.stock,status:c,disabled:l,onSwitch:()=>{m(!0),j(void 0,()=>{m(!1)})}}),(0,r.jsx)(ed,{content:eM.credit,status:p,disabled:l,onSwitch:()=>{h(!0),g(void 0,()=>{h(!1)})}}),(0,r.jsx)(ed,{content:eM.promotion,status:v,disabled:l,onSwitch:()=>{f(!0),C(void 0,()=>{f(!1)})}})]}),(0,r.jsx)("hr",{className:"border-t border-t-light-oms-gray"}),(0,r.jsxs)("div",{className:"mt-[9px] mb-[16px]",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsxs)("h3",{className:"text-sm font-medium mb-[12px] text-black-1",children:[a("distributors.orders.order-details.products.title")," (",(null==(s=d.items)?void 0:s.length)||0,")"]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("div",{className:"h-1.5 w-1.5 self-center rounded-full flex-shrink-0 bg-oms-red-2"}),(0,r.jsx)("span",{className:"text-oms-red-2 text-sm",children:"Promotion"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[(0,r.jsx)("div",{className:"h-1.5 w-1.5 self-center rounded-full flex-shrink-0 bg-oms-orange-5"}),(0,r.jsx)("span",{className:"text-oms-orange-5 text-sm",children:"Return"})]})]})]}),(0,r.jsxs)("div",{className:"text-black-1 text-sm",children:[(null==(t=d.items)?void 0:t.length)>0?d.items.slice(0,6).map(e=>(0,r.jsx)(en,{item:e,region:d.region},e.id)):(0,r.jsx)("div",{className:"text-bold text-center text-oms-gray text-lg mb-10",children:a("distributors.orders.order-details.products.no-items")}),(0,r.jsx)("div",{className:"flex justify-center items-center",children:(0,r.jsx)("button",{onClick:()=>{l?o(!1):o(!0)},className:"text-center text-oms-green underline font-bold px-3 whitespace-nowrap",disabled:l,children:a("distributors.orders.order-details.products.view-all")})})]})]})]}),(0,r.jsxs)("div",{className:"col-span-3 bg-gradient-primary rounded-r-[10px] m-0.5 px-5 pb-[15px]",children:[(0,r.jsx)("div",{className:"font-medium text-base mt-5 mb-[15px] text-oms-gray",children:a("distributors.orders.order-details.order-history.title")}),(0,r.jsx)(eb,{order:d}),(0,r.jsx)("hr",{className:"border-t border-t-light-oms-gray"}),(0,r.jsx)("div",{children:(0,r.jsxs)("div",{className:"flex items-center text-oms-green gap-2 cursor-pointer",children:[(0,r.jsx)("h3",{className:"text-sm underline font-bold my-3",children:a("distributors.orders.order-details.credit-history.title")}),(0,r.jsx)(ej.A,{size:14})]})})]})]}),n&&d&&(0,r.jsx)(eV,{isOpen:n,onClose:()=>o(!n),order:d})]})},eH=e=>{let{onClose:s,isOpen:t,handleCancelOrder:l,isLoading:a=!1}=e,{t:i}=(0,z.Bd)();return(0,r.jsxs)(eA.A,{isOpen:t,close:s,children:[(0,r.jsx)(eA.A.Title,{children:(0,r.jsx)("span",{className:"block text-xl font-bold mt-8 ml-10",children:i("distributors.orders.order-details.cancel-order-modal.title")})}),(0,r.jsx)(eA.A.Body,{children:(0,r.jsx)("div",{className:"my-8 px-10",children:(0,r.jsx)("p",{children:i("distributors.orders.order-details.cancel-order-modal.description")})})}),(0,r.jsx)(eA.A.Footer,{children:(0,r.jsxs)("div",{className:"flex px-10 mb-10 justify-between",children:[(0,r.jsx)(F.A,{variant:"secondary",title:i("distributors.orders.order-details.cancel-order-modal.cancel"),handleClick:s,className:"whitespace-nowrap"}),(0,r.jsx)(F.A,{variant:"danger",title:a?(0,r.jsx)(H.y$,{}):i("distributors.orders.order-details.cancel-order-modal.submit"),handleClick:l,className:"whitespace-nowrap"})]})})]})};function eE(e){let{action:s,name:t,size:l,created_date:a}=e;return(0,r.jsx)("div",{className:"relative",children:(0,r.jsxs)("div",{className:"relative flex items-center",children:[(0,r.jsx)("div",{className:"mr-3 shrink-0",children:(0,r.jsx)(ee(),{src:"/distributor/pdf.jpg",height:48,width:48,alt:"pdf-image",className:"w-12"})}),(0,r.jsxs)("div",{className:"truncate",children:[(0,r.jsx)("div",{className:"text-sm mb-2 truncate ...",children:t}),(0,r.jsxs)("div",{className:"text-sm text-oms-gray",children:[a," - ",l]})]}),(0,r.jsx)("div",{className:"m-6",children:s})]})})}let eq=e=>{let{size:s="24",color:t="currentColor",...l}=e;return(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:s,viewBox:"0 0 32 32",fill:"none",...l,children:(0,r.jsx)("path",{d:"M31.3744 15.3912C31.3281 15.29 30.2331 12.8587 27.8144 10.44C24.5781 7.20875 20.4994 5.5 15.9994 5.5C11.4994 5.5 7.42064 7.20875 4.18814 10.44C1.76939 12.8587 0.674392 15.29 0.624392 15.3912C0.539709 15.5832 0.495972 15.7908 0.495972 16.0006C0.495972 16.2105 0.539709 16.418 0.624392 16.61C0.670642 16.7125 1.76564 19.1425 4.18564 21.5613C7.42064 24.7925 11.4994 26.5 15.9994 26.5C20.4994 26.5 24.5781 24.7925 27.8094 21.5613C30.2294 19.1425 31.3244 16.7125 31.3706 16.61C31.4559 16.4183 31.5003 16.2109 31.5009 16.
1001C31.5016 15.7912 31.4585 15.5835 31.3744 15.3912ZM25.6169 19.5163C22.9331 22.1588 19.6981 23.5 15.9994 23.5C12.3006 23.5 9.06564 22.1587 6.38564 19.515C5.33107 18.4715 4.42394 17.2889 3.68939 16C4.42415 14.7116 5.33127 13.5294 6.38564 12.4862C9.06689 9.84125 12.3006 8.5 15.9994 8.5C19.6981 8.5 22.9319 9.84125 25.6131 12.4862C26.6676 13.5293 27.5747 14.7115 28.3094 16C27.5747 17.2889 26.6676 18.4714 25.6131 19.515L25.6169 19.5163ZM15.9994 10.5C14.9116 10.5 13.8482 10.8226 12.9438 11.4269C12.0393 12.0313 11.3343 12.8902 10.9181 13.8952C10.5018 14.9002 10.3929 16.0061 10.6051 17.073C10.8173 18.1399 11.3411 19.1199 12.1103 19.8891C12.8795 20.6583 13.8595 21.1821 14.9264 21.3943C15.9933 21.6065 17.0992 21.4976 18.1042 21.0813C19.1091 20.6651 19.9681 19.9601 20.5725 19.0556C21.1768 18.1512 21.4994 17.0878 21.4994 16C21.4977 14.5418 20.9177 13.1438 19.8867 12.1127C18.8556 11.0816 17.4576 10.5017 15.9994 10.5ZM15.9994 18.5C15.5049 18.5 15.0216 18.3534 14.6105 18.0787C14.1993 17.804 13.8789 17.4135 13.6897 16.9567C13.5005 16.4999 13.451 15.9972 13.5474 15.5123C13.6439 15.0273 13.882 14.5819 14.2316 14.2322C14.5813 13.8826 15.0267 13.6445 15.5117 13.548C15.9966 13.4516 16.4993 13.5011 16.9561 13.6903C17.4129 13.8795 17.8034 14.2 18.0781 14.6111C18.3528 15.0222 18.4994 15.5055 18.4994 16C18.4994 16.663 18.236 17.2989 17.7672 17.7678C17.2983 18.2366 16.6624 18.5 15.9994 18.5Z",fill:t,fillOpacity:"0.87"})})};var ez=t(18847),eB=t.n(ez),eZ=t(47994);let eP=eB()(()=>Promise.all([t.e(4031),t.e(2339),t.e(3480)]).then(t.bind(t,42472)),{loadableGenerated:{webpack:()=>[42472]},ssr:!1}),eT=e=>{let{invoiceList:s,isOpen:t,onClose:l,isLoading:a=!1}=e,{t:n}=(0,z.Bd)(),[o,c]=(0,x.useState)({url:"",item:{}}),[m,p]=(0,x.useState)(!0),{depot:h,depots:v}=(0,u.X)(),{handleDownloadInvoice:f,getGMTTimeFromExternalId:b}=_(),[j,g]=(0,x.useState)(0);(0,x.useEffect)(()=>{(null==s?void 0:s.length)?p(!1):p(!0)},[s]),(0,x.useEffect)(()=>{c({...o,url:"",item:{}})},[h]),(0,x.useEffect)(()=>{(null==v?void 0:v.length)&&g(b(h,v))},[h,v]);let C=()=>{var e,t;f(null==(t=s[0])||null==(e=t.response)?void 0:e.order_id,e=>{N(s[0],e)})},N=(e,s)=>{var t;let r=document.createElement("a"),l=null==e||null==(t=e.response)?void 0:t.file_name;r.href=s,r.setAttribute("download",l),document.body.appendChild(r),r.click(),r.remove()};return(0,r.jsx)(r.Fragment,{children:(null==o?void 0:o.url)?(0,r.jsx)(eP,{data:o,isOpen:!!(null==o?void 0:o.url),onClose:()=>c({...o,item:{},url:""})}):(0,r.jsxs)(eA.A,{isOpen:t,close:l,size:"medium",children:[(0,r.jsx)(eA.A.Title,{children:(0,r.jsx)("span",{className:"block text-xl font-bold mt-8 ml-10",children:n("distributors.orders.order-details.download-invoice-modal.title")})}),(0,r.jsx)(eA.A.Body,{children:(0,r.jsx)("div",{className:"my-8 px-10 max-h-[32rem] overflow-hidden overflow-y-scroll",children:a?(0,r.jsx)("div",{className:"text-oms-green flex justify-center items-center",children:(0,r.jsx)(eZ.A,{})}):null==s?void 0:s.map((e,t)=>{var l,a,d;return(0,r.jsx)(eE,{name:null==(l=e.response)?void 0:l.file_name,size:null==(a=e.response)?void 0:a.file_size,created_date:ep()(null==(d=e.invoice)?void 0:d.created_at).utcOffset(j).format("DD MMMM [at] HH:mm"),action:(0,r.jsxs)("div",{className:"flex items-center gap-6",children:[(0,r.jsx)("div",{className:"cursor-pointer",onClick:()=>(e=>{var t,r;f(null==(r=s[0])||null==(t=r.response)?void 0:t.order_id,s=>{c({...o,item:e,url:s})})})(e),children:(0,r.jsx)(eq,{})}),(0,r.jsx)("div",{className:"cursor-pointer",onClick:C,children:(0,r.jsx)(i,{})})]})},t)})})}),(0,r.jsx)(eA.A.Footer,{children:(0,r.jsxs)("div",{className:"flex px-10 mb-6 pt-5 justify-end gap-4 border-t-2 border-t-oms-gray-3",children:[(0,r.jsx)(F.A,{variant:"secondary",title:n("distributors.orders.order-details.download-invoice-modal.cancel"),handleClick:l,className:"whitespace-nowrap"}),(0,r.jsx)(F.A,{variant:"primary",title:n("distributors.orders.order-details.download-invoice-modal.submit"),disabled:m,handleClick:()=>{s.forEach(e=>{var s;f(null==e||null==(s=e.response)?void 0:s.order_id,s=>{N(e,s)})})},className:(0,d.A)("whitespace-nowrap",m?"opacity-40":"")})]})})]})})},eI={expand:"outlet,outlet.geographicalLocations,items,items.variant,items.variant.product,fulfillments,invoices,customer,depot",fields:"id,display_id,credit_checked,inventory_checked,promotion_checked,currency_code,status,region,metadata,customer_id,is_processing,fulfillment_status,extended_status"},eD=e=>{let{orderId:s}=e,{t}=(0,z.Bd)(),{orderExtended:l,setOrderExtended:a,isRefetchOrderDetail
1:n,setIsRefetchOrderDetail:o,orders:c,setOrders:p}=b(),{order:h,isLoading:v,refetch:f}=(0,j.Hzn)(s,eI,{enabled:!1}),{isLoadingUpdateOrder:g,changeProcessingStatus:C,handleGenerateInvoice:N,changeCancelStatus:y,isLoadingCreateOrderFulfillment:w,isLoadingGenerateInvoice:k,isLoadingCancelOrder:A,isAllowAction:S}=_(l),[L,O]=(0,x.useState)(!1),[V,E]=(0,x.useState)(!1),[q,B]=(0,x.useState)([]),[Z,P]=(0,x.useState)(!1),{depot:T}=(0,u.X)(),I=(0,x.useMemo)(()=>(null==l?void 0:l.status)==="canceled",[l]);return(0,x.useEffect)(()=>{E(!1)},[T]),(0,x.useEffect)(()=>{s&&f()},[s]),(0,x.useEffect)(()=>{if(a({...h}),Z){let e=[...c],s={...h},t=e.findIndex(e=>e.id===s.id);e[t].inventory_checked=s.inventory_checked,e[t].promotion_checked=s.promotion_checked,e[t].credit_checked=s.credit_checked,e[t].fulfillment_status=s.fulfillment_status,e[t].items=s.items,p(e),P(!1)}},[h]),(0,x.useEffect)(()=>{n&&(f(),o(!1),P(!0))},[n]),(0,x.useEffect)(()=>{l&&h&&l.id===h.id&&"pending"===(0,m.ih)(l)&&C()},[l,h]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex justify-between mb-3",children:[(0,r.jsxs)("h2",{className:"font-medium text-oms-gray leading-[2.125rem] text-xl",children:[t("distributors.orders.order-details.title")," #",null==l?void 0:l.display_id]}),(0,r.jsx)("div",{className:"relative",children:(0,r.jsx)("div",{className:"flex gap-[15px] items-center absolute top-1/2 -mt-[17px] right-0 justify-end",children:!I&&!v&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F.A,{variant:"danger",title:t("distributors.orders.order-details.cancel-order"),icon:(0,r.jsx)(M.A,{size:18}),handleClick:()=>O(!0),size:"medium",className:"whitespace-nowrap"}),(0,r.jsx)(F.A,{variant:"primary",title:t("distributors.orders.order-details.download-invoice"),icon:(0,r.jsx)(i,{size:20}),size:"medium",disabled:!S,handleClick:()=>{E(!0),N((e,s)=>{B(s.downloaded)})},className:"whitespace-nowrap"})]})})})]}),(0,r.jsx)("div",{className:(0,d.A)({"opacity-30":I&&!v},"relative h-[calc(100vh-80px-32px-169px-28px-34px-12px-32px)] min-h-[600px] shadow-section rounded-[10px] bg-white overflow-auto"),children:v||g?(0,r.jsx)("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-oms-green",children:(0,r.jsx)(H.y$,{size:28})}):h&&(null==l?void 0:l.id)===h.id?(0,r.jsx)(eF,{disabled:I}):(0,r.jsx)("div",{className:"absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-xl",children:t("distributors.orders.order-details.no-data-found")})}),L&&(0,r.jsx)(eH,{isLoading:A,isOpen:L,onClose:()=>O(!1),handleCancelOrder:()=>{y(()=>{O(!1)})}}),V&&(0,r.jsx)(eT,{isLoading:w||k,invoiceList:q,isOpen:V,onClose:()=>E(!1)})]})};var eR=t(85113);let eG=[{name:"distributors.orders.orders-list.update-status-modal.status.processing",value:"processing",icon:(0,r.jsx)(eu,{size:18,className:"text-oms-green"})},{name:"distributors.orders.orders-list.update-status-modal.status.invoiced",value:"invoiced",icon:(0,r.jsx)(ef,{size:18,className:"text-oms-green"})},{name:"distributors.orders.orders-list.update-status-modal.status.shipped",value:"shipped",icon:(0,r.jsx)(em,{size:18,className:"text-oms-green"})},{name:"distributors.orders.orders-list.update-status-modal.status.delivered",value:"delivered",icon:(0,r.jsx)(eo,{size:18,className:"text-oms-green"})},{name:"distributors.orders.orders-list.update-status-modal.status.paid",value:"paid",icon:(0,r.jsx)(ec,{size:18,className:"text-oms-green"})}],eK=e=>{let{onClose:s,isOpen:t,onSubmit:l,defaultValue:a}=e,{t:i}=(0,z.Bd)(),[n,o]=(0,x.useState)(eG[0]);(0,x.useEffect)(()=>{a&&o(eG.find(e=>e.value===a)||eG[0])},[a]);let c=e=>{let s=eG.findIndex(e=>e.value===a);return s!==e&&s+1!==e&&(s+2!==e||a!==eG[0].value)};return(0,r.jsxs)(eA.A,{isOpen:t,close:s,children:[(0,r.jsx)(eA.A.Title,{children:(0,r.jsx)("span",{className:"block text-[22px] font-bold mt-8 ml-10",children:i("distributors.orders.orders-list.update-status-modal.title")})}),(0,r.jsx)(eA.A.Body,{children:(0,r.jsx)("div",{className:"mt-8 mb-10 px-10",children:(0,r.jsx)(eR.z,{value:n,onChange:o,children:(0,r.jsx)("div",{className:"space-y-4",children:eG.map((e,s)=>(e.value!==eG[1].value||e.value===eG[1].value&&a===e.value)&&(0,r.jsx)(eR.z.Option,{value:e,className:e=>{let{active:t,checked:r}=e;return(0,d.A)(r?"border-oms-green bg-[#E0FAE0]":"border-[#DADADA]","relative block cursor-pointer rounded-lg border bg-white p-5 focu
1s:outline-none sm:flex sm:justify-between h-16",{"opacity-30":c(s)})},disabled:c(s),children:s=>{let{active:t,checked:l}=s;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("span",{className:"flex items-center gap-x-4",children:[(0,r.jsxs)(eR.z.Label,{as:"div",className:"font-medium text-gray-900",children:[(0,r.jsx)(H.sx,{className:(0,d.A)("text-[#9AA2A9]",{hidden:l})}),(0,r.jsx)(H.jn,{className:(0,d.A)("text-oms-green",{hidden:!l})})]}),(0,r.jsxs)(eR.z.Description,{as:"div",className:"flex items-center gap-x-2.5",children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:e.icon}),(0,r.jsx)("span",{className:"font-bold",children:i(e.name)})]})]})})}},e.value))})})})}),(0,r.jsx)(eA.A.Footer,{children:(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-x-8 px-10 mb-10",children:[(0,r.jsx)("button",{type:"button",className:"h-10 rounded-lg border border-oms-green text-oms-green px-5 font-bold flex items-center justify-center gap-x-2.5 disabled:opacity-30",onClick:s,children:i("distributors.orders.orders-list.update-status-modal.cancel")}),(0,r.jsx)("button",{type:"button",className:"transition-all duration-300 h-10 rounded-lg bg-gradient-to-r from-[rgba(0,130,0,0.70)] to-oms-green text-white px-5 font-bold flex items-center justify-center gap-x-2.5 disabled:opacity-30",onClick:()=>{null==l||l({...n}),s()},disabled:a===(null==n?void 0:n.value)||!eG.some(e=>e.value===a),children:i("distributors.orders.orders-list.update-status-modal.submit")})]})})]})},eX=()=>{let{t:e}=(0,z.Bd)(),{depot:s,depots:t}=(0,u.X)(),{setClickedOrder:l,orders:a,setOrders:i,queryOrdersObject:n,setQueryOrdersObject:o,orderFilterType:c,preventPageChangeTable:p,setPreventPageChangeTable:v}=b(),[f,g]=(0,x.useState)(null),[C,N]=(0,x.useState)([]),[y,w]=(0,x.useState)(0),[k,A]=(0,x.useState)(!1),[S,L]=(0,x.useState)(!1),[O,V]=(0,x.useState)([]),[M,F]=(0,x.useState)(0),{orders:E,isLoading:q,count:B,refetch:Z,isRefetching:I,isPreviousData:D}=(0,j.w8n)(n,{enabled:!1,keepPreviousData:!0}),{handleGenerateInvoice:R,isLoadingCreateOrderFulfillment:G,isLoadingGenerateInvoice:K,isAllowAction:X,isLoadingUpdateStatus:J,getOrderActive:U,getOrderNeedReview:W,isAllowMultipleUpdateStatus:$,updateExtendedStatus:Q,getGMTTimeFromExternalId:Y}=_(null==C?void 0:C[0]);(0,x.useEffect)(()=>{(null==t?void 0:t.length)&&F(Y(s,t))},[s,t]),(0,x.useEffect)(()=>{!E||D||I||p||es(E,B)},[E,I,D]),(0,x.useEffect)(()=>{if(v(!1),c)switch(c){case"order-active":U(n,e=>{let{orders:s,count:t}=e;es(s,t)});break;case"order-need-review":W(n,e=>{let{orders:s,count:t}=e;es(s,t)});break;default:Z()}else Z()},[n]),(0,x.useEffect)(()=>{c&&o({...n,offset:0})},[c]);let ee=e=>{o({...n,offset:0,order:(0,m.E8)(e)})},es=(e,s)=>{n.offset>0?i(a.concat(e)):(i(e),w(s),l(e[0]),g(e[0]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-x-2",children:[(0,r.jsx)(P.A,{placeholder:e("distributors.orders.orders-list.search-order-placeholder"),onHandleSubmit:e=>{let{q:s}=e;o({...n,offset:0,q:s||void 0})}}),(0,r.jsxs)("div",{className:"flex justify-end items-center gap-x-2.5",children:[(0,r.jsx)("button",{type:"button",className:"h-10 rounded-lg border border-oms-green text-oms-green px-5 font-bold flex items-center justify-center gap-x-2.5 disabled:opacity-30",disabled:(C.length>0,!C.length||!$(C)||J),onClick:()=>A(!0),children:(0,r.jsx)("span",{className:"truncate",title:e("distributors.orders.orders-list.update-orders-status"),children:e("distributors.orders.orders-list.update-orders-status")})}),(0,r.jsxs)("button",{type:"button",className:"h-10 rounded-lg border border-oms-green text-oms-green px-5 font-bold flex items-center justify-center gap-x-2.5 disabled:opacity-30",disabled:C.length>1||!C.length||!X,onClick:()=>void(L(!0),R((e,s)=>{V(s.downloaded)})),children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:(0,r.jsx)(H.f5,{})}),(0,r.jsx)("span",{className:"truncate",title:e("distributors.orders.orders-list.download-invoices",{invoiceNumber:C.length?"".concat(C.length," "):""}),children:e("distributors.orders.orders-list.download-invoices",{invoiceNumber:C.length?"".concat(C.length," "):""})})]})]})]}),(0,r.jsx)("div",{className:"mt-3 h-[calc(100%-40px-24px-40px-8px)]",children:(0,r.jsx)(T.A,{className:"text-sm h-full",contentClassName:"h-[calc(100%-48px)]",columns:[{label:"#",header:{className:"min-[1441px]:col-span-4 col-span-5"},content:{className:"min-[1441px]:col-span-4 col-span-5",formatter:e=>(0,r.jsxs)("div",{className:"truncate",title:e.display_id,children:["#",e.display_id]})}},{label:"No Order",header:{className:"col-span-6"},content:{className:"col-span-6",formatter:e=>{var s,t;return(0,r.jsx)("div",{className:"break-words",title:null==(s=e.metadata)?void 0:s.external_number,children:null==(t=e.metadata)?void 0:t.external_number})}}},{label:e("distributors.orders.orders-list.columns.date"),header:{className:"min-[1441px]:col-span-6 col-span-7",sortKey:"created_at",sortAction:e=>{ee(e)}},content:{className:"min-[1441px]:col-span-6 col-span-7",formatter:e=>(0,r.jsx)("div",{children:ep()(e.created_at).utcOffset(M).format("DD MMM, HH:mm")}
1)}},{label:e("distributors.orders.orders-list.columns.status"),header:{className:"min-[1441px]:col-span-7 col-span-8",sortKey:"extended_status",sortAction:e=>{ee(e)}},content:{className:"min-[1441px]:col-span-7 col-span-8",formatter:s=>{let t=(0,m.ih)(s);return(0,r.jsxs)("div",{className:"capitalize flex gap-x-1",children:[(0,r.jsx)("div",{className:(0,d.A)("h-1.5 w-1.5 self-center rounded-full flex-shrink-0",{"bg-oms-green":"pending"===t,"bg-blue-300":"processing"===t,"bg-yellow-800":"invoiced"===t,"bg-oms-orange-4":"shipped"===t,"bg-[#B5B5B5]":"delivered"===t,"bg-violet-600":"paid"===t,"bg-oms-red":"cancelled"===t})}),(0,r.jsx)("span",{className:(0,d.A)("capitalize",{"text-oms-red":"cancelled"===t}),children:e("distributors.orders.orders-list.status.".concat(t))})]})}}},{label:e("distributors.orders.orders-list.columns.customer"),header:{className:"min-[1441px]:col-span-7 col-span-9",sortKey:"outlet_id",sortAction:e=>{ee(e)}},content:{className:"min-[1441px]:col-span-7 col-span-9",formatter:e=>{var s,t;let l=(null==(s=e.outlet)?void 0:s.legal_name)||(null==(t=e.outlet)?void 0:t.trading_name)||"";return(0,r.jsx)("div",{className:"line-clamp-2",title:l,children:l})}}},{label:e("distributors.orders.orders-list.columns.sales-rep"),header:{className:"col-span-8 min-[1441px]:flex hidden",sortAction:e=>{ee(e)}},content:{className:"col-span-8 min-[1441px]:flex hidden",formatter:e=>{let s=(0,m.OM)(e),t=(null==s?void 0:s.first_name)&&(null==s?void 0:s.last_name)?"".concat(s.first_name," ").concat(s.last_name):"".concat((null==s?void 0:s.first_name)||(null==s?void 0:s.last_name)||"");return(0,r.jsx)("div",{className:"line-clamp-2",title:t,children:t})}}},{label:e("distributors.orders.orders-list.columns.from"),header:{className:"min-[1441px]:col-span-3 col-span-5"},content:{className:"min-[1441px]:col-span-3 col-span-5 uppercase",formatter:e=>(0,r.jsx)("div",{children:(0,m.O)(e)})}},{label:e("distributors.orders.orders-list.columns.checks"),header:{className:"min-[1441px]:col-span-4 col-span-5 pr-5 truncate",sortAction:e=>{ee(e)}},content:{className:"min-[1441px]:col-span-4 col-span-5 flex justify-end pr-5",formatter:e=>(0,r.jsx)("div",{children:e.credit_checked&&e.inventory_checked&&e.promotion_checked?(0,r.jsx)(H.lC,{}):(0,r.jsx)(H.wC,{className:"text-oms-orange-4"})})}}],row:{header:{className:"grid-cols-48",selectClassName:"col-span-3"},content:{className:"grid-cols-48",selectClassName:"col-span-3"}},loading:q||I,data:a,totalCount:y,pageSize:20,onPageChange:e=>{q||I||p||o({...n,offset:(e-1)*20})},infinite:!0,onSelectedChange:e=>{N(e)},defaultClickedItem:f,onClickedChange:e=>{l(e)},currentPage:n.offset/20+1,defaultSort:[h],disabled:J})}),(0,r.jsx)(eK,{defaultValue:(0,m.ih)(null==C?void 0:C[0]),isOpen:k,onClose:()=>A(!k),onSubmit:e=>{Q(C,e.value)}}),S&&(0,r.jsx)(eT,{isLoading:G||K,invoiceList:O,isOpen:S,onClose:()=>L(!1)})]})},eJ=[{name:"distributors.orders.orders-list.tabs.orders-from-customer",key:"customer",icon:(0,r.jsx)(H.HK,{})},{name:"distributors.orders.orders-list.tabs.purchase-to-heineken",key:"hnk",icon:(0,r.jsx)(H.Uw,{})},{name:"distributors.orders.orders-list.tabs.draft-orders",key:"draft",icon:(0,r.jsx)(H._s,{})}],eU=()=>{let{t:e}=(0,z.Bd)(),[s,t]=(0,x.useState)(eJ[0].key);return(0,r.jsxs)("div",{className:"h-[calc(100vh-80px-32px-169px-28px-34px-12px-32px)] min-h-[600px]",children:[(0,r.jsx)("div",{className:"bg-[#eee] p-1 rounded-lg mb-5",children:(0,r.jsx)("nav",{className:"grid grid-cols-3 gap-x-1","aria-label":"Tabs",children:eJ.map(l=>(0,r.jsxs)("button",{className:(0,d.A)(l.key===s?"bg-white text-oms-green shadow-tab cursor-default":"text-[rgba(0,0,0,0.38)]","transition-all duration-300 rounded-md px-3 text-[13px] font-bold flex items-center justify-center gap-x-2 hover:bg-white hover:text-oms-green h-8 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-[rgba(0,0,0,0.38)]"),"aria-current":l.key===s?"page":void 0,onClick:()=>{l.key!==s&&t(l.key)},disabled:"customer"!==l.key,children:[(0,r.jsx)("span",{className:"flex-shrink-0",children:l.icon}),(0,r.jsx)("span",{className:"truncate",title:e(l.name),children:e(l.name)}
1)]},l.name))})}),"customer"===s&&(0,r.jsx)(eX,{})]})},eW=()=>{let{t:e}=(0,z.Bd)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h2",{className:"font-medium text-xl leading-[2.125rem] text-oms-gray mb-3",children:e("distributors.orders.orders-list.title")}),(0,r.jsx)(eU,{})]})},e$=()=>{let{t:e}=(0,z.Bd)(),{clickedOrder:s}=b();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.A,{title:e("distributors.orders.head.title"),description:e("distributors.orders.head.description"),page:"oms"}),(0,r.jsxs)("div",{className:"px-[50px] py-8",children:[(0,r.jsx)(el,{}),(0,r.jsxs)("div",{className:"grid grid-cols-2 mt-7 gap-[35px]",children:[(0,r.jsx)("div",{children:(0,r.jsx)(eW,{})}),(0,r.jsx)("div",{children:(0,r.jsx)(eD,{orderId:null==s?void 0:s.id})})]})]})]})};e$.getLayout=e=>(0,r.jsx)(a.A,{children:(0,r.jsx)(f,{children:(0,r.jsx)("div",{children:e})})});var eQ=!0;let eY=e$},9519:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});var r=t(37876),l=t(49995);t(14232);let a=e=>{let{variant:s="primary",title:t="",size:a="large",disabled:i=!1,icon:d,handleClick:n,className:o}=e,c=(0,l.A)({"btn-primary":"primary"===s,"btn-secondary":"secondary"===s,"btn-ghost":"ghost"===s,"btn-danger":"danger"===s,"btn-nuclear":"nuclear"===s}),u=(0,l.A)({"btn-large":"large"===a,"btn-medium":"medium"===a,"btn-small":"small"===a});return(0,r.jsx)("button",{className:(0,l.A)("btn",c,u,o,{"opacity-40":i}),onClick:n,disabled:i,children:d?(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[d,t]}):(0,r.jsx)("span",{className:"inline-block mx-auto",children:t})})}},44636:(e,s,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/distributors/orders",function(){return t(5609)}])}},e=>{e.O(0,[73,2202,7020,475,9451,9381,7259,270,5056,636,6593,8792],()=>e(e.s=44636)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.