@dropins/storefront-order 0.1.0-alpha5 → 0.1.0-alpha7
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/getCustomer/getCustomer.d.ts +4 -0
- package/api/getCustomer/graphql/getCustomer.graphql.d.ts +2 -0
- package/api/getCustomer/index.d.ts +2 -0
- package/api/helpers/initializeOrderDetails.d.ts +3 -1
- package/api/index.d.ts +2 -0
- package/api.js +10 -9
- package/chunks/CustomerDetailsContent.js +1 -0
- package/chunks/OrderLoaders.js +1 -1
- package/chunks/fetch-graphql.js +1 -0
- package/chunks/getAttributesForm.js +47 -0
- package/chunks/getCustomer.js +185 -0
- package/components/CustomerDetailsContent/CustomerDetailsContent.d.ts +5 -0
- package/components/CustomerDetailsContent/index.d.ts +3 -0
- package/components/OrderLoaders/OrderLoaders.d.ts +1 -0
- package/components/index.d.ts +1 -0
- package/configs/defaultAttributePreset.config.d.ts +2 -0
- package/configs/mock.config.d.ts +53 -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.js +1 -1
- package/containers/ShippingStatus.js +1 -1
- package/containers/index.d.ts +1 -0
- package/data/models/attributes-form.d.ts +46 -0
- package/data/models/customer.d.ts +6 -0
- package/data/models/index.d.ts +2 -0
- package/data/transforms/index.d.ts +2 -0
- package/data/transforms/transform-attributes-form.d.ts +6 -0
- package/data/transforms/transform-customer.d.ts +5 -0
- package/hooks/containers/useCustomerDetails.d.ts +12 -0
- package/hooks/containers/useOrderSearch.d.ts +1 -1
- package/hooks/index.d.ts +1 -0
- package/i18n/en_US.json.d.ts +20 -1
- package/lib/getQueryParam.d.ts +2 -0
- package/lib/redirectTo.d.ts +3 -0
- package/package.json +1 -1
- package/render.js +2 -2
- package/types/api/getAttributesForm.types.d.ts +31 -0
- package/types/api/getCustomer.types.d.ts +13 -0
- package/types/customerDetails.types.d.ts +49 -0
- package/types/index.d.ts +6 -3
- package/types/orderSearch.types.d.ts +13 -8
- package/chunks/OrderActions.js +0 -1
- package/chunks/getGuestOrder.js +0 -177
|
@@ -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,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,10 +1,11 @@
|
|
|
1
|
-
import{Initializer as u}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";import{
|
|
1
|
+
import{Initializer as u}from"@dropins/tools/lib.js";import{events as s}from"@dropins/tools/event-bus.js";import{f as n,h as m,a as o}from"./chunks/fetch-graphql.js";import{g as $,r as w,s as A,b as C,c as N}from"./chunks/fetch-graphql.js";import{O as c,a as _,A as p,t as h,b as O}from"./chunks/getCustomer.js";import{c as F,g as M}from"./chunks/getCustomer.js";import{g as x}from"./chunks/getAttributesForm.js";import"@dropins/tools/fetch-graphql.js";const y=`
|
|
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
|
|
8
9
|
available_actions
|
|
9
10
|
status
|
|
10
11
|
number
|
|
@@ -76,10 +77,10 @@ query ORDER_BY_NUMBER($orderNumber: String!) {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
${
|
|
80
|
-
${
|
|
81
|
-
${
|
|
82
|
-
`,
|
|
80
|
+
${c}
|
|
81
|
+
${_}
|
|
82
|
+
${p}
|
|
83
|
+
`,g=async(e,r)=>await n(y,{method:"GET",cache:"force-cache",variables:{orderNumber:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?m(t.errors):h(r??"orderData",t)}).catch(o),R=`
|
|
83
84
|
query ORDER_BY_TOKEN($token: String!) {
|
|
84
85
|
guestOrderByToken(input: { token: $token }) {
|
|
85
86
|
email
|
|
@@ -158,7 +159,7 @@ query ORDER_BY_TOKEN($token: String!) {
|
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
|
-
${
|
|
162
|
-
${
|
|
163
|
-
${
|
|
164
|
-
`,
|
|
162
|
+
${c}
|
|
163
|
+
${_}
|
|
164
|
+
${p}
|
|
165
|
+
`,b=async e=>await n(R,{method:"GET",cache:"no-cache",variables:{token:e}}).then(r=>{var t;return(t=r.errors)!=null&&t.length?m(r.errors):O(r)}).catch(o),f=async e=>{var d;const r=(e==null?void 0:e.orderRef)??"",t=r&&typeof(e==null?void 0:e.orderRef)=="string"&&((d=e==null?void 0:e.orderRef)==null?void 0:d.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 i=t?await b(r):await g(r);i?s.emit("order/data",i):s.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},l=new u({init:async e=>{const r={};l.config.setConfig({...r,...e}),f(e).catch(console.error)},listeners:()=>[]}),T=l.config;export{T as config,n as fetchGraphQl,x as getAttributesForm,$ as getConfig,F as getCustomer,M as getGuestOrder,g as getOrderDetailsById,b as guestOrderByToken,l as initialize,w as removeFetchGraphQlHeader,A as setEndpoint,C as setFetchGraphQlHeader,N as setFetchGraphQlHeaders};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as h,Fragment as v,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{useRef as _,useState as D,useEffect as w,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 V,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:$,defaultValue:c})=>($&&(u[p]=c),u),{}),S=({fieldsConfig:l,onSubmit:u})=>{const{requiredFieldError:p}=y({requiredFieldError:"Order.Form.notifications.requiredFieldError"}),$=_(null),[c,n]=D({}),[o,t]=D({});w(()=>{if(n({}),!l||!l.length)return;const s=H(l);n(s)},[l==null?void 0:l.length]),w(()=>()=>{var s;n({}),(s=$.current)==null||s.reset()},[]);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&&$.current){const d=$.current.elements.namedItem(a);d==null||d.focus()}u==null||u(s,e)},[c,f,u]);return{formData:c,errors:o,formRef:$,handleChange:b,handleBlur:x,handleSubmit:F}},U=V(({loading:l,values:u,fields:p=[],errors:$,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 h(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:h(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?h(j,{}):void 0,E=d?"username":"";return h(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:h(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)=>h(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:h(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)=>h(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:h(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)=>h(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:h(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?h(v,{children:p.map(e=>{var d;const r=($==null?void 0:$[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=V(({name:l,loading:u,children:p,className:$="defaultForm",fieldsConfig:c,onSubmit:n})=>{const{formData:o,errors:t,formRef:f,handleChange:b,handleBlur:x,handleSubmit:F}=S({fieldsConfig:c,onSubmit:n});return M("form",{className:k(["dropin-form",$]),onSubmit:F,name:l,ref:f,children:[h(U,{className:$,loading:u,fields:c,onChange:b,onBlur:x,errors:t,values:o}),p]})});export{K as F};
|
package/chunks/OrderLoaders.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as
|
|
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};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import{d as w,f as $,h as B,a as Q}from"./fetch-graphql.js";const L=`
|
|
2
|
+
fragment OrderSummary on OrderTotal {
|
|
3
|
+
grand_total {
|
|
4
|
+
value
|
|
5
|
+
currency
|
|
6
|
+
}
|
|
7
|
+
subtotal {
|
|
8
|
+
currency
|
|
9
|
+
value
|
|
10
|
+
}
|
|
11
|
+
taxes {
|
|
12
|
+
amount {
|
|
13
|
+
currency
|
|
14
|
+
value
|
|
15
|
+
}
|
|
16
|
+
rate
|
|
17
|
+
title
|
|
18
|
+
}
|
|
19
|
+
total_tax {
|
|
20
|
+
currency
|
|
21
|
+
value
|
|
22
|
+
}
|
|
23
|
+
total_shipping {
|
|
24
|
+
currency
|
|
25
|
+
value
|
|
26
|
+
}
|
|
27
|
+
discounts {
|
|
28
|
+
amount {
|
|
29
|
+
currency
|
|
30
|
+
value
|
|
31
|
+
}
|
|
32
|
+
label
|
|
33
|
+
}
|
|
34
|
+
}`,F=`
|
|
35
|
+
fragment AddressesList on OrderAddress {
|
|
36
|
+
city
|
|
37
|
+
company
|
|
38
|
+
country_code
|
|
39
|
+
fax
|
|
40
|
+
firstname
|
|
41
|
+
lastname
|
|
42
|
+
middlename
|
|
43
|
+
postcode
|
|
44
|
+
prefix
|
|
45
|
+
region
|
|
46
|
+
region_id
|
|
47
|
+
street
|
|
48
|
+
suffix
|
|
49
|
+
telephone
|
|
50
|
+
vat_id
|
|
51
|
+
}`,K=`
|
|
52
|
+
fragment OrderItems on OrderItem {
|
|
53
|
+
__typename
|
|
54
|
+
status
|
|
55
|
+
product_name
|
|
56
|
+
id
|
|
57
|
+
quantity_ordered
|
|
58
|
+
quantity_shipped
|
|
59
|
+
quantity_canceled
|
|
60
|
+
quantity_invoiced
|
|
61
|
+
quantity_refunded
|
|
62
|
+
quantity_returned
|
|
63
|
+
product_sale_price {
|
|
64
|
+
value
|
|
65
|
+
currency
|
|
66
|
+
}
|
|
67
|
+
selected_options {
|
|
68
|
+
label
|
|
69
|
+
value
|
|
70
|
+
}
|
|
71
|
+
product {
|
|
72
|
+
__typename
|
|
73
|
+
canonical_url
|
|
74
|
+
uid
|
|
75
|
+
name
|
|
76
|
+
sku
|
|
77
|
+
thumbnail {
|
|
78
|
+
label
|
|
79
|
+
url
|
|
80
|
+
}
|
|
81
|
+
price_range {
|
|
82
|
+
maximum_price {
|
|
83
|
+
regular_price {
|
|
84
|
+
currency
|
|
85
|
+
value
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
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,t,l,_,y,s,g,f,e,h,O,p,b,q,E,T,G,R,C,S,x,k,N,A,U,D,M;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:((t=(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:t.value)*(a==null?void 0:a.quantity_ordered)!==((l=a==null?void 0:a.product_sale_price)==null?void 0:l.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:(g=a==null?void 0:a.product_sale_price)==null?void 0:g.currency},price:{value:(f=a==null?void 0:a.product_sale_price)==null?void 0:f.value,currency:(e=a==null?void 0:a.product_sale_price)==null?void 0:e.currency},priceInclTax:{value:(h=a==null?void 0:a.product_sale_price)==null?void 0:h.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=(p=a==null?void 0:a.product)==null?void 0:p.price_range)==null?void 0:b.maximum_price)==null?void 0:q.regular_price)==null?void 0:E.value,currency:(C=(R=(G=(T=a==null?void 0:a.product)==null?void 0:T.price_range)==null?void 0:G.maximum_price)==null?void 0:R.regular_price)==null?void 0:C.currency},product:Y(a==null?void 0:a.product),thumbnail:{label:((x=(S=a==null?void 0:a.product)==null?void 0:S.thumbnail)==null?void 0:x.label)||"",url:((N=(k=a==null?void 0:a.product)==null?void 0:k.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:((U=a.gift_card)==null?void 0:U.sender_email)||"",recipientEmail:((D=a.gift_card)==null?void 0:D.recipient_email)||"",recipientName:((M=a.gift_card)==null?void 0:M.recipient_name)||""}:void 0,configurableOptions:j(a)}}),v=n=>{var s,g,f,e,h;const a=z(n.items),{total:u,...i}=w({...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],t=(c==null?void 0:c.type)||"",l=(c==null?void 0:c.name)||"",_=(g=i==null?void 0:i.items)==null?void 0:g.reduce((O,p)=>O+p.totalQuantity,0);return{...u,...i,totalQuantity:_,shipping:{amount:((f=i==null?void 0:i.total)==null?void 0:f.totalShipping.value)??0,currency:((h=(e=i.total)==null?void 0:e.totalShipping)==null?void 0:h.currency)||"",code:i.shippingMethod??""},payments:[{code:t,name:l}]}},m=(n,a)=>{var u,i,c,t,l,_,y;if((t=(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&&t.length&&n==="orderData"){const s=(y=(_=(l=a==null?void 0:a.data)==null?void 0:l.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)},d=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=n=>{var a,u,i,c,t,l;return{email:((u=(a=n==null?void 0:n.data)==null?void 0:a.customer)==null?void 0:u.email)||"",firstname:((c=(i=n==null?void 0:n.data)==null?void 0:i.customer)==null?void 0:c.firstname)||"",lastname:((l=(t=n==null?void 0:n.data)==null?void 0:t.customer)==null?void 0:l.lastname)||""}},V=`
|
|
91
|
+
fragment guestOrderData on CustomerOrder {
|
|
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
|
|
104
|
+
payment_methods {
|
|
105
|
+
name
|
|
106
|
+
type
|
|
107
|
+
}
|
|
108
|
+
applied_coupons {
|
|
109
|
+
code
|
|
110
|
+
}
|
|
111
|
+
shipments {
|
|
112
|
+
id
|
|
113
|
+
tracking {
|
|
114
|
+
title
|
|
115
|
+
number
|
|
116
|
+
carrier
|
|
117
|
+
}
|
|
118
|
+
comments {
|
|
119
|
+
message
|
|
120
|
+
timestamp
|
|
121
|
+
}
|
|
122
|
+
items {
|
|
123
|
+
id
|
|
124
|
+
product_sku
|
|
125
|
+
product_name
|
|
126
|
+
order_item {
|
|
127
|
+
...OrderItems
|
|
128
|
+
... on GiftCardOrderItem {
|
|
129
|
+
gift_card {
|
|
130
|
+
recipient_name
|
|
131
|
+
recipient_email
|
|
132
|
+
sender_name
|
|
133
|
+
sender_email
|
|
134
|
+
message
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
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
|
+
${L}
|
|
168
|
+
${F}
|
|
169
|
+
${K}
|
|
170
|
+
`,W=`
|
|
171
|
+
query GET_GUEST_ORDER($input: OrderInformationInput!) {
|
|
172
|
+
guestOrder(input:$input) {
|
|
173
|
+
...guestOrderData
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
${V}
|
|
177
|
+
`,r=async n=>await $(W,{method:"GET",cache:"no-cache",variables:{input:n}}).then(a=>{var u;return(u=a.errors)!=null&&u.length?B(a.errors):H(a)}).catch(Q),X=`
|
|
178
|
+
query GET_CUSTOMER {
|
|
179
|
+
customer {
|
|
180
|
+
firstname
|
|
181
|
+
lastname
|
|
182
|
+
email
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
`,o=async()=>await $(X,{method:"GET",cache:"force-cache"}).then(n=>{var a;return(a=n.errors)!=null&&a.length?B(n.errors):J(n)}).catch(Q);export{F as A,L as O,K as a,d as b,o as c,r as g,m as t};
|
|
@@ -3,4 +3,5 @@ export declare const CardLoader: ({ testId, withCard, }: {
|
|
|
3
3
|
testId?: string | undefined;
|
|
4
4
|
withCard?: boolean | undefined;
|
|
5
5
|
}) => import("preact").JSX.Element;
|
|
6
|
+
export declare const DetailsSkeleton: (props: any) => import("preact").JSX.Element;
|
|
6
7
|
//# sourceMappingURL=OrderLoaders.d.ts.map
|
package/components/index.d.ts
CHANGED
package/configs/mock.config.d.ts
CHANGED
|
@@ -878,4 +878,57 @@ export declare const storyBookOrderData: {
|
|
|
878
878
|
code: string;
|
|
879
879
|
};
|
|
880
880
|
};
|
|
881
|
+
export declare const storyBookShortOrderData: {
|
|
882
|
+
email: string;
|
|
883
|
+
status: string;
|
|
884
|
+
number: string;
|
|
885
|
+
id: string;
|
|
886
|
+
orderDate: string;
|
|
887
|
+
carrier: string;
|
|
888
|
+
shippingMethod: string;
|
|
889
|
+
payments: {
|
|
890
|
+
code: string;
|
|
891
|
+
name: string;
|
|
892
|
+
}[];
|
|
893
|
+
totalQuantity: number;
|
|
894
|
+
shipping: {
|
|
895
|
+
amount: number;
|
|
896
|
+
currency: string;
|
|
897
|
+
code: string;
|
|
898
|
+
};
|
|
899
|
+
};
|
|
900
|
+
export declare const storyBookNormalizeAddress: {
|
|
901
|
+
billingAddress: ({
|
|
902
|
+
name: string;
|
|
903
|
+
orderNumber: number;
|
|
904
|
+
value: string;
|
|
905
|
+
label: null;
|
|
906
|
+
} | {
|
|
907
|
+
name: string;
|
|
908
|
+
orderNumber: number;
|
|
909
|
+
value: string[];
|
|
910
|
+
label: null;
|
|
911
|
+
} | {
|
|
912
|
+
name: string;
|
|
913
|
+
orderNumber: number;
|
|
914
|
+
value: string;
|
|
915
|
+
label: string;
|
|
916
|
+
})[];
|
|
917
|
+
shippingAddress: ({
|
|
918
|
+
name: string;
|
|
919
|
+
orderNumber: number;
|
|
920
|
+
value: string;
|
|
921
|
+
label: null;
|
|
922
|
+
} | {
|
|
923
|
+
name: string;
|
|
924
|
+
orderNumber: number;
|
|
925
|
+
value: string[];
|
|
926
|
+
label: null;
|
|
927
|
+
} | {
|
|
928
|
+
name: string;
|
|
929
|
+
orderNumber: number;
|
|
930
|
+
value: string;
|
|
931
|
+
label: string;
|
|
932
|
+
})[];
|
|
933
|
+
};
|
|
881
934
|
//# sourceMappingURL=mock.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t,jsxs as p,Fragment as L}from"@dropins/tools/preact-jsx-runtime.js";import{classes as k}from"@dropins/tools/lib.js";import{useMemo as O,useState as v,useEffect as D,useCallback as V}from"@dropins/tools/preact-hooks.js";import{events as S}from"@dropins/tools/event-bus.js";import{e as W}from"../chunks/fetch-graphql.js";import{g as j}from"../chunks/getAttributesForm.js";import{Card as P,Header as Z,Price as x,Icon as z}from"@dropins/tools/components.js";import"../chunks/CustomerDetailsContent.js";import*as o from"@dropins/tools/preact-compat.js";import{D as B}from"../chunks/OrderLoaders.js";import{useText as q}from"@dropins/tools/i18n.js";import"@dropins/tools/fetch-graphql.js";const F=d=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},o.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"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),K=d=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d},o.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}),o.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}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M3.01465 15.9682H8.40305",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round"}),o.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}),o.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})),R=({loading:d,order:i,withHeader:f=!0,title:l,paymentIconsMap:u={},normalizeAddress:h})=>{var E,N,A,T,$,y,w;const a=q({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"}),g=O(()=>({checkmo:F,card:K,...u}),[u]);if(!i||d)return t(B,{});const C=(i==null?void 0:i.email)??"",n=(E=i==null?void 0:i.shipping)==null?void 0:E.code,c=(N=i==null?void 0:i.shipping)==null?void 0:N.amount,s=(A=i==null?void 0:i.shipping)==null?void 0:A.currency,m=i==null?void 0:i.payments,_=m&&m.length>0,b=_?(T=m[0])==null?void 0:T.name:"",M=_?($=m[0])==null?void 0:$.code:"",H=_&&b!=="";return p(P,{"data-testid":"order-details",variant:"secondary",className:k(["dropin-details"]),children:[f?t(Z,{title:l??a.headerText}):null,p("div",{className:"dropin-details__container",children:[p("div",{className:"dropin-details__container-email",children:[t("div",{className:"dropin-details__container-title",children:a.emailTitle}),t("p",{children:C})]}),p("div",{className:"dropin-details__container-shipping_address",children:[t("div",{className:"dropin-details__container-title",children:a.shippingAddressTitle}),t("div",{className:"dropin-details__container-description",children:(y=h.shippingAddress)==null?void 0:y.filter(({value:e})=>e).map((e,r)=>r===1?t("p",{"data-testid":`${e.name}_${r}`,children:t("span",{children:e.label?`${e.label}: ${e==null?void 0:e.value}`:e==null?void 0:e.value})},r):t("p",{"data-testid":`${e.name}_${r}`,children:e.label?`${e.label}: ${e==null?void 0:e.value}`:e==null?void 0:e.value},r))})]}),p("div",{className:"dropin-details__container-billing_address",children:[t("div",{className:"dropin-details__container-title",children:a.billingAddressTitle}),t("div",{className:"dropin-details__container-description",children:(w=h.billingAddress)==null?void 0:w.filter(({value:e})=>e).map((e,r)=>r===1||r===5?t("p",{"data-testid":`${e.name}_${r}`,children:t("span",{children:e.label?`${e.label}: ${e==null?void 0:e.value}`:e==null?void 0:e.value})},r):t("p",{"data-testid":`${e.name}_${r}`,children:e.label?`${e.label}: ${e==null?void 0:e.value}`:e==null?void 0:e.value},r))})]}),p("div",{className:"dropin-details__container-shipping_methods",children:[t("div",{className:"dropin-details__container-title",children:a.shippingMethodsTitle}),n?t(L,{children:c?p("p",{"data-testid":"shipping_methods_price",children:[t(x,{amount:c,currency:s})," ",n]}):t("p",{"data-testid":"shipping_methods_placeholder",children:a.freeShipping})}):null]}),p("div",{className:"dropin-details__container-billing_methods",children:[t("div",{className:"dropin-details__container-title",children:a.billingMethodsTitle}),H&&p("p",{"data-testid":"billing_methods_description",className:k([["dropin-details__container-billing_methods--icon",!!g[M]]]),children:[t(z,{source:g[M]}),b]})]})]})]})},G=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_2","default_shipping","default_billing"],I=({orderData:d})=>{const[i,f]=v(!0),[l,u]=v(d),[h,a]=v([]);D(()=>{const n=S.on("order/data",c=>{u(c)},{eager:!0});return()=>{n==null||n.off()}},[]),D(()=>{j("shortRequest").then(n=>{if(n){const c=n.map(({name:s,orderNumber:m,label:_})=>({name:W(s),orderNumber:m,label:G.includes(s)?null:_}));a(c)}}).finally(()=>{f(!1)})},[]);const g=V(n=>{if(!h.length||!l||!l[n])return[];const c=Object.fromEntries(Object.entries(l[n]).map(([s,m])=>[s.toLowerCase(),m]));return h.filter(({name:s})=>c[s.toLowerCase()]).map(s=>({name:s.name,orderNumber:s.orderNumber,value:c[s.name],label:s.label}))},[h,l]),C=O(()=>({billingAddress:g("billingAddress"),shippingAddress:g("shippingAddress")}),[g]);return{order:l,normalizeAddress:C,loading:i}},ae=({paymentIconsMap:d,orderData:i,title:f,className:l})=>{const{order:u,normalizeAddress:h,loading:a}=I({orderData:i});return t("div",{className:k(["dropin-customer-details",l]),children:t(R,{loading:a,order:u,title:f,paymentIconsMap:d,normalizeAddress:h})})};export{ae as CustomerDetails,ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as
|
|
1
|
+
import{jsxs as v,jsx as n}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/CustomerDetailsContent.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{Text as S,useText as H}from"@dropins/tools/i18n.js";import{events as w}from"@dropins/tools/event-bus.js";import{c as A,g as P}from"../chunks/getCustomer.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.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:r})=>v(U,{variant:"secondary",className:"dropin-order-search-form",children:[n("h2",{className:"dropin-order-search-form__title",children:n(S,{id:"Order.OrderSearchForm.title"})}),n("p",{children:n(S,{id:"Order.OrderSearchForm.description"})}),o.text?n(C,{"data-testid":"orderAlert",className:"dropin-order-search-form__alert",type:o.type,variant:"secondary",heading:o.text,icon:n(x,{source:X})}):null,n(L,{className:"dropin-order-search-form__wrapper",name:"orderSearchForm",loading:t,fieldsConfig:r,onSubmit:e,children:n("div",{className:"dropin-order-search-form__button-container",children:n(V,{className:"dropin-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:t,children:n(S,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});var T=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(T||{});const j=e=>{if(!e)return null;const t=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{t.has(r.name)||t.set(r.name,"false"),r.checked&&t.set(r.name,"true")}),t&&typeof t.entries=="function"){const r=t.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}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 r=new URLSearchParams;Object.entries(t).forEach(([u,d])=>{r.append(u,String(d))});const c=o.includes("?")?"&":"?";window.location.href=`${o}${c}${r.toString()}`},I=e=>{try{return new URL(window.location.href).searchParams.get(e)}catch{return null}},q=({onError:e,isAuth:t,renderSignIn:o,routeCustomerOrder:r,routeGuestOrder:c})=>{const[u,d]=D({text:"",type:"success"}),[E,h]=D(!1),f=H({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",postcode:"Order.OrderSearchForm.postcode",number:"Order.OrderSearchForm.orderNumber"}),b=O(async a=>{const s=I("orderRef"),i=s&&s.length>20;if(!a&&!s||!(a!=null&&a.number)&&!(a!=null&&a.token)&&!s)return null;if(t){const m=await A();(m==null?void 0:m.email)===a.email?p(r,{orderRef:a==null?void 0:a.number}):i||p(c,{orderRef:a.token})}else i||p(c,{orderRef:a==null?void 0:a.token})},[t,r,c]);g(()=>{const a=w.on("order/data",s=>{b(s)},{eager:!0});return()=>{a==null||a.off()}},[b]),g(()=>{const a=I("orderRef"),s=a&&a.length>20?a:null;a&&(s?p(c,{orderRef:a}):t?p(r,{orderRef:a}):o==null||o({render:!0,formValues:{number:a}}))},[t,r,c,o]);const M=k(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:f.email,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:f.postcode,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:2,name:"postcode",id:"postcode",code:"postcode"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:f.number,options:[],defaultValue:"",fieldType:T.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[f]);return{onSubmit:O(async(a,s)=>{if(!s)return null;h(!0);const i=j(a.target);await P(i).then(l=>{l||d({text:f.invalidSearch,type:"warning"}),w.emit("order/data",l)}).catch(async l=>{var N;let m=!0;e==null||e({error:l.message});const y=t?await A():{email:""};(y==null?void 0:y.email)===(i==null?void 0:i.email)?(m=!1,p(r,{orderRef:i.number})):m=o==null?void 0:o({render:(N=l==null?void 0:l.message)==null?void 0:N.includes("Please login to view the order."),formValues:i}),m&&d({text:l.message,type:"warning"})}).finally(()=>{h(!1)})},[t,e,o,r,f.invalidSearch]),inLineAlert:u,loading:E,normalizeFieldsConfig:M}},te=({className:e,isAuth:t,renderSignIn:o,routeCustomerOrder:r,routeGuestOrder:c,onError:u})=>{const{onSubmit:d,loading:E,inLineAlert:h,normalizeFieldsConfig:f}=q({onError:u,isAuth:t,renderSignIn:o,routeCustomerOrder:r,routeGuestOrder:c});return n("div",{className:_(["dropin-order-search",e]),children:n(B,{onSubmit:d,loading:E,inLineAlert:h,fieldsConfig:f})})};export{te as OrderSearch,te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as O,Fragment as
|
|
1
|
+
import{jsx as t,jsxs as O,Fragment as f}from"@dropins/tools/preact-jsx-runtime.js";import{Card as E,Header as v,Button as p}from"@dropins/tools/components.js";import"../chunks/CustomerDetailsContent.js";import{Slot as g,classes as m}from"@dropins/tools/lib.js";import{useMemo as N}from"@dropins/tools/preact-compat.js";import{useText as l}from"@dropins/tools/i18n.js";import{useState as C,useEffect as w}from"@dropins/tools/preact-hooks.js";import{C as y}from"../chunks/OrderLoaders.js";import{events as A}from"@dropins/tools/event-bus.js";const h={pending:"orderPending",shiping:"orderShipped",complete:"orderComplete",processing:"orderProcessing","on hold":"orderOnHold",canceled:"orderCanceled","suspected fraud":"orderSuspectedFraud","payment Review":"orderPaymentReview","order received":"orderReceived"},_=({slots:r,title:a,status:n,orderData:e})=>{var s;const c=String(n).toLocaleLowerCase(),d=l(`Order.OrderStatusContent.${h[c]}.title`),o=l(`Order.OrderStatusContent.${h[c]}.message`);return n?O(E,{className:"dropin-order-status-content",variant:"secondary",children:[t(v,{title:a??d.title}),O("div",{className:"dropin-order-status-content__wrapper",children:[t("div",{className:"dropin-order-status-content__wrapper-description",children:t("p",{children:(s=o.message)==null?void 0:s.replace("{DATE}","01.01.1900")})}),t(T,{orderData:e,slots:r})]})]}):t("div",{})};var i=(r=>(r.CANCEL="CANCEL",r.RETURN="RETURN",r.REORDER="REORDER",r))(i||{});const T=({className:r,children:a,orderData:n,slots:e,...c})=>{const d=l({cancel:"Order.OrderStatusContent.actions.cancel",return:"Order.OrderStatusContent.actions.return",reorder:"Order.OrderStatusContent.actions.reorder"}),o=N(()=>{const s=n==null?void 0:n.availableActions,R=!!(s!=null&&s.length);return t(f,{children:e!=null&&e.OrderActions?t(g,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:e==null?void 0:e.OrderActions,context:n}):t("div",{"data-testid":"availableActionsList",className:m(["dropin-order-actions__wrapper",["dropin-order-actions__wrapper--empty",!R]]),children:s==null?void 0:s.map((S,u)=>{switch(S){case i.CANCEL:return t(p,{variant:"secondary",children:d.cancel},u);case i.RETURN:return t(p,{variant:"secondary",children:d.return},u);case i.REORDER:return t(p,{variant:"secondary",children:d.reorder},u)}})})})},[n,e==null?void 0:e.OrderActions,d]);return t("div",{...c,className:m(["dropin-order-actions",r]),children:o})},L=({orderData:r})=>{const[a,n]=C(r),[e,c]=C(r==null?void 0:r.status);return w(()=>{const d=A.on("order/data",o=>{n(o),c(o.status)},{eager:!0});return()=>{d==null||d.off()}},[]),{orderStatus:e,order:a}},k=({slots:r,orderData:a,className:n,statusTitle:e,status:c})=>{const{orderStatus:d,order:o}=L({orderData:a});return t("div",{className:m(["dropin-order-status",n]),children:o?t(_,{title:e,status:c||d,slots:r,orderData:o}):t(y,{withCard:!1})})};export{k as OrderStatus,k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsxs as r,jsx as e,Fragment as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as E,classes as R}from"@dropins/tools/lib.js";import{Card as g,Header as u,Accordion as b,AccordionSection as x,ContentGrid as U,Image as w}from"@dropins/tools/components.js";import"../chunks/CustomerDetailsContent.js";import{useText as Y}from"@dropins/tools/i18n.js";import{C as $}from"../chunks/OrderLoaders.js";import"@dropins/tools/preact-compat.js";import{useState as j,useEffect as F}from"@dropins/tools/preact-hooks.js";import{events as q}from"@dropins/tools/event-bus.js";var m=(i=>(i.PENDING="pending",i.SHIPPING="shipping",i.COMPLETE="complete",i.PROCESSING="processing",i.HOLD="on hold",i.CANCELED="Canceled",i.SUSPECTED_FRAUD="suspected fraud",i.PAYMENT_REVIEW="payment review",i))(m||{});const V=({slots:i,orderData:n,collapseThreshold:d=0})=>{var C,f,T,S,I;const t=Y({carrier:"Order.ShippingStatusCard.carrier",prepositionOf:"Order.ShippingStatusCard.prepositionOf",shippingCardTitle:"Order.ShippingStatusCard.shippingCardTitle",shippingInfoTitle:"Order.ShippingStatusCard.shippingInfoTitle",notYetShippedTitle:"Order.ShippingStatusCard.notYetShippedTitle",notYetShippedImagesTitle:"Order.ShippingStatusCard.notYetShippedImagesTitle",noInfoTitle:"Order.OrderStatusContent.noInfoTitle"}),l=(C=n==null?void 0:n.status)==null?void 0:C.toLocaleLowerCase(),G=((f=n==null?void 0:n.shipments)==null?void 0:f.length)===1&&(l==null?void 0:l.includes(m.COMPLETE)),c=(T=n==null?void 0:n.items)==null?void 0:T.filter(h=>(h==null?void 0:h.quantityShipped)===0);return!n||l!=null&&l.includes(m.CANCELED)?null:(S=n==null?void 0:n.shipments)!=null&&S.length?r(A,{children:[(I=n==null?void 0:n.shipments)==null?void 0:I.map(({tracking:h,items:s,id:a},H)=>r(g,{variant:"secondary",className:"dropin-shipping-status-card",children:[e(u,{title:t.shippingCardTitle}),h==null?void 0:h.map(p=>{var o;return r("div",{className:"dropin-shipping-status-card__header",role:"status",children:[r("div",{className:"dropin-shipping-status-card__header--content",children:[r("p",{children:[t.carrier," ",(o=p==null?void 0:p.carrier)==null?void 0:o.toLocaleUpperCase()," | ",p==null?void 0:p.number]}),e("p",{children:p==null?void 0:p.title})]}),i!=null&&i.DeliveryTrackActions?e(E,{"data-testid":"deliverySlotActions",name:"DeliveryTrackActions",slot:i==null?void 0:i.DeliveryTrackActions,context:{trackInformation:p}}):null]},p.number)}),G?null:e(b,{actionIconPosition:"right","data-testid":"dropinAccordion",children:e(x,{"data-position":H+1,defaultOpen:d>=(s==null?void 0:s.length),title:`Package contents (${s==null?void 0:s.length} items)`,children:e(U,{maxColumns:6,emptyGridContent:e(A,{}),className:"dropin-shipping-status-card__images",children:s==null?void 0:s.map(p=>{var v,O,y,_,L,N;const o=(y=(O=(v=p==null?void 0:p.orderItem)==null?void 0:v.product)==null?void 0:O.thumbnail)==null?void 0:y.label,M=(N=(L=(_=p==null?void 0:p.orderItem)==null?void 0:_.product)==null?void 0:L.thumbnail)==null?void 0:N.url;return e(w,{alt:o,src:M,width:85,height:114},p.id)})})})}),i!=null&&i.DeliveryTimeLine?e(E,{"data-testid":"deliverySlotTimeLine",name:"DeliveryTimeLine",slot:i==null?void 0:i.DeliveryTimeLine,context:{}}):null]},a)),c!=null&&c.length?r(g,{variant:"secondary",className:"dropin-shipping-status-card","data-testid":"dropinAccordionNotYetShipped2",children:[e(u,{title:t.notYetShippedTitle}),e(b,{actionIconPosition:"right",children:e(x,{title:`${t.notYetShippedImagesTitle} ${c==null?void 0:c.length}`,children:e("div",{className:"dropin-shipping-status-card__images",children:c==null?void 0:c.map(({id:h,thumbnail:{url:s,label:a}})=>e(w,{alt:a,src:s,width:85,height:114},h))})})})]}):null]}):r(g,{variant:"secondary",className:"dropin-shipping-status-card",children:[e(u,{title:t.shippingInfoTitle}),e("div",{className:"dropin-shipping-status-card__header",children:r("div",{className:"dropin-shipping-status-card__header--content",children:[n!=null&&n.carrier?e("p",{children:n==null?void 0:n.carrier}):null,e("p",{children:t.noInfoTitle})]})})]})},W=({orderData:i})=>{const[n,d]=j(i);return F(()=>{const t=q.on("order/data",l=>{d(l)},{eager:!0});return()=>{t==null||t.off()}},[]),{order:n}},ii=({slots:i,className:n,collapseThreshold:d,orderData:t})=>{const{order:l}=W({orderData:t});return e("div",{className:R(["dropin-shipping-status",n]),children:l?e(V,{slots:i,orderData:l,collapseThreshold:d}):e($,{withCard:!1})})};export{ii as ShippingStatus,ii as default};
|
package/containers/index.d.ts
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare enum FieldEnumList {
|
|
2
|
+
BOOLEAN = "BOOLEAN",
|
|
3
|
+
DATE = "DATE",
|
|
4
|
+
DATETIME = "DATETIME",
|
|
5
|
+
DROPDOWN = "DROPDOWN",
|
|
6
|
+
FILE = "FILE",
|
|
7
|
+
GALLERY = "GALLERY",
|
|
8
|
+
HIDDEN = "HIDDEN",
|
|
9
|
+
IMAGE = "IMAGE",
|
|
10
|
+
MEDIA_IMAGE = "MEDIA_IMAGE",
|
|
11
|
+
MULTILINE = "MULTILINE",
|
|
12
|
+
MULTISELECT = "MULTISELECT",
|
|
13
|
+
PRICE = "PRICE",
|
|
14
|
+
SELECT = "SELECT",
|
|
15
|
+
TEXT = "TEXT",
|
|
16
|
+
TEXTAREA = "TEXTAREA",
|
|
17
|
+
UNDEFINED = "UNDEFINED",
|
|
18
|
+
VISUAL = "VISUAL",
|
|
19
|
+
WEIGHT = "WEIGHT",
|
|
20
|
+
EMPTY = ""
|
|
21
|
+
}
|
|
22
|
+
export interface AttributesFormItemsProps {
|
|
23
|
+
code?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
id?: string;
|
|
26
|
+
required?: boolean;
|
|
27
|
+
label?: string;
|
|
28
|
+
options?: {
|
|
29
|
+
is_default: boolean;
|
|
30
|
+
label: string;
|
|
31
|
+
value: string;
|
|
32
|
+
}[];
|
|
33
|
+
entityType?: string;
|
|
34
|
+
className?: string;
|
|
35
|
+
defaultValue?: string | boolean | number;
|
|
36
|
+
fieldType?: FieldEnumList;
|
|
37
|
+
multilineCount?: number;
|
|
38
|
+
isUnique?: boolean;
|
|
39
|
+
orderNumber: number;
|
|
40
|
+
isHidden?: boolean;
|
|
41
|
+
customUpperCode: string;
|
|
42
|
+
validateRules: Record<string, string>[];
|
|
43
|
+
}
|
|
44
|
+
export interface AttributesFormModel extends AttributesFormItemsProps {
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=attributes-form.d.ts.map
|
package/data/models/index.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GetAttributesFormResponse, ResponseAttributesFormItemsProps } from '../../types';
|
|
2
|
+
import { AttributesFormModel } from '../models';
|
|
3
|
+
|
|
4
|
+
export declare const cloneArrayIfExists: (fields: ResponseAttributesFormItemsProps[]) => any;
|
|
5
|
+
export declare const transformAttributesForm: (response: GetAttributesFormResponse) => AttributesFormModel[];
|
|
6
|
+
//# sourceMappingURL=transform-attributes-form.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OrderDataModel } from '../../data/models';
|
|
2
|
+
import { NormalizeAddressProps, UseCustomerDetails } from '../../types';
|
|
3
|
+
|
|
4
|
+
export declare const useCustomerDetails: ({ orderData }: UseCustomerDetails) => {
|
|
5
|
+
order: OrderDataModel | undefined;
|
|
6
|
+
normalizeAddress: {
|
|
7
|
+
billingAddress: [] | NormalizeAddressProps[];
|
|
8
|
+
shippingAddress: [] | NormalizeAddressProps[];
|
|
9
|
+
};
|
|
10
|
+
loading: boolean;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useCustomerDetails.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FieldEnumList, inLineAlertProps, useOrderSearchProps } from '../../types';
|
|
2
2
|
|
|
3
|
-
export declare const useOrderSearch: ({ onError }: useOrderSearchProps) => {
|
|
3
|
+
export declare const useOrderSearch: ({ onError, isAuth, renderSignIn, routeCustomerOrder, routeGuestOrder, }: useOrderSearchProps) => {
|
|
4
4
|
onSubmit: (event: Event, valid: boolean) => Promise<null | undefined>;
|
|
5
5
|
inLineAlert: inLineAlertProps;
|
|
6
6
|
loading: boolean;
|
package/hooks/index.d.ts
CHANGED
package/i18n/en_US.json.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare const _default: {
|
|
|
17
17
|
"trackButton": "Track package",
|
|
18
18
|
"carrier": "Carrier:",
|
|
19
19
|
"prepositionOf": "of",
|
|
20
|
-
"shippingCardTitle": "Package",
|
|
20
|
+
"shippingCardTitle": "Package details",
|
|
21
21
|
"shippingInfoTitle": "Shipping info",
|
|
22
22
|
"notYetShippedTitle": "Not yet shipped",
|
|
23
23
|
"notYetShippedImagesTitle": "Package contents"
|
|
@@ -62,6 +62,25 @@ declare const _default: {
|
|
|
62
62
|
"message": "The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships."
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
+
"CustomerDetails": {
|
|
66
|
+
"headerText": "Customer information",
|
|
67
|
+
"freeShipping": "Free shipping",
|
|
68
|
+
"email": {
|
|
69
|
+
"title": "Contact details"
|
|
70
|
+
},
|
|
71
|
+
"shippingAddress": {
|
|
72
|
+
"title": "Shipping address"
|
|
73
|
+
},
|
|
74
|
+
"shippingMethods": {
|
|
75
|
+
"title": "Shipping method"
|
|
76
|
+
},
|
|
77
|
+
"billingAddress": {
|
|
78
|
+
"title": "Billing address"
|
|
79
|
+
},
|
|
80
|
+
"billingMethods": {
|
|
81
|
+
"title": "Payment method"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
65
84
|
"Errors": {
|
|
66
85
|
"invalidOrder": "Invalid order. Please try again.",
|
|
67
86
|
"invalidSearch": "No order found with these order details."
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-order", "version": "0.1.0-
|
|
1
|
+
{"name": "@dropins/storefront-order", "version": "0.1.0-alpha7", "@dropins/elsie": "0.30.1-alpha917833"}
|
package/render.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as n}from"@dropins/tools/lib.js";import{useState as
|
|
1
|
+
(function(a,i){try{if(typeof document<"u"){const r=document.createElement("style"),n=i.styleId;for(const t in i.attributes)r.setAttribute(t,i.attributes[t]);r.setAttribute("data-dropin",n),r.appendChild(document.createTextNode(a));const e=document.querySelector('style[data-dropin="sdk"]');if(e)e.after(r);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(r):document.head.append(r)}}}catch(r){console.error("dropin-styles (injectCodeFunction)",r)}})('.dropin-order-search-form{gap:var(--spacing-small);border-color:transparent}.dropin-order-search-form .dropin-card__content{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}.dropin-order-search-form p{color:var(--color-neutral-700);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.dropin-order-search-form__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin:0}.dropin-order-search-form__wrapper{display:grid;grid-template-columns:1fr;grid-template-rows:auto;grid-template-areas:"email" "postcode" "number" "button";gap:var(--spacing-medium)}.dropin-order-search-form__wrapper__item--email{grid-area:email}.dropin-order-search-form__wrapper__item--postcode{grid-area:postcode}.dropin-order-search-form__wrapper__item--number{grid-area:number}.dropin-order-search-form__button-container{display:flex;justify-content:flex-end;grid-area:button}.dropin-order-search-form form button{align-self:flex-end;justify-self:flex-end;margin-top:var(--spacing-small)}@media (min-width: 768px){.dropin-order-search-form__wrapper{grid-template-columns:1fr 1fr;grid-template-rows:auto auto auto;grid-template-areas:"email postcode" "number number" "button button"}}.dropin-order-status-content{margin-bottom:var(--spacing-small)}.dropin-order-status-content.dropin-card--secondary{border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.dropin-order-status-content .dropin-card__content{gap:0}.dropin-order-status-content__wrapper p{padding:0;margin:0;box-sizing:border-box;font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.dropin-order-status-content__wrapper-description{margin-bottom:var(--spacing-medium)}.dropin-shipping-status-card{margin-bottom:var(--spacing-small)}.dropin-shipping-status-card .dropin-card__content{gap:0}.dropin-shipping-status-card.dropin-card--secondary{border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.dropin-shipping-status-card--count-steper{font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing)}.dropin-shipping-status-card__header{display:grid;grid-template-columns:1fr auto;justify-items:self-start;align-items:center;margin-bottom:var(--spacing-xsmall)}.dropin-shipping-status-card__header button{max-height:40px}.dropin-shipping-status-card__header--content p{margin:0;padding:0;margin-bottom:var(--spacing-xsmall)}.dropin-shipping-status-card .dropin-shipping-status-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important;overflow:auto!important}.dropin-shipping-status-card .dropin-shipping-status-card__images img{object-fit:contain}.dropin-order-loaders--card-loader{margin-bottom:var(--spacing-small);border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.dropin-order-actions__wrapper{display:flex;justify-content:space-between;gap:0 var(--spacing-small);margin-bottom:var(--spacing-small);margin-top:var(--spacing-medium)}.dropin-order-actions__wrapper button{width:100%;font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.dropin-order-actions__wrapper--empty{display:none}.dropin-details .dropin-card__content{gap:0}.dropin-customer-details .dropin-card--secondary{border:var(--shape-border-width-1) solid var(--color-neutral-400);border-radius:var(--shape-border-radius-1)}.dropin-details__container{display:grid;flex-direction:column;gap:var(--spacing-medium)}@media (min-width: 768px){.dropin-details__container{display:grid;grid-template-columns:max-content max-content;grid-template-rows:auto auto auto;gap:var(--spacing-medium);grid-auto-flow:row}.dropin-details__container-email{grid-area:1 / 1 / 2 / 2}.dropin-details__container-shipping_address{grid-area:2 / 1 / 3 / 2}.dropin-details__container-billing_address{grid-area:2 / 2 / 3 / 3}.dropin-details__container-shipping_methods{grid-area:3 / 1 / 4 / 2}.dropin-details__container-billing_methods{grid-area:3 / 2 / 4 / 3}}.dropin-details__container-title{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing);margin:0 0 var(--spacing-xsmall) 0}.dropin-details__container p{color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin-top:0}.dropin-details__container-billing_methods p{display:grid;gap:0;grid-template-columns:auto 1fr}.dropin-details__container-billing_methods p.dropin-details__container-billing_methods--icon{gap:0 var(--spacing-xsmall)}.dropin-details__container-description p{margin:0;padding:0;display:inline-flex;overflow:hidden}.dropin-details__container-description p:nth-child(1),.dropin-details__container-description p:nth-child(2){text-align:left;cursor:default;margin-bottom:var(--spacing-xsmall)}.dropin-details__container-description p:nth-child(2){position:relative}.dropin-details__container-description p:nth-child(2) span{position:absolute}.dropin-details__container-description p:nth-child(1),.dropin-details__container-description p:nth-child(7){float:left;width:auto;margin-right:var(--spacing-xsmall)}.dropin-details__container-description p:nth-child(5){position:relative;margin-right:var(--spacing-xsmall)}.dropin-details__container-description p:nth-child(5) span{position:absolute}.dropin-details__container-description p:nth-child(2),.dropin-details__container-description p:nth-child(6),.dropin-details__container-description p:nth-child(8){display:inline;width:50%}.dropin-details__container-description p:nth-child(2):after,.dropin-details__container-description p:nth-child(6):after,.dropin-details__container-description p:nth-child(8):after{content:"\\a";white-space:pre;display:block;height:var(--spacing-xsmall)}.dropin-details__container-description p:nth-child(3),.dropin-details__container-description p:nth-child(4),.dropin-details__container-description p:nth-child(n+9){display:block;width:100%;margin-bottom:var(--spacing-xsmall)}',{styleId:"order"});
|
|
2
|
+
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as n}from"@dropins/tools/lib.js";import{useState as d,useEffect as a}from"@dropins/tools/preact-hooks.js";import{UIProvider as c}from"@dropins/tools/components.js";import{events as l}from"@dropins/tools/event-bus.js";const p={OrderSearchForm:{title:"Enter your information to view order details",description:"You can find your order number in the receipt you received via email.",button:"View Order",email:"Email",postcode:"Zip Code",orderNumber:"Order Number"},Form:{notifications:{requiredFieldError:"This is a required field."}},ShippingStatusCard:{trackButton:"Track package",carrier:"Carrier:",prepositionOf:"of",shippingCardTitle:"Package details",shippingInfoTitle:"Shipping info",notYetShippedTitle:"Not yet shipped",notYetShippedImagesTitle:"Package contents"},OrderStatusContent:{noInfoTitle:"Check back later for more details.",actions:{cancel:"Cancel order",return:"Return or replace",reorder:"Reorder"},orderPending:{title:"Pending",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships."},orderProcessing:{title:"Processing",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships."},orderOnHold:{title:"On hold",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information."},orderReceived:{title:"Order received",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships."},orderComplete:{title:"Complete",message:"Your order is complete. Need help with your order? Contact us at support@adobe.com"},orderCanceled:{title:"Canceled",message:"This order was cancelled by you. You should see a refund to your original payment method with 5-7 business days."},orderSuspectedFraud:{title:"Suspected fraud",message:"We’ve run into an issue while processing your order on {DATE}. Please check back later or contact us at support@adobe.com for more information."},orderPaymentReview:{title:"Payment Review",message:"The order was successfully placed on {DATE} and your order is processing. Check back for more details when your order ships."}},CustomerDetails:{headerText:"Customer information",freeShipping:"Free shipping",email:{title:"Contact details"},shippingAddress:{title:"Shipping address"},shippingMethods:{title:"Shipping method"},billingAddress:{title:"Billing address"},billingMethods:{title:"Payment method"}},Errors:{invalidOrder:"Invalid order. Please try again.",invalidSearch:"No order found with these order details."}},u={Order:p},m={default:u},h=({children:o})=>{const[i,t]=d("en_US");return a(()=>{const e=l.on("locale",s=>{t(s)},{eager:!0});return()=>{e==null||e.off()}},[]),r(c,{lang:i,langDefinitions:m,children:o})},C=new n(r(h,{}));export{C as render};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface ResponseAttributesFormItemsProps {
|
|
2
|
+
code: string;
|
|
3
|
+
sort_order: string;
|
|
4
|
+
default_value: null | string;
|
|
5
|
+
entity_type: string;
|
|
6
|
+
frontend_class: null | string;
|
|
7
|
+
multiline_count: number;
|
|
8
|
+
frontend_input: string;
|
|
9
|
+
is_required: boolean;
|
|
10
|
+
is_unique: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
options: {
|
|
13
|
+
is_default: boolean;
|
|
14
|
+
label: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
export interface GetAttributesFormResponse {
|
|
19
|
+
data: {
|
|
20
|
+
attributesForm: {
|
|
21
|
+
errors?: {
|
|
22
|
+
message: string;
|
|
23
|
+
}[];
|
|
24
|
+
items?: ResponseAttributesFormItemsProps[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
errors?: {
|
|
28
|
+
message: string;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=getAttributesForm.types.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { OrderDataModel } from '../data/models';
|
|
2
|
+
|
|
3
|
+
export interface KeysSortOrderProps {
|
|
4
|
+
name: string;
|
|
5
|
+
orderNumber?: number;
|
|
6
|
+
label?: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface NormalizeAddressProps extends KeysSortOrderProps {
|
|
9
|
+
value: any;
|
|
10
|
+
}
|
|
11
|
+
export interface CustomerDetailsProps {
|
|
12
|
+
className?: string;
|
|
13
|
+
paymentIconsMap?: Record<string, string>;
|
|
14
|
+
orderData?: OrderDataModel;
|
|
15
|
+
withHeader?: boolean;
|
|
16
|
+
title?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface UseCustomerDetails {
|
|
19
|
+
orderData?: OrderDataModel;
|
|
20
|
+
}
|
|
21
|
+
export interface CustomerDetailsContentProps extends Omit<CustomerDetailsProps, 'orderData' | 'className'> {
|
|
22
|
+
loading: boolean;
|
|
23
|
+
order?: OrderDataModel;
|
|
24
|
+
normalizeAddress?: {
|
|
25
|
+
billingAddress: NormalizeAddressProps[];
|
|
26
|
+
shippingAddress: NormalizeAddressProps[];
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface CustomerAddressesModel {
|
|
30
|
+
firstname?: string;
|
|
31
|
+
lastname?: string;
|
|
32
|
+
city?: string;
|
|
33
|
+
company?: string;
|
|
34
|
+
countryCode?: string;
|
|
35
|
+
region?: {
|
|
36
|
+
region: string;
|
|
37
|
+
regionCode: string;
|
|
38
|
+
regionId: string | number;
|
|
39
|
+
};
|
|
40
|
+
telephone?: string;
|
|
41
|
+
id?: string;
|
|
42
|
+
vatId?: string;
|
|
43
|
+
postcode?: string;
|
|
44
|
+
street?: string;
|
|
45
|
+
street_2?: string;
|
|
46
|
+
defaultShipping?: boolean;
|
|
47
|
+
defaultBilling?: boolean;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=customerDetails.types.d.ts.map
|
package/types/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
export * from './api/guestOrderByToken.types';
|
|
2
|
+
export * from './api/getOrderDetails.types';
|
|
3
|
+
export * from './api/getGuestOrder.types';
|
|
4
|
+
export * from './api/getAttributesForm.types';
|
|
5
|
+
export * from './api/getCustomer.types';
|
|
1
6
|
export * from './orderSearch.types';
|
|
2
7
|
export * from './form.types';
|
|
3
8
|
export * from './orderStatus.types';
|
|
4
9
|
export * from './shippingStatus.types';
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './api/getOrderDetails.types';
|
|
7
|
-
export * from './api/getGuestOrder.types';
|
|
10
|
+
export * from './customerDetails.types';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -2,22 +2,27 @@ import { FieldsProps } from '.';
|
|
|
2
2
|
|
|
3
3
|
type errorInformationProps = {
|
|
4
4
|
error: string;
|
|
5
|
-
formValues: {
|
|
6
|
-
email: string;
|
|
7
|
-
postcode: string;
|
|
8
|
-
number: string;
|
|
9
|
-
};
|
|
10
5
|
};
|
|
11
6
|
export interface inLineAlertProps {
|
|
12
7
|
text: string;
|
|
13
8
|
type: 'success' | 'warning' | 'error';
|
|
14
9
|
}
|
|
10
|
+
export type RouteSignInProps = {
|
|
11
|
+
render: boolean;
|
|
12
|
+
formValues?: {
|
|
13
|
+
number: number | string;
|
|
14
|
+
email?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
15
17
|
export interface OrderSearchProps {
|
|
16
18
|
className?: string;
|
|
17
|
-
onError?: (errorInformation: errorInformationProps) =>
|
|
19
|
+
onError?: (errorInformation: errorInformationProps) => void;
|
|
20
|
+
isAuth: boolean;
|
|
21
|
+
renderSignIn?: ({ render, formValues, }: RouteSignInProps) => boolean | undefined;
|
|
22
|
+
routeCustomerOrder?: () => string;
|
|
23
|
+
routeGuestOrder?: () => string;
|
|
18
24
|
}
|
|
19
|
-
export interface useOrderSearchProps {
|
|
20
|
-
onError?: (errorInformation: errorInformationProps) => boolean | Promise<boolean> | undefined;
|
|
25
|
+
export interface useOrderSearchProps extends Omit<OrderSearchProps, 'className'> {
|
|
21
26
|
}
|
|
22
27
|
export interface OrderSearchFormProps {
|
|
23
28
|
onSubmit?: (event: SubmitEvent, isValid: boolean) => Promise<void | null | undefined>;
|
package/chunks/OrderActions.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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};
|
package/chunks/getGuestOrder.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import{events as M}from"@dropins/tools/event-bus.js";import{FetchGraphQL as F}from"@dropins/tools/fetch-graphql.js";const U=`
|
|
2
|
-
fragment OrderSummary on OrderTotal {
|
|
3
|
-
grand_total {
|
|
4
|
-
value
|
|
5
|
-
currency
|
|
6
|
-
}
|
|
7
|
-
subtotal {
|
|
8
|
-
currency
|
|
9
|
-
value
|
|
10
|
-
}
|
|
11
|
-
taxes {
|
|
12
|
-
amount {
|
|
13
|
-
currency
|
|
14
|
-
value
|
|
15
|
-
}
|
|
16
|
-
rate
|
|
17
|
-
title
|
|
18
|
-
}
|
|
19
|
-
total_tax {
|
|
20
|
-
currency
|
|
21
|
-
value
|
|
22
|
-
}
|
|
23
|
-
total_shipping {
|
|
24
|
-
currency
|
|
25
|
-
value
|
|
26
|
-
}
|
|
27
|
-
discounts {
|
|
28
|
-
amount {
|
|
29
|
-
currency
|
|
30
|
-
value
|
|
31
|
-
}
|
|
32
|
-
label
|
|
33
|
-
}
|
|
34
|
-
}`,$=`
|
|
35
|
-
fragment AddressesList on OrderAddress {
|
|
36
|
-
city
|
|
37
|
-
company
|
|
38
|
-
country_code
|
|
39
|
-
fax
|
|
40
|
-
firstname
|
|
41
|
-
lastname
|
|
42
|
-
middlename
|
|
43
|
-
postcode
|
|
44
|
-
prefix
|
|
45
|
-
region
|
|
46
|
-
region_id
|
|
47
|
-
street
|
|
48
|
-
suffix
|
|
49
|
-
telephone
|
|
50
|
-
vat_id
|
|
51
|
-
}`,L=`
|
|
52
|
-
fragment OrderItems on OrderItem {
|
|
53
|
-
__typename
|
|
54
|
-
status
|
|
55
|
-
product_name
|
|
56
|
-
id
|
|
57
|
-
quantity_ordered
|
|
58
|
-
quantity_shipped
|
|
59
|
-
quantity_canceled
|
|
60
|
-
quantity_invoiced
|
|
61
|
-
quantity_refunded
|
|
62
|
-
quantity_returned
|
|
63
|
-
product_sale_price {
|
|
64
|
-
value
|
|
65
|
-
currency
|
|
66
|
-
}
|
|
67
|
-
selected_options {
|
|
68
|
-
label
|
|
69
|
-
value
|
|
70
|
-
}
|
|
71
|
-
product {
|
|
72
|
-
__typename
|
|
73
|
-
canonical_url
|
|
74
|
-
uid
|
|
75
|
-
name
|
|
76
|
-
sku
|
|
77
|
-
thumbnail {
|
|
78
|
-
label
|
|
79
|
-
url
|
|
80
|
-
}
|
|
81
|
-
price_range {
|
|
82
|
-
maximum_price {
|
|
83
|
-
regular_price {
|
|
84
|
-
currency
|
|
85
|
-
value
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}`,j=n=>{const a=n.map(i=>i.message).join(" ");throw Error(a)},B=n=>{throw n instanceof DOMException&&n.name==="AbortError"||M.emit("order/error",{source:"auth",type:"network",error:n.message}),n},H=n=>n.replace(/_([a-z])/g,(a,i)=>i.toUpperCase()),b=(n,a,i)=>{const u=["string","boolean","number"],t=H;return Array.isArray(n)?n.map(c=>u.includes(typeof c)||c===null?c:typeof c=="object"?b(c,a,i):c):n!==null&&typeof n=="object"?Object.entries(n).reduce((c,[l,s])=>{const _=i&&i[l]?i[l]:t(l);return c[_]=u.includes(typeof s)||s===null?s:b(s,a,i),c},{}):n},K=n=>n||0,z=n=>{var a,i,u;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:((i=n==null?void 0:n.thumbnail)==null?void 0:i.label)||"",url:((u=n==null?void 0:n.thumbnail)==null?void 0:u.url)||""}}},P=n=>{if(!n||!("selected_options"in n))return;const a={};for(const i of n.selected_options)a[i.label]=i.value;return a},Y=n=>n==null?void 0:n.map(a=>{var i,u,t,c,l,s,_,e,y,p,g,f,h,O,q,E,G,T,C,R,r,x,A,S,k,N,Q,w,D;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:((c=(t=(u=(i=a==null?void 0:a.product)==null?void 0:i.price_range)==null?void 0:u.maximum_price)==null?void 0:t.regular_price)==null?void 0:c.value)*(a==null?void 0:a.quantity_ordered)!==((l=a==null?void 0:a.product_sale_price)==null?void 0:l.value)*(a==null?void 0:a.quantity_ordered),total:{value:((s=a==null?void 0:a.product_sale_price)==null?void 0:s.value)*(a==null?void 0:a.quantity_ordered),currency:(_=a==null?void 0:a.product_sale_price)==null?void 0:_.currency},totalInclTax:{value:((e=a==null?void 0:a.product_sale_price)==null?void 0:e.value)*(a==null?void 0:a.quantity_ordered),currency:(y=a==null?void 0:a.product_sale_price)==null?void 0:y.currency},price:{value:(p=a==null?void 0:a.product_sale_price)==null?void 0:p.value,currency:(g=a==null?void 0:a.product_sale_price)==null?void 0:g.currency},priceInclTax:{value:(f=a==null?void 0:a.product_sale_price)==null?void 0:f.value,currency:(h=a==null?void 0:a.product_sale_price)==null?void 0:h.currency},totalQuantity:K(a==null?void 0:a.quantity_ordered),regularPrice:{value:(G=(E=(q=(O=a==null?void 0:a.product)==null?void 0:O.price_range)==null?void 0:q.maximum_price)==null?void 0:E.regular_price)==null?void 0:G.value,currency:(r=(R=(C=(T=a==null?void 0:a.product)==null?void 0:T.price_range)==null?void 0:C.maximum_price)==null?void 0:R.regular_price)==null?void 0:r.currency},product:z(a==null?void 0:a.product),thumbnail:{label:((A=(x=a==null?void 0:a.product)==null?void 0:x.thumbnail)==null?void 0:A.label)||"",url:((k=(S=a==null?void 0:a.product)==null?void 0:S.thumbnail)==null?void 0:k.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((N=a.gift_card)==null?void 0:N.sender_name)||"",senderEmail:((Q=a.gift_card)==null?void 0:Q.sender_email)||"",recipientEmail:((w=a.gift_card)==null?void 0:w.recipient_email)||"",recipientName:((D=a.gift_card)==null?void 0:D.recipient_name)||""}:void 0,configurableOptions:P(a)}}),v=n=>{var e,y,p,g,f;const a=Y(n.items),{total:i,...u}=b({...n,items:a},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),t=(e=n==null?void 0:n.payment_methods)==null?void 0:e[0],c=(t==null?void 0:t.type)||"",l=(t==null?void 0:t.name)||"",s=(y=u==null?void 0:u.items)==null?void 0:y.reduce((h,O)=>h+O.totalQuantity,0);return{...i,...u,totalQuantity:s,shipping:{amount:((p=u==null?void 0:u.total)==null?void 0:p.totalShipping.value)??0,currency:((f=(g=u.total)==null?void 0:g.totalShipping)==null?void 0:f.currency)||"",code:u.shippingMethod??""},payments:[{code:c,name:l}]}},d=(n,a)=>{var i,u,t,c,l,s,_;if((c=(t=(u=(i=a==null?void 0:a.data)==null?void 0:i.customer)==null?void 0:u.orders)==null?void 0:t.items)!=null&&c.length&&n==="orderData"){const e=(_=(s=(l=a==null?void 0:a.data)==null?void 0:l.customer)==null?void 0:s.orders)==null?void 0:_.items[0];return v(e)}return null},J=n=>{var i,u;if(!((i=n==null?void 0:n.data)!=null&&i.guestOrder))return null;const a=(u=n==null?void 0:n.data)==null?void 0:u.guestOrder;return v(a)},o=n=>{var i,u;if(!((i=n==null?void 0:n.data)!=null&&i.guestOrderByToken))return null;const a=(u=n==null?void 0:n.data)==null?void 0:u.guestOrderByToken;return v(a)},{setEndpoint:I,setFetchGraphQlHeader:aa,removeFetchGraphQlHeader:na,setFetchGraphQlHeaders:ia,fetchGraphQl:V,getConfig:ua}=new F().getMethods(),W=`
|
|
91
|
-
fragment guestOrderData on CustomerOrder {
|
|
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
|
|
104
|
-
payment_methods {
|
|
105
|
-
name
|
|
106
|
-
type
|
|
107
|
-
}
|
|
108
|
-
applied_coupons {
|
|
109
|
-
code
|
|
110
|
-
}
|
|
111
|
-
shipments {
|
|
112
|
-
id
|
|
113
|
-
tracking {
|
|
114
|
-
title
|
|
115
|
-
number
|
|
116
|
-
carrier
|
|
117
|
-
}
|
|
118
|
-
comments {
|
|
119
|
-
message
|
|
120
|
-
timestamp
|
|
121
|
-
}
|
|
122
|
-
items {
|
|
123
|
-
id
|
|
124
|
-
product_sku
|
|
125
|
-
product_name
|
|
126
|
-
order_item {
|
|
127
|
-
...OrderItems
|
|
128
|
-
... on GiftCardOrderItem {
|
|
129
|
-
gift_card {
|
|
130
|
-
recipient_name
|
|
131
|
-
recipient_email
|
|
132
|
-
sender_name
|
|
133
|
-
sender_email
|
|
134
|
-
message
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
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
|
-
${U}
|
|
168
|
-
${$}
|
|
169
|
-
${L}
|
|
170
|
-
`,X=`
|
|
171
|
-
query GET_GUEST_ORDER($input: OrderInformationInput!) {
|
|
172
|
-
guestOrder(input:$input) {
|
|
173
|
-
...guestOrderData
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
${W}
|
|
177
|
-
`,ca=async n=>await V(X,{method:"GET",cache:"no-cache",variables:{input:n}}).then(a=>{var i;return(i=a.errors)!=null&&i.length?j(a.errors):J(a)}).catch(B);export{$ as A,U as O,L as a,B as b,o as c,aa as d,ia as e,V as f,ua as g,j as h,ca as i,na as r,I as s,d as t};
|