import{u as x,ci as h,a as v,b$ as p,f,ah as j,d as y,g,b as $,j as e,C,S as b,bW as N,D as k,m as _,i as t,I as w,h as B,O as F,a4 as S,c9 as T,r as D,e as q}from"./bundle.CHKSNOJF.js";import{H as z}from"./History-n6M92Y0g.js";import{C as H}from"./chevron-right-CHJ6fP-X.js";const I=S.div`
  display: flex;
  background-color: ${i=>i.theme.backgroundColor};

  &:hover {
    background-color: ${i=>i.theme.hoverBackgroundColor};
  }
`;t.extend(T);function M(){const[i]=x(),{id:o}=h(),a=v(),{timeFormat:n}=p(),{dateFormat:l}=f(),d=j(),c=y(),m=g(),{data:r,isLoading:u}=$({queryKey:["/api/v1/purchase_orders",o,"history"],queryFn:()=>D("GET",q(`/api/v1/purchase_orders/${o}?include=vendor,activities.history&reminder_schedule=true`)).then(s=>s.data.data),enabled:!!o,staleTime:1/0});return e.jsx(C,{title:i("history"),className:"shadow-sm",style:{borderColor:a.$24},headerStyle:{borderColor:a.$20},withoutBodyPadding:!0,children:e.jsxs("div",{className:F("w-full px-2 pt-2",{"pb-10":r?.activities?.length,"pb-6":r?.activities&&r?.activities.filter(({history:s})=>s?.id).length===0}),children:[u&&e.jsx("div",{className:"flex justify-center",children:e.jsx(b,{})}),e.jsxs("div",{children:[r?.activities&&r.activities.filter(({history:s})=>s?.id).length===0&&e.jsx("div",{className:"px-3 pt-3 text-sm",children:i("api_404")}),!!r?.activities?.length&&e.jsx("div",{className:"flex flex-col w-full gap-3",children:r?.activities&&r.activities.filter(({history:s})=>s?.id).map(s=>e.jsxs(I,{className:"flex items-center justify-between p-4 rounded-md cursor-pointer",onClick:()=>d(B("/activities/:id",{id:s.id})),theme:{backgroundColor:a.$4,hoverBackgroundColor:a.$15},children:[e.jsxs("div",{className:"flex items-center justify-start space-x-3",children:[e.jsx("div",{className:"p-2 rounded-full",style:{backgroundColor:a.$20},children:e.jsx(z,{size:"1.3rem",color:a.$16,filledColor:a.$16})}),e.jsxs("div",{className:"flex flex-col items-start space-y-0.5 justify-center",children:[e.jsxs("div",{className:"flex space-x-1 text-sm",children:[e.jsx("span",{style:{color:a.$3},children:r?.vendor?c(s.history.amount,r?.vendor?.country_id,r?.vendor?.currency_id):null}),e.jsx("div",{children:e.jsx(N,{color:a.$17,size:"1.1rem"})}),e.jsx(k,{to:`/vendors/${s.vendor_id}`,renderSpan:m("vendor",r?.vendor),children:r?.vendor?.name})]}),e.jsxs("div",{className:"flex items-center space-x-1 text-xs",style:{color:a.$17},children:[e.jsx("span",{children:_(s.created_at,`${l} ${n}`)}),e.jsx("span",{children:t.unix(s.created_at).fromNow()})]})]})]}),e.jsx("div",{children:e.jsx(w,{element:H,size:16,color:a.$17})})]},s.id))})]})]})})}export{M as default};
