@dropins/storefront-order 0.1.0-alpha13 → 0.1.0-alpha14
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.
- package/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts +1 -1
- package/api/getOrderDetailsById/graphql/index.d.ts +1 -0
- package/api/getOrderDetailsById/graphql/orderItemsFragment.graphql.d.ts +2 -2
- package/api/getOrderDetailsById/graphql/returnsFragment.graphql.d.ts +2 -0
- package/api.js +11 -3
- package/chunks/getAttributesForm.js +1 -1
- package/chunks/getCustomerOrdersReturn.js +12 -45
- package/chunks/getGuestOrder.graphql.js +10 -6
- package/chunks/transform-order-details.js +48 -6
- package/chunks/useIsMobile.js +1 -0
- package/configs/mock.config.d.ts +12 -0
- package/containers/CustomerDetails.js +1 -1
- package/containers/OrderCostSummary.js +1 -1
- package/containers/OrderProductList.js +1 -1
- package/containers/OrderReturns/OrderReturns.d.ts +5 -0
- package/containers/OrderReturns/index.d.ts +3 -0
- package/containers/OrderReturns.d.ts +3 -0
- package/containers/OrderReturns.js +1 -0
- package/containers/OrderSearch.js +1 -1
- package/containers/ReturnsList.js +1 -1
- package/containers/ShippingStatus.js +1 -1
- package/containers/index.d.ts +1 -0
- package/data/models/customer-orders-return.d.ts +7 -5
- package/data/models/order-details.d.ts +4 -0
- package/data/transforms/index.d.ts +1 -1
- package/data/transforms/transform-customer-orders-returns.d.ts +5 -0
- package/hooks/containers/useCustomerDetails.d.ts +2 -2
- package/hooks/containers/useOrderReturns.d.ts +8 -0
- package/hooks/containers/useReturnsList.d.ts +2 -2
- package/i18n/en_US.json.d.ts +48 -6
- package/lib/returnOrdersHelper.d.ts +19 -0
- package/package.json +1 -1
- package/render.js +2 -2
- package/types/api/getCustomerOrdersReturn.types.d.ts +10 -35
- package/types/api/getOrderDetails.types.d.ts +31 -2
- package/types/orderProductList.types.d.ts +2 -0
- package/types/returnsList.types.d.ts +40 -9
- package/types/shippingStatus.types.d.ts +1 -0
- package/data/transforms/transform-customer-orders-return.d.ts +0 -5
- package/lib/formatAddressFields.d.ts +0 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const GET_ATTRIBUTES_FORM = "\n query GET_ATTRIBUTES_FORM($formCode: String!) {\n attributesForm(formCode: $formCode) {\n items {\n code\n default_value\n entity_type\n frontend_class\n frontend_input\n is_required\n is_unique\n label\n options {\n is_default\n label\n value\n }\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n }\n errors {\n type\n message\n }\n }\n }\n";
|
|
2
|
-
export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: customer_register_address) {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n";
|
|
2
|
+
export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n";
|
|
3
3
|
//# sourceMappingURL=getAttributesForm.graphql.d.ts.map
|
|
@@ -2,4 +2,5 @@ export * from './orderSummaryFragment.graphql';
|
|
|
2
2
|
export * from './orderByNumber.graphql';
|
|
3
3
|
export * from './customerAddressFragment.graphql';
|
|
4
4
|
export * from './orderItemsFragment.graphql';
|
|
5
|
+
export * from './returnsFragment.graphql';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const PRODUCT_DETAILS_FRAGMENT = "\n fragment ProductDetails on ProductInterface {\n __typename\n canonical_url\n uid\n name\n sku\n only_x_left_in_stock\n stock_status\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n";
|
|
1
|
+
export declare const PRODUCT_DETAILS_FRAGMENT = "\n fragment ProductDetails on ProductInterface {\n __typename\n canonical_url\n url_key\n uid\n name\n sku\n only_x_left_in_stock\n stock_status\n thumbnail {\n label\n url\n }\n price_range {\n maximum_price {\n regular_price {\n currency\n value\n }\n }\n }\n }\n";
|
|
2
2
|
export declare const PRICE_DETAILS_FRAGMENT = "\n fragment PriceDetails on OrderItemInterface {\n prices {\n price_including_tax {\n value\n currency\n }\n original_price {\n value\n currency\n }\n original_price_including_tax {\n value\n currency\n }\n price {\n value\n currency\n }\n }\n }\n";
|
|
3
3
|
export declare const GIFT_CARD_DETAILS_FRAGMENT = "\n fragment GiftCardDetails on GiftCardOrderItem {\n ...PriceDetails\n gift_message {\n message\n }\n gift_card {\n recipient_name\n recipient_email\n sender_name\n sender_email\n message\n }\n }\n";
|
|
4
|
-
export declare const ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment OrderItemDetails on OrderItemInterface {\n __typename\n status\n product_name\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n quantity_returned\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...ProductDetails\n }\n ...PriceDetails\n }\n";
|
|
4
|
+
export declare const ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment OrderItemDetails on OrderItemInterface {\n __typename\n status\n product_name\n product_url_key\n id\n quantity_ordered\n quantity_shipped\n quantity_canceled\n quantity_invoiced\n quantity_refunded\n quantity_returned\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n ...ProductDetails\n }\n ...PriceDetails\n }\n";
|
|
5
5
|
export declare const BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT = "\n fragment BundleOrderItemDetails on BundleOrderItem {\n ...PriceDetails\n bundle_options {\n uid\n label\n values {\n uid\n product_name\n }\n }\n }\n";
|
|
6
6
|
//# sourceMappingURL=orderItemsFragment.graphql.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const RETURNS_FRAGMENT = "\n fragment OrderReturns on Returns {\n __typename\n items {\n number\n status\n shipping {\n tracking {\n status {\n text\n type\n }\n carrier {\n uid\n label\n }\n tracking_number\n }\n }\n order {\n number\n token\n }\n items {\n uid\n quantity\n status\n request_quantity\n order_item {\n ...OrderItemDetails\n ... on GiftCardOrderItem {\n ...GiftCardDetails\n product {\n ...ProductDetails\n }\n }\n }\n }\n }\n }\n";
|
|
2
|
+
//# sourceMappingURL=returnsFragment.graphql.d.ts.map
|
package/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Initializer as E}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";import{f as i,h as n}from"./chunks/fetch-graphql.js";import{g as
|
|
1
|
+
import{Initializer as E}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";import{f as i,h as n}from"./chunks/fetch-graphql.js";import{g as x,r as P,s as U,a as Y,b as q}from"./chunks/fetch-graphql.js";import{h as m}from"./chunks/network-error.js";import{P as l,a as u,G as c,O as _,B as p,R as O,b as f}from"./chunks/transform-order-details.js";import{O as h,A as D}from"./chunks/getGuestOrder.graphql.js";import{t as T}from"./chunks/getCustomer.js";import{g as z,a as H}from"./chunks/getCustomer.js";import{g as j}from"./chunks/getAttributesForm.js";import{g as V}from"./chunks/getStoreConfig.js";import{g as X}from"./chunks/getCustomerOrdersReturn.js";import{c as ee,r as re}from"./chunks/requestGuestOrderCancel.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/convertCase.js";const G=`
|
|
2
2
|
query ORDER_BY_NUMBER($orderNumber: String!) {
|
|
3
3
|
customer {
|
|
4
4
|
orders(
|
|
@@ -15,6 +15,9 @@ query ORDER_BY_NUMBER($orderNumber: String!) {
|
|
|
15
15
|
carrier
|
|
16
16
|
shipping_method
|
|
17
17
|
is_virtual
|
|
18
|
+
returns {
|
|
19
|
+
...OrderReturns
|
|
20
|
+
}
|
|
18
21
|
applied_coupons {
|
|
19
22
|
code
|
|
20
23
|
}
|
|
@@ -88,7 +91,8 @@ ${_}
|
|
|
88
91
|
${p}
|
|
89
92
|
${h}
|
|
90
93
|
${D}
|
|
91
|
-
|
|
94
|
+
${O}
|
|
95
|
+
`,I=async(e,r)=>await i(G,{method:"GET",cache:"force-cache",variables:{orderNumber:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?n(t.errors):f(r??"orderData",t)}).catch(m),b=`
|
|
92
96
|
query ORDER_BY_TOKEN($token: String!) {
|
|
93
97
|
guestOrderByToken(input: { token: $token }) {
|
|
94
98
|
email
|
|
@@ -104,6 +108,9 @@ query ORDER_BY_TOKEN($token: String!) {
|
|
|
104
108
|
gift_receipt_included
|
|
105
109
|
available_actions
|
|
106
110
|
is_virtual
|
|
111
|
+
returns {
|
|
112
|
+
...OrderReturns
|
|
113
|
+
}
|
|
107
114
|
payment_methods {
|
|
108
115
|
name
|
|
109
116
|
type
|
|
@@ -178,4 +185,5 @@ ${_}
|
|
|
178
185
|
${p}
|
|
179
186
|
${h}
|
|
180
187
|
${D}
|
|
181
|
-
|
|
188
|
+
${O}
|
|
189
|
+
`,g=async e=>await i(b,{method:"GET",cache:"no-cache",variables:{token:e}}).then(r=>{var t;return(t=r.errors)!=null&&t.length?n(r.errors):T(r)}).catch(m),y=async e=>{var o;const r=(e==null?void 0:e.orderRef)??"",t=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((o=e==null?void 0:e.orderRef)==null?void 0:o.length)>20,a=(e==null?void 0:e.orderData)??null;if(a){s.emit("order/data",a);return}if(!r){console.error("Order Token or number not received.");return}const d=t?await g(r):await I(r);d?s.emit("order/data",d):s.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},R=new E({init:async e=>{const r={};R.config.setConfig({...r,...e}),y(e).catch(console.error)},listeners:()=>[]}),M=R.config;export{ee as cancelOrder,M as config,i as fetchGraphQl,j as getAttributesForm,x as getConfig,z as getCustomer,X as getCustomerOrdersReturn,H as getGuestOrder,I as getOrderDetailsById,V as getStoreConfig,g as guestOrderByToken,R as initialize,P as removeFetchGraphQlHeader,re as requestGuestOrderCancel,U as setEndpoint,Y as setFetchGraphQlHeader,q as setFetchGraphQlHeaders};
|
|
@@ -32,7 +32,7 @@ import{h as l}from"./network-error.js";import{f as m,h as _}from"./fetch-graphql
|
|
|
32
32
|
}
|
|
33
33
|
`,p=`
|
|
34
34
|
query GET_ATTRIBUTES_FORM_SHORT {
|
|
35
|
-
attributesForm(formCode: customer_register_address) {
|
|
35
|
+
attributesForm(formCode: "customer_register_address") {
|
|
36
36
|
items {
|
|
37
37
|
frontend_input
|
|
38
38
|
label
|
|
@@ -1,52 +1,19 @@
|
|
|
1
|
-
import{h as
|
|
1
|
+
import{h as R}from"./network-error.js";import{f as e,h as E}from"./fetch-graphql.js";import{R as _,P as T,a as o,G as c,O as s,c as u}from"./transform-order-details.js";const h=`
|
|
2
2
|
query GET_CUSTOMER_ORDERS_RETURN {
|
|
3
3
|
customer {
|
|
4
4
|
returns {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
items {
|
|
11
|
-
number
|
|
12
|
-
shipping {
|
|
13
|
-
tracking {
|
|
14
|
-
status {
|
|
15
|
-
text
|
|
16
|
-
type
|
|
17
|
-
}
|
|
18
|
-
carrier {
|
|
19
|
-
uid
|
|
20
|
-
label
|
|
21
|
-
}
|
|
22
|
-
tracking_number
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
order {
|
|
26
|
-
number
|
|
27
|
-
token
|
|
28
|
-
}
|
|
29
|
-
items {
|
|
30
|
-
uid
|
|
31
|
-
quantity
|
|
32
|
-
status
|
|
33
|
-
request_quantity
|
|
34
|
-
order_item {
|
|
35
|
-
...OrderItemDetails
|
|
36
|
-
... on GiftCardOrderItem {
|
|
37
|
-
...GiftCardDetails
|
|
38
|
-
product {
|
|
39
|
-
...ProductDetails
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
5
|
+
page_info {
|
|
6
|
+
page_size
|
|
7
|
+
total_pages
|
|
8
|
+
current_page
|
|
43
9
|
}
|
|
44
|
-
|
|
10
|
+
...OrderReturns
|
|
45
11
|
}
|
|
46
12
|
}
|
|
47
13
|
}
|
|
48
|
-
${
|
|
49
|
-
${
|
|
50
|
-
${
|
|
51
|
-
${
|
|
52
|
-
|
|
14
|
+
${_}
|
|
15
|
+
${T}
|
|
16
|
+
${o}
|
|
17
|
+
${c}
|
|
18
|
+
${s}
|
|
19
|
+
`,A=async()=>await e(h,{method:"GET",cache:"force-cache"}).then(r=>{var t,a;return(t=r.errors)!=null&&t.length?E(r.errors):u((a=r==null?void 0:r.data)==null?void 0:a.customer.returns)}).catch(R);export{A as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{P as e,a as t,G as r,O as a,B as s}from"./transform-order-details.js";const
|
|
1
|
+
import{P as e,a as t,G as r,O as a,B as s,R as d}from"./transform-order-details.js";const n=`
|
|
2
2
|
fragment OrderSummary on OrderTotal {
|
|
3
3
|
grand_total {
|
|
4
4
|
value
|
|
@@ -35,7 +35,7 @@ fragment OrderSummary on OrderTotal {
|
|
|
35
35
|
}
|
|
36
36
|
label
|
|
37
37
|
}
|
|
38
|
-
}`,
|
|
38
|
+
}`,i=`
|
|
39
39
|
fragment AddressesList on OrderAddress {
|
|
40
40
|
city
|
|
41
41
|
company
|
|
@@ -52,7 +52,7 @@ fragment AddressesList on OrderAddress {
|
|
|
52
52
|
suffix
|
|
53
53
|
telephone
|
|
54
54
|
vat_id
|
|
55
|
-
}`,
|
|
55
|
+
}`,o=`
|
|
56
56
|
fragment guestOrderData on CustomerOrder {
|
|
57
57
|
email
|
|
58
58
|
id
|
|
@@ -67,6 +67,9 @@ fragment AddressesList on OrderAddress {
|
|
|
67
67
|
gift_receipt_included
|
|
68
68
|
available_actions
|
|
69
69
|
is_virtual
|
|
70
|
+
returns {
|
|
71
|
+
...OrderReturns
|
|
72
|
+
}
|
|
70
73
|
payment_methods {
|
|
71
74
|
name
|
|
72
75
|
type
|
|
@@ -138,13 +141,14 @@ ${t}
|
|
|
138
141
|
${r}
|
|
139
142
|
${a}
|
|
140
143
|
${s}
|
|
141
|
-
${d}
|
|
142
144
|
${n}
|
|
145
|
+
${i}
|
|
146
|
+
${d}
|
|
143
147
|
`,_=`
|
|
144
148
|
query GET_GUEST_ORDER($input: OrderInformationInput!) {
|
|
145
149
|
guestOrder(input:$input) {
|
|
146
150
|
...guestOrderData
|
|
147
151
|
}
|
|
148
152
|
}
|
|
149
|
-
${
|
|
150
|
-
`;export{
|
|
153
|
+
${o}
|
|
154
|
+
`;export{i as A,o as G,n as O,_ as a};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import{a as F}from"./convertCase.js";const
|
|
1
|
+
import{a as F}from"./convertCase.js";const J=`
|
|
2
2
|
fragment ProductDetails on ProductInterface {
|
|
3
3
|
__typename
|
|
4
4
|
canonical_url
|
|
5
|
+
url_key
|
|
5
6
|
uid
|
|
6
7
|
name
|
|
7
8
|
sku
|
|
@@ -20,7 +21,7 @@ import{a as F}from"./convertCase.js";const H=`
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
`,
|
|
24
|
+
`,V=`
|
|
24
25
|
fragment PriceDetails on OrderItemInterface {
|
|
25
26
|
prices {
|
|
26
27
|
price_including_tax {
|
|
@@ -41,7 +42,7 @@ import{a as F}from"./convertCase.js";const H=`
|
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
`,
|
|
45
|
+
`,W=`
|
|
45
46
|
fragment GiftCardDetails on GiftCardOrderItem {
|
|
46
47
|
...PriceDetails
|
|
47
48
|
gift_message {
|
|
@@ -55,11 +56,12 @@ import{a as F}from"./convertCase.js";const H=`
|
|
|
55
56
|
message
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
|
-
`,
|
|
59
|
+
`,X=`
|
|
59
60
|
fragment OrderItemDetails on OrderItemInterface {
|
|
60
61
|
__typename
|
|
61
62
|
status
|
|
62
63
|
product_name
|
|
64
|
+
product_url_key
|
|
63
65
|
id
|
|
64
66
|
quantity_ordered
|
|
65
67
|
quantity_shipped
|
|
@@ -80,7 +82,7 @@ import{a as F}from"./convertCase.js";const H=`
|
|
|
80
82
|
}
|
|
81
83
|
...PriceDetails
|
|
82
84
|
}
|
|
83
|
-
`,
|
|
85
|
+
`,Y=`
|
|
84
86
|
fragment BundleOrderItemDetails on BundleOrderItem {
|
|
85
87
|
...PriceDetails
|
|
86
88
|
bundle_options {
|
|
@@ -92,4 +94,44 @@ import{a as F}from"./convertCase.js";const H=`
|
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
|
-
`,
|
|
97
|
+
`,Z=`
|
|
98
|
+
fragment OrderReturns on Returns {
|
|
99
|
+
__typename
|
|
100
|
+
items {
|
|
101
|
+
number
|
|
102
|
+
status
|
|
103
|
+
shipping {
|
|
104
|
+
tracking {
|
|
105
|
+
status {
|
|
106
|
+
text
|
|
107
|
+
type
|
|
108
|
+
}
|
|
109
|
+
carrier {
|
|
110
|
+
uid
|
|
111
|
+
label
|
|
112
|
+
}
|
|
113
|
+
tracking_number
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
order {
|
|
117
|
+
number
|
|
118
|
+
token
|
|
119
|
+
}
|
|
120
|
+
items {
|
|
121
|
+
uid
|
|
122
|
+
quantity
|
|
123
|
+
status
|
|
124
|
+
request_quantity
|
|
125
|
+
order_item {
|
|
126
|
+
...OrderItemDetails
|
|
127
|
+
... on GiftCardOrderItem {
|
|
128
|
+
...GiftCardDetails
|
|
129
|
+
product {
|
|
130
|
+
...ProductDetails
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`,B=n=>{var s;if(!((s=n==null?void 0:n.items)!=null&&s.length))return null;const a=n==null?void 0:n.items,u=n==null?void 0:n.page_info;return{ordersReturn:a.map(l=>{var f,b;const{order:_,status:t,number:y}=l,v=((b=(f=l==null?void 0:l.shipping)==null?void 0:f.tracking)==null?void 0:b.map(i=>{const{status:p,carrier:g,tracking_number:q}=i;return{status:p,carrier:g,trackingNumber:q}}))??[],O=l.items.map(i=>{var h;const p=i==null?void 0:i.quantity,g=i==null?void 0:i.status,q=i==null?void 0:i.request_quantity,e=i==null?void 0:i.uid,R=i==null?void 0:i.order_item,E=((h=M([R]))==null?void 0:h.reduce((T,N)=>N,{}))??{};return{uid:e,quantity:p,status:g,requestQuantity:q,orderItem:E}});return{returnStatus:t,token:_==null?void 0:_.token,orderNumber:_==null?void 0:_.number,returnNumber:y,items:O,tracking:v}}),...u?{pageInfo:{pageSize:u.page_size,totalPages:u.total_pages,currentPage:u.current_page}}:{}}},U=n=>n||0,Q=n=>{var a,u,c;return{...n,canonicalUrl:(n==null?void 0:n.canonical_url)||"",urlKey:(n==null?void 0:n.url_key)||"",id:(n==null?void 0:n.uid)||"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((a=n==null?void 0:n.image)==null?void 0:a.url)||"",productType:(n==null?void 0:n.__typename)||"",thumbnail:{label:((u=n==null?void 0:n.thumbnail)==null?void 0:u.label)||"",url:((c=n==null?void 0:n.thumbnail)==null?void 0:c.url)||""}}},j=n=>{if(!n||!("selected_options"in n))return;const a={};for(const u of n.selected_options)a[u.label]=u.value;return a},w=n=>{const a=n==null?void 0:n.map(c=>({uid:c.uid,label:c.label,values:c.values.map(s=>s.product_name).join(", ")})),u={};return a==null||a.forEach(c=>{u[c.label]=c.values}),Object.keys(u).length>0?u:null},K=n=>(n==null?void 0:n.length)>0?{count:n.length,result:n.map(a=>a.title).join(", ")}:null,M=n=>n==null?void 0:n.filter(a=>a.__typename).map(a=>{var u,c,s,l,_,t,y,v,O,f,b,i,p,g,q,e,R,E,h,T,N,k,C,D,P,G,A,x,S,L;return{type:a==null?void 0:a.__typename,productName:a.product_name,productUrlKey:a.product_url_key,quantityCanceled:(a==null?void 0:a.quantity_canceled)||0,quantityInvoiced:(a==null?void 0:a.quantity_invoiced)||0,quantityOrdered:(a==null?void 0:a.quantity_ordered)||0,quantityRefunded:(a==null?void 0:a.quantity_refunded)||0,quantityReturned:(a==null?void 0:a.quantity_returned)||0,quantityShipped:(a==null?void 0:a.quantity_shipped)||0,id:a==null?void 0:a.id,discounted:((l=(s=(c=(u=a==null?void 0:a.product)==null?void 0:u.price_range)==null?void 0:c.maximum_price)==null?void 0:s.regular_price)==null?void 0:l.value)*(a==null?void 0:a.quantity_ordered)!==((_=a==null?void 0:a.product_sale_price)==null?void 0:_.value)*(a==null?void 0:a.quantity_ordered),total:{value:((t=a==null?void 0:a.product_sale_price)==null?void 0:t.value)*(a==null?void 0:a.quantity_ordered)||0,currency:((y=a==null?void 0:a.product_sale_price)==null?void 0:y.currency)||""},totalInclTax:{value:((v=a==null?void 0:a.product_sale_price)==null?void 0:v.value)*(a==null?void 0:a.quantity_ordered)||0,currency:(O=a==null?void 0:a.product_sale_price)==null?void 0:O.currency},price:{value:((f=a==null?void 0:a.product_sale_price)==null?void 0:f.value)||0,currency:(b=a==null?void 0:a.product_sale_price)==null?void 0:b.currency},priceInclTax:{value:((i=a==null?void 0:a.product_sale_price)==null?void 0:i.value)||0,currency:(p=a==null?void 0:a.product_sale_price)==null?void 0:p.currency},totalQuantity:U(a==null?void 0:a.quantity_ordered),regularPrice:{value:(R=(e=(q=(g=a==null?void 0:a.product)==null?void 0:g.price_range)==null?void 0:q.maximum_price)==null?void 0:e.regular_price)==null?void 0:R.value,currency:(N=(T=(h=(E=a==null?void 0:a.product)==null?void 0:E.price_range)==null?void 0:h.maximum_price)==null?void 0:T.regular_price)==null?void 0:N.currency},product:Q(a==null?void 0:a.product),thumbnail:{label:((C=(k=a==null?void 0:a.product)==null?void 0:k.thumbnail)==null?void 0:C.label)||"",url:((P=(D=a==null?void 0:a.product)==null?void 0:D.thumbnail)==null?void 0:P.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((G=a.gift_card)==null?void 0:G.sender_name)||"",senderEmail:((A=a.gift_card)==null?void 0:A.sender_email)||"",recipientEmail:((x=a.gift_card)==null?void 0:x.recipient_email)||"",recipientName:((S=a.gift_card)==null?void 0:S.recipient_name)||"",message:((L=a.gift_card)==null?void 0:L.message)||""}:void 0,configurableOptions:j(a),bundleOptions:a.__typename==="BundleOrderItem"?w(a.bundle_options):null,itemPrices:a.prices,downloadableLinks:a.__typename==="DownloadableOrderItem"?K(a==null?void 0:a.downloadable_links):null}}),z=n=>{var O,f,b,i,p,g;const a=M(n.items),u=((O=B(n==null?void 0:n.returns))==null?void 0:O.ordersReturn)??[],{total:c,...s}=F({...n,items:a,returns:u},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),l=(f=n==null?void 0:n.payment_methods)==null?void 0:f[0],_=(l==null?void 0:l.type)||"",t=(l==null?void 0:l.name)||"",y=(b=s==null?void 0:s.items)==null?void 0:b.reduce((q,e)=>q+(e==null?void 0:e.totalQuantity),0);return{...c,...s,totalQuantity:y,shipping:{amount:((i=s==null?void 0:s.total)==null?void 0:i.totalShipping.value)??0,currency:((g=(p=s.total)==null?void 0:p.totalShipping)==null?void 0:g.currency)||"",code:s.shippingMethod??""},payments:[{code:_,name:t}]}},$=(n,a)=>{var u,c,s,l,_,t,y;if((l=(s=(c=(u=a==null?void 0:a.data)==null?void 0:u.customer)==null?void 0:c.orders)==null?void 0:s.items)!=null&&l.length&&n==="orderData"){const v=(y=(t=(_=a==null?void 0:a.data)==null?void 0:_.customer)==null?void 0:t.orders)==null?void 0:y.items[0];return z(v)}return null};export{Y as B,W as G,X as O,J as P,Z as R,V as a,$ as b,B as c,z as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r,jsxs as a,Fragment as p}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as A,useState as X,useCallback as K,useEffect as r1}from"@dropins/tools/preact-hooks.js";import{classes as F,Slot as T,debounce as e1}from"@dropins/tools/lib.js";import{IllustratedMessage as n1,Icon as x,Card as B,ContentGrid as t1,Image as L1,Header as j,Pagination as s1}from"@dropins/tools/components.js";import*as o from"@dropins/tools/preact-compat.js";import{useMemo as a1}from"@dropins/tools/preact-compat.js";import"./OrderCancelReasonsForm.js";import{C as R}from"./OrderLoaders.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{Text as Y}from"@dropins/tools/i18n.js";const G=n=>o.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...n},o.createElement("g",{id:"Large"},o.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),o.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},o.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),i1=n=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},o.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"#D6D6D6"})),U=({typeList:n,isEmpty:h,minifiedView:c,message:t})=>{const L=a1(()=>{switch(n){case"orders":return{icon:i1,text:r("p",{children:t}),className:"order-empty-list--empty-box"};default:return{icon:"",text:"",className:""}}},[n,t]);return!h||!n||!L.text?null:r(n1,{className:F(["order-empty-list",L.className,c?"order-empty-list--minified":""]),message:L.text,icon:r(x,{source:L.icon}),"data-testid":"emptyList"})},c1={PENDING:"pending",AUTHORIZED:"authorized",PARTIALLY_AUTHORIZED:"partiallyAuthorized",RECEIVED:"received",PARTIALLY_RECEIVED:"partiallyReceived",APPROVED:"approved",PARTIALLY_APPROVED:"partiallyApproved",REJECTED:"rejected",PARTIALLY_REJECTED:"partiallyRejected",DENIED:"denied",PROCESSED_AND_CLOSED:"processedAndClosed",CLOSED:"closed"},d1=n=>typeof n!="string"?"":c1[n]??"",k={size:"32",stroke:"2"},E1=({minifiedViewKey:n,withReturnNumber:h=!1,withOrderNumber:c=!1,slots:t,pageInfo:L,withReturnsListButton:y=!0,isMobile:v=!1,returnsInMinifiedView:J=1,translations:s={},orderReturns:d=[],minifiedView:C=!1,withHeader:Z=!0,withThumbnails:w=!0,selectedPage:H=1,handleSetSelectPage:I,routeReturnDetails:l,routeOrderDetails:u,routeTracking:_,routeReturnsList:E,routeProductDetails:m,loading:N})=>{const S=C?J:d.length,V=m!=null&&m()?"a":"span",g=A(()=>d.slice(0,S).map((e,D)=>{var P,$;return r(B,{variant:"secondary",className:"order-returns-list-content__cards-list",children:a("div",{className:"order-returns-list-content__cards-grid",children:[a("div",{className:"order-returns-list-content__descriptions",children:[r("p",{className:"order-returns-list-content__return-status",children:r(Y,{id:`Order.Returns.${n}.returnsList.resturnStatus.${d1(e.returnStatus)}`})}),h?a("p",{children:[s.returnNumber," ",r("a",{href:(l==null?void 0:l({returnNumber:e.returnNumber,orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.returnNumber})]}):null,c?a("p",{children:[s.orderNumber," ",r("a",{href:(u==null?void 0:u({orderNumber:e.orderNumber,token:e.token}))??"#",rel:"noreferrer",children:e.orderNumber})]}):null,(P=e==null?void 0:e.tracking)==null?void 0:P.map((i,b)=>{var M,f;return a("p",{children:[`${s.carrier} ${(f=(M=i==null?void 0:i.carrier)==null?void 0:M.label)==null?void 0:f.toLocaleUpperCase()}: `,r("a",{href:`${(_==null?void 0:_(i))||"#"}`,target:"_blank",rel:"noreferrer",children:i.trackingNumber})]},`${i.trackingNumber}_${b}`)}),t!=null&&t.ReturnItemsDetails?r(T,{"data-testid":"returnItemsDetails",name:"ReturnItemsDetails",slot:t==null?void 0:t.ReturnItemsDetails,context:{items:e.items}}):e.items.length?a("p",{children:[e.items.length," ",r(Y,{id:`Order.Returns.${n}.returnsList.itemText`,plural:e.items.length,fields:{count:e.items.length}})]}):null]}),w?r(t1,{maxColumns:v?3:9,emptyGridContent:r(p,{}),className:F(["order-returns-list-content__images",["order-returns-list-content__images-3",v]]),children:($=e==null?void 0:e.items)==null?void 0:$.map((i,b)=>{var z,O;const M=i.orderItem,f=(z=M.thumbnail)==null?void 0:z.label,Q=(O=M.thumbnail)==null?void 0:O.url;return r(V,{href:(m==null?void 0:m(i.orderItem))??"#",children:r(L1,{alt:f,src:Q,width:85,height:114})},b+i.uid)})}):null,t!=null&&t.DetailsActionParams?r(T,{className:"order-returns-list-content__actions","data-testid":"detailsActionParams",name:"DetailsActionParams",slot:t==null?void 0:t.DetailsActionParams,context:{returnOrderItem:e}}):r("a",{href:(l==null?void 0:l({returnNumber:e.returnNumber,token:e.token,orderNumber:e.orderNumber}))??"#",className:"order-returns-list-content__actions",children:r(x,{source:G,...k})})]})},D)}),[d,S,s,t,w,v,u,l,_,m,V,c,n,h]),W=A(()=>a(p,{children:[Z?r(j,{title:s.minifiedViewTitle,divider:!1,className:"order-returns__header--minified"}):null,N?r(R,{withCard:!1}):a(p,{children:[g,r(U,{minifiedView:C,typeList:"orders",isEmpty:!d.length,message:s.emptyOrdersListMessage}),y?r("a",{className:"order-returns-list-content__actions",href:(E==null?void 0:E())??"#",children:r(B,{variant:"secondary",className:"order-returns-list-content__card",children:a("div",{className:"order-returns-list-content__card-wrapper",children:[r("p",{children:s.viewAllOrdersButton}),r(x,{source:G,...k})]})})}):null]})]}),[E,y,Z,s,g,C,d.length,N]),q=A(()=>a(p,{children:[Z?r(j,{title:s.minifiedViewTitle,divider:!0,className:"order-returns__header--full-size"}):null,N?r(R,{withCard:!1}):a(p,{children:[r(U,{minifiedView:C,typeList:"orders",isEmpty:!d.length,message:s.emptyOrdersListMessage}),g,(L==null?void 0:L.totalPages)>1?r(s1,{totalPages:L==null?void 0:L.totalPages,currentPage:H,onChange:I}):null]})]}),[g,C,d,s,L,H,I,N,Z]);return r("div",{className:"order-returns-list-content",children:C?W:q})},N1=()=>{const[n,h]=X(window.innerWidth<768),c=K(e1(()=>{h(window.innerWidth<768)},1e3),[]);return r1(()=>(window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}),[c]),n};export{E1 as R,N1 as u};
|
package/configs/mock.config.d.ts
CHANGED
|
@@ -1707,4 +1707,16 @@ export declare const returnOrderListMock: {
|
|
|
1707
1707
|
trackingNumber: string;
|
|
1708
1708
|
}[];
|
|
1709
1709
|
}[];
|
|
1710
|
+
export declare const translationsOrderCostSummaryMock: {
|
|
1711
|
+
headerText: string;
|
|
1712
|
+
subtotal: string;
|
|
1713
|
+
shipping: string;
|
|
1714
|
+
freeShipping: string;
|
|
1715
|
+
tax: string;
|
|
1716
|
+
incl: string;
|
|
1717
|
+
excl: string;
|
|
1718
|
+
discount: string;
|
|
1719
|
+
discountSubtitle: string;
|
|
1720
|
+
total: string;
|
|
1721
|
+
};
|
|
1710
1722
|
//# sourceMappingURL=mock.config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as d,Fragment as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as f}from"@dropins/tools/lib.js";import{useMemo as L,useCallback as O,useState as k,useEffect as D}from"@dropins/tools/preact-hooks.js";import{events as S}from"@dropins/tools/event-bus.js";import{c as W}from"../chunks/convertCase.js";import{g as P}from"../chunks/getAttributesForm.js";import{Card as Z,Header as z,Price as B,Icon as $}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import*as i from"@dropins/tools/preact-compat.js";import{D as q}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact.js";import{useText as F}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const K=a=>i.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},i.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"}),i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),R=a=>i.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},i.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}),i.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}),i.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),i.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}),i.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})),G=({loading:a,order:e,withHeader:g=!0,title:c,paymentIconsMap:h={},normalizeAddress:m})=>{var A,M,E,N,T;const n=F({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=L(()=>({checkmo:K,card:R,...h}),[h]),_=O(H=>{var w;return(w=m[H])==null?void 0:w.map((s,V)=>t("p",{children:s.label?`${s.label}: ${Array.isArray(s.value)?s.value.join(" "):s==null?void 0:s.value}`:Array.isArray(s.value)?s.value.join(" "):s==null?void 0:s.value},V))},[m]);if(!e||a)return t(q,{});const o=(e==null?void 0:e.email)??"",l=(A=e==null?void 0:e.shipping)==null?void 0:A.code,r=(M=e==null?void 0:e.shipping)==null?void 0:M.amount,C=(E=e==null?void 0:e.shipping)==null?void 0:E.currency,u=e==null?void 0:e.payments,v=u&&u.length>0,b=v?(N=u[0])==null?void 0:N.name:"",y=v?(T=u[0])==null?void 0:T.code:"",x=v&&b!=="";return d(Z,{"data-testid":"order-details",variant:"secondary",className:f(["order-customer-details-content"]),children:[g?t(z,{title:c??n.headerText}):null,d("div",{className:"order-customer-details-content__container",children:[d("div",{className:"order-customer-details-content__container-email",children:[t("div",{className:"order-customer-details-content__container-title",children:n.emailTitle}),t("p",{children:o})]}),d("div",{className:"order-customer-details-content__container-shipping_address",children:[t("div",{className:"order-customer-details-content__container-title",children:n.shippingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("shippingAddress")})]}),d("div",{className:"order-customer-details-content__container-billing_address",children:[t("div",{className:"order-customer-details-content__container-title",children:n.billingAddressTitle}),t("div",{className:"order-customer-details-content__container-description",children:_("billingAddress")})]}),d("div",{className:"order-customer-details-content__container-shipping_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:n.shippingMethodsTitle}),l?t(j,{children:r?d("p",{"data-testid":"shipping_methods_price",children:[t(B,{amount:r,currency:C})," ",l]}):t("p",{"data-testid":"shipping_methods_placeholder",children:n.freeShipping})}):null]}),d("div",{className:"order-customer-details-content__container-payment_methods",children:[t("div",{className:"order-customer-details-content__container-title",children:n.billingMethodsTitle}),x&&d("p",{"data-testid":"billing_methods_description",className:f([["order-customer-details-content__container-payment_methods--icon",!!p[y]]]),children:[t($,{source:p[y]}),b]})]})]})]})},I=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],J=({orderData:a})=>{const[e,g]=k(!0),[c,h]=k(a),[m,n]=k([]);D(()=>{const o=S.on("order/data",l=>{h(l)},{eager:!0});return()=>{o==null||o.off()}},[]),D(()=>{P("shortRequest").then(o=>{if(o){const l=o.map(({name:r,orderNumber:C,label:u})=>({name:W(r),orderNumber:C,label:I.includes(r)?null:u}));n(l)}}).finally(()=>{g(!1)})},[]);const p=O(o=>{if(!m.length||!c||!c[o])return[];const l=Object.fromEntries(Object.entries(c[o]).map(([r,C])=>[r.toLowerCase(),C]));return m.filter(({name:r})=>l[r.toLowerCase()]).map(r=>({name:r.name,orderNumber:r.orderNumber,value:l[r.name.toLowerCase()],label:r.label}))},[m,c]),_=L(()=>({billingAddress:p("billingAddress"),shippingAddress:p("shippingAddress")}),[p]);return{order:c,normalizeAddress:_,loading:e}},de=({paymentIconsMap:a,orderData:e,title:g,className:c})=>{const{order:h,normalizeAddress:m,loading:n}=J({orderData:e});return t("div",{className:f(["order-customer-details",c]),children:t(G,{loading:n,order:h,title:g,paymentIconsMap:a,normalizeAddress:m})})};export{de as CustomerDetails,de as default};
|
|
@@ -1 +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
|
+
import{jsxs as i,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 d,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 y 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=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},y.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),I=e=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},y.createElement("path",{d:"M7.74512 14.132L12.0001 9.87701L16.2551 14.132",stroke:"#2B2B2B",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),j=e=>y.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},y.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,r;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--subtotal",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.subtotal}),c(d,{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})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[!n.taxExcluded&&n.taxIncluded?c("span",{children:e.incl}):null,n.taxExcluded&&n.taxIncluded?i(v,{children:[c(d,{currency:(r=a==null?void 0:a.subtotal)==null?void 0:r.currency,amount:t,size:"small"})," ",c("span",{children:e.excl})]}):null]})]})},W=({translations:e,shoppingOrdersDisplayShipping:a,order:t,totalShipping:n})=>{var l,r,o,s;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--shipping",children:[i("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(d,{weight:"normal",currency:(r=t==null?void 0:t.totalShipping)==null?void 0:r.currency,amount:n}):c("span",{children:e.freeShipping})]}),i("div",{className:"order-cost-summary-content__description--subheader",children:[a.taxIncluded&&a.taxExcluded?i(v,{children:[c(d,{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"}),i("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,r,o;return!((l=a==null?void 0:a.discounts)!=null&&l.length)&&!t?null:i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--discount",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.discount}),c("span",{children:(r=a==null?void 0:a.discounts)!=null&&r.length?(o=a==null?void 0:a.discounts)==null?void 0:o.map(({amount:s},m)=>{const u=(s==null?void 0:s.value)??0;return c(d,{weight:"normal",sale:!0,currency:s==null?void 0:s.currency,amount:-(u+t)},m)}):null})]}),!(a!=null&&a.discounts.length)&&t?i("div",{className:"order-cost-summary-content__description--subheader",children:[i("span",{children:[c(b,{source:j,size:"16"}),c("span",{children:e.discountSubtitle.toLocaleUpperCase()})]}),c(d,{weight:"normal",sale:!0,currency:n,amount:-t})]}):null]})},F=({order:e})=>{var a;return c("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--coupon",children:(a=e==null?void 0:e.coupons)==null?void 0:a.map((t,n)=>i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:t.code}),c("span",{children:"TBD"})]},n))})},U=({translations:e,renderTaxAccordion:a,totalAccordionTaxValue:t,order:n})=>{var o,s,m;const[l,r]=_(!1);return a?c(f,{"data-testid":"tax-accordionTaxes",className:"order-cost-summary-content__accordion",iconOpen:A,iconClose:I,children:i(E,{onStateChange:r,title:e.accordionTitle,secondaryText:c(v,{children:l?null:c(d,{weight:"normal",amount:t,currency:(s=n==null?void 0:n.totalTax)==null?void 0:s.currency})}),renderContentWhenClosed:!1,children:[(m=n==null?void 0:n.taxes)==null?void 0:m.map((u,x)=>{var p,h;return i("div",{className:"order-cost-summary-content__accordion-row",children:[c("p",{children:u==null?void 0:u.title}),c("p",{children:c(d,{weight:"normal",amount:(p=u==null?void 0:u.amount)==null?void 0:p.value,currency:(h=u==null?void 0:u.amount)==null?void 0:h.currency})})]},x)}),i("div",{className:"order-cost-summary-content__accordion-row order-cost-summary-content__accordion-total",children:[c("p",{children:e.accordionTotalTax}),c("p",{children:c(d,{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:i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.tax}),c(d,{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,r,o;return i("div",{className:"order-cost-summary-content__description order-cost-summary-content__description--total",children:[i("div",{className:"order-cost-summary-content__description--header",children:[c("span",{children:e.total}),c(d,{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?i("div",{className:"order-cost-summary-content__description--subheader",children:[c("span",{children:e.totalExcludingTaxes}),c(d,{currency:(r=t==null?void 0:t.grandTotal)==null?void 0:r.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 p,h,S,O,w,L;if(a||!n)return c(z,{});const r=((p=n==null?void 0:n.totalGiftcard)==null?void 0:p.value)??0,o=((h=n.totalGiftcard)==null?void 0:h.currency)??"",s=((S=n.subtotal)==null?void 0:S.value)??0,m=((O=n.totalShipping)==null?void 0:O.value)??0,u=!!((w=n==null?void 0:n.taxes)!=null&&w.length)&&(t==null?void 0:t.shoppingOrdersDisplayFullSummary),x=u?(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 i(D,{variant:"secondary",className:H(["order-cost-summary-content"]),children:[l?c(k,{title:e.headerText}):null,i("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:r,totalGiftcardCurrency:o}),c(F,{order:n}),c(U,{order:n,translations:e,renderTaxAccordion:u,totalAccordionTaxValue:x}),c(G,{translations:e,shoppingOrdersDisplaySubtotal:t==null?void 0:t.shoppingOrdersDisplaySubtotal,order:n})]})]})},J=({orderData:e})=>{const[a,t]=_(!0),[n,l]=_(e),[r,o]=_(null);return T(()=>{N().then(s=>{if(s){const{shoppingCartDisplayPrice:m,shoppingOrdersDisplayShipping:u,shoppingOrdersDisplaySubtotal:x,...p}=s;o(h=>({...h,...p,shoppingCartDisplayPrice:C(m),shoppingOrdersDisplayShipping:C(u),shoppingOrdersDisplaySubtotal:C(x)}))}}).finally(()=>{t(!1)})},[]),T(()=>{const s=V.on("order/data",m=>{l(m)},{eager:!0});return()=>{s==null||s.off()}},[]),{loading:a,storeConfig:r,order:n}},rt=({withHeader:e,orderData:a,children:t,className:n,...l})=>{const{loading:r,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:r,storeConfig:o,translations:m})})};export{rt as OrderCostSummary,rt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a,jsxs as b,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{Card as U,Header as X,Price as Y,CartItem as g,Icon as I,Image as P}from"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import{classes as C}from"@dropins/tools/lib.js";import*as u from"@dropins/tools/preact-compat.js";import{useMemo as T,useCallback as p,useState as S,useEffect as R}from"@dropins/tools/preact-hooks.js";import{Fragment as ee}from"@dropins/tools/preact.js";import{O as te}from"../chunks/OrderLoaders.js";import{events as le}from"@dropins/tools/event-bus.js";import{useText as ne}from"@dropins/tools/i18n.js";import{s as ae}from"../chunks/setTaxStatus.js";import{g as se}from"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";const ie=v=>u.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...v},u.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"}),u.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"})),me=({loading:v,taxConfig:e,order:y=null,withHeader:O=!0,showConfigurableOptions:r,routeProductDetails:f})=>{const h=ne({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"}),i=T(()=>{if(!y)return[];const{items:m}=y;return[{type:"cancelled",list:m.filter(s=>s.quantityCanceled),title:h.cancelled},{type:"",list:m.filter(s=>!s.quantityCanceled),title:h.allOrders}]},[y,h]);return y?a(U,{variant:"secondary",className:"order-order-product-list-content",children:i.filter(m=>m.list.length).map((m,s)=>{var k;return b(ee,{children:[O?a(X,{title:`${m.title} (${m.list.length})`}):null,a("ul",{className:"order-order-product-list-content__items",children:(k=m.list)==null?void 0:k.map(E=>a("li",{"data-testid":"order-product-list-content-item",children:a(re,{loading:v,product:E,itemType:m.type,taxConfig:e,translations:h,showConfigurableOptions:r,routeProductDetails:f})},E.id))})]},s)})}):a(te,{})},re=({loading:v,product:e,itemType:y,taxConfig:O,translations:r,showConfigurableOptions:f,routeProductDetails:h})=>{var _,c,x,Q,H,V,$,M,q,F,G,Z,j,z,W,B,K;const{taxExcluded:i,taxIncluded:m}=O,s=p((d,D,J)=>a(Y,{amount:d,currency:D,weight:"normal",...J}),[]);let k={};const E=y==="cancelled",A=(c=(_=e==null?void 0:e.product)==null?void 0:_.stockStatus)==null?void 0:c.includes("IN_STOCK"),t=(e==null?void 0:e.giftCard)||{},l=(x=e==null?void 0:e.itemPrices)==null?void 0:x.priceIncludingTax,n=(Q=e==null?void 0:e.itemPrices)==null?void 0:Q.originalPrice,o=(H=e==null?void 0:e.itemPrices)==null?void 0:H.price,L=e.discounted&&((V=e.price)==null?void 0:V.value)!==(n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),N={..."configurableOptions"in e?e.configurableOptions:{},..."bundleOptions"in e?e.bundleOptions:{},..."senderName"in t&&(t!=null&&t.senderName)?{[r.sender]:t==null?void 0:t.senderName}:{},..."senderEmail"in t&&(t!=null&&t.senderEmail)?{[r.sender]:t==null?void 0:t.senderEmail}:{},..."recipientName"in t&&(t!=null&&t.recipientName)?{[r.recipient]:t==null?void 0:t.recipientName}:{},..."recipientEmail"in t&&(t!=null&&t.recipientEmail)?{[r.recipient]:t==null?void 0:t.recipientEmail}:{},..."message"in t&&(t!=null&&t.message)?{[r.message]:t==null?void 0:t.message}:{},..."downloadableLinks"in e&&(e!=null&&e.downloadableLinks)?{[`${($=e==null?void 0:e.downloadableLinks)==null?void 0:$.count} ${r.downloadableCount}`]:(M=e==null?void 0:e.downloadableLinks)==null?void 0:M.result}:{}};if(m&&i){const d=L?n==null?void 0:n.value:(l==null?void 0:l.value)*(e==null?void 0:e.totalQuantity);k={taxExcluded:!0,taxIncluded:void 0,price:s(n==null?void 0:n.value,n==null?void 0:n.currency),total:b(w,{children:[s(d,n==null?void 0:n.currency,{variant:e.discounted&&(l==null?void 0:l.value)!==d?"strikethrough":"default"}),e.discounted&&(l==null?void 0:l.value)!==d?s(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:s((o==null?void 0:o.value)*e.totalQuantity,o==null?void 0:o.currency)}}else if(!m&&i)k={taxExcluded:void 0,taxIncluded:void 0,price:s(n==null?void 0:n.value,n==null?void 0:n.currency),total:b(w,{children:[s((n==null?void 0:n.value)*(e==null?void 0:e.totalQuantity),l==null?void 0:l.currency,{variant:L?"strikethrough":"default"}),L?s((q=e.price)==null?void 0:q.value,(F=e.price)==null?void 0:F.currency,{sale:!0,weight:"bold"}):null]}),totalExcludingTax:s((o==null?void 0:o.value)*(e==null?void 0:e.totalQuantity),o==null?void 0:o.currency)};else if(m&&!i){const d=L?n.value:l.value*e.totalQuantity;k={taxExcluded:void 0,taxIncluded:!0,price:s(l==null?void 0:l.value,l==null?void 0:l.currency),total:b(w,{children:[s(d,l==null?void 0:l.currency,{variant:L?"strikethrough":"default",weight:"bold"}),L?s(l==null?void 0:l.value,l==null?void 0:l.currency,{sale:!0,weight:"bold"}):null]})}}return a(g,{loading:v,alert:E&&A?b("span",{children:[a(I,{source:ie}),r.outOfStock]}):a(w,{}),configurations:(f==null?void 0:f(N))??N,title:h?a("a",{"data-testid":"product-name",className:C(["cart-summary-item__title",["cart-summary-item__title--strikethrough",E]]),href:h(e),children:(G=e==null?void 0:e.product)==null?void 0:G.name}):a("div",{"data-testid":"product-name",className:C(["cart-summary-item__title",["cart-summary-item__title--strikethrough",E]]),children:(Z=e==null?void 0:e.product)==null?void 0:Z.name}),sku:a("div",{children:(j=e==null?void 0:e.product)==null?void 0:j.sku}),quantity:e.totalQuantity,image:h?a("a",{href:h(e),children:a(P,{src:(z=e==null?void 0:e.product)==null?void 0:z.thumbnail.url,alt:(W=e==null?void 0:e.product)==null?void 0:W.thumbnail.label,loading:"lazy",width:"90",height:"120"})}):a(P,{src:(B=e==null?void 0:e.product)==null?void 0:B.thumbnail.url,alt:(K=e==null?void 0:e.product)==null?void 0:K.thumbnail.label,loading:"lazy",width:"90",height:"120"}),...k})},he=({orderData:v})=>{const[e,y]=S(!0),[O,r]=S(v),[f,h]=S({taxIncluded:!1,taxExcluded:!1});return R(()=>{se().then(i=>{i&&h(ae(i==null?void 0:i.shoppingCartDisplayPrice))}).finally(()=>{y(!1)})},[]),R(()=>{const i=le.on("order/data",m=>{r(m)},{eager:!0});return()=>{i==null||i.off()}},[]),{loading:e,taxConfig:f,order:O}},Ce=({className:v,orderData:e,withHeader:y,showConfigurableOptions:O,routeProductDetails:r})=>{const{loading:f,taxConfig:h,order:i}=he({orderData:e});return a("div",{className:C(["order-order-product-list",v]),children:a(me,{loading:f,taxConfig:h,order:i,withHeader:y,showConfigurableOptions:O,routeProductDetails:r})})};export{Ce as OrderProductList,Ce as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as m}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/OrderCancelReasonsForm.js";import{classes as p}from"@dropins/tools/lib.js";import"@dropins/tools/preact-compat.js";import{useState as d,useEffect as R}from"@dropins/tools/preact-hooks.js";import{u as L,R as O}from"../chunks/useIsMobile.js";import"@dropins/tools/preact.js";import{events as b}from"@dropins/tools/event-bus.js";import{useText as g}from"@dropins/tools/i18n.js";import"../chunks/OrderLoaders.js";const w=({orderData:s})=>{const[i,n]=d(s),[u,o]=d([]);return R(()=>{const t=b.on("order/data",e=>{n(e),o(e==null?void 0:e.returns)},{eager:!0});return()=>{t==null||t.off()}},[]),{order:i,orderReturns:u}},I=({slots:s,className:i,orderData:n,withHeader:u,withThumbnails:o,routeReturnDetails:t,routeProductDetails:e,routeTracking:l})=>{const{orderReturns:a}=w({orderData:n}),f=L(),r="fullSizeView",c=g({minifiedViewTitle:`Order.Returns.${r}.returnsList.minifiedViewTitle`,ariaLabelLink:`Order.Returns.${r}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${r}.returnsList.emptyOrdersListMessage`,orderNumber:`Order.Returns.${r}.returnsList.orderNumber`,returnNumber:`Order.Returns.${r}.returnsList.returnNumber`,carrier:`Order.Returns.${r}.returnsList.carrier`});return m("div",{className:p(["order-order-returns",i]),children:a.length?m(O,{pageInfo:{pageSize:1,totalPages:1,currentPage:1},minifiedViewKey:r,slots:s,isMobile:f,withOrderNumber:!1,withReturnNumber:!0,orderReturns:a,translations:c,withHeader:u,withThumbnails:o,minifiedView:!1,routeReturnDetails:t,routeProductDetails:e,routeTracking:l,loading:!1}):null})};export{I as OrderReturns,I 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/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
|
|
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 E=(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))(E||{});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,f])=>{a.append(u,String(f))});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,f]=D({text:"",type:"success"}),[y,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 d=await A();(d==null?void 0:d.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:E.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.postcode,options:[],defaultValue:"",fieldType:E.TEXT,className:"",required:!0,orderNumber:2,name:"postcode",id:"postcode",code:"postcode"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:m.number,options:[],defaultValue:"",fieldType:E.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||f({text:m.invalidSearch,type:"warning"}),w.emit("order/data",l)}).catch(async l=>{var N;let d=!0;e==null||e({error:l.message});const T=t?await A():{email:""};(T==null?void 0:T.email)===(i==null?void 0:i.email)?p(a,{orderRef:i.number}):d=o==null?void 0:o({render:T===null||((N=l==null?void 0:l.message)==null?void 0:N.includes("Please login to view the order.")),formValues:i}),d&&f({text:l.message,type:"warning"})}).finally(()=>{h(!1)})},[t,e,o,a,m.invalidSearch]),inLineAlert:u,loading:y,normalizeFieldsConfig:M}},ce=({className:e,isAuth:t,renderSignIn:o,routeCustomerOrder:a,routeGuestOrder:c,onError:u})=>{const{onSubmit:f,loading:y,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:f,loading:y,inLineAlert:h,fieldsConfig:m})})};export{ce as OrderSearch,ce as default};
|