"use strict";(globalThis.webpackChunkstoresuite=globalThis.webpackChunkstoresuite||[]).push([[472],{7252(e,t,r){r.r(t),r.d(t,{default:()=>h});var s=r(6087),a=r(7723),o=r(1455),l=r.n(o),i=r(6773),n=r(112),u=r(5),c=r(638),d=r(9473),b=r(4622),m=r(790);const _=[{label:(0,a.__)("Order","storesuite"),key:"order",isLeftAligned:!0,isSortable:!1,required:!0},{label:(0,a.__)("Customer","storesuite"),key:"customer",isLeftAligned:!1,isSortable:!1},{label:(0,a.__)("Date","storesuite"),key:"date",isLeftAligned:!1,isSortable:!1},{label:(0,a.__)("Total","storesuite"),key:"total",isLeftAligned:!1,isSortable:!1,isNumeric:!0},{label:(0,a.__)("Status","storesuite"),key:"status",isLeftAligned:!1,isSortable:!1}];function h(){const e=!1!==d.Y.canViewOrders,[t,r]=(0,s.useState)([]),[o,h]=(0,s.useState)(e),{render:f}=(0,s.useContext)(n.CurrencyContext);(0,s.useEffect)(()=>{e&&l()({path:"/wc/v3/orders?per_page=5&orderby=date&order=desc"}).then(e=>{r(Array.isArray(e)?e:[]),h(!1)}).catch(()=>{h(!1)})},[e]);const y=(0,s.useMemo)(()=>o?[]:function(e,t){const r=(0,c.Qk)("dateFormat",u.defaultTableDateFormat),s=(0,c.Qk)("orderStatuses",{});return e.map(e=>{const{number:o,date_created:l,status:n,total:u,billing:c}=e,d=c?[c.first_name,c.last_name].filter(Boolean).join(" "):(0,a.__)("Guest","storesuite");return[{display:(0,m.jsxs)("span",{className:"storesuite-recent-orders__number",children:["#",o]}),value:o},{display:d,value:d},{display:(0,m.jsx)(i.Date,{date:l,visibleFormat:r}),value:l},{display:t(u),value:Number(u)},{display:(0,m.jsx)(i.OrderStatus,{className:"storesuite-recent-orders__status",order:{status:n},labelPositionToLeft:!1,orderStatusMap:s}),value:n}]})}(t,f),[t,o,f]);return e?(0,m.jsx)("div",{className:"storesuite-dashboard-recent-orders",children:(0,m.jsx)(b.A,{children:(0,m.jsx)(i.TableCard,{className:"storesuite-recent-orders-table",title:(0,a.__)("Recent Orders","storesuite"),headers:_,rows:y,rowsPerPage:5,totalRows:y.length,isLoading:o,showMenu:!1,onPageChange:()=>{},onQueryChange:()=>()=>{},query:{}})})}):null}},4622(e,t,r){r.d(t,{A:()=>o});var s=r(6087),a=r(790);function o({children:e,className:t=""}){const r=(0,s.useRef)(null);return(0,s.useEffect)(()=>{const e=r.current;if(!e)return;const t=()=>{e.querySelectorAll(".woocommerce-table__table table").forEach(e=>{const t=Array.from(e.querySelectorAll(".woocommerce-table__header")).map(e=>e.textContent.trim());t.length&&e.querySelectorAll("tbody tr").forEach(e=>{e.querySelectorAll(".woocommerce-table__item").forEach((e,r)=>{t[r]&&e.setAttribute("data-label",t[r])})})})};t();const s=new window.MutationObserver(t);return s.observe(e,{childList:!0,subtree:!0}),()=>s.disconnect()},[]),(0,a.jsx)("div",{className:`storesuite-responsive-table ${t}`.trim(),ref:r,children:e})}}}]);