From 3ca2336a2a943b46ee06ab8ce206d797bde4b3a0 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Mon, 23 Sep 2024 14:55:55 +0200 Subject: [PATCH] Update versions --- package-lock.json | 8 ++++---- package.json | 2 +- .../graphql/getOrderHistoryList.graphql.d.ts | 2 +- .../storefront-account/chunks/getOrderHistoryList.js | 5 +++-- .../storefront-account/configs/mockOrdersList.config.d.ts | 1 + .../storefront-account/containers/OrdersList.js | 2 +- .../data/models/order-history-list.d.ts | 1 + .../hooks/containers/useOrderSelectList.d.ts | 1 + .../hooks/containers/useOrdersList.d.ts | 2 +- .../__dropins__/storefront-account/lib/getDateRange.d.ts | 6 +++++- .../types/api/getOrderHistoryList.types.d.ts | 1 + .../storefront-account/types/ordersList.types.d.ts | 1 + 12 files changed, 21 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index dbb23d72eb..7da064487d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@adobe/magento-storefront-event-collector": "^1.8.0", "@adobe/magento-storefront-events-sdk": "^1.8.0", - "@dropins/storefront-account": "0.1.0-alpha8", + "@dropins/storefront-account": "0.1.0-alpha9", "@dropins/storefront-auth": "0.0.1-alpha20", "@dropins/storefront-cart": "0.6.0", "@dropins/storefront-checkout": "0.1.0-alpha49", @@ -768,9 +768,9 @@ } }, "node_modules/@dropins/storefront-account": { - "version": "0.1.0-alpha8", - "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-0.1.0-alpha8.tgz", - "integrity": "sha512-kxooakE0faYeAZcNhwCl8oqQq4ablVAjdfBDXEVO3I53q6alxWFfLe0vvHyLxaCiwqJa9IjEXI59zS6GriC7zw==" + "version": "0.1.0-alpha9", + "resolved": "https://registry.npmjs.org/@dropins/storefront-account/-/storefront-account-0.1.0-alpha9.tgz", + "integrity": "sha512-Gg2CgXwWc/YHiYU72UsKMb9h9nicml3aK0LAa5JHa32Au4GX/hYeYzaFd8lcJTa5XpIBXddQgYDVQ99sloHh1Q==" }, "node_modules/@dropins/storefront-auth": { "version": "0.0.1-alpha20", diff --git a/package.json b/package.json index c9ed18a180..f0bfe2e576 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@dropins/storefront-cart": "0.6.0", "@dropins/storefront-checkout": "0.1.0-alpha49", "@dropins/storefront-auth": "0.0.1-alpha20", - "@dropins/storefront-account": "0.1.0-alpha8", + "@dropins/storefront-account": "0.1.0-alpha9", "@dropins/storefront-order": "0.1.0-alpha6", "@dropins/storefront-order-confirmation": "0.1.0-alpha33", "@dropins/storefront-pdp": "0.4.0-alpha3", diff --git a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/getOrderHistoryList.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/getOrderHistoryList.graphql.d.ts index 3d0cc2c1ba..73fdabd686 100644 --- a/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/getOrderHistoryList.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/getOrderHistoryList/graphql/getOrderHistoryList.graphql.d.ts @@ -1,2 +1,2 @@ -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"; +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"; //# sourceMappingURL=getOrderHistoryList.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js index aba28181fd..60b59a69ba 100644 --- a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js +++ b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js @@ -1,4 +1,4 @@ -import{c as i,f as l,h as u,a as m}from"./convertCase.js";import{t as d}from"./transform-customer-address.js";const _=(e,r="en-US",o={})=>{const t={...{day:"2-digit",month:"2-digit",year:"numeric"},...o},s=new Date(e);return isNaN(s.getTime())?"Invalid Date":new Intl.DateTimeFormat(r,t).format(s)},p=e=>{var t,s;if(!((s=(t=e.data)==null?void 0:t.customer)!=null&&s.orders))return null;const{items:r,page_info:o,total_count:a}=e.data.customer.orders;return{items:r.map(n=>{const c={...n,order_date:_(n.order_date),shipping_address:d(n.shipping_address),billing_address:d(n.billing_address)};return i(c,"camelCase",{})}),pageInfo:i(o,"camelCase",{}),totalCount:i(a,"camelCase",{})}},g=` +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=` query GET_CUSTOMER_ORDERS_LIST($pageSize: Int, $filter: CustomerOrdersFilterInput, $sort: CustomerOrderSortInput) { customer { 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 total_pages current_page } + date_of_first_order total_count items { 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 } } } -`,y=async(e,r)=>{const o=r?{order_date:JSON.parse(r)}:{};return await l(g,{method:"GET",cache:"no-cache",variables:{pageSize:e,filter:o,sort:{sort_direction:"DESC",sort_field:"CREATED_AT"}}}).then(a=>{var t;return(t=a.errors)!=null&&t.length?u(a.errors):p(a)}).catch(m)};export{y as g}; +`,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}; diff --git a/scripts/__dropins__/storefront-account/configs/mockOrdersList.config.d.ts b/scripts/__dropins__/storefront-account/configs/mockOrdersList.config.d.ts index 40328c56ca..c4422eea4d 100644 --- a/scripts/__dropins__/storefront-account/configs/mockOrdersList.config.d.ts +++ b/scripts/__dropins__/storefront-account/configs/mockOrdersList.config.d.ts @@ -7,6 +7,7 @@ export declare const mockOrdersListResponse: { current_page: number; }; total_count: number; + date_of_first_order: string; items: { token: string; email: string; diff --git a/scripts/__dropins__/storefront-account/containers/OrdersList.js b/scripts/__dropins__/storefront-account/containers/OrdersList.js index 1426b1b6ae..539f2c7fe0 100644 --- a/scripts/__dropins__/storefront-account/containers/OrdersList.js +++ b/scripts/__dropins__/storefront-account/containers/OrdersList.js @@ -1 +1 @@ -import{jsx as t,jsxs as f,Fragment as y}from"@dropins/tools/preact-jsx-runtime.js";import{classes as A,Slot as D}from"@dropins/tools/lib.js";import{P as x,C as k}from"../chunks/AddressFormWrapper2.js";import"@dropins/tools/preact-compat.js";import{Card as b,Icon as N,Image as T,Header as M,Picker as H}from"@dropins/tools/components.js";import{S as z,c as Y,E}from"../chunks/checkIsFunction.js";import{useText as L}from"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";import{useState as g,useEffect as P,useMemo as B,useCallback as F}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as $}from"../chunks/getOrderHistoryList.js";import"../chunks/convertCase.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-customer-address.js";const C={size:"32",stroke:"2"},I=({minifiedView:i,orderNumber:r,orderToken:e,routeOrdersList:d,routeOrderDetails:s})=>{const a={minifiedView:{},fullSizeView:{}};return a.minifiedView=L({viewAllOrdersButton:"Account.OrdersList.minifiedView.viewAllOrdersButton"}),d?t("a",{className:A(["dropin-orders-list-action",["dropin-orders-list-action--minifiedView",i]]),"data-testid":"ordersListActionButtonMinifiedView",href:d(),children:t(b,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:f("div",{className:"dropin-orders-list-action__card-wrapper",children:[t("p",{children:a.minifiedView.viewAllOrdersButton}),t(N,{source:z,...C})]})})}):t("a",{href:Y(s)?s(r,e):"#",className:"dropin-orders-list-action","data-testid":"ordersListActionButton",children:t(N,{source:z,...C})})},J=({minifiedView:i,item:r,withThumbnails:e,children:d,slots:s,...a})=>{var l,p,n,o;const c={minifiedView:{},fullSizeView:{}};return c.minifiedView=L({orderNumber:"Account.OrdersList.minifiedView.OrdersListCard.orderNumber",itemsAmount:"Account.OrdersList.minifiedView.OrdersListCard.itemsAmount"}),c.fullSizeView=L({orderNumber:"Account.OrdersList.fullSizeView.OrdersListCard.orderNumber",itemsAmount:"Account.OrdersList.fullSizeView.OrdersListCard.itemsAmount"}),f(b,{...a,className:A(["dropin-orders-list-card",["dropin-orders-list-card--full",((l=r==null?void 0:r.items)==null?void 0:l.length)>6]]),variant:"secondary",children:[t("div",{className:"dropin-orders-list-card--content",children:s!=null&&s.OrdersListCard?t(D,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:s==null?void 0:s.OrdersListCard,context:{orderHistoryListItem:r}}):f(y,{children:[t("div",{children:r==null?void 0:r.status}),t("p",{children:r==null?void 0:r.orderDate}),f("p",{children:[i?c.minifiedView.orderNumber:c.fullSizeView.orderNumber," ",r.number]}),f("p",{children:["$",(p=r==null?void 0:r.total)==null?void 0:p.grandTotal.value]}),f("p",{children:[(n=r==null?void 0:r.items)==null?void 0:n.length," ",i?c.minifiedView.itemsAmount:c.fullSizeView.itemsAmount]})]})}),e&&((o=r==null?void 0:r.items)!=null&&o.length)?t("div",{className:"dropin-orders-list-card--images","data-testid":"ordersListCardImages",children:r.items.map((u,m)=>{var h;const w=(h=u==null?void 0:u.product)==null?void 0:h.smallImage.url,S=u==null?void 0:u.productName;return t(T,{src:w,width:65,height:65,alt:S},u.id+m)})}):null,t("div",{className:"dropin-orders-list-card--actions",children:d})]})},_=({ordersInMinifiedView:i,minifiedView:r,pageSize:e,selectedDate:d})=>{const[s,a]=g([]),[c,l]=g({}),[p,n]=g(!1);return P(()=>{a([]),n(!0),$(r?i:e,d).then(o=>{!o||!o.items||(l(o.pageInfo),a(o.items))}).finally(()=>{n(!1)})},[r,i,e,d]),{loading:p,orderHistoryListItems:s,pageInfo:c}},v=i=>{const r=new Date,e=new Date(r);switch(i){case"sixMonthsAgo":{e.setMonth(e.getMonth()-6);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-1);break}default:return""}return{from:e.toISOString().split("T")[0],to:`${r.toISOString().split("T")[0]} 23:59:59`}},j=()=>{const i=L({pastSixMonths:"Account.OrdersList.fullSizeView.OrdersListSelectDate.pastSixMonths",currentYear:"Account.OrdersList.fullSizeView.OrdersListSelectDate.currentYear",viewAll:"Account.OrdersList.fullSizeView.OrdersListSelectDate.viewAll"}),[r,e]=g(JSON.stringify(v("sixMonthsAgo"))),d=B(()=>[{value:JSON.stringify(v("sixMonthsAgo")),text:i.pastSixMonths},{value:JSON.stringify(v("oneYearAgo")),text:i.currentYear},{value:"",text:i.viewAll}],[i]),s=F(a=>{const l=a.target.value;e(l)},[]);return{selectableDateList:d,selectedDate:r,handleSelectDate:s}},R=({className:i,withHeader:r=!0,minifiedView:e=!1,withThumbnails:d=!0,withFilter:s=!0,ordersInMinifiedView:a=1,pageSize:c=10,routeOrdersList:l,routeOrderDetails:p,slots:n})=>{const o={minifiedView:{},fullSizeView:{}};o.minifiedView=L({containerTitle:"Account.OrdersList.minifiedView.containerTitle"}),o.fullSizeView=L({containerTitle:"Account.OrdersList.fullSizeView.containerTitle"}),o.fullSizeView=L({titleSelectOrder:"Account.OrdersList.fullSizeView.titleSelectOrder"});const{selectableDateList:u,selectedDate:m,handleSelectDate:w}=j(),{loading:S,orderHistoryListItems:h}=_({minifiedView:e,pageSize:c,ordersInMinifiedView:a,selectedDate:m});return f("div",{children:[r?t(M,{title:e?o.minifiedView.containerTitle:o.fullSizeView.containerTitle,divider:!e,className:e?"dropin-orders-list-header":""}):null,f("div",{className:A(["dropin-orders-list",i]),children:[!e&&s?t("div",{className:"dropin-orders-list--date-select",children:S?t(x,{"data-testid":"selectPickerLoader"}):f(y,{children:[t("span",{children:o.fullSizeView.titleSelectOrder}),t(H,{value:m,name:"orderDatePicker",options:u,handleSelect:w})]})}):null,S?t(k,{testId:"orderSkeletonLoader",withCard:!1}):t(E,{isEmpty:!h.length,typeList:"orders",minifiedView:e}),h.map((O,V)=>t(J,{minifiedView:e,item:O,withThumbnails:d,slots:n,children:n!=null&&n.OrdersListAction?t(D,{"data-testid":`ordersListActionSlot_${V}`,name:"OrdersListAction",slot:n==null?void 0:n.OrdersListAction,context:{orderHistoryListItem:O}}):t(I,{minifiedView:e,orderNumber:O.number,orderToken:O.token,routeOrderDetails:p})},V)),e?t(I,{minifiedView:e,routeOrdersList:l}):null]})]})},dr=({className:i,withHeader:r,minifiedView:e,withThumbnails:d,withFilter:s,ordersInMinifiedView:a,pageSize:c,routeOrdersList:l,routeOrderDetails:p,slots:n})=>t("div",{className:A(["dropin-orders-list",i]),"data-testid":"ordersListId",children:t(R,{className:i,withHeader:r,minifiedView:e,withThumbnails:d,withFilter:s,ordersInMinifiedView:a,pageSize:c,routeOrdersList:l,routeOrderDetails:p,slots:n})});export{dr as OrdersList,dr as default}; +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}; diff --git a/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts b/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts index 685cf4b0d3..b26adf69d7 100644 --- a/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/order-history-list.d.ts @@ -59,5 +59,6 @@ export interface OrderHistory { items: OrderDetails[]; pageInfo: PaginationInfo; totalCount: number; + dateOfFirstOrder: string; } //# sourceMappingURL=order-history-list.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/containers/useOrderSelectList.d.ts b/scripts/__dropins__/storefront-account/hooks/containers/useOrderSelectList.d.ts index a250c97aa3..cb6c7978ae 100644 --- a/scripts/__dropins__/storefront-account/hooks/containers/useOrderSelectList.d.ts +++ b/scripts/__dropins__/storefront-account/hooks/containers/useOrderSelectList.d.ts @@ -5,5 +5,6 @@ export declare const useOrderSelectList: () => { }[]; selectedDate: string; handleSelectDate: (event: Event) => void; + handleSetFirstOrderDate: (date: string) => void; }; //# sourceMappingURL=useOrderSelectList.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts b/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts index ef97242aad..b1a55d09a4 100644 --- a/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts +++ b/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts @@ -1,7 +1,7 @@ import { OrderDetails } from '../../data/models'; import { useOrdersListProps } from '../../types'; -export declare const useOrdersList: ({ ordersInMinifiedView, minifiedView, pageSize, selectedDate, }: useOrdersListProps) => { +export declare const useOrdersList: ({ ordersInMinifiedView, minifiedView, pageSize, selectedDate, handleSetFirstOrderDate, }: useOrdersListProps) => { loading: boolean; orderHistoryListItems: OrderDetails[]; pageInfo: {}; diff --git a/scripts/__dropins__/storefront-account/lib/getDateRange.d.ts b/scripts/__dropins__/storefront-account/lib/getDateRange.d.ts index d2c15e1fd2..8d9ced633b 100644 --- a/scripts/__dropins__/storefront-account/lib/getDateRange.d.ts +++ b/scripts/__dropins__/storefront-account/lib/getDateRange.d.ts @@ -2,5 +2,9 @@ export interface FilterDateProps { from: string; to: string; } -export declare const getDateRange: (key: 'sixMonthsAgo' | 'oneYearAgo' | '') => FilterDateProps | ''; +export declare const getDateRange: (key: 'sixMonthsAgo' | 'oneYearAgo' | '', numberRange?: number) => FilterDateProps | ''; +export declare const addYearsToList: (startYear: number) => { + value: string; + text: string; +}[]; //# sourceMappingURL=getDateRange.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts b/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts index 976e064954..21107652c1 100644 --- a/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getOrderHistoryList.types.d.ts @@ -59,6 +59,7 @@ export interface OrdersProps { page_info: PageInfoProps; total_count: number; items: OrderProps[]; + date_of_first_order: string; } export interface OrderHistoryListResponse { data: { diff --git a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts index aba8cae2ad..1f62471419 100644 --- a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts @@ -44,5 +44,6 @@ export interface useOrdersListProps { pageSize: number; ordersInMinifiedView: number; selectedDate: string; + handleSetFirstOrderDate: (date: string) => void; } //# sourceMappingURL=ordersList.types.d.ts.map \ No newline at end of file