@dropins/storefront-account 0.1.0-alpha8 → 0.1.0-alpha9
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/getOrderHistoryList/graphql/getOrderHistoryList.graphql.d.ts +1 -1
- package/chunks/getOrderHistoryList.js +3 -2
- package/configs/mockOrdersList.config.d.ts +1 -0
- package/containers/OrdersList.js +1 -1
- package/data/models/order-history-list.d.ts +1 -0
- package/hooks/containers/useOrderSelectList.d.ts +1 -0
- package/hooks/containers/useOrdersList.d.ts +1 -1
- package/lib/getDateRange.d.ts +5 -1
- package/package.json +1 -1
- package/types/api/getOrderHistoryList.types.d.ts +1 -0
- package/types/ordersList.types.d.ts +1 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const GET_CUSTOMER_ORDERS_LIST = "\n query GET_CUSTOMER_ORDERS_LIST($pageSize: Int, $filter: CustomerOrdersFilterInput, $sort: CustomerOrderSortInput) {\n customer {\n orders(pageSize: $pageSize, filter: $filter, sort: $sort) {\n page_info {\n page_size\n total_pages\n current_page\n }\n total_count\n items {\n token\n email\n shipping_method\n shipping_address {\n firstname\n lastname\n postcode\n street\n region\n city\n country_code\n region_id\n }\n billing_address {\n firstname\n lastname\n postcode\n street\n region\n city\n country_code\n region_id\n }\n payment_methods {\n name\n }\n number\n id\n order_date\n carrier\n status\n items {\n status\n product_name\n id\n product {\n small_image {\n url\n }\n }\n }\n total {\n grand_total {\n value\n currency\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n }\n }\n }\n}\n";
|
|
1
|
+
export declare const GET_CUSTOMER_ORDERS_LIST = "\n query GET_CUSTOMER_ORDERS_LIST($pageSize: Int, $filter: CustomerOrdersFilterInput, $sort: CustomerOrderSortInput) {\n customer {\n orders(pageSize: $pageSize, filter: $filter, sort: $sort) {\n page_info {\n page_size\n total_pages\n current_page\n }\n date_of_first_order\n total_count\n items {\n token\n email\n shipping_method\n shipping_address {\n firstname\n lastname\n postcode\n street\n region\n city\n country_code\n region_id\n }\n billing_address {\n firstname\n lastname\n postcode\n street\n region\n city\n country_code\n region_id\n }\n payment_methods {\n name\n }\n number\n id\n order_date\n carrier\n status\n items {\n status\n product_name\n id\n product {\n small_image {\n url\n }\n }\n }\n total {\n grand_total {\n value\n currency\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n title\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n }\n }\n }\n}\n";
|
|
2
2
|
//# sourceMappingURL=getOrderHistoryList.graphql.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as i,f as
|
|
1
|
+
import{c as i,f as u,h as m,a as _}from"./convertCase.js";import{t as c}from"./transform-customer-address.js";const f=(t,e="en-US",o={})=>{const a={...{day:"2-digit",month:"2-digit",year:"numeric"},...o},s=new Date(t);return isNaN(s.getTime())?"Invalid Date":new Intl.DateTimeFormat(e,a).format(s)},p=t=>{var s,d;if(!((d=(s=t.data)==null?void 0:s.customer)!=null&&d.orders))return null;const{items:e,page_info:o,total_count:r,date_of_first_order:a}=t.data.customer.orders;return{items:e.map(n=>{const l={...n,order_date:f(n.order_date),shipping_address:c(n.shipping_address),billing_address:c(n.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(o,"camelCase",{}),totalCount:i(r,"camelCase",{}),dateOfFirstOrder:i(a,"camelCase",{})}},g=`
|
|
2
2
|
query GET_CUSTOMER_ORDERS_LIST($pageSize: Int, $filter: CustomerOrdersFilterInput, $sort: CustomerOrderSortInput) {
|
|
3
3
|
customer {
|
|
4
4
|
orders(pageSize: $pageSize, filter: $filter, sort: $sort) {
|
|
@@ -7,6 +7,7 @@ import{c as i,f as l,h as u,a as m}from"./convertCase.js";import{t as d}from"./t
|
|
|
7
7
|
total_pages
|
|
8
8
|
current_page
|
|
9
9
|
}
|
|
10
|
+
date_of_first_order
|
|
10
11
|
total_count
|
|
11
12
|
items {
|
|
12
13
|
token
|
|
@@ -87,4 +88,4 @@ import{c as i,f as l,h as u,a as m}from"./convertCase.js";import{t as d}from"./t
|
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
`,
|
|
91
|
+
`,O=async(t,e)=>{const o=e?{order_date:JSON.parse(e)}:{};return await u(g,{method:"GET",cache:"no-cache",variables:{pageSize:t,filter:o,sort:{sort_direction:"DESC",sort_field:"CREATED_AT"}}}).then(r=>{var a;return(a=r.errors)!=null&&a.length?m(r.errors):p(r)}).catch(_)};export{O as g};
|
package/containers/OrdersList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i,jsxs as L,Fragment as x}from"@dropins/tools/preact-jsx-runtime.js";import{classes as g,Slot as b}from"@dropins/tools/lib.js";import{P as T,C as Y}from"../chunks/AddressFormWrapper2.js";import"@dropins/tools/preact-compat.js";import{Card as k,Icon as y,Image as M,Header as F,Picker as H}from"@dropins/tools/components.js";import{S as C,c as E,E as P}from"../chunks/checkIsFunction.js";import{useText as h}from"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";import{useState as O,useEffect as $,useMemo as B,useCallback as z}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as J}from"../chunks/getOrderHistoryList.js";import"../chunks/convertCase.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-customer-address.js";const D={size:"32",stroke:"2"},I=({minifiedView:s,orderNumber:r,orderToken:e,routeOrdersList:t,routeOrderDetails:n})=>{const u={minifiedView:{},fullSizeView:{}};return u.minifiedView=h({viewAllOrdersButton:"Account.OrdersList.minifiedView.viewAllOrdersButton"}),t?i("a",{className:g(["dropin-orders-list-action",["dropin-orders-list-action--minifiedView",s]]),"data-testid":"ordersListActionButtonMinifiedView",href:t(),children:i(k,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:L("div",{className:"dropin-orders-list-action__card-wrapper",children:[i("p",{children:u.minifiedView.viewAllOrdersButton}),i(y,{source:C,...D})]})})}):i("a",{href:E(n)?n(r,e):"#",className:"dropin-orders-list-action","data-testid":"ordersListActionButton",children:i(y,{source:C,...D})})},_=({minifiedView:s,item:r,withThumbnails:e,children:t,slots:n,...u})=>{var f,d,o,c;const a={minifiedView:{},fullSizeView:{}};return a.minifiedView=h({orderNumber:"Account.OrdersList.minifiedView.OrdersListCard.orderNumber",itemsAmount:"Account.OrdersList.minifiedView.OrdersListCard.itemsAmount"}),a.fullSizeView=h({orderNumber:"Account.OrdersList.fullSizeView.OrdersListCard.orderNumber",itemsAmount:"Account.OrdersList.fullSizeView.OrdersListCard.itemsAmount"}),L(k,{...u,className:g(["dropin-orders-list-card",["dropin-orders-list-card--full",((f=r==null?void 0:r.items)==null?void 0:f.length)>6]]),variant:"secondary",children:[i("div",{className:"dropin-orders-list-card--content",children:n!=null&&n.OrdersListCard?i(b,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):L(x,{children:[i("div",{children:r==null?void 0:r.status}),i("p",{children:r==null?void 0:r.orderDate}),L("p",{children:[s?a.minifiedView.orderNumber:a.fullSizeView.orderNumber," ",r.number]}),L("p",{children:["$",(d=r==null?void 0:r.total)==null?void 0:d.grandTotal.value]}),L("p",{children:[(o=r==null?void 0:r.items)==null?void 0:o.length," ",s?a.minifiedView.itemsAmount:a.fullSizeView.itemsAmount]})]})}),e&&((c=r==null?void 0:r.items)!=null&&c.length)?i("div",{className:"dropin-orders-list-card--images","data-testid":"ordersListCardImages",children:r.items.map((l,m)=>{var p;const A=(p=l==null?void 0:l.product)==null?void 0:p.smallImage.url,w=l==null?void 0:l.productName;return i(M,{src:A,width:65,height:65,alt:w},l.id+m)})}):null,i("div",{className:"dropin-orders-list-card--actions",children:t})]})},j=({ordersInMinifiedView:s,minifiedView:r,pageSize:e,selectedDate:t,handleSetFirstOrderDate:n})=>{const[u,a]=O([]),[f,d]=O({}),[o,c]=O(!1);return $(()=>{a([]),c(!0),J(r?s:e,t).then(l=>{!l||!l.items||(d(l.pageInfo),a(l.items),n(l.dateOfFirstOrder))}).finally(()=>{c(!1)})},[n,r,s,e,t]),{loading:o,orderHistoryListItems:u,pageInfo:f}},v=(s,r=1)=>{const e=new Date,t=new Date(e);switch(s){case"sixMonthsAgo":{t.setMonth(t.getMonth()-r);break}case"oneYearAgo":{t.setFullYear(t.getFullYear()-r);break}default:return""}return{from:t==null?void 0:t.toISOString().split("T")[0],to:`${e==null?void 0:e.toISOString().split("T")[0]} 23:59:59`}},R=s=>{const r=[],e=new Date().getFullYear();for(let t=s;t<=e-1;t++)r.push({value:`{"from":"${t}-01-01","to":"${t+1}-01-01 23:59:59"}`,text:t.toString()});return r},W=()=>{const s=h({pastSixMonths:"Account.OrdersList.fullSizeView.OrdersListSelectDate.pastSixMonths",currentYear:"Account.OrdersList.fullSizeView.OrdersListSelectDate.currentYear",viewAll:"Account.OrdersList.fullSizeView.OrdersListSelectDate.viewAll"}),[r,e]=O(),[t,n]=O(JSON.stringify(v("sixMonthsAgo",6))),u=B(()=>{const d=[{value:JSON.stringify(v("sixMonthsAgo",6)),text:s.pastSixMonths},{value:JSON.stringify(v("oneYearAgo",1)),text:s.currentYear},{value:"",text:s.viewAll}];if(r){const c=new Date(r).getFullYear();d==null||d.splice(2,0,...R(c))}return d},[s,r]),a=z(d=>{e(d)},[]),f=z(d=>{const c=d.target.value;n(c)},[]);return{selectableDateList:u,selectedDate:t,handleSelectDate:f,handleSetFirstOrderDate:a}},q=({className:s,withHeader:r=!0,minifiedView:e=!1,withThumbnails:t=!0,withFilter:n=!0,ordersInMinifiedView:u=1,pageSize:a=10,routeOrdersList:f,routeOrderDetails:d,slots:o})=>{const c={minifiedView:{},fullSizeView:{}};c.minifiedView=h({containerTitle:"Account.OrdersList.minifiedView.containerTitle"}),c.fullSizeView=h({containerTitle:"Account.OrdersList.fullSizeView.containerTitle",titleSelectOrder:"Account.OrdersList.fullSizeView.titleSelectOrder"});const{selectableDateList:l,selectedDate:m,handleSelectDate:A,handleSetFirstOrderDate:w}=W(),{loading:p,orderHistoryListItems:N}=j({minifiedView:e,pageSize:a,ordersInMinifiedView:u,selectedDate:m,handleSetFirstOrderDate:w});return L("div",{children:[r?i(F,{title:e?c.minifiedView.containerTitle:c.fullSizeView.containerTitle,divider:!e,className:e?"dropin-orders-list-header":""}):null,L("div",{className:g(["dropin-orders-list",s]),children:[!e&&n?i("div",{className:"dropin-orders-list--date-select",children:p?i(T,{"data-testid":"selectPickerLoader"}):L(x,{children:[i("span",{children:c.fullSizeView.titleSelectOrder}),i(H,{value:m,name:"orderDatePicker",options:l,handleSelect:A})]})}):null,p?i(Y,{testId:"orderSkeletonLoader",withCard:!1}):i(P,{isEmpty:!N.length,typeList:"orders",minifiedView:e}),N.map((S,V)=>i(_,{minifiedView:e,item:S,withThumbnails:t,slots:o,children:o!=null&&o.OrdersListAction?i(b,{"data-testid":`ordersListActionSlot_${V}`,name:"OrdersListAction",slot:o==null?void 0:o.OrdersListAction,context:{orderHistoryListItem:S}}):i(I,{minifiedView:e,orderNumber:S.number,orderToken:S.token,routeOrderDetails:d})},V)),e?i(I,{minifiedView:e,routeOrdersList:f}):null]})]})},ar=({className:s,withHeader:r,minifiedView:e,withThumbnails:t,withFilter:n,ordersInMinifiedView:u,pageSize:a,routeOrdersList:f,routeOrderDetails:d,slots:o})=>i("div",{className:g(["dropin-orders-list",s]),"data-testid":"ordersListId",children:i(q,{className:s,withHeader:r,minifiedView:e,withThumbnails:t,withFilter:n,ordersInMinifiedView:u,pageSize:a,routeOrdersList:f,routeOrderDetails:d,slots:o})});export{ar as OrdersList,ar as default};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OrderDetails } from '../../data/models';
|
|
2
2
|
import { useOrdersListProps } from '../../types';
|
|
3
3
|
|
|
4
|
-
export declare const useOrdersList: ({ ordersInMinifiedView, minifiedView, pageSize, selectedDate, }: useOrdersListProps) => {
|
|
4
|
+
export declare const useOrdersList: ({ ordersInMinifiedView, minifiedView, pageSize, selectedDate, handleSetFirstOrderDate, }: useOrdersListProps) => {
|
|
5
5
|
loading: boolean;
|
|
6
6
|
orderHistoryListItems: OrderDetails[];
|
|
7
7
|
pageInfo: {};
|
package/lib/getDateRange.d.ts
CHANGED
|
@@ -2,5 +2,9 @@ export interface FilterDateProps {
|
|
|
2
2
|
from: string;
|
|
3
3
|
to: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const getDateRange: (key: 'sixMonthsAgo' | 'oneYearAgo' | '') => FilterDateProps | '';
|
|
5
|
+
export declare const getDateRange: (key: 'sixMonthsAgo' | 'oneYearAgo' | '', numberRange?: number) => FilterDateProps | '';
|
|
6
|
+
export declare const addYearsToList: (startYear: number) => {
|
|
7
|
+
value: string;
|
|
8
|
+
text: string;
|
|
9
|
+
}[];
|
|
6
10
|
//# sourceMappingURL=getDateRange.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-account", "version": "0.1.0-
|
|
1
|
+
{"name": "@dropins/storefront-account", "version": "0.1.0-alpha9", "@dropins/elsie": "0.31.0"}
|