@dropins/storefront-order 0.1.0-alpha11 → 0.1.0-alpha13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/api/confirmCancelOrder/confirmCancelOrder.d.ts +16 -0
  2. package/api/confirmCancelOrder/graphql/ConfirmCancelOrder.d.ts +16 -0
  3. package/api/confirmCancelOrder/index.d.ts +16 -0
  4. package/api/getCustomerOrdersReturn/getCustomerOrdersReturn.d.ts +4 -0
  5. package/api/getCustomerOrdersReturn/graphql/getCustomerOrdersReturn.graphql.d.ts +2 -0
  6. package/api/getCustomerOrdersReturn/index.d.ts +2 -0
  7. package/api/getGuestOrder/graphql/index.d.ts +2 -0
  8. package/api/getOrderDetailsById/graphql/orderItemsFragment.graphql.d.ts +5 -5
  9. package/api/getOrderDetailsById/graphql/orderSummaryFragment.graphql.d.ts +1 -1
  10. package/api/getStoreConfig/graphql/StoreConfigQuery.d.ts +1 -1
  11. package/api/index.d.ts +3 -0
  12. package/api/requestGuestOrderCancel/graphql/requestGuestOrderCancelMutation.d.ts +2 -0
  13. package/api/requestGuestOrderCancel/index.d.ts +2 -0
  14. package/api/requestGuestOrderCancel/requestGuestOrderCancel.d.ts +2 -0
  15. package/api.js +85 -41
  16. package/chunks/OrderLoaders.js +1 -1
  17. package/chunks/getCustomer.js +2 -74
  18. package/chunks/getCustomerOrdersReturn.js +52 -0
  19. package/chunks/getGuestOrder.graphql.js +150 -0
  20. package/chunks/getStoreConfig.js +6 -2
  21. package/chunks/requestGuestOrderCancel.js +97 -0
  22. package/chunks/setTaxStatus.js +1 -0
  23. package/chunks/transform-order-details.js +45 -116
  24. package/chunks/useGetStoreConfig.js +1 -0
  25. package/components/EmptyList/EmptyList.d.ts +5 -0
  26. package/components/EmptyList/index.d.ts +3 -0
  27. package/components/OrderCostSummaryContent/Blocks.d.ts +38 -0
  28. package/components/OrderCostSummaryContent/OrderCostSummaryContent.d.ts +5 -0
  29. package/components/OrderCostSummaryContent/index.d.ts +3 -0
  30. package/components/OrderLoaders/OrderLoaders.d.ts +1 -0
  31. package/components/ReturnsListContent/ReturnsListContent.d.ts +5 -0
  32. package/components/ReturnsListContent/index.d.ts +3 -0
  33. package/components/index.d.ts +3 -0
  34. package/configs/mock.config.d.ts +318 -0
  35. package/containers/CustomerDetails.js +1 -1
  36. package/containers/OrderCancel.js +1 -79
  37. package/containers/OrderCostSummary/OrderCostSummary.d.ts +5 -0
  38. package/containers/OrderCostSummary/index.d.ts +3 -0
  39. package/containers/OrderCostSummary.d.ts +3 -0
  40. package/containers/OrderCostSummary.js +1 -0
  41. package/containers/OrderProductList.js +1 -1
  42. package/containers/OrderSearch.js +1 -1
  43. package/containers/OrderStatus.js +20 -1
  44. package/containers/ReturnsList/ReturnsList.d.ts +5 -0
  45. package/containers/ReturnsList/index.d.ts +3 -0
  46. package/containers/ReturnsList.d.ts +3 -0
  47. package/containers/ReturnsList.js +1 -0
  48. package/containers/index.d.ts +2 -0
  49. package/data/models/customer-orders-return.d.ts +36 -0
  50. package/data/models/index.d.ts +2 -0
  51. package/data/models/order-details.d.ts +27 -16
  52. package/data/models/store-config.d.ts +6 -0
  53. package/data/transforms/index.d.ts +2 -0
  54. package/data/transforms/transform-customer-orders-return.d.ts +5 -0
  55. package/data/transforms/transform-order-details.d.ts +2 -1
  56. package/hooks/containers/useConfirmCancelOrder.d.ts +9 -0
  57. package/hooks/containers/useOrderCostSummary.d.ts +9 -0
  58. package/hooks/containers/useReturnsList.d.ts +14 -0
  59. package/hooks/index.d.ts +3 -0
  60. package/hooks/useIsMobile.d.ts +2 -0
  61. package/i18n/en_US.json.d.ts +58 -9
  62. package/package.json +1 -1
  63. package/render.js +2 -2
  64. package/types/api/getCustomerOrdersReturn.types.d.ts +46 -0
  65. package/types/api/getOrderDetails.types.d.ts +1 -0
  66. package/types/emptyList.types.d.ts +7 -0
  67. package/types/index.d.ts +4 -0
  68. package/types/orderCancel.types.d.ts +5 -2
  69. package/types/orderCostSummary.types.d.ts +28 -0
  70. package/types/returnsList.types.d.ts +42 -0
@@ -921,6 +921,186 @@ export declare const storyBookNormalizeAddress: {
921
921
  label: null;
922
922
  }[])[];
923
923
  };
924
+ export declare const orderCostSummaryMockup: {
925
+ number: string;
926
+ email: string;
927
+ token: string;
928
+ status: string;
929
+ isVirtual: boolean;
930
+ totalQuantity: number;
931
+ shippingMethod: string;
932
+ carrier: string;
933
+ discounts: {
934
+ amount: {
935
+ value: number;
936
+ currency: string;
937
+ };
938
+ label: string;
939
+ }[];
940
+ coupons: {
941
+ code: string;
942
+ }[];
943
+ payments: {
944
+ code: string;
945
+ name: string;
946
+ }[];
947
+ shipping: {
948
+ code: string;
949
+ amount: number;
950
+ currency: string;
951
+ };
952
+ shipments: {
953
+ id: string;
954
+ number: string;
955
+ tracking: {
956
+ carrier: string;
957
+ number: string;
958
+ title: string;
959
+ }[];
960
+ comments: {
961
+ message: string;
962
+ timestamp: string;
963
+ }[];
964
+ items: {
965
+ id: string;
966
+ productSku: string;
967
+ productName: string;
968
+ orderItem: {
969
+ id: string;
970
+ type: string;
971
+ discounted: boolean;
972
+ productName: string;
973
+ totalQuantity: number;
974
+ price: {
975
+ value: number;
976
+ currency: string;
977
+ };
978
+ totalInclTax: {};
979
+ priceInclTax: {};
980
+ regularPrice: {
981
+ value: number;
982
+ currency: string;
983
+ };
984
+ total: {
985
+ value: number;
986
+ currency: string;
987
+ };
988
+ configurableOptions: {};
989
+ product: {
990
+ id: string;
991
+ name: string;
992
+ productType: string;
993
+ sku: string;
994
+ thumbnail: {
995
+ url: string;
996
+ label: string;
997
+ };
998
+ };
999
+ thumbnail: {
1000
+ url: string;
1001
+ label: string;
1002
+ };
1003
+ quantityCanceled: number;
1004
+ quantityInvoiced: number;
1005
+ quantityOrdered: number;
1006
+ quantityRefunded: number;
1007
+ quantityReturned: number;
1008
+ quantityShipped: number;
1009
+ };
1010
+ }[];
1011
+ }[];
1012
+ items: {
1013
+ id: string;
1014
+ type: string;
1015
+ discounted: boolean;
1016
+ productName: string;
1017
+ totalQuantity: number;
1018
+ price: {
1019
+ value: number;
1020
+ currency: string;
1021
+ };
1022
+ totalInclTax: {};
1023
+ priceInclTax: {};
1024
+ regularPrice: {
1025
+ value: number;
1026
+ currency: string;
1027
+ };
1028
+ total: {
1029
+ value: number;
1030
+ currency: string;
1031
+ };
1032
+ configurableOptions: {};
1033
+ product: {
1034
+ id: string;
1035
+ name: string;
1036
+ productType: string;
1037
+ sku: string;
1038
+ thumbnail: {
1039
+ url: string;
1040
+ label: string;
1041
+ };
1042
+ };
1043
+ thumbnail: {
1044
+ url: string;
1045
+ label: string;
1046
+ };
1047
+ quantityCanceled: number;
1048
+ quantityInvoiced: number;
1049
+ quantityOrdered: number;
1050
+ quantityRefunded: number;
1051
+ quantityReturned: number;
1052
+ quantityShipped: number;
1053
+ }[];
1054
+ totalGiftcard: {
1055
+ value: number;
1056
+ currency: string;
1057
+ };
1058
+ grandTotal: {
1059
+ value: number;
1060
+ currency: string;
1061
+ };
1062
+ totalShipping: {
1063
+ value: number;
1064
+ currency: string;
1065
+ };
1066
+ subtotal: {
1067
+ value: number;
1068
+ currency: string;
1069
+ };
1070
+ totalTax: {
1071
+ value: number;
1072
+ currency: string;
1073
+ };
1074
+ shippingAddress: {
1075
+ street: string[];
1076
+ city: string;
1077
+ country: string;
1078
+ company: string;
1079
+ firstName: string;
1080
+ middleName: string;
1081
+ lastName: string;
1082
+ postCode: string;
1083
+ region: string;
1084
+ regionId: string;
1085
+ telephone: string;
1086
+ customAttributes: never[];
1087
+ };
1088
+ billingAddress: {
1089
+ street: string[];
1090
+ city: string;
1091
+ company: string;
1092
+ country: string;
1093
+ firstName: string;
1094
+ middleName: string;
1095
+ lastName: string;
1096
+ postCode: string;
1097
+ region: string;
1098
+ regionId: string;
1099
+ telephone: string;
1100
+ customAttributes: never[];
1101
+ };
1102
+ availableActions: never[];
1103
+ };
924
1104
  export declare const orderMockOrderProductItemsList: {
925
1105
  items: ({
926
1106
  type: string;
@@ -1389,4 +1569,142 @@ export declare const orderMockOrderProductItemsList: {
1389
1569
  })[];
1390
1570
  totalQuantity: number;
1391
1571
  };
1572
+ export declare const returnOrderListMockResponse: {
1573
+ customer: {
1574
+ returns: {
1575
+ page_info: {
1576
+ page_size: number;
1577
+ total_pages: number;
1578
+ current_page: number;
1579
+ };
1580
+ items: {
1581
+ number: string;
1582
+ shipping: {
1583
+ tracking: {
1584
+ status: null;
1585
+ carrier: {
1586
+ uid: string;
1587
+ label: string;
1588
+ };
1589
+ tracking_number: string;
1590
+ }[];
1591
+ };
1592
+ order: {
1593
+ number: string;
1594
+ token: string;
1595
+ };
1596
+ items: {
1597
+ uid: string;
1598
+ quantity: number;
1599
+ status: string;
1600
+ request_quantity: number;
1601
+ order_item: {
1602
+ __typename: string;
1603
+ status: string;
1604
+ product_name: string;
1605
+ id: string;
1606
+ quantity_ordered: number;
1607
+ quantity_shipped: number;
1608
+ quantity_canceled: number;
1609
+ quantity_invoiced: number;
1610
+ quantity_refunded: number;
1611
+ quantity_returned: number;
1612
+ product_sale_price: {
1613
+ value: number;
1614
+ currency: string;
1615
+ };
1616
+ selected_options: never[];
1617
+ product: {
1618
+ __typename: string;
1619
+ canonical_url: null;
1620
+ uid: string;
1621
+ name: string;
1622
+ sku: string;
1623
+ thumbnail: {
1624
+ label: string;
1625
+ url: string;
1626
+ };
1627
+ price_range: {
1628
+ maximum_price: {
1629
+ regular_price: {
1630
+ currency: string;
1631
+ value: number;
1632
+ };
1633
+ };
1634
+ };
1635
+ };
1636
+ };
1637
+ }[];
1638
+ }[];
1639
+ };
1640
+ };
1641
+ };
1642
+ export declare const returnOrderListMock: {
1643
+ token: string;
1644
+ orderNumber: string;
1645
+ items: {
1646
+ uid: string;
1647
+ quantity: number;
1648
+ status: string;
1649
+ requestQuantity: number;
1650
+ orderItem: {
1651
+ type: string;
1652
+ productName: string;
1653
+ quantityCanceled: number;
1654
+ quantityInvoiced: number;
1655
+ quantityOrdered: number;
1656
+ quantityRefunded: number;
1657
+ quantityReturned: number;
1658
+ quantityShipped: number;
1659
+ id: string;
1660
+ discounted: boolean;
1661
+ total: {
1662
+ value: number;
1663
+ currency: string;
1664
+ };
1665
+ totalInclTax: {
1666
+ value: number;
1667
+ currency: string;
1668
+ };
1669
+ price: {
1670
+ value: number;
1671
+ currency: string;
1672
+ };
1673
+ priceInclTax: {
1674
+ value: number;
1675
+ currency: string;
1676
+ };
1677
+ totalQuantity: number;
1678
+ regularPrice: {
1679
+ value: number;
1680
+ currency: string;
1681
+ };
1682
+ product: {
1683
+ canonicalUrl: string;
1684
+ id: string;
1685
+ name: string;
1686
+ sku: string;
1687
+ image: string;
1688
+ productType: string;
1689
+ thumbnail: {
1690
+ label: string;
1691
+ url: string;
1692
+ };
1693
+ };
1694
+ thumbnail: {
1695
+ label: string;
1696
+ url: string;
1697
+ };
1698
+ configurableOptions: {};
1699
+ };
1700
+ }[];
1701
+ tracking: {
1702
+ status: null;
1703
+ carrier: {
1704
+ uid: string;
1705
+ label: string;
1706
+ };
1707
+ trackingNumber: string;
1708
+ }[];
1709
+ }[];
1392
1710
  //# sourceMappingURL=mock.config.d.ts.map
@@ -1 +1 @@
1
- import{jsx as t,jsxs as u,Fragment as P}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b}from"@dropins/tools/lib.js";import{useMemo as V,useCallback as x,useState as k,useEffect as L}from"@dropins/tools/preact-hooks.js";import{events as Z}from"@dropins/tools/event-bus.js";import{c as R}from"../chunks/convertCase.js";import{g as z}from"../chunks/getAttributesForm.js";import{Card as B,Header as F,Price as $,Icon as q}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import*as m from"@dropins/tools/preact-compat.js";import{D as K}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact.js";import{useText as G}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const I=o=>m.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),J=o=>m.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.00718 5H22.1507C22.7047 5 23.1579 5.45323 23.1579 6.00718V7.51794C23.1579 7.51794 1.01007 7.58844 1 7.55823V6.00718C1 5.45323 1.45323 5 2.00718 5Z",stroke:"currentColor",strokeWidth:1}),m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M23.1579 9.78409V18.3451C23.1579 18.899 22.7047 19.3523 22.1507 19.3523H2.00718C1.45323 19.3523 1 18.899 1 18.3451V9.78409H23.1579Z",stroke:"currentColor",strokeWidth:1}),m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.6192 17.5897C18.4535 17.5897 19.1299 16.9133 19.1299 16.0789C19.1299 15.2446 18.4535 14.5682 17.6192 14.5682C16.7848 14.5682 16.1084 15.2446 16.1084 16.0789C16.1084 16.9133 16.7848 17.5897 17.6192 17.5897Z",stroke:"currentColor",strokeWidth:1}),m.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8848 17.5897C20.7192 17.5897 21.3956 16.9133 21.3956 16.0789C21.3956 15.2446 20.7192 14.5682 19.8848 14.5682C19.0504 14.5682 18.374 15.2446 18.374 16.0789C18.374 16.9133 19.0504 17.5897 19.8848 17.5897Z",stroke:"currentColor",strokeWidth:1})),Q=({loading:o,order:e,withHeader:a=!0,title:c,paymentIconsMap:s={},normalizeAddress:r})=>{var N,M,E,T,D;const i=G({emailTitle:"Order.CustomerDetails.email.title",shippingAddressTitle:"Order.CustomerDetails.shippingAddress.title",shippingMethodsTitle:"Order.CustomerDetails.shippingMethods.title",billingAddressTitle:"Order.CustomerDetails.billingAddress.title",billingMethodsTitle:"Order.CustomerDetails.billingMethods.title",headerText:"Order.CustomerDetails.headerText",freeShipping:"Order.CustomerDetails.freeShipping"}),p=V(()=>({checkmo:I,card:J,...s}),[s]),_=x(j=>{var w;return(w=r[j])==null?void 0:w.map((f,S)=>t("div",{className:"order-customer-details-content__container-description--row",children:f==null?void 0:f.map((l,W)=>t("p",{children:l.label?`${l.label}: ${Array.isArray(l.value)?l.value.join(" "):l==null?void 0:l.value}`:Array.isArray(l.value)?l.value.join(" "):l==null?void 0:l.value},W))},S))},[r]);if(!e||o)return t(K,{});const d=(e==null?void 0:e.email)??"",h=(N=e==null?void 0:e.shipping)==null?void 0:N.code,n=(M=e==null?void 0:e.shipping)==null?void 0:M.amount,v=(E=e==null?void 0:e.shipping)==null?void 0:E.currency,g=e==null?void 0:e.payments,C=g&&g.length>0,A=C?(T=g[0])==null?void 0:T.name:"",y=C?(D=g[0])==null?void 0:D.code:"",H=C&&A!=="";return u(B,{"data-testid":"order-details",variant:"secondary",className:b(["order-customer-details-content"]),children:[a?t(F,{title:c??i.headerText}):null,u("div",{className:"order-customer-details-content__container",children:[u("div",{className:"order-customer-details-content__container-email",children:[t("div",{className:"order-customer-details-content__container-title",children:i.emailTitle}),t("p",{children:d})]}),u("div",{className:"order-customer-details-content__container-shipping_address",children:[t("div",{className:"order-customer-details-content__container-title",children:i.shippingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("shippingAddress")})]}),u("div",{className:"order-customer-details-content__container-billing_address",children:[t("div",{className:"order-customer-details-content__container-title",children:i.billingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("billingAddress")})]}),u("div",{className:"order-customer-details-content__container-shipping_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:i.shippingMethodsTitle}),h?t(P,{children:n?u("p",{"data-testid":"shipping_methods_price",children:[t($,{amount:n,currency:v})," ",h]}):t("p",{"data-testid":"shipping_methods_placeholder",children:i.freeShipping})}):null]}),u("div",{className:"order-customer-details-content__container-billing_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:i.billingMethodsTitle}),H&&u("p",{"data-testid":"billing_methods_description",className:b([["order-customer-details-content__container-billing_methods--icon",!!p[y]]]),children:[t(q,{source:p[y]}),A]})]})]})]})},U=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],O=o=>{o.sort((s,r)=>s.orderNumber-r.orderNumber);const e=[];let a=[];const c=s=>s.value!==void 0&&s.value!==null&&s.value!=="";for(let s=0;s<o.length;s++){const r=o[s];if(c(r))if(Array.isArray(r.value)){const i=r.value.map(p=>({...r,value:p}));e.push(i)}else e.length<4?(a.push(r),a.length===2&&(e.push(a),a=[])):e.push([r])}return a.length>0&&e.length<4&&e.push(a),e},X=({orderData:o})=>{const[e,a]=k(!0),[c,s]=k(o),[r,i]=k([]);L(()=>{const d=Z.on("order/data",h=>{s(h)},{eager:!0});return()=>{d==null||d.off()}},[]),L(()=>{z("shortRequest").then(d=>{if(d){const h=d.map(({name:n,orderNumber:v,label:g})=>({name:R(n),orderNumber:v,label:U.includes(n)?null:g}));i(h)}}).finally(()=>{a(!1)})},[]);const p=x(d=>{if(!r.length||!c||!c[d])return[];const h=Object.fromEntries(Object.entries(c[d]).map(([n,v])=>[n.toLowerCase(),v]));return r.filter(({name:n})=>h[n.toLowerCase()]).map(n=>({name:n.name,orderNumber:n.orderNumber,value:h[n.name.toLowerCase()],label:n.label}))},[r,c]),_=V(()=>({billingAddress:O(p("billingAddress")),shippingAddress:O(p("shippingAddress"))}),[p]);return{order:c,normalizeAddress:_,loading:e}},ue=({paymentIconsMap:o,orderData:e,title:a,className:c})=>{const{order:s,normalizeAddress:r,loading:i}=X({orderData:e});return t("div",{className:b(["order-customer-details",c]),children:t(Q,{loading:i,order:s,title:a,paymentIconsMap:o,normalizeAddress:r})})};export{ue as CustomerDetails,ue as default};
1
+ import{jsx as t,jsxs as m,Fragment as L}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b}from"@dropins/tools/lib.js";import{useMemo as x,useCallback as H,useState as k,useEffect as O}from"@dropins/tools/preact-hooks.js";import{events as Z}from"@dropins/tools/event-bus.js";import{c as R}from"../chunks/convertCase.js";import{g as z}from"../chunks/getAttributesForm.js";import{Card as B,Header as F,Price as $,Icon as q}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import*as h from"@dropins/tools/preact-compat.js";import{D as K}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact.js";import{useText as G}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const I=o=>h.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),J=o=>h.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.00718 5H22.1507C22.7047 5 23.1579 5.45323 23.1579 6.00718V7.51794C23.1579 7.51794 1.01007 7.58844 1 7.55823V6.00718C1 5.45323 1.45323 5 2.00718 5Z",stroke:"currentColor",strokeWidth:1}),h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M23.1579 9.78409V18.3451C23.1579 18.899 22.7047 19.3523 22.1507 19.3523H2.00718C1.45323 19.3523 1 18.899 1 18.3451V9.78409H23.1579Z",stroke:"currentColor",strokeWidth:1}),h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.6192 17.5897C18.4535 17.5897 19.1299 16.9133 19.1299 16.0789C19.1299 15.2446 18.4535 14.5682 17.6192 14.5682C16.7848 14.5682 16.1084 15.2446 16.1084 16.0789C16.1084 16.9133 16.7848 17.5897 17.6192 17.5897Z",stroke:"currentColor",strokeWidth:1}),h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8848 17.5897C20.7192 17.5897 21.3956 16.9133 21.3956 16.0789C21.3956 15.2446 20.7192 14.5682 19.8848 14.5682C19.0504 14.5682 18.374 15.2446 18.374 16.0789C18.374 16.9133 19.0504 17.5897 19.8848 17.5897Z",stroke:"currentColor",strokeWidth:1})),Q=({loading:o,order:e,withHeader:a=!0,title:c,paymentIconsMap:s={},normalizeAddress:r})=>{var N,M,E,T,D;const i=G({emailTitle:"Order.CustomerDetails.email.title",shippingAddressTitle:"Order.CustomerDetails.shippingAddress.title",shippingMethodsTitle:"Order.CustomerDetails.shippingMethods.title",billingAddressTitle:"Order.CustomerDetails.billingAddress.title",billingMethodsTitle:"Order.CustomerDetails.billingMethods.title",headerText:"Order.CustomerDetails.headerText",freeShipping:"Order.CustomerDetails.freeShipping"}),p=x(()=>({checkmo:I,card:J,...s}),[s]),_=H(S=>{var w;return(w=r[S])==null?void 0:w.map((f,W)=>t("div",{className:"order-customer-details-content__container-description--row",children:f==null?void 0:f.map((l,P)=>m(L,{children:[t("p",{children:l.label?`${l.label}: ${Array.isArray(l.value)?l.value.join(" "):l==null?void 0:l.value}`:Array.isArray(l.value)?l.value.join(" "):l==null?void 0:l.value},P)," "]}))},W))},[r]);if(!e||o)return t(K,{});const d=(e==null?void 0:e.email)??"",u=(N=e==null?void 0:e.shipping)==null?void 0:N.code,n=(M=e==null?void 0:e.shipping)==null?void 0:M.amount,v=(E=e==null?void 0:e.shipping)==null?void 0:E.currency,g=e==null?void 0:e.payments,C=g&&g.length>0,A=C?(T=g[0])==null?void 0:T.name:"",y=C?(D=g[0])==null?void 0:D.code:"",j=C&&A!=="";return m(B,{"data-testid":"order-details",variant:"secondary",className:b(["order-customer-details-content"]),children:[a?t(F,{title:c??i.headerText}):null,m("div",{className:"order-customer-details-content__container",children:[m("div",{className:"order-customer-details-content__container-email",children:[t("div",{className:"order-customer-details-content__container-title",children:i.emailTitle}),t("p",{children:d})]}),m("div",{className:"order-customer-details-content__container-shipping_address",children:[t("div",{className:"order-customer-details-content__container-title",children:i.shippingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("shippingAddress")})]}),m("div",{className:"order-customer-details-content__container-billing_address",children:[t("div",{className:"order-customer-details-content__container-title",children:i.billingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("billingAddress")})]}),m("div",{className:"order-customer-details-content__container-shipping_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:i.shippingMethodsTitle}),u?t(L,{children:n?m("p",{"data-testid":"shipping_methods_price",children:[t($,{amount:n,currency:v})," ",u]}):t("p",{"data-testid":"shipping_methods_placeholder",children:i.freeShipping})}):null]}),m("div",{className:"order-customer-details-content__container-billing_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:i.billingMethodsTitle}),j&&m("p",{"data-testid":"billing_methods_description",className:b([["order-customer-details-content__container-billing_methods--icon",!!p[y]]]),children:[t(q,{source:p[y]}),A]})]})]})]})},U=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],V=o=>{o.sort((s,r)=>s.orderNumber-r.orderNumber);const e=[];let a=[];const c=s=>s.value!==void 0&&s.value!==null&&s.value!=="";for(let s=0;s<o.length;s++){const r=o[s];if(c(r))if(Array.isArray(r.value)){const i=r.value.map(p=>({...r,value:p}));e.push(i)}else e.length<4?(a.push(r),a.length===2&&(e.push(a),a=[])):e.push([r])}return a.length>0&&e.length<4&&e.push(a),e},X=({orderData:o})=>{const[e,a]=k(!0),[c,s]=k(o),[r,i]=k([]);O(()=>{const d=Z.on("order/data",u=>{s(u)},{eager:!0});return()=>{d==null||d.off()}},[]),O(()=>{z("shortRequest").then(d=>{if(d){const u=d.map(({name:n,orderNumber:v,label:g})=>({name:R(n),orderNumber:v,label:U.includes(n)?null:g}));i(u)}}).finally(()=>{a(!1)})},[]);const p=H(d=>{if(!r.length||!c||!c[d])return[];const u=Object.fromEntries(Object.entries(c[d]).map(([n,v])=>[n.toLowerCase(),v]));return r.filter(({name:n})=>u[n.toLowerCase()]).map(n=>({name:n.name,orderNumber:n.orderNumber,value:u[n.name.toLowerCase()],label:n.label}))},[r,c]),_=x(()=>({billingAddress:V(p("billingAddress")),shippingAddress:V(p("shippingAddress"))}),[p]);return{order:c,normalizeAddress:_,loading:e}},ue=({paymentIconsMap:o,orderData:e,title:a,className:c})=>{const{order:s,normalizeAddress:r,loading:i}=X({orderData:e});return t("div",{className:b(["order-customer-details",c]),children:t(Q,{loading:i,order:s,title:a,paymentIconsMap:o,normalizeAddress:r})})};export{ue as CustomerDetails,ue as default};
@@ -1,79 +1 @@
1
- import{jsx as o,Fragment as p,jsxs as R}from"@dropins/tools/preact-jsx-runtime.js";import{P as m,O as b,A as E,t as D}from"../chunks/transform-order-details.js";import{f as v,h as A}from"../chunks/fetch-graphql.js";import{useState as l,useEffect as I}from"@dropins/tools/preact-hooks.js";import{g as N}from"../chunks/getStoreConfig.js";import{InLineAlert as F,Picker as x,Button as y}from"@dropins/tools/components.js";import{F as L}from"../chunks/OrderCancelReasonsForm.js";import"@dropins/tools/lib.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as u}from"@dropins/tools/event-bus.js";import{useText as $,Text as f}from"@dropins/tools/i18n.js";import"../chunks/convertCase.js";import"@dropins/tools/fetch-graphql.js";const T=({pickerProps:a,submitButtonProps:e,cancelReasons:r,cancelOrder:s,orderId:t})=>{const n=$({ErrorHeading:"Order.OrderCancellationReasonsForm.errorHeading",ErrorDescription:"Order.OrderCancellationReasonsForm.errorDescription",orderCancellationLabel:"Order.OrderCancellationReasonsForm.label"}),[i,g]=l(0),[_,O]=l(!1),[C,h]=l(!1);u.on("authenticated",d=>{d&&h(!0)},{eager:!0});const S=d=>{d.preventDefault();const c=Number(d.target.value);g(c)};return o(p,{children:R(L,{onSubmit:async d=>(d.preventDefault(),s(t,r[i].text,c=>{C||(c.status="guest order cancellation requested"),u.emit("order/data",c)},()=>{O(!0)})),"data-testid":"order-order-cancel-reasons-form__text",children:[_&&o(F,{heading:n.ErrorHeading,description:n.ErrorDescription}),o("div",{className:"order-order-cancel-reasons-form__text",children:o(f,{id:"Order.OrderCancellationReasonsForm.description"})}),o(x,{name:"cancellationReasons",floatingLabel:n.orderCancellationLabel,defaultOption:r[0],variant:"primary",options:r,value:String(i),handleSelect:S,required:!0,"data-testid":"order-cancellation-reasons-selector",...a}),o("div",{className:"order-order-cancel-reasons-form__button-container",children:o(y,{variant:"primary",...e,children:o(f,{id:"Order.OrderCancellationReasonsForm.button"})})})]})})},w=`
2
- mutation CANCEL_ORDER_MUTATION($orderId: ID!, $reason: String!) {
3
- cancelOrder(input: { order_id: $orderId, reason: $reason }) {
4
- error
5
- order {
6
- email
7
- available_actions
8
- status
9
- number
10
- id
11
- order_date
12
- carrier
13
- shipping_method
14
- is_virtual
15
- applied_coupons {
16
- code
17
- }
18
- shipments {
19
- id
20
- number
21
- tracking {
22
- title
23
- number
24
- carrier
25
- }
26
- comments {
27
- message
28
- timestamp
29
- }
30
- items {
31
- id
32
- product_sku
33
- product_name
34
- order_item {
35
- ${m}
36
- ... on GiftCardOrderItem {
37
- gift_card {
38
- recipient_name
39
- recipient_email
40
- sender_name
41
- sender_email
42
- message
43
- }
44
- }
45
- }
46
- }
47
- }
48
- payment_methods {
49
- name
50
- type
51
- }
52
- shipping_address {
53
- ...AddressesList
54
- }
55
- billing_address {
56
- ...AddressesList
57
- }
58
- items {
59
- ${m}
60
- ... on GiftCardOrderItem {
61
- __typename
62
- gift_card {
63
- recipient_name
64
- recipient_email
65
- sender_name
66
- sender_email
67
- message
68
- }
69
- }
70
- }
71
- total {
72
- ...OrderSummary
73
- }
74
- }
75
- }
76
- }
77
- ${b}
78
- ${E}
79
- `,G=async(a,e,r,s)=>{if(!a)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return v(w,{variables:{orderId:a,reason:e}}).then(({errors:t,data:n})=>{if(t)return A(t);if(n.cancelOrder.error!=null){s();return}const i=D(n.cancelOrder.order);r(i)})},M=()=>{const[a,e]=l(null);return I(()=>{const r=sessionStorage.getItem("orderStoreConfig"),s=r?JSON.parse(r):null;s?e(s):N().then(t=>{t&&(sessionStorage.setItem("orderStoreConfig",JSON.stringify(t)),e(t))})},[]),a},Z=({orderId:a})=>{const e=M(),r=(e==null?void 0:e.orderCancellationReasons)??[];return o(p,{children:o(T,{orderId:a,cancelOrder:G,cancelReasons:(t=>t.map((n,i)=>({text:n==null?void 0:n.description,value:i.toString()})))(r)})})};export{Z as OrderCancel,Z as default};
1
+ import{jsxs as g,jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import{u as h}from"../chunks/useGetStoreConfig.js";import{InLineAlert as v,Picker as x,Button as S}from"@dropins/tools/components.js";import{F}from"../chunks/OrderCancelReasonsForm.js";import"@dropins/tools/lib.js";import"@dropins/tools/preact-compat.js";import{useState as d}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as u}from"@dropins/tools/event-bus.js";import{useText as E,Text as p}from"@dropins/tools/i18n.js";import{c as _,r as D}from"../chunks/requestGuestOrderCancel.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";import"../chunks/getGuestOrder.graphql.js";const L=({pickerProps:s,submitButtonProps:o,cancelReasons:n,cancelOrder:i,orderRef:m})=>{const a=E({ErrorHeading:"Order.OrderCancellationReasonsForm.errorHeading",ErrorDescription:"Order.OrderCancellationReasonsForm.errorDescription",orderCancellationLabel:"Order.OrderCancellationReasonsForm.label"}),[r,c]=d(0),[f,C]=d(!1),[O,b]=d(!1);u.on("authenticated",t=>{t&&b(!0)},{eager:!0});const R=t=>{t.preventDefault();const l=Number(t.target.value);c(l)};return g(F,{onSubmit:async t=>(t.preventDefault(),i(m,n[r].text,l=>{O||(l.status="guest order cancellation requested"),u.emit("order/data",l)},()=>{C(!0)})),"data-testid":"order-order-cancel-reasons-form__text",children:[f&&e(v,{heading:a.ErrorHeading,description:a.ErrorDescription}),e("div",{className:"order-order-cancel-reasons-form__text",children:e(p,{id:"Order.OrderCancellationReasonsForm.description"})}),e(x,{name:"cancellationReasons",floatingLabel:a.orderCancellationLabel,defaultOption:n[0],variant:"primary",options:n,value:String(r),handleSelect:R,required:!0,"data-testid":"order-cancellation-reasons-selector",...s}),e("div",{className:"order-order-cancel-reasons-form__button-container",children:e(S,{variant:"primary","data-testid":"order-cancel-submit-button",...o,children:e(p,{id:"Order.OrderCancellationReasonsForm.button"})})})]})},Q=({orderRef:s})=>{const o=h(),n=(o==null?void 0:o.orderCancellationReasons)??[];let i=_;return s.length>20&&(i=D),e(L,{orderRef:s,cancelOrder:i,cancelReasons:(a=>a.map((r,c)=>({text:r==null?void 0:r.description,value:c.toString()})))(n)})};export{Q as OrderCancel,Q as default};
@@ -0,0 +1,5 @@
1
+ import { Container } from '@dropins/tools/types/elsie/src/lib';
2
+ import { OrderCostSummaryProps } from '../../types';
3
+
4
+ export declare const OrderCostSummary: Container<OrderCostSummaryProps>;
5
+ //# sourceMappingURL=OrderCostSummary.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './OrderCostSummary';
2
+ export { OrderCostSummary as default } from './OrderCostSummary';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ export * from './OrderCostSummary/index'
2
+ import _default from './OrderCostSummary/index'
3
+ export default _default
@@ -0,0 +1 @@
1
+ import{jsxs as r,jsx as c,Fragment as v}from"@dropins/tools/preact-jsx-runtime.js";import{classes as H}from"@dropins/tools/lib.js";import{useState as _,useEffect as T}from"@dropins/tools/preact-hooks.js";import{events as V}from"@dropins/tools/event-bus.js";import{s as C}from"../chunks/setTaxStatus.js";import{g as N}from"../chunks/getStoreConfig.js";import{Price as u,Icon as b,Accordion as f,AccordionSection as E,Card as D,Header as k}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import*as h from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{a as z}from"../chunks/OrderLoaders.js";import{useText as B}from"@dropins/tools/i18n.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const A=e=>h.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},h.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),I=e=>h.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},h.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),j=e=>h.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},h.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M22 6.25H22.75C22.75 5.83579 22.4142 5.5 22 5.5V6.25ZM22 9.27L22.2514 9.97663C22.5503 9.87029 22.75 9.58731 22.75 9.27H22ZM20.26 12.92L19.5534 13.1714L19.5539 13.1728L20.26 12.92ZM22 14.66H22.75C22.75 14.3433 22.551 14.0607 22.2528 13.9539L22 14.66ZM22 17.68V18.43C22.4142 18.43 22.75 18.0942 22.75 17.68H22ZM2 17.68H1.25C1.25 18.0942 1.58579 18.43 2 18.43V17.68ZM2 14.66L1.74865 13.9534C1.44969 14.0597 1.25 14.3427 1.25 14.66H2ZM3.74 11.01L4.44663 10.7586L4.44611 10.7572L3.74 11.01ZM2 9.27H1.25C1.25 9.58675 1.44899 9.86934 1.7472 9.97611L2 9.27ZM2 6.25V5.5C1.58579 5.5 1.25 5.83579 1.25 6.25H2ZM21.25 6.25V9.27H22.75V6.25H21.25ZM21.7486 8.56337C19.8706 9.23141 18.8838 11.2889 19.5534 13.1714L20.9666 12.6686C20.5762 11.5711 21.1494 10.3686 22.2514 9.97663L21.7486 8.56337ZM19.5539 13.1728C19.9195 14.1941 20.7259 15.0005 21.7472 15.3661L22.2528 13.9539C21.6541 13.7395 21.1805 13.2659 20.9661 12.6672L19.5539 13.1728ZM21.25 14.66V17.68H22.75V14.66H21.25ZM22 16.93H2V18.43H22V16.93ZM2.75 17.68V14.66H1.25V17.68H2.75ZM2.25135 15.3666C4.12941 14.6986 5.11623 12.6411 4.44663 10.7586L3.03337 11.2614C3.42377 12.3589 2.85059 13.5614 1.74865 13.9534L2.25135 15.3666ZM4.44611 10.7572C4.08045 9.73588 3.27412 8.92955 2.2528 8.56389L1.7472 9.97611C2.34588 10.1905 2.81955 10.6641 3.03389 11.2628L4.44611 10.7572ZM2.75 9.27V6.25H1.25V9.27H2.75ZM2 7H22V5.5H2V7ZM7.31 6.74V18.17H8.81V6.74H7.31ZM17.0997 8.39967L11.0397 14.4597L12.1003 15.5203L18.1603 9.46033L17.0997 8.39967ZM12.57 9.67C12.57 9.87231 12.4159 10 12.27 10V11.5C13.2839 11.5 14.07 10.6606 14.07 9.67H12.57ZM12.27 10C12.1241 10 11.97 9.87231 11.97 9.67H10.47C10.47 10.6606 11.2561 11.5 12.27 11.5V10ZM11.97 9.67C11.97 9.46769 12.1241 9.34 12.27 9.34V7.84C11.2561 7.84 10.47 8.67938 10.47 9.67H11.97ZM12.27 9.34C12.4159 9.34 12.57 9.46769 12.57 9.67H14.07C14.07 8.67938 13.2839 7.84 12.27 7.84V9.34ZM17.22 14.32C17.22 14.5223 17.0659 14.65 16.92 14.65V16.15C17.9339 16.15 18.72 15.3106 18.72 14.32H17.22ZM16.92 14.65C16.7741 14.65 16.62 14.5223 16.62 14.32H15.12C15.12 15.3106 15.9061 16.15 16.92 16.15V14.65ZM16.62 14.32C16.62 14.1177 16.7741 13.99 16.92 13.99V12.49C15.9061 12.49 15.12 13.3294 15.12 14.32H16.62ZM16.92 13.99C17.0659 13.99 17.22 14.1177 17.22 14.32H18.72C18.72 13.3294 17.9339 12.49 16.92 12.49V13.99Z",fill:"#3D3D3D"})),P=({translations:e,order:a,subTotalValue:t,shoppingOrdersDisplaySubtotal:n})=>{var l,i;return r("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[r("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.subtotal}),c(u,{className:"order-cost-summary-content__description--normal-price",weight:"normal",currency:(l=a==null?void 0:a.subtotal)==null?void 0:l.currency,amount:t})]}),r("div",{className:"order-cost-summary-content__description--subheader",children:[!n.taxExcluded&&n.taxIncluded?c("span",{children:e.incl}):null,n.taxExcluded&&n.taxIncluded?r(v,{children:[c(u,{currency:(i=a==null?void 0:a.subtotal)==null?void 0:i.currency,amount:t,size:"small"})," ",c("span",{children:e.excl})]}):null]})]})},W=({translations:e,shoppingOrdersDisplayShipping:a,order:t,totalShipping:n})=>{var l,i,o,s;return r("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--shipping",children:[r("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.shipping}),(l=t==null?void 0:t.totalShipping)!=null&&l.value?c(u,{weight:"normal",currency:(i=t==null?void 0:t.totalShipping)==null?void 0:i.currency,amount:n}):c("span",{children:e.freeShipping})]}),r("div",{className:"order-cost-summary-content__description--subheader",children:[a.taxIncluded&&a.taxExcluded?r(v,{children:[c(u,{weight:"normal",currency:(o=t==null?void 0:t.totalShipping)==null?void 0:o.currency,amount:(s=t==null?void 0:t.totalShipping)==null?void 0:s.value,size:"small"}),r("span",{children:[" ",e.excl]})]}):null,a.taxIncluded&&!a.taxExcluded?c("span",{children:e.incl}):null]})]})},q=({translations:e,order:a,totalGiftcardValue:t,totalGiftcardCurrency:n})=>{var l;return!(a!=null&&a.discounts.length)&&!t?null:r("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--discount",children:[r("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.discount}),c("span",{children:a!=null&&a.discounts.length?(l=a==null?void 0:a.discounts)==null?void 0:l.map(({amount:i},o)=>{const s=(i==null?void 0:i.value)??0;return c(u,{weight:"normal",sale:!0,currency:i==null?void 0:i.currency,amount:-(s+t)},o)}):null})]}),!(a!=null&&a.discounts.length)&&t?r("div",{className:"order-cost-summary-content__description--subheader",children:[r("span",{children:[c(b,{source:j,size:"16"}),c("span",{children:e.discountSubtitle.toLocaleUpperCase()})]}),c(u,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},F=({order:e})=>c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:e.coupons.map((a,t)=>r("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:a.code}),c("span",{children:"TBD"})]},t))}),U=({translations:e,renderTaxAccordion:a,totalAccordionTaxValue:t,order:n})=>{var o;const[l,i]=_(!1);return a?c(f,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:A,iconClose:I,children:r(E,{onStateChange:i,title:e.accordionTitle,secondaryText:c(v,{children:l?null:c(u,{weight:"normal",amount:t,currency:n.totalTax.currency})}),renderContentWhenClosed:!1,children:[n.taxes.map((s,m)=>{var d,p;return r("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:s==null?void 0:s.title}),c("p",{children:c(u,{weight:"normal",amount:(d=s==null?void 0:s.amount)==null?void 0:d.value,currency:(p=s==null?void 0:s.amount)==null?void 0:p.currency})})]},m)}),r("div",{className:"order-cost-summary-content__accordion-row order-cost-summary-content__accordion-total",children:[c("p",{children:e.accordionTotalTax}),c("p",{children:c(u,{weight:"normal",amount:t,currency:n.totalTax.currency,size:"medium"})})]})]})}):c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--tax",children:r("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.tax}),c(u,{currency:(o=n==null?void 0:n.totalTax)==null?void 0:o.currency,amount:n==null?void 0:n.totalTax.value,weight:"normal",size:"small"})]})})},G=({translations:e,shoppingOrdersDisplaySubtotal:a,order:t})=>{var n,l,i,o;return r("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--total",children:[r("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.total}),c(u,{currency:(n=t==null?void 0:t.grandTotal)==null?void 0:n.currency,amount:(l=t==null?void 0:t.grandTotal)==null?void 0:l.value,weight:"bold",size:"medium"})]}),a.taxExcluded&&a.taxIncluded?r("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:e.totalExcludingTaxes}),c(u,{currency:(i=t==null?void 0:t.grandTotal)==null?void 0:i.currency,amount:((o=t==null?void 0:t.grandTotal)==null?void 0:o.value)-(t==null?void 0:t.totalTax.value),weight:"normal",size:"small"})]}):null]})},R=({translations:e,loading:a,storeConfig:t,order:n,withHeader:l=!0})=>{var y,x,S,O,w,L;if(a||!n)return c(z,{});const i=((y=n==null?void 0:n.totalGiftcard)==null?void 0:y.value)??0,o=((x=n.totalGiftcard)==null?void 0:x.currency)??"",s=((S=n.subtotal)==null?void 0:S.value)??0,m=((O=n.totalShipping)==null?void 0:O.value)??0,d=!!((w=n==null?void 0:n.taxes)!=null&&w.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),p=d?(L=n==null?void 0:n.taxes)==null?void 0:L.reduce((Z,g)=>{var M;return+((M=g==null?void 0:g.amount)==null?void 0:M.value)+Z},0):0;return r(D,{variant:"secondary",className:H(["order-cost-summary-content"]),children:[l?c(k,{title:e.headerText}):null,r("div",{className:"order-cost-summary-content__wrapper",children:[c(P,{translations:e,order:n,subTotalValue:s,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal}),c(W,{translations:e,order:n,totalShipping:m,shoppingOrdersDisplayShipping:t==null?void 0:t.shoppingOrdersDisplayShipping}),c(q,{translations:e,order:n,totalGiftcardValue:i,totalGiftcardCurrency:o}),c(F,{order:n}),c(U,{order:n,translations:e,renderTaxAccordion:d,totalAccordionTaxValue:p}),c(G,{translations:e,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})},J=({orderData:e})=>{const[a,t]=_(!0),[n,l]=_(e),[i,o]=_(null);return T(()=>{N().then(s=>{if(s){const{shoppingCartDisplayPrice:m,shoppingOrdersDisplayShipping:d,shoppingOrdersDisplaySubtotal:p,...y}=s;o(x=>({...x,...y,shoppingCartDisplayPrice:C(m),shoppingOrdersDisplayShipping:C(d),shoppingOrdersDisplaySubtotal:C(p)}))}}).finally(()=>{t(!1)})},[]),T(()=>{const s=V.on("order/data",m=>{l(m)},{eager:!0});return()=>{s==null||s.off()}},[]),{loading:a,storeConfig:i,order:n}},lt=({withHeader:e,orderData:a,children:t,className:n,...l})=>{const{loading:i,storeConfig:o,order:s}=J({orderData:a}),m=B({headerText:"Order.OrderCostSummary.headerText",subtotal:"Order.OrderCostSummary.subtotal.title",shipping:"Order.OrderCostSummary.shipping.title",freeShipping:"Order.OrderCostSummary.shipping.freeShipping",tax:"Order.OrderCostSummary.tax.title",incl:"Order.OrderCostSummary.tax.incl",excl:"Order.OrderCostSummary.tax.excl",discount:"Order.OrderCostSummary.discount.title",discountSubtitle:"Order.OrderCostSummary.discount.subtitle",total:"Order.OrderCostSummary.total.title",accordionTitle:"Order.OrderCostSummary.tax.accordionTitle",accordionTotalTax:"Order.OrderCostSummary.tax.accordionTotalTax",totalExcludingTaxes:"Order.OrderCostSummary.tax.totalExcludingTaxes"});return c("div",{...l,className:H(["order-cost-summary",n]),children:c(R,{order:s,withHeader:e,loading:i,storeConfig:o,translations:m})})};export{lt as OrderCostSummary,lt as default};
@@ -1 +1 @@
1
- import{jsx as i,jsxs as k,Fragment as E}from"@dropins/tools/preact-jsx-runtime.js";import{Card as Z,Header as j,Price as W,CartItem as z,Icon as B,Image as K}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import{classes as q}from"@dropins/tools/lib.js";import*as L from"@dropins/tools/preact-compat.js";import{useMemo as R,useCallback as A,useState as b,useEffect as P}from"@dropins/tools/preact-hooks.js";import{Fragment as J}from"@dropins/tools/preact.js";import{O as U}from"../chunks/OrderLoaders.js";import{events as X}from"@dropins/tools/event-bus.js";import{useText as Y}from"@dropins/tools/i18n.js";import{g}from"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const I=d=>L.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},L.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),L.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),T=({loading:d,taxConfig:e,order:r=null,withHeader:h=!0,showConfigurableOptions:m})=>{const o=Y({cancelled:"Order.OrderProductListContent.cancelledTitle",allOrders:"Order.OrderProductListContent.allOrdersTitle",sender:"Order.OrderProductListContent.GiftCard.sender",recipient:"Order.OrderProductListContent.GiftCard.recipient",message:"Order.OrderProductListContent.GiftCard.message",outOfStock:"Order.OrderProductListContent.stockStatus.outOfStock",downloadableCount:"Order.OrderProductListContent.downloadableCount"}),c=R(()=>{if(!r)return[];const{items:a}=r;return[{type:"cancelled",list:a.filter(s=>s.quantityCanceled),title:o.cancelled},{type:"",list:a.filter(s=>!s.quantityCanceled),title:o.allOrders}]},[r,o]);return r?i(Z,{variant:"secondary",className:"order-order-product-list-content",children:c.filter(a=>a.list.length).map((a,s)=>{var f;return k(J,{children:[h?i(j,{title:`${a.title} (${a.list.length})`}):null,i("ul",{className:"order-order-product-list-content__items",children:(f=a.list)==null?void 0:f.map(O=>i("li",{"data-testid":"order-product-list-content-item",children:i(p,{loading:d,product:O,itemType:a.type,taxConfig:e,translations:o,showConfigurableOptions:m})},O.id))})]},s)})}):i(U,{})},p=({loading:d,product:e,itemType:r,taxConfig:h,translations:m,showConfigurableOptions:o})=>{var S,x,C,N,Q,_,H,V,$,M;const{taxExcluded:c,taxIncluded:a}=h,s=A((v,F,G)=>i(W,{amount:v,currency:F,weight:"normal",...G}),[]);let f={};const O=r==="cancelled",D=(x=(S=e==null?void 0:e.product)==null?void 0:S.stockStatus)==null?void 0:x.includes("IN_STOCK"),t=(e==null?void 0:e.giftCard)||{},l=(C=e==null?void 0:e.itemPrices)==null?void 0:C.priceIncludingTax,n=(N=e==null?void 0:e.itemPrices)==null?void 0:N.originalPrice,u=(Q=e==null?void 0:e.itemPrices)==null?void 0:Q.price,y=e.discounted&&((_=e.price)==null?void 0:_.value)!==(n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),w={..."configurableOptions"in e?e.configurableOptions:{},..."bundleOptions"in e?e.bundleOptions:{},..."senderName"in t&&(t!=null&&t.senderName)?{[m.sender]:t==null?void 0:t.senderName}:{},..."senderEmail"in t&&(t!=null&&t.senderEmail)?{[m.sender]:t==null?void 0:t.senderEmail}:{},..."recipientName"in t&&(t!=null&&t.recipientName)?{[m.recipient]:t==null?void 0:t.recipientName}:{},..."recipientEmail"in t&&(t!=null&&t.recipientEmail)?{[m.recipient]:t==null?void 0:t.recipientEmail}:{},..."message"in t&&(t!=null&&t.message)?{[m.message]:t==null?void 0:t.message}:{},..."downloadableLinks"in e&&(e!=null&&e.downloadableLinks)?{[`${(H=e==null?void 0:e.downloadableLinks)==null?void 0:H.count} ${m.downloadableCount}`]:(V=e==null?void 0:e.downloadableLinks)==null?void 0:V.result}:{}};if(a&&c){const v=y?n==null?void 0:n.value:(l==null?void 0:l.value)*(e==null?void 0:e.totalQuantity);f={taxExcluded:!0,taxIncluded:void 0,price:s(n==null?void 0:n.value,n==null?void 0:n.currency),total:k(E,{children:[s(v,n==null?void 0:n.currency,{variant:e.discounted&&(l==null?void 0:l.value)!==v?"strikethrough":"default"}),e.discounted&&(l==null?void 0:l.value)!==v?s(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:s((u==null?void 0:u.value)*e.totalQuantity,u==null?void 0:u.currency)}}else if(!a&&c)f={taxExcluded:void 0,taxIncluded:void 0,price:s(n==null?void 0:n.value,n==null?void 0:n.currency),total:k(E,{children:[s((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),l==null?void 0:l.currency,{variant:y?"strikethrough":"default"}),y?s(($=e.price)==null?void 0:$.value,(M=e.price)==null?void 0:M.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:s((u==null?void 0:u.value)*(e==null?void 0:e.totalQuantity),u==null?void 0:u.currency)};else if(a&&!c){const v=y?n.value:l.value*e.totalQuantity;f={taxExcluded:void 0,taxIncluded:!0,price:s(l==null?void 0:l.value,l==null?void 0:l.currency),total:k(E,{children:[s(v,l==null?void 0:l.currency,{variant:y?"strikethrough":"default",weight:"bold"}),y?s(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]})}}return i(z,{loading:d,alert:O&&D?k("span",{children:[i(B,{source:I}),m.outOfStock]}):i(E,{}),configurations:(o==null?void 0:o(w))??w,title:i("div",{"data-testid":"product-name",className:q(["cart-summary-item__title",["cart-summary-item__title--strikethrough",O]]),children:e.product.name}),sku:i("div",{children:e.product.sku}),quantity:e.totalQuantity,image:i(K,{src:e.product.thumbnail.url,alt:e.product.thumbnail.label,loading:"lazy",width:"90",height:"120"}),...f})},ee=d=>{let e=!1,r=!1;switch(d){case 1:r=!0;break;case 2:e=!0;break;case 3:e=!0,r=!0;break;default:e=!1,r=!1}return{taxIncluded:e,taxExcluded:r}},te=({orderData:d})=>{const[e,r]=b(!0),[h,m]=b(d),[o,c]=b({taxIncluded:!1,taxExcluded:!1});return P(()=>{g().then(a=>{a&&c(ee(a==null?void 0:a.shoppingCartDisplayPrice))}).finally(()=>{r(!1)})},[]),P(()=>{const a=X.on("order/data",s=>{m(s)},{eager:!0});return()=>{a==null||a.off()}},[]),{loading:e,taxConfig:o,order:h}},fe=({className:d,orderData:e,withHeader:r,showConfigurableOptions:h})=>{const{loading:m,taxConfig:o,order:c}=te({orderData:e});return i("div",{className:q(["order-order-product-list",d]),children:i(T,{loading:m,taxConfig:o,order:c,withHeader:r,showConfigurableOptions:h})})};export{fe as OrderProductList,fe as default};
1
+ import{jsx as r,jsxs as k,Fragment as E}from"@dropins/tools/preact-jsx-runtime.js";import{Card as Z,Header as j,Price as W,CartItem as z,Icon as B,Image as K}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import{classes as q}from"@dropins/tools/lib.js";import*as L from"@dropins/tools/preact-compat.js";import{useMemo as R,useCallback as A,useState as b,useEffect as P}from"@dropins/tools/preact-hooks.js";import{Fragment as J}from"@dropins/tools/preact.js";import{O as U}from"../chunks/OrderLoaders.js";import{events as X}from"@dropins/tools/event-bus.js";import{useText as Y}from"@dropins/tools/i18n.js";import{s as g}from"../chunks/setTaxStatus.js";import{g as I}from"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const T=u=>L.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...u},L.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M0.75 12C0.75 5.78421 5.78421 0.75 12 0.75C18.2158 0.75 23.25 5.78421 23.25 12C23.25 18.2158 18.2158 23.25 12 23.25C5.78421 23.25 0.75 18.2158 0.75 12Z",stroke:"currentColor"}),L.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.75 5.88423V4.75H12.25V5.88423L12.0485 13.0713H11.9515L11.75 5.88423ZM11.7994 18.25V16.9868H12.2253V18.25H11.7994Z",stroke:"currentColor"})),p=({loading:u,taxConfig:e,order:d=null,withHeader:c=!0,showConfigurableOptions:i})=>{const m=Y({cancelled:"Order.OrderProductListContent.cancelledTitle",allOrders:"Order.OrderProductListContent.allOrdersTitle",sender:"Order.OrderProductListContent.GiftCard.sender",recipient:"Order.OrderProductListContent.GiftCard.recipient",message:"Order.OrderProductListContent.GiftCard.message",outOfStock:"Order.OrderProductListContent.stockStatus.outOfStock",downloadableCount:"Order.OrderProductListContent.downloadableCount"}),h=R(()=>{if(!d)return[];const{items:s}=d;return[{type:"cancelled",list:s.filter(a=>a.quantityCanceled),title:m.cancelled},{type:"",list:s.filter(a=>!a.quantityCanceled),title:m.allOrders}]},[d,m]);return d?r(Z,{variant:"secondary",className:"order-order-product-list-content",children:h.filter(s=>s.list.length).map((s,a)=>{var v;return k(J,{children:[c?r(j,{title:`${s.title} (${s.list.length})`}):null,r("ul",{className:"order-order-product-list-content__items",children:(v=s.list)==null?void 0:v.map(O=>r("li",{"data-testid":"order-product-list-content-item",children:r(ee,{loading:u,product:O,itemType:s.type,taxConfig:e,translations:m,showConfigurableOptions:i})},O.id))})]},a)})}):r(U,{})},ee=({loading:u,product:e,itemType:d,taxConfig:c,translations:i,showConfigurableOptions:m})=>{var S,C,N,x,Q,_,H,V,$,M;const{taxExcluded:h,taxIncluded:s}=c,a=A((y,F,G)=>r(W,{amount:y,currency:F,weight:"normal",...G}),[]);let v={};const O=d==="cancelled",D=(C=(S=e==null?void 0:e.product)==null?void 0:S.stockStatus)==null?void 0:C.includes("IN_STOCK"),t=(e==null?void 0:e.giftCard)||{},l=(N=e==null?void 0:e.itemPrices)==null?void 0:N.priceIncludingTax,n=(x=e==null?void 0:e.itemPrices)==null?void 0:x.originalPrice,o=(Q=e==null?void 0:e.itemPrices)==null?void 0:Q.price,f=e.discounted&&((_=e.price)==null?void 0:_.value)!==(n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),w={..."configurableOptions"in e?e.configurableOptions:{},..."bundleOptions"in e?e.bundleOptions:{},..."senderName"in t&&(t!=null&&t.senderName)?{[i.sender]:t==null?void 0:t.senderName}:{},..."senderEmail"in t&&(t!=null&&t.senderEmail)?{[i.sender]:t==null?void 0:t.senderEmail}:{},..."recipientName"in t&&(t!=null&&t.recipientName)?{[i.recipient]:t==null?void 0:t.recipientName}:{},..."recipientEmail"in t&&(t!=null&&t.recipientEmail)?{[i.recipient]:t==null?void 0:t.recipientEmail}:{},..."message"in t&&(t!=null&&t.message)?{[i.message]:t==null?void 0:t.message}:{},..."downloadableLinks"in e&&(e!=null&&e.downloadableLinks)?{[`${(H=e==null?void 0:e.downloadableLinks)==null?void 0:H.count} ${i.downloadableCount}`]:(V=e==null?void 0:e.downloadableLinks)==null?void 0:V.result}:{}};if(s&&h){const y=f?n==null?void 0:n.value:(l==null?void 0:l.value)*(e==null?void 0:e.totalQuantity);v={taxExcluded:!0,taxIncluded:void 0,price:a(n==null?void 0:n.value,n==null?void 0:n.currency),total:k(E,{children:[a(y,n==null?void 0:n.currency,{variant:e.discounted&&(l==null?void 0:l.value)!==y?"strikethrough":"default"}),e.discounted&&(l==null?void 0:l.value)!==y?a(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:a((o==null?void 0:o.value)*e.totalQuantity,o==null?void 0:o.currency)}}else if(!s&&h)v={taxExcluded:void 0,taxIncluded:void 0,price:a(n==null?void 0:n.value,n==null?void 0:n.currency),total:k(E,{children:[a((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),l==null?void 0:l.currency,{variant:f?"strikethrough":"default"}),f?a(($=e.price)==null?void 0:$.value,(M=e.price)==null?void 0:M.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:a((o==null?void 0:o.value)*(e==null?void 0:e.totalQuantity),o==null?void 0:o.currency)};else if(s&&!h){const y=f?n.value:l.value*e.totalQuantity;v={taxExcluded:void 0,taxIncluded:!0,price:a(l==null?void 0:l.value,l==null?void 0:l.currency),total:k(E,{children:[a(y,l==null?void 0:l.currency,{variant:f?"strikethrough":"default",weight:"bold"}),f?a(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]})}}return r(z,{loading:u,alert:O&&D?k("span",{children:[r(B,{source:T}),i.outOfStock]}):r(E,{}),configurations:(m==null?void 0:m(w))??w,title:r("div",{"data-testid":"product-name",className:q(["cart-summary-item__title",["cart-summary-item__title--strikethrough",O]]),children:e.product.name}),sku:r("div",{children:e.product.sku}),quantity:e.totalQuantity,image:r(K,{src:e.product.thumbnail.url,alt:e.product.thumbnail.label,loading:"lazy",width:"90",height:"120"}),...v})},te=({orderData:u})=>{const[e,d]=b(!0),[c,i]=b(u),[m,h]=b({taxIncluded:!1,taxExcluded:!1});return P(()=>{I().then(s=>{s&&h(g(s==null?void 0:s.shoppingCartDisplayPrice))}).finally(()=>{d(!1)})},[]),P(()=>{const s=X.on("order/data",a=>{i(a)},{eager:!0});return()=>{s==null||s.off()}},[]),{loading:e,taxConfig:m,order:c}},ye=({className:u,orderData:e,withHeader:d,showConfigurableOptions:c})=>{const{loading:i,taxConfig:m,order:h}=te({orderData:e});return r("div",{className:q(["order-order-product-list",u]),children:r(p,{loading:i,taxConfig:m,order:h,withHeader:d,showConfigurableOptions:c})})};export{ye as OrderProductList,ye as default};
@@ -1 +1 @@
1
- import{jsxs as v,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as _}from"@dropins/tools/lib.js";import{Card as U,InLineAlert as C,Icon as x,Button as V}from"@dropins/tools/components.js";import{F as L}from"../chunks/OrderCancelReasonsForm.js";import*as R from"@dropins/tools/preact-compat.js";import{useState as D,useCallback as O,useEffect as g,useMemo as k}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as w}from"@dropins/tools/event-bus.js";import{Text as S,useText as H}from"@dropins/tools/i18n.js";import{g as A,a as P}from"../chunks/getCustomer.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";const X=e=>R.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},R.createElement("path",{vectorEffect:"non-scaling-stroke",fillRule:"evenodd",clipRule:"evenodd",d:"M1 20.8953L12.1922 1.5L23.395 20.8953H1ZM13.0278 13.9638L13.25 10.0377V9H11.25V10.0377L11.4722 13.9638H13.0278ZM11.2994 16V17.7509H13.2253V16H11.2994Z",fill:"currentColor"})),B=({onSubmit:e,loading:t,inLineAlert:o,fieldsConfig:a})=>v(U,{variant:"secondary",className:"order-order-search-form",children:[s("h2",{className:"order-order-search-form__title",children:s(S,{id:"Order.OrderSearchForm.title"})}),s("p",{children:s(S,{id:"Order.OrderSearchForm.description"})}),o.text?s(C,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:o.type,variant:"secondary",heading:o.text,icon:s(x,{source:X})}):null,s(L,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:t,fieldsConfig:a,onSubmit:e,children:s("div",{className:"order-order-search-form__button-container",children:s(V,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:t,children:s(S,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});var T=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(T||{});const j=e=>{if(!e)return null;const t=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(a=>{t.has(a.name)||t.set(a.name,"false"),a.checked&&t.set(a.name,"true")}),t&&typeof t.entries=="function"){const a=t.entries();if(a&&typeof a[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(a)))||{}}return{}},p=(e,t)=>{if(typeof e!="function")return;const o=e();if(!t||Object.keys(t).length===0){window.location.href=o;return}const a=new URLSearchParams;Object.entries(t).forEach(([u,d])=>{a.append(u,String(d))});const c=o.includes("?")?"&":"?";window.location.href=`${o}${c}${a.toString()}`},I=e=>{try{return new URL(window.location.href).searchParams.get(e)}catch{return null}},q=({onError:e,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c})=>{const[u,d]=D({text:"",type:"success"}),[E,h]=D(!1),m=H({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",postcode:"Order.OrderSearchForm.postcode",number:"Order.OrderSearchForm.orderNumber"}),b=O(async r=>{const n=I("orderRef"),i=n&&n.length>20;if(!r&&!n||!(r!=null&&r.number)&&!(r!=null&&r.token)&&!n)return null;if(t){const f=await A();(f==null?void 0:f.email)===r.email?p(a,{orderRef:r==null?void 0:r.number}):i||p(c,{orderRef:r.token})}else i||p(c,{orderRef:r==null?void 0:r.token})},[t,a,c]);g(()=>{const r=w.on("order/data",n=>{b(n)},{eager:!0});return()=>{r==null||r.off()}},[b]),g(()=>{const r=I("orderRef"),n=r&&r.length>20?r:null;r&&(n?p(c,{orderRef:r}):t?p(a,{orderRef:r}):o==null||o({render:!0,formValues:{number:r}}))},[t,a,c,o]);const M=k(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.email,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.postcode,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:2,name:"postcode",id:"postcode",code:"postcode"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[m]);return{onSubmit:O(async(r,n)=>{if(!n)return null;h(!0);const i=j(r.target);await P(i).then(l=>{l||d({text:m.invalidSearch,type:"warning"}),w.emit("order/data",l)}).catch(async l=>{var N;let f=!0;e==null||e({error:l.message});const y=t?await A():{email:""};(y==null?void 0:y.email)===(i==null?void 0:i.email)?(f=!1,p(a,{orderRef:i.number})):f=o==null?void 0:o({render:(N=l==null?void 0:l.message)==null?void 0:N.includes("Please login to view the order."),formValues:i}),f&&d({text:l.message,type:"warning"})}).finally(()=>{h(!1)})},[t,e,o,a,m.invalidSearch]),inLineAlert:u,loading:E,normalizeFieldsConfig:M}},ne=({className:e,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c,onError:u})=>{const{onSubmit:d,loading:E,inLineAlert:h,normalizeFieldsConfig:m}=q({onError:u,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c});return s("div",{className:_(["order-order-search",e]),children:s(B,{onSubmit:d,loading:E,inLineAlert:h,fieldsConfig:m})})};export{ne as OrderSearch,ne as default};
1
+ import{jsxs as v,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as _}from"@dropins/tools/lib.js";import{Card as U,InLineAlert as C,Icon as x,Button as V}from"@dropins/tools/components.js";import{F as L}from"../chunks/OrderCancelReasonsForm.js";import*as R from"@dropins/tools/preact-compat.js";import{useState as D,useCallback as O,useEffect as g,useMemo as k}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as w}from"@dropins/tools/event-bus.js";import{Text as S,useText as H}from"@dropins/tools/i18n.js";import{g as A,a as P}from"../chunks/getCustomer.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getGuestOrder.graphql.js";import"../chunks/transform-order-details.js";import"../chunks/convertCase.js";const X=e=>R.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},R.createElement("path",{vectorEffect:"non-scaling-stroke",fillRule:"evenodd",clipRule:"evenodd",d:"M1 20.8953L12.1922 1.5L23.395 20.8953H1ZM13.0278 13.9638L13.25 10.0377V9H11.25V10.0377L11.4722 13.9638H13.0278ZM11.2994 16V17.7509H13.2253V16H11.2994Z",fill:"currentColor"})),B=({onSubmit:e,loading:t,inLineAlert:o,fieldsConfig:a})=>v(U,{variant:"secondary",className:"order-order-search-form",children:[s("h2",{className:"order-order-search-form__title",children:s(S,{id:"Order.OrderSearchForm.title"})}),s("p",{children:s(S,{id:"Order.OrderSearchForm.description"})}),o.text?s(C,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:o.type,variant:"secondary",heading:o.text,icon:s(x,{source:X})}):null,s(L,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:t,fieldsConfig:a,onSubmit:e,children:s("div",{className:"order-order-search-form__button-container",children:s(V,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:t,children:s(S,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});var T=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(T||{});const j=e=>{if(!e)return null;const t=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(a=>{t.has(a.name)||t.set(a.name,"false"),a.checked&&t.set(a.name,"true")}),t&&typeof t.entries=="function"){const a=t.entries();if(a&&typeof a[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(a)))||{}}return{}},p=(e,t)=>{if(typeof e!="function")return;const o=e();if(!t||Object.keys(t).length===0){window.location.href=o;return}const a=new URLSearchParams;Object.entries(t).forEach(([u,d])=>{a.append(u,String(d))});const c=o.includes("?")?"&":"?";window.location.href=`${o}${c}${a.toString()}`},I=e=>{try{return new URL(window.location.href).searchParams.get(e)}catch{return null}},q=({onError:e,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c})=>{const[u,d]=D({text:"",type:"success"}),[E,h]=D(!1),m=H({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",postcode:"Order.OrderSearchForm.postcode",number:"Order.OrderSearchForm.orderNumber"}),b=O(async r=>{const n=I("orderRef"),i=n&&n.length>20;if(!r&&!n||!(r!=null&&r.number)&&!(r!=null&&r.token)&&!n)return null;if(t){const f=await A();(f==null?void 0:f.email)===r.email?p(a,{orderRef:r==null?void 0:r.number}):i||p(c,{orderRef:r.token})}else i||p(c,{orderRef:r==null?void 0:r.token})},[t,a,c]);g(()=>{const r=w.on("order/data",n=>{b(n)},{eager:!0});return()=>{r==null||r.off()}},[b]),g(()=>{const r=I("orderRef"),n=r&&r.length>20?r:null;r&&(n?p(c,{orderRef:r}):t?p(a,{orderRef:r}):o==null||o({render:!0,formValues:{number:r}}))},[t,a,c,o]);const M=k(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.email,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.postcode,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:2,name:"postcode",id:"postcode",code:"postcode"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[m]);return{onSubmit:O(async(r,n)=>{if(!n)return null;h(!0);const i=j(r.target);await P(i).then(l=>{l||d({text:m.invalidSearch,type:"warning"}),w.emit("order/data",l)}).catch(async l=>{var N;let f=!0;e==null||e({error:l.message});const y=t?await A():{email:""};(y==null?void 0:y.email)===(i==null?void 0:i.email)?(f=!1,p(a,{orderRef:i.number})):f=o==null?void 0:o({render:(N=l==null?void 0:l.message)==null?void 0:N.includes("Please login to view the order."),formValues:i}),f&&d({text:l.message,type:"warning"})}).finally(()=>{h(!1)})},[t,e,o,a,m.invalidSearch]),inLineAlert:u,loading:E,normalizeFieldsConfig:M}},ce=({className:e,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c,onError:u})=>{const{onSubmit:d,loading:E,inLineAlert:h,normalizeFieldsConfig:m}=q({onError:u,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c});return s("div",{className:_(["order-order-search",e]),children:s(B,{onSubmit:d,loading:E,inLineAlert:h,fieldsConfig:m})})};export{ce as OrderSearch,ce as default};
@@ -1 +1,20 @@
1
- import{jsx as t,jsxs as C,Fragment as R}from"@dropins/tools/preact-jsx-runtime.js";import{Card as g,Header as f,Button as p}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import{Slot as E,classes as O}from"@dropins/tools/lib.js";import{useMemo as v}from"@dropins/tools/preact-compat.js";import{useText as i}from"@dropins/tools/i18n.js";import{useState as h,useEffect as N}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as w}from"@dropins/tools/event-bus.js";import{C as y}from"../chunks/OrderLoaders.js";const l={pending:"orderPending",shiping:"orderShipped",complete:"orderComplete",processing:"orderProcessing","on hold":"orderOnHold",canceled:"orderCanceled","suspected fraud":"orderSuspectedFraud","payment Review":"orderPaymentReview","order received":"orderReceived","guest order cancellation requested":"guestOrderCancellationRequested"},A=({slots:r,title:a,status:n,orderData:e})=>{const o=String(n).toLocaleLowerCase(),s=i(`Order.OrderStatusContent.${l[o]}.title`),d=i(`Order.OrderStatusContent.${l[o]}.message`),c=i(`Order.OrderStatusContent.${l[o]}.messageWithoutDate`);if(!n)return t("div",{});const m=e!=null&&e.orderStatusChangeDate?d==null?void 0:d.message.replace("{DATE}",e==null?void 0:e.orderStatusChangeDate):c.messageWithoutDate;return C(g,{className:"order-order-status-content",variant:"secondary",children:[t(f,{title:a??s.title}),C("div",{className:"order-order-status-content__wrapper",children:[t("div",{className:"order-order-status-content__wrapper-description",children:t("p",{children:m})}),t(_,{orderData:e,slots:r})]})]})};var u=(r=>(r.CANCEL="CANCEL",r.RETURN="RETURN",r.REORDER="REORDER",r))(u||{});const _=({className:r,children:a,orderData:n,slots:e,...o})=>{const s=i({cancel:"Order.OrderStatusContent.actions.cancel",return:"Order.OrderStatusContent.actions.return",reorder:"Order.OrderStatusContent.actions.reorder"}),d=v(()=>{const c=n==null?void 0:n.availableActions,m=!!(c!=null&&c.length);return t(R,{children:e!=null&&e.OrderActions?t(E,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:e==null?void 0:e.OrderActions,context:n}):t("div",{"data-testid":"availableActionsList",className:O(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!m]]),children:c==null?void 0:c.map(S=>{switch(S){case u.CANCEL:return t(p,{variant:"secondary",children:s.cancel});case u.RETURN:return t(p,{variant:"secondary",children:s.return});case u.REORDER:return t(p,{variant:"secondary",children:s.reorder})}})})})},[n,e==null?void 0:e.OrderActions,s]);return t("div",{...o,className:O(["order-order-actions",r]),children:d})},T=({orderData:r})=>{const[a,n]=h(r),[e,o]=h(r==null?void 0:r.status);return N(()=>{const s=w.on("order/data",d=>{n(d),o(d.status)},{eager:!0});return()=>{s==null||s.off()}},[]),{orderStatus:e,order:a}},B=({slots:r,orderData:a,className:n,statusTitle:e,status:o})=>{const{orderStatus:s,order:d}=T({orderData:a});return t("div",{className:O(["order-order-status",n]),children:d?t(A,{title:e,status:o||s,slots:r,orderData:d}):t(y,{withCard:!1})})};export{B as OrderStatus,B as default};
1
+ import{jsx as i,jsxs as g,Fragment as v}from"@dropins/tools/preact-jsx-runtime.js";import{Card as A,Header as I,Button as p,InLineAlert as T}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import{Slot as x,classes as S}from"@dropins/tools/lib.js";import{useMemo as L,useState as $}from"@dropins/tools/preact-compat.js";import{useText as u}from"@dropins/tools/i18n.js";import{useState as R,useEffect as E}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact.js";import{events as y}from"@dropins/tools/event-bus.js";import{C as U}from"../chunks/OrderLoaders.js";import{G as K}from"../chunks/getGuestOrder.graphql.js";import{f as M,h as F}from"../chunks/fetch-graphql.js";import{t as P}from"../chunks/transform-order-details.js";import{u as G}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/convertCase.js";import"../chunks/getStoreConfig.js";const h={pending:"orderPending",shiping:"orderShipped",complete:"orderComplete",processing:"orderProcessing","on hold":"orderOnHold",canceled:"orderCanceled","suspected fraud":"orderSuspectedFraud","payment Review":"orderPaymentReview","order received":"orderReceived","guest order cancellation requested":"guestOrderCancellationRequested"},H=({slots:r,title:d,status:o,orderData:e})=>{const s=String(o).toLocaleLowerCase(),t=u(`Order.OrderStatusContent.${h[s]}.title`),n=u(`Order.OrderStatusContent.${h[s]}.message`),c=u(`Order.OrderStatusContent.${h[s]}.messageWithoutDate`);if(!o)return i("div",{});const a=e!=null&&e.orderStatusChangeDate?n==null?void 0:n.message.replace("{DATE}",e==null?void 0:e.orderStatusChangeDate):c.messageWithoutDate;return g(A,{className:"order-order-status-content",variant:"secondary",children:[i(I,{title:d??t.title}),g("div",{className:"order-order-status-content__wrapper",children:[i("div",{className:"order-order-status-content__wrapper-description",children:i("p",{children:a})}),i(V,{orderData:e,slots:r})]})]})};var C=(r=>(r.CANCEL="CANCEL",r.RETURN="RETURN",r.REORDER="REORDER",r))(C||{});const V=({className:r,children:d,orderData:o,slots:e,...s})=>{const t=u({cancel:"Order.OrderStatusContent.actions.cancel",return:"Order.OrderStatusContent.actions.return",reorder:"Order.OrderStatusContent.actions.reorder"}),n=L(()=>{const c=o==null?void 0:o.availableActions,a=!!(c!=null&&c.length);return i(v,{children:e!=null&&e.OrderActions?i(x,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:e==null?void 0:e.OrderActions,context:o}):i("div",{"data-testid":"availableActionsList",className:S(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!a]]),children:c==null?void 0:c.map(m=>{switch(m){case C.CANCEL:return i(p,{variant:"secondary",children:t.cancel});case C.RETURN:return i(p,{variant:"secondary",children:t.return});case C.REORDER:return i(p,{variant:"secondary",children:t.reorder})}})})})},[o,e==null?void 0:e.OrderActions,t]);return i("div",{...s,className:S(["order-order-actions",r]),children:n})},W=({orderData:r})=>{const[d,o]=R(r),[e,s]=R(r==null?void 0:r.status);return E(()=>{const t=y.on("order/data",n=>{o(n),s(n.status)},{eager:!0});return()=>{t==null||t.off()}},[]),{orderStatus:e,order:d}},j=`
2
+ mutation CONFIRM_CANCEL_ORDER_MUTATION(
3
+ $orderId: ID!,
4
+ $confirmationKey: String!
5
+ ) {
6
+ confirmCancelOrder(input: {
7
+ order_id: $orderId,
8
+ confirmation_key: $confirmationKey
9
+ }) {
10
+ order {
11
+ ...guestOrderData
12
+ }
13
+ errorV2 {
14
+ message
15
+ code
16
+ }
17
+ }
18
+ }
19
+ ${K}
20
+ `,q=async(r,d)=>M(j,{variables:{orderId:r,confirmationKey:d}}).then(async({errors:o,data:e})=>{var n,c,a,m;const s=[...(n=e==null?void 0:e.confirmCancelOrder)!=null&&n.errorV2?[(c=e==null?void 0:e.confirmCancelOrder)==null?void 0:c.errorV2]:[],...o??[]];let t=null;return(a=e==null?void 0:e.confirmCancelOrder)!=null&&a.order&&(t=P((m=e==null?void 0:e.confirmCancelOrder)==null?void 0:m.order),y.emit("order/data",t)),s.length>0?F(s):t}),b=({enableOrderCancellation:r})=>{const d=u({orderCancelled:"Order.OrderStatusContent.orderCanceled.message"}),[o,e]=R({text:"",status:void 0});return E(()=>{if(!r)return;const s=new URLSearchParams(window.location.search),t=s.get("orderId"),n=s.get("confirmationKey");t&&n&&q(atob(t),n).then(()=>{e({text:d.orderCancelled,status:"success"})}).catch(c=>{e({text:c.message,status:"warning"})})},[r,d.orderCancelled]),{confirmOrderCancellation:o}},de=({slots:r,orderData:d,className:o,statusTitle:e,status:s})=>{const{orderStatus:t,order:n}=W({orderData:d}),[c,a]=$(!1),m=()=>{a(!0);const O=new URL(window.location.href),_=O.searchParams.get("orderId"),w=O.searchParams.get("confirmationKey");_&&w&&(O.searchParams.delete("orderId"),O.searchParams.delete("confirmationKey"),window.history.replaceState({},document.title,O.toString()))},N=u({cancelOrder:"Order.OrderStatusContent.actions.cancel"}),f=G(),{confirmOrderCancellation:l}=b({enableOrderCancellation:f==null?void 0:f.orderCancellationEnabled});return g("div",{className:S(["order-order-status",o]),children:[!c&&(l==null?void 0:l.status)!==void 0&&i(T,{heading:N.cancelOrder,onDismiss:m,description:l.text,type:l.status}),n?i(H,{title:e,status:s||t,slots:r,orderData:n}):i(U,{withCard:!1})]})};export{de as OrderStatus,de as default};
@@ -0,0 +1,5 @@
1
+ import { ReturnsListProps } from '../../types';
2
+ import { Container } from '@dropins/tools/types/elsie/src/lib';
3
+
4
+ export declare const ReturnsList: Container<ReturnsListProps>;
5
+ //# sourceMappingURL=ReturnsList.d.ts.map