@dropins/storefront-order 0.1.0-alpha4 → 0.1.0-alpha6
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/getAttributesForm.d.ts +4 -0
- package/api/getAttributesForm/graphql/getAttributesForm.graphql.d.ts +3 -0
- package/api/getAttributesForm/index.d.ts +2 -0
- package/api/getGuestOrder/getGuestOrder.d.ts +2 -2
- package/api/getOrderDetailsById/getOrderDetailsById.d.ts +1 -2
- package/api/getOrderDetailsById/graphql/orderItemsFragment.graphql.d.ts +1 -1
- package/api/guestOrderByToken/guestOrderByToken.d.ts +2 -2
- package/api/helpers/initializeOrderDetails.d.ts +3 -1
- package/api/index.d.ts +1 -0
- package/api.js +129 -27
- package/chunks/CustomerDetailsContent.js +1 -0
- package/chunks/OrderLoaders.js +1 -0
- package/chunks/fetch-graphql.js +1 -0
- package/chunks/getAttributesForm.js +47 -0
- package/chunks/getGuestOrder.js +75 -31
- package/components/CustomerDetailsContent/CustomerDetailsContent.d.ts +5 -0
- package/components/CustomerDetailsContent/index.d.ts +3 -0
- package/components/OrderActions/OrderActions.d.ts +5 -0
- package/components/OrderActions/index.d.ts +3 -0
- package/components/OrderLoaders/OrderLoaders.d.ts +7 -0
- package/components/OrderLoaders/index.d.ts +3 -0
- package/components/OrderStatusContent/OrderStatusContent.d.ts +5 -0
- package/components/OrderStatusContent/index.d.ts +3 -0
- package/components/ShippingStatusCard/ShippingStatusCard.d.ts +5 -0
- package/components/ShippingStatusCard/index.d.ts +3 -0
- package/components/index.d.ts +5 -0
- package/configs/defaultAttributePreset.config.d.ts +2 -0
- package/configs/mock.config.d.ts +773 -0
- package/containers/CustomerDetails/CustomerDetails.d.ts +5 -0
- package/containers/CustomerDetails/index.d.ts +3 -0
- package/containers/CustomerDetails.d.ts +3 -0
- package/containers/CustomerDetails.js +1 -0
- package/containers/OrderSearch.js +1 -1
- package/containers/OrderStatus/OrderStatus.d.ts +5 -0
- package/containers/OrderStatus/index.d.ts +3 -0
- package/containers/OrderStatus.d.ts +3 -0
- package/containers/OrderStatus.js +1 -0
- package/containers/ShippingStatus/ShippingStatus.d.ts +5 -0
- package/containers/ShippingStatus/index.d.ts +3 -0
- package/containers/ShippingStatus.d.ts +3 -0
- package/containers/ShippingStatus.js +1 -0
- package/containers/index.d.ts +3 -0
- package/data/models/attributes-form.d.ts +46 -0
- package/data/models/index.d.ts +1 -1
- package/data/models/order-details.d.ts +109 -32
- package/data/transforms/index.d.ts +1 -0
- package/data/transforms/transform-attributes-form.d.ts +6 -0
- package/data/transforms/transform-guest-order.d.ts +3 -3
- package/data/transforms/transform-order-details.d.ts +4 -2
- package/hooks/containers/useCustomerDetails.d.ts +12 -0
- package/hooks/containers/useOrderSearch.d.ts +1 -1
- package/hooks/containers/useOrderStatus.d.ts +8 -0
- package/hooks/containers/useShippingStatus.d.ts +7 -0
- package/hooks/index.d.ts +3 -0
- package/i18n/en_US.json.d.ts +69 -2
- package/lib/convertCase.d.ts +4 -0
- package/lib/convertToInputDateFormat.d.ts +1 -0
- package/package.json +1 -1
- package/render.js +2 -2
- package/types/api/getAttributesForm.types.d.ts +31 -0
- package/types/api/getOrderDetails.types.d.ts +54 -28
- package/types/customerDetails.types.d.ts +49 -0
- package/types/form.types.d.ts +5 -5
- package/types/index.d.ts +5 -1
- package/types/orderSearch.types.d.ts +5 -5
- package/types/orderStatus.types.d.ts +41 -0
- package/types/shippingStatus.types.d.ts +18 -0
- package/data/models/guest-order.d.ts +0 -21
|
@@ -0,0 +1,3 @@
|
|
|
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";
|
|
3
|
+
//# sourceMappingURL=getAttributesForm.graphql.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrderDataModel } from '../../data/models';
|
|
2
2
|
|
|
3
3
|
export declare const getGuestOrder: (form: {
|
|
4
4
|
number: string;
|
|
5
5
|
email: string;
|
|
6
6
|
postcode: string;
|
|
7
|
-
}) => Promise<
|
|
7
|
+
}) => Promise<OrderDataModel | null>;
|
|
8
8
|
//# sourceMappingURL=getGuestOrder.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { QueryType } from '../../types';
|
|
2
1
|
import { TransformedData } from '../../data/models';
|
|
3
2
|
|
|
4
|
-
export declare const getOrderDetailsById: <T extends
|
|
3
|
+
export declare const getOrderDetailsById: <T extends "orderData">(orderId?: string, queryType?: T | undefined) => Promise<TransformedData<T>>;
|
|
5
4
|
//# sourceMappingURL=getOrderDetailsById.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const ORDER_ITEMS = "\nfragment OrderItems on OrderItem {\n status\n product_name\n id\n quantity_ordered\n product_sale_price {\n value\n currency\n }\n selected_options {\n label\n value\n }\n product {\n
|
|
1
|
+
export declare const ORDER_ITEMS = "\nfragment OrderItems on OrderItem {\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 __typename\n canonical_url\n uid\n name\n sku\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
|
//# sourceMappingURL=orderItemsFragment.graphql.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OrderDataModel } from '../../data/models';
|
|
2
2
|
|
|
3
|
-
export declare const guestOrderByToken: (token?: string) => Promise<
|
|
3
|
+
export declare const guestOrderByToken: (token?: string) => Promise<OrderDataModel | null>;
|
|
4
4
|
//# sourceMappingURL=guestOrderByToken.d.ts.map
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { OrderDataModel } from '../../data/models';
|
|
2
|
+
|
|
3
|
+
export declare const initializeOrderDetails: (config: Record<string, string | OrderDataModel | null> | undefined) => Promise<void>;
|
|
2
4
|
//# sourceMappingURL=initializeOrderDetails.d.ts.map
|
package/api/index.d.ts
CHANGED
package/api.js
CHANGED
|
@@ -1,13 +1,55 @@
|
|
|
1
|
-
import{Initializer as
|
|
1
|
+
import{Initializer as p}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";import{f as n,h as d,a as o}from"./chunks/fetch-graphql.js";import{g as B,r as N,s as $,b as w,c as A}from"./chunks/fetch-graphql.js";import{O as m,a as c,A as _,t as u,b as h}from"./chunks/getGuestOrder.js";import{g as C}from"./chunks/getGuestOrder.js";import{g as F}from"./chunks/getAttributesForm.js";import"@dropins/tools/fetch-graphql.js";const O=`
|
|
2
2
|
query ORDER_BY_NUMBER($orderNumber: String!) {
|
|
3
3
|
customer {
|
|
4
4
|
orders(
|
|
5
5
|
filter: {number: {eq: $orderNumber}},
|
|
6
6
|
) {
|
|
7
7
|
items {
|
|
8
|
+
email
|
|
9
|
+
available_actions
|
|
10
|
+
status
|
|
11
|
+
number
|
|
12
|
+
id
|
|
13
|
+
order_date
|
|
14
|
+
carrier
|
|
8
15
|
shipping_method
|
|
16
|
+
is_virtual
|
|
17
|
+
applied_coupons {
|
|
18
|
+
code
|
|
19
|
+
}
|
|
20
|
+
shipments {
|
|
21
|
+
id
|
|
22
|
+
number
|
|
23
|
+
tracking {
|
|
24
|
+
title
|
|
25
|
+
number
|
|
26
|
+
carrier
|
|
27
|
+
}
|
|
28
|
+
comments {
|
|
29
|
+
message
|
|
30
|
+
timestamp
|
|
31
|
+
}
|
|
32
|
+
items {
|
|
33
|
+
id
|
|
34
|
+
product_sku
|
|
35
|
+
product_name
|
|
36
|
+
order_item {
|
|
37
|
+
...OrderItems
|
|
38
|
+
... on GiftCardOrderItem {
|
|
39
|
+
gift_card {
|
|
40
|
+
recipient_name
|
|
41
|
+
recipient_email
|
|
42
|
+
sender_name
|
|
43
|
+
sender_email
|
|
44
|
+
message
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
9
50
|
payment_methods {
|
|
10
51
|
name
|
|
52
|
+
type
|
|
11
53
|
}
|
|
12
54
|
shipping_address {
|
|
13
55
|
...AddressesList
|
|
@@ -15,12 +57,18 @@ query ORDER_BY_NUMBER($orderNumber: String!) {
|
|
|
15
57
|
billing_address {
|
|
16
58
|
...AddressesList
|
|
17
59
|
}
|
|
18
|
-
number
|
|
19
|
-
id
|
|
20
|
-
order_date
|
|
21
|
-
carrier
|
|
22
60
|
items {
|
|
23
61
|
...OrderItems
|
|
62
|
+
... on GiftCardOrderItem {
|
|
63
|
+
__typename
|
|
64
|
+
gift_card {
|
|
65
|
+
recipient_name
|
|
66
|
+
recipient_email
|
|
67
|
+
sender_name
|
|
68
|
+
sender_email
|
|
69
|
+
message
|
|
70
|
+
}
|
|
71
|
+
}
|
|
24
72
|
}
|
|
25
73
|
total {
|
|
26
74
|
...OrderSummary
|
|
@@ -29,35 +77,89 @@ query ORDER_BY_NUMBER($orderNumber: String!) {
|
|
|
29
77
|
}
|
|
30
78
|
}
|
|
31
79
|
}
|
|
80
|
+
${m}
|
|
32
81
|
${c}
|
|
33
|
-
${
|
|
34
|
-
|
|
35
|
-
`,E=r=>{const{shipping_address:e,billing_address:t,payment_methods:s,gift_receipt_included:d,order_date:n,shipping_method:o,total:a,gift_wrapping:i,gift_message:u,items:m}=r;return{defaultShipping:e,defaultBulling:t,paymentMethods:s,giftReceiptIncluded:d,orderDate:n,shippingMethod:o,giftWrapping:i,giftMessage:u,items:m,total:{discount:a==null?void 0:a.discounts,subtotal:a==null?void 0:a.subtotal,totalTax:a==null?void 0:a.total_tax,totalShipping:a==null?void 0:a.total_shipping,grandTotal:a==null?void 0:a.grand_total}}},R=r=>r.total,S=r=>({carrier:r==null?void 0:r.carrier,id:r==null?void 0:r.id,items:r==null?void 0:r.items,number:r==null?void 0:r.number,orderDate:r==null?void 0:r.order_date,paymentMethods:r==null?void 0:r.payment_methods,shippingMethod:r==null?void 0:r.shipping_method}),T=r=>({defaultShipping:r==null?void 0:r.shipping_address,defaultBulling:r==null?void 0:r.billing_address}),B=(r,e)=>{var s,d,n,o,a,i,u;if(!((o=(n=(d=(s=e==null?void 0:e.data)==null?void 0:s.customer)==null?void 0:d.orders)==null?void 0:n.items)!=null&&o.length))return null;const t=(u=(i=(a=e==null?void 0:e.data)==null?void 0:a.customer)==null?void 0:i.orders)==null?void 0:u.items[0];switch(r){case"orderData":return E(t);case"orderSummary":return R(t);case"orderStatus":return S(t);case"orderCustomerInformation":return T(t);default:return null}},k=async(r,e)=>await p(b,{method:"GET",cache:"force-cache",variables:{orderNumber:r}}).then(t=>{var s;return(s=t.errors)!=null&&s.length?g(t.errors):B(e||"orderData",t)}).catch(_),I=`
|
|
82
|
+
${_}
|
|
83
|
+
`,g=async(e,r)=>await n(O,{method:"GET",cache:"force-cache",variables:{orderNumber:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?d(t.errors):u(r??"orderData",t)}).catch(o),b=`
|
|
36
84
|
query ORDER_BY_TOKEN($token: String!) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
85
|
+
guestOrderByToken(input: { token: $token }) {
|
|
86
|
+
email
|
|
87
|
+
id
|
|
88
|
+
number
|
|
89
|
+
order_date
|
|
90
|
+
status
|
|
91
|
+
token
|
|
92
|
+
carrier
|
|
93
|
+
shipping_method
|
|
94
|
+
printed_card_included
|
|
95
|
+
gift_receipt_included
|
|
96
|
+
available_actions
|
|
97
|
+
is_virtual
|
|
98
|
+
payment_methods {
|
|
99
|
+
name
|
|
100
|
+
type
|
|
101
|
+
}
|
|
102
|
+
applied_coupons {
|
|
103
|
+
code
|
|
104
|
+
}
|
|
105
|
+
shipments {
|
|
106
|
+
id
|
|
107
|
+
tracking {
|
|
108
|
+
title
|
|
48
109
|
number
|
|
49
|
-
id
|
|
50
|
-
order_date
|
|
51
110
|
carrier
|
|
52
|
-
|
|
111
|
+
}
|
|
112
|
+
comments {
|
|
113
|
+
message
|
|
114
|
+
timestamp
|
|
115
|
+
}
|
|
116
|
+
items {
|
|
117
|
+
id
|
|
118
|
+
product_sku
|
|
119
|
+
product_name
|
|
120
|
+
order_item {
|
|
53
121
|
...OrderItems
|
|
122
|
+
... on GiftCardOrderItem {
|
|
123
|
+
gift_card {
|
|
124
|
+
recipient_name
|
|
125
|
+
recipient_email
|
|
126
|
+
sender_name
|
|
127
|
+
sender_email
|
|
128
|
+
message
|
|
129
|
+
}
|
|
130
|
+
}
|
|
54
131
|
}
|
|
55
|
-
|
|
56
|
-
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
payment_methods {
|
|
135
|
+
name
|
|
136
|
+
type
|
|
137
|
+
}
|
|
138
|
+
shipping_address {
|
|
139
|
+
...AddressesList
|
|
140
|
+
}
|
|
141
|
+
billing_address {
|
|
142
|
+
...AddressesList
|
|
143
|
+
}
|
|
144
|
+
items {
|
|
145
|
+
...OrderItems
|
|
146
|
+
... on GiftCardOrderItem {
|
|
147
|
+
__typename
|
|
148
|
+
gift_card {
|
|
149
|
+
recipient_name
|
|
150
|
+
recipient_email
|
|
151
|
+
sender_name
|
|
152
|
+
sender_email
|
|
153
|
+
message
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
total {
|
|
158
|
+
...OrderSummary
|
|
57
159
|
}
|
|
58
160
|
}
|
|
59
161
|
}
|
|
162
|
+
${m}
|
|
60
163
|
${c}
|
|
61
|
-
${
|
|
62
|
-
|
|
63
|
-
`,M=async r=>await p(I,{method:"GET",cache:"no-cache",variables:{token:r}}).then(e=>{var t;return(t=e.errors)!=null&&t.length?g(e.errors):D(e)}).catch(_),$=async r=>{let e=null;const t=(r==null?void 0:r.orderId)||"",s=(r==null?void 0:r.orderToken)||"";if(!t&&!s){console.error("Order Token or ID not received.");return}if(t&&s){console.error("Error: You cannot pass both id and token together. You should pass only one identifier.");return}t&&(e=await k(t,"orderData")),s&&(e=await M(s)),y.emit("order/data",e)},f=new O({init:async r=>{const e={};f.config.setConfig({...e,...r}),$(r).catch(console.error)},listeners:()=>[]}),Y=f.config;export{Y as config,p as fetchGraphQl,x as getConfig,F as getGuestOrder,k as getOrderDetailsById,M as guestOrderByToken,f as initialize,L as removeFetchGraphQlHeader,Q as setEndpoint,q as setFetchGraphQlHeader,z as setFetchGraphQlHeaders};
|
|
164
|
+
${_}
|
|
165
|
+
`,f=async e=>await n(b,{method:"GET",cache:"no-cache",variables:{token:e}}).then(r=>{var t;return(t=r.errors)!=null&&t.length?d(r.errors):h(r)}).catch(o),y=async e=>{let r=null;const t=(e==null?void 0:e.orderNumber)??"",a=(e==null?void 0:e.orderToken)??"",i=(e==null?void 0:e.orderData)??null;if(i){s.emit("order/data",i);return}if(!t&&!a){console.error("Order Token or number not received.");return}if(t&&a){console.error("Error: You cannot pass both number and token together. You should pass only one identifier.");return}t&&(r=await g(t)),a&&(r=await f(a)),r?s.emit("order/data",r):s.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},l=new p({init:async e=>{const r={};l.config.setConfig({...r,...e}),y(e).catch(console.error)},listeners:()=>[]}),T=l.config;export{T as config,n as fetchGraphQl,F as getAttributesForm,B as getConfig,C as getGuestOrder,g as getOrderDetailsById,f as guestOrderByToken,l as initialize,N as removeFetchGraphQlHeader,$ as setEndpoint,w as setFetchGraphQlHeader,A as setFetchGraphQlHeaders};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as $,Fragment as V,jsxs as v}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as M,useState as D,useEffect as _,useCallback as T}from"@dropins/tools/preact-hooks.js";import{useText as y}from"@dropins/tools/i18n.js";import*as C from"@dropins/tools/preact-compat.js";import{memo as w,useCallback as L}from"@dropins/tools/preact-compat.js";import{classes as k}from"@dropins/tools/lib.js";import{Field as q,Picker as A,Input as I,InputDate as R,Checkbox as O,TextArea as N}from"@dropins/tools/components.js";const j=l=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...l},C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.8052 14.4968C10.8552 14.4968 9.9752 14.0268 9.4452 13.2368L9.4152 13.1868L9.3852 13.1268C8.1352 11.2268 7.5352 8.96681 7.6852 6.68681C7.7552 4.42681 9.6052 2.61681 11.8652 2.60681H12.0052C14.2752 2.47681 16.2152 4.21681 16.3452 6.47681C16.3452 6.55681 16.3452 6.62681 16.3452 6.70681C16.4852 8.94681 15.9052 11.1768 14.6852 13.0568L14.6052 13.1768C14.0552 13.9868 13.1352 14.4668 12.1652 14.4768H12.0052C11.9352 14.4768 11.8652 14.4868 11.7952 14.4868L11.8052 14.4968Z",stroke:"currentColor"}),C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M4.3252 21.5469C4.3552 20.4169 4.4752 19.2869 4.6752 18.1769C4.8952 17.1669 6.4752 16.0269 8.9052 15.1569C9.2352 15.0369 9.4852 14.7869 9.5952 14.4569L9.8052 14.0269",stroke:"currentColor"}),C.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M14.425 14.4069L14.165 14.1569C14.375 14.5969 14.725 14.9569 15.155 15.1869C16.945 15.7969 19.125 16.9569 19.375 18.2069C19.585 19.3069 19.685 20.4269 19.675 21.5369",stroke:"currentColor"})),H=l=>l.reduce((u,{code:p,required:h,defaultValue:c})=>(h&&(u[p]=c),u),{}),S=({fieldsConfig:l,onSubmit:u})=>{const{requiredFieldError:p}=y({requiredFieldError:"Order.Form.notifications.requiredFieldError"}),h=M(null),[c,n]=D({}),[o,t]=D({});_(()=>{if(!l||!l.length)return;const s=H(l);n(s)},[l==null?void 0:l.length]);const f=T((s,e)=>{const r=l.find(d=>d.code===s);return r!=null&&r.required&&!e?p:""},[l,p]),b=T(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,i=a==="checkbox"?d:r;n(E=>({...E,[e]:i}))},[]),x=T(s=>{const{name:e,value:r,type:a,checked:d}=s==null?void 0:s.target,i=a==="checkbox"?d:r;t(E=>({...E,[e]:f(e,i)}))},[f]),F=T(s=>{s.preventDefault();let e=!0,r={},a=null;for(const[d,i]of Object.entries(c)){const E=f(d,i);E&&(r[d]=E,e=!1,a||(a=d))}if(t(r),a&&h.current){const d=h.current.elements.namedItem(a);d==null||d.focus()}u==null||u(s,e)},[c,f,u]);return{formData:c,errors:o,formRef:h,handleChange:b,handleBlur:x,handleSubmit:F}},U=w(({loading:l,values:u,fields:p=[],errors:h,className:c="",onChange:n,onBlur:o})=>{const t=`${c}__item`,f=L((e,r,a)=>{const d=e.options.map(i=>({text:i.label,value:i.value}));return $(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(A,{name:e.id,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:d,onBlur:o,handleSelect:n,value:r||e.defaultValue})},e.id)},[c,l,t,o,n]),b=L((e,r,a)=>{const d=e.id==="email",i=d?$(j,{}):void 0,E=d?"username":"";return $(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e==null?void 0:e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(I,{"aria-label":e.label,"aria-required":e.required,autoComplete:E,icon:i,type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id)},[c,l,t,o,n]),x=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(R,{type:"text",name:e.id,value:r||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id),[c,l,t,o,n]),F=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(O,{name:e.id,checked:r||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id),[c,l,t,o,n]),s=L((e,r,a)=>$(q,{error:a,className:k([t,`${t}--${e.id}`,[`${t}--${e.id}-hidden`,e.is_hidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:l,children:$(N,{type:"text",name:e.id,value:r===void 0?e.defaultValue:r,label:`${e.label} ${e.required?"*":""}`,onBlur:o,onChange:n})},e.id),[c,l,t,o,n]);return p.length?$(V,{children:p.map(e=>{var d;const r=(h==null?void 0:h[e.id])??"",a=(u==null?void 0:u[e.id])??"";switch(e.fieldType){case"TEXT":return(d=e==null?void 0:e.options)!=null&&d.length?f(e,a,r):b(e,a,r);case"MULTILINE":return b(e,a,r);case"SELECT":return f(e,a,r);case"DATE":return x(e,a,r);case"BOOLEAN":return F(e,a,r);case"TEXTAREA":return s(e,a,r);default:return null}})}):null}),K=w(({name:l,loading:u,children:p,className:h="defaultForm",fieldsConfig:c,onSubmit:n})=>{const{formData:o,errors:t,formRef:f,handleChange:b,handleBlur:x,handleSubmit:F}=S({fieldsConfig:c,onSubmit:n});return v("form",{className:k(["dropin-form",h]),onSubmit:F,name:l,ref:f,children:[$(U,{className:h,loading:u,fields:c,onChange:b,onBlur:x,errors:t,values:o}),p]})});export{K as F};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as e,jsxs as t}from"@dropins/tools/preact-jsx-runtime.js";import{Card as l,Skeleton as s,SkeletonRow as r}from"@dropins/tools/components.js";import"./CustomerDetailsContent.js";import{classes as n}from"@dropins/tools/lib.js";const h=({testId:a,withCard:d=!0})=>{const i=t(s,{"data-testid":a??"skeletonLoader",children:[e(r,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(r,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(r,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return d?i:e(l,{variant:"secondary",className:n(["dropin-order-loaders","dropin-order-loaders--card-loader"]),children:i})},g=a=>e(l,{variant:"secondary",...a,children:t(s,{"data-testid":"order-details-skeleton",children:[e(r,{variant:"heading",size:"medium",fullWidth:!0}),e(r,{size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"}),e(r,{size:"xlarge"})]})});export{h as C,g as D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{events as f}from"@dropins/tools/event-bus.js";import{FetchGraphQL as u}from"@dropins/tools/fetch-graphql.js";const g=r=>{const t=r.map(e=>e.message).join(" ");throw Error(t)},m=r=>{throw r instanceof DOMException&&r.name==="AbortError"||f.emit("order/error",{source:"auth",type:"network",error:r.message}),r},i=r=>r.replace(/_([a-z])/g,(t,e)=>e.toUpperCase()),a=(r,t,e)=>{const c=["string","boolean","number"],p=i;return Array.isArray(r)?r.map(s=>c.includes(typeof s)||s===null?s:typeof s=="object"?a(s,t,e):s):r!==null&&typeof r=="object"?Object.entries(r).reduce((s,[n,o])=>{const h=e&&e[n]?e[n]:p(n);return s[h]=c.includes(typeof o)||o===null?o:a(o,t,e),s},{}):r},{setEndpoint:E,setFetchGraphQlHeader:w,removeFetchGraphQlHeader:A,setFetchGraphQlHeaders:C,fetchGraphQl:F,getConfig:G}=new u().getMethods();export{m as a,w as b,C as c,a as d,i as e,F as f,G as g,g as h,A as r,E as s};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import{e as l,d as m,f as _,h as f,a as T}from"./fetch-graphql.js";const b=o=>{let t=[];for(const e of o)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let s=2;s<=e.multiline_count;s++){const i={...e,name:`${e.code}_${s}`,code:`${e.code}_${s}`,id:`${e.code}_${s}`};t.push(i)}return t},h=o=>{var u,c,d;const t=((c=(u=o==null?void 0:o.data)==null?void 0:u.attributesForm)==null?void 0:c.items)||[];if(!t.length)return[];const e=(d=t.filter(r=>{var n;return!((n=r.frontend_input)!=null&&n.includes("HIDDEN"))}))==null?void 0:d.map(({code:r,...n})=>{const a=r!=="country_id"?r:"country_code";return{...n,name:a,id:a,code:a}}),s=b(e);return e.concat(s).map(r=>{const n=l(r.code);return m({...r,customUpperCode:n},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((r,n)=>r.orderNumber-n.orderNumber)},E=`
|
|
2
|
+
query GET_ATTRIBUTES_FORM($formCode: String!) {
|
|
3
|
+
attributesForm(formCode: $formCode) {
|
|
4
|
+
items {
|
|
5
|
+
code
|
|
6
|
+
default_value
|
|
7
|
+
entity_type
|
|
8
|
+
frontend_class
|
|
9
|
+
frontend_input
|
|
10
|
+
is_required
|
|
11
|
+
is_unique
|
|
12
|
+
label
|
|
13
|
+
options {
|
|
14
|
+
is_default
|
|
15
|
+
label
|
|
16
|
+
value
|
|
17
|
+
}
|
|
18
|
+
... on CustomerAttributeMetadata {
|
|
19
|
+
multiline_count
|
|
20
|
+
sort_order
|
|
21
|
+
validate_rules {
|
|
22
|
+
name
|
|
23
|
+
value
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
errors {
|
|
28
|
+
type
|
|
29
|
+
message
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`,C=`
|
|
34
|
+
query GET_ATTRIBUTES_FORM_SHORT {
|
|
35
|
+
attributesForm(formCode: customer_register_address) {
|
|
36
|
+
items {
|
|
37
|
+
frontend_input
|
|
38
|
+
label
|
|
39
|
+
code
|
|
40
|
+
... on CustomerAttributeMetadata {
|
|
41
|
+
multiline_count
|
|
42
|
+
sort_order
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`,y=async o=>await _(o!=="shortRequest"?E:C,{method:"GET",cache:"force-cache",variables:{formCode:o}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?f(t.errors):h(t)}).catch(T);export{y as g};
|
package/chunks/getGuestOrder.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as B,f as M,h as Q,a as L}from"./fetch-graphql.js";const w=`
|
|
2
2
|
fragment OrderSummary on OrderTotal {
|
|
3
3
|
grand_total {
|
|
4
4
|
value
|
|
@@ -31,7 +31,7 @@ fragment OrderSummary on OrderTotal {
|
|
|
31
31
|
}
|
|
32
32
|
label
|
|
33
33
|
}
|
|
34
|
-
}`,
|
|
34
|
+
}`,F=`
|
|
35
35
|
fragment AddressesList on OrderAddress {
|
|
36
36
|
city
|
|
37
37
|
company
|
|
@@ -48,12 +48,18 @@ fragment AddressesList on OrderAddress {
|
|
|
48
48
|
suffix
|
|
49
49
|
telephone
|
|
50
50
|
vat_id
|
|
51
|
-
}`,
|
|
51
|
+
}`,K=`
|
|
52
52
|
fragment OrderItems on OrderItem {
|
|
53
|
+
__typename
|
|
53
54
|
status
|
|
54
55
|
product_name
|
|
55
56
|
id
|
|
56
57
|
quantity_ordered
|
|
58
|
+
quantity_shipped
|
|
59
|
+
quantity_canceled
|
|
60
|
+
quantity_invoiced
|
|
61
|
+
quantity_refunded
|
|
62
|
+
quantity_returned
|
|
57
63
|
product_sale_price {
|
|
58
64
|
value
|
|
59
65
|
currency
|
|
@@ -63,11 +69,11 @@ fragment OrderItems on OrderItem {
|
|
|
63
69
|
value
|
|
64
70
|
}
|
|
65
71
|
product {
|
|
72
|
+
__typename
|
|
73
|
+
canonical_url
|
|
74
|
+
uid
|
|
66
75
|
name
|
|
67
76
|
sku
|
|
68
|
-
small_image {
|
|
69
|
-
url
|
|
70
|
-
}
|
|
71
77
|
thumbnail {
|
|
72
78
|
label
|
|
73
79
|
url
|
|
@@ -81,33 +87,43 @@ fragment OrderItems on OrderItem {
|
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
|
-
}`,
|
|
90
|
+
}`,P=n=>n||0,Y=n=>{var a,u,i;return{canonicalUrl:(n==null?void 0:n.canonical_url)||"",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:((i=n==null?void 0:n.thumbnail)==null?void 0:i.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},z=n=>n==null?void 0:n.map(a=>{var u,i,c,l,t,_,y,s,p,g,e,f,O,h,b,q,E,T,R,G,x,S,k,C,N,A,D,$,U;return{type:a==null?void 0:a.__typename,productName:a.product_name,quantityCanceled:a==null?void 0:a.quantity_canceled,quantityInvoiced:a==null?void 0:a.quantity_invoiced,quantityOrdered:a==null?void 0:a.quantity_ordered,quantityRefunded:a==null?void 0:a.quantity_refunded,quantityReturned:a==null?void 0:a.quantity_returned,quantityShipped:a==null?void 0:a.quantity_shipped,id:a==null?void 0:a.id,discounted:((l=(c=(i=(u=a==null?void 0:a.product)==null?void 0:u.price_range)==null?void 0:i.maximum_price)==null?void 0:c.regular_price)==null?void 0:l.value)*(a==null?void 0:a.quantity_ordered)!==((t=a==null?void 0:a.product_sale_price)==null?void 0:t.value)*(a==null?void 0:a.quantity_ordered),total:{value:((_=a==null?void 0:a.product_sale_price)==null?void 0:_.value)*(a==null?void 0:a.quantity_ordered),currency:(y=a==null?void 0:a.product_sale_price)==null?void 0:y.currency},totalInclTax:{value:((s=a==null?void 0:a.product_sale_price)==null?void 0:s.value)*(a==null?void 0:a.quantity_ordered),currency:(p=a==null?void 0:a.product_sale_price)==null?void 0:p.currency},price:{value:(g=a==null?void 0:a.product_sale_price)==null?void 0:g.value,currency:(e=a==null?void 0:a.product_sale_price)==null?void 0:e.currency},priceInclTax:{value:(f=a==null?void 0:a.product_sale_price)==null?void 0:f.value,currency:(O=a==null?void 0:a.product_sale_price)==null?void 0:O.currency},totalQuantity:P(a==null?void 0:a.quantity_ordered),regularPrice:{value:(E=(q=(b=(h=a==null?void 0:a.product)==null?void 0:h.price_range)==null?void 0:b.maximum_price)==null?void 0:q.regular_price)==null?void 0:E.value,currency:(x=(G=(R=(T=a==null?void 0:a.product)==null?void 0:T.price_range)==null?void 0:R.maximum_price)==null?void 0:G.regular_price)==null?void 0:x.currency},product:Y(a==null?void 0:a.product),thumbnail:{label:((k=(S=a==null?void 0:a.product)==null?void 0:S.thumbnail)==null?void 0:k.label)||"",url:((N=(C=a==null?void 0:a.product)==null?void 0:C.thumbnail)==null?void 0:N.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((A=a.gift_card)==null?void 0:A.sender_name)||"",senderEmail:((D=a.gift_card)==null?void 0:D.sender_email)||"",recipientEmail:(($=a.gift_card)==null?void 0:$.recipient_email)||"",recipientName:((U=a.gift_card)==null?void 0:U.recipient_name)||""}:void 0,configurableOptions:j(a)}}),v=n=>{var s,p,g,e,f;const a=z(n.items),{total:u,...i}=B({...n,items:a},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),c=(s=n==null?void 0:n.payment_methods)==null?void 0:s[0],l=(c==null?void 0:c.type)||"",t=(c==null?void 0:c.name)||"",_=(p=i==null?void 0:i.items)==null?void 0:p.reduce((O,h)=>O+h.totalQuantity,0);return{...u,...i,totalQuantity:_,shipping:{amount:((g=i==null?void 0:i.total)==null?void 0:g.totalShipping.value)??0,currency:((f=(e=i.total)==null?void 0:e.totalShipping)==null?void 0:f.currency)||"",code:i.shippingMethod??""},payments:[{code:l,name:t}]}},X=(n,a)=>{var u,i,c,l,t,_,y;if((l=(c=(i=(u=a==null?void 0:a.data)==null?void 0:u.customer)==null?void 0:i.orders)==null?void 0:c.items)!=null&&l.length&&n==="orderData"){const s=(y=(_=(t=a==null?void 0:a.data)==null?void 0:t.customer)==null?void 0:_.orders)==null?void 0:y.items[0];return v(s)}return null},H=n=>{var u,i;if(!((u=n==null?void 0:n.data)!=null&&u.guestOrder))return null;const a=(i=n==null?void 0:n.data)==null?void 0:i.guestOrder;return v(a)},Z=n=>{var u,i;if(!((u=n==null?void 0:n.data)!=null&&u.guestOrderByToken))return null;const a=(i=n==null?void 0:n.data)==null?void 0:i.guestOrderByToken;return v(a)},J=`
|
|
85
91
|
fragment guestOrderData on CustomerOrder {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
email
|
|
93
|
+
id
|
|
94
|
+
number
|
|
95
|
+
order_date
|
|
96
|
+
status
|
|
97
|
+
token
|
|
98
|
+
carrier
|
|
99
|
+
shipping_method
|
|
100
|
+
printed_card_included
|
|
101
|
+
gift_receipt_included
|
|
102
|
+
available_actions
|
|
103
|
+
is_virtual
|
|
96
104
|
payment_methods {
|
|
97
105
|
name
|
|
98
106
|
type
|
|
99
107
|
}
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
applied_coupons {
|
|
109
|
+
code
|
|
102
110
|
}
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
shipments {
|
|
112
|
+
id
|
|
113
|
+
tracking {
|
|
114
|
+
title
|
|
115
|
+
number
|
|
116
|
+
carrier
|
|
105
117
|
}
|
|
106
|
-
|
|
107
|
-
|
|
118
|
+
comments {
|
|
119
|
+
message
|
|
120
|
+
timestamp
|
|
108
121
|
}
|
|
109
|
-
|
|
110
|
-
|
|
122
|
+
items {
|
|
123
|
+
id
|
|
124
|
+
product_sku
|
|
125
|
+
product_name
|
|
126
|
+
order_item {
|
|
111
127
|
...OrderItems
|
|
112
128
|
... on GiftCardOrderItem {
|
|
113
129
|
gift_card {
|
|
@@ -116,18 +132,46 @@ fragment OrderItems on OrderItem {
|
|
|
116
132
|
sender_name
|
|
117
133
|
sender_email
|
|
118
134
|
message
|
|
135
|
+
}
|
|
119
136
|
}
|
|
120
137
|
}
|
|
121
138
|
}
|
|
122
139
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
140
|
+
payment_methods {
|
|
141
|
+
name
|
|
142
|
+
type
|
|
143
|
+
}
|
|
144
|
+
shipping_address {
|
|
145
|
+
...AddressesList
|
|
146
|
+
}
|
|
147
|
+
billing_address {
|
|
148
|
+
...AddressesList
|
|
149
|
+
}
|
|
150
|
+
items {
|
|
151
|
+
...OrderItems
|
|
152
|
+
... on GiftCardOrderItem {
|
|
153
|
+
__typename
|
|
154
|
+
gift_card {
|
|
155
|
+
recipient_name
|
|
156
|
+
recipient_email
|
|
157
|
+
sender_name
|
|
158
|
+
sender_email
|
|
159
|
+
message
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
total {
|
|
164
|
+
...OrderSummary
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
${w}
|
|
168
|
+
${F}
|
|
169
|
+
${K}
|
|
170
|
+
`,V=`
|
|
127
171
|
query GET_GUEST_ORDER($input: OrderInformationInput!) {
|
|
128
172
|
guestOrder(input:$input) {
|
|
129
173
|
...guestOrderData
|
|
130
174
|
}
|
|
131
175
|
}
|
|
132
|
-
${
|
|
133
|
-
`,
|
|
176
|
+
${J}
|
|
177
|
+
`,d=async n=>await M(V,{method:"GET",cache:"no-cache",variables:{input:n}}).then(a=>{var u;return(u=a.errors)!=null&&u.length?Q(a.errors):H(a)}).catch(L);export{F as A,w as O,K as a,Z as b,d as g,X as t};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
export declare const CardLoader: ({ testId, withCard, }: {
|
|
3
|
+
testId?: string | undefined;
|
|
4
|
+
withCard?: boolean | undefined;
|
|
5
|
+
}) => import("preact").JSX.Element;
|
|
6
|
+
export declare const DetailsSkeleton: (props: any) => import("preact").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=OrderLoaders.d.ts.map
|
package/components/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export * from './OrderSearchForm';
|
|
2
2
|
export * from './Form';
|
|
3
|
+
export * from './OrderStatusContent';
|
|
4
|
+
export * from './ShippingStatusCard';
|
|
5
|
+
export * from './OrderLoaders';
|
|
6
|
+
export * from './OrderActions';
|
|
7
|
+
export * from './CustomerDetailsContent';
|
|
3
8
|
//# sourceMappingURL=index.d.ts.map
|