1import{b0 as k,b7 as $,b5 as i,b6 as u,b8 as e,b9 as s,bd as t,bh as U,bJ as T,bm as C,bs as w,bf as O,bg as z,ba as g,bb as R,bc as F,bu as M,bK as L,bk as I,bw as N,bn as A,bo as V,bz as q,br as j,bN as G,be as H,bt as P}from"#entry";import{_ as D}from"./DUOOQeVw.js";import{_ as J}from"./C21SHZqJ.js";import{_ as B}from"./0iZWz1KM.js";import{u as K}from"./4UzTv0L3.js";import{u as Q}from"./BnlMBgfD.js";import{a as W}from"./C_5tmQj7.js";import"./Bro7qKL0.js";const X={class:"flex flex-col gap-3 sm:flex-row"},Y={class:"flex flex-1 flex-col gap-1 rounded-xl border border-slate-100 bg-white p-[18px]"},Z={class:"text-sm leading-5 text-neutral-600"},ee={class:"text-2xl leading-8 font-semibold text-success-100"},te={class:"text-xs leading-4 text-neutral-500"},se={class:"flex flex-1 flex-col gap-1 rounded-xl border border-slate-100 bg-white p-[18px]"},ne={class:"text-sm leading-5 text-neutral-600"},ae={class:"text-2xl leading-8 font-semibold text-neutral-900"},oe={class:"text-xs leading-4 text-neutral-500"},le={class:"flex flex-1 flex-col gap-1 rounded-xl border border-slate-100 bg-white p-[18px]"},re={class:"text-sm leading-5 text-neutral-600"},ie={class:"text-2xl leading-8 font-semibold text-neutral-900"},ce={class:"text-xs leading-4 text-neutral-500"},de=k({__name:"MyInvoicesSummary",props:{summary:{type:Object,required:!0}},setup(a){const{t:n}=$();return(p,_)=>(i(),u("div",X,[e("div",Y,[e("p",Z,s(t(n)("my_invoices.summary.current_balance")),1),e("p",ee,s(a.summary.current_balance),1),e("p",te,s(a.summary.current_balance_label),1)]),e("div",se,[e("p",ne,s(t(n)("my_invoices.summary.next_invoice")),1),e("p",ae,s(a.summary.next_invoice_amount),1),e("p",oe,s(t(n)("my_invoices.summary.due_date",{date:a.summary.next_invoice_due})),1)]),e("div",le,[e("p",re,s(t(n)("my_invoices.summary.this_month")),1),e("p",ie,s(a.summary.this_month_amount),1),e("p",ce,s(t(n)("my_invoices.summary.paid_on",{date:a.summary.this_month_paid})),1)])]))}}),ue=Object.assign(de,{__name:"MyInvoicesSummary"}),me={class:"border-b border-neutral-200 px-6 pt-6 pb-3"},pe={class:"text-base leading-6 font-medium text-neutral-900"},_e={class:"text-base leading-6 text-neutral-600"},be={class:"overflow-x-auto"},ge={class:"min-w-[640px]"},xe={class:"whitespace-nowrap"},fe={class:"whitespace-nowrap"},ye={class:"sr-only"},he={class:"text-sm leading-5 whitespace-nowrap text-neutral-900"},ve={class:"text-sm leading-5 text-neutral-900"},we={class:"text-sm leading-5 font-medium whitespace-nowrap text-neutral-900"},$e=["disabled","aria-label","onClick"],ke={key:1,"aria-hidden":"true"},Ie={key:0,class:"border-t border-neutral-200 px-6 py-4"},Ce={key:1,class:"h-8","aria-hidden":"true"},Me=20,E="grid-cols-[max-content_max-content_minmax(0,1fr)_max-content_max-content_max-content]",je=k({__name:"MyInvoicesTable",props:L({invoices:{type:Array,required:!0},pagination:{type:Object,default:null}},{page:{default:1},pageModifiers:{}}),emits:["update:page"],setup(a){const{t:n}=$(),p=U(),_=T(a,"page"),d=I(null);C(_,()=>{N(()=>d.value?.scrollIntoView({behavior:"smooth",block:"start"}))});const h={paid:"success",unpaid:"error",pending:"warning"},b=c=>n(`my_invoices.status.${c}`),m=I(new Set),v=async c=>{if(!m.value.has(c)){m.value=new Set(m.value).add(c);try{const l=await $fetch(`/api/crm/invoices/download/${c}`,{responseType:"blob"}),f=URL.createObjectURL(l),x=document.createElement("a");x.href=f,x.download=`invoice-${c}.pdf`,document.body.appendChild(x),x.click(),document.body.removeChild(x),URL.revokeObjectURL(f)}catch{p.add({title:n("my_invoices.download_error"),color:"error"})}finally{const l=new Set(m.value);l.delete(c),m.value=l}}};return(c,l)=>{const f=D,x=J,o=M,y=B;return i(),u("div",{ref_key:"rootEl",ref:d,class:"scroll-mt-20 rounded-xl border border-neutral-200 bg-white"},[e("div",me,[e("p",pe,s(t(n)("my_invoices.recent.title")),1),e("p",_e,s(t(n)("my_invoices.recent.subtitle")),1)]),e("div",be,[e("div",ge,[e("div",{class:w([E,"grid items-center gap-4 border-b border-neutral-200 px-6 py-2 text-sm leading-5 font-medium text-neutral-900"])},[e("span",xe,s(t(n)("my_invoices.table.number")),1),e("span",fe,s(t(n)("my_invoices.table.date")),1),e("span",null,s(t(n)("my_invoices.table.description")),1),e("span",null,s(t(n)("my_invoices.table.amount")),1),e("span",null,s(t(n)("my_invoices.table.status")),1),e("span",ye,s(t(n)("my_invoices.table.actions")),1)]),(i(!0),u(O,null,z(a.invoices,r=>(i(),u("div",{key:r.id,class:w([E,"relative grid items-center gap-4 border-b border-neutral-200 px-6 py-3 transition-colors last:border-b-0 hover:bg-slate-50"])},[g(f,{to:{name:"profile-racun-id",params:{id:r.id}},class:"text-sm leading-5 font-semibold whitespace-nowrap text-neutral-900 after:absolute after:inset-0 hover:text-primary"},{default:R(()=>[F(s(r.number),1)]),_:2}
1,1032,["to"]),e("span",he,s(r.date),1),e("span",ve,s(r.description),1),e("span",we,s(r.amount),1),g(x,{color:h[r.status],variant:"soft",size:"sm",class:"rounded-full",label:b(r.status)},null,8,["color","label"]),r.downloadable?(i(),u("button",{key:0,type:"button",disabled:t(m).has(r.id),class:"relative z-10 justify-self-start text-neutral-600 hover:text-neutral-900 disabled:cursor-not-allowed disabled:opacity-50","aria-label":t(n)("my_invoices.table.download_aria"),onClick:at=>v(r.id)},[g(o,{name:t(m).has(r.id)?"i-lucide-loader-circle":"i-lucide-download",class:w(["size-6",{"animate-spin":t(m).has(r.id)}]),"aria-hidden":"true"},null,8,["name","class"])],8,$e)):(i(),u("span",ke))]))),128))])]),a.pagination&&a.pagination.pageCount>1?(i(),u("div",Ie,[g(y,{page:_.value,"onUpdate:page":l[0]||(l[0]=r=>_.value=r),total:a.pagination.totalCount,"items-per-page":Me,"sibling-count":1,"show-edges":"",color:"neutral",variant:"ghost",size:"md",class:"flex justify-center",ui:{first:"rounded-full border border-neutral-300",prev:"rounded-full border border-neutral-300",next:"rounded-full border border-neutral-300",last:"rounded-full border border-neutral-300"}},null,8,["page","total"])])):(i(),u("div",Ce))],512)}}}),Pe=Object.assign(je,{__name:"MyInvoicesTable"}),Ee={class:"flex w-full flex-col items-center justify-center gap-4 roun
1ded-2xl border border-neutral-100 bg-white p-10"},Se={class:"flex w-full flex-col items-center gap-1 text-center"},Ue={class:"text-2xl font-semibold text-neutral-900"},Te={class:"text-[15px] leading-5 text-neutral-600"},Oe=k({__name:"MyInvoicesEmptyState",setup(a){const{t:n}=$();return(p,_)=>{const d=M;return i(),u("div",Ee,[g(d,{name:"i-lucide-receipt-text",size:"24",class:"text-neutral-900"}),e("div",Se,[e("p",Ue,s(t(n)("my_invoices.empty_state.title")),1),e("p",Te,s(t(n)("my_invoices.empty_state.description")),1)])])}}}),ze=Object.assign(Oe,{__name:"MyInvoicesEmptyState"}),Re={class:"text-xl font-semibold text-neutral-900"},Le={key:0,class:"mt-6 overflow-hidden rounded-lg border border-neutral-100 shadow-md"},Ne={class:"flex items-center justify-between lg:block"},Ae={class:"text-sm font-medium text-neutral-900 lg:font-normal"},De={class:"flex items-center justify-between gap-2 lg:contents"},Be={class:"text-sm text-neutral-600 lg:text-neutral-900"},Fe={class:"text-sm font-medium text-neutral-900"},Ve={class:"line-clamp-2 text-xs text-neutral-600"},qe={key:1,class:"mt-6 rounded-lg border border-neutral-100 px-6 py-8 text-center text-sm text-neutral-600 shadow-md"},Ge={key:2,class:"mt-4"},He=20,S="lg:grid-cols-[143px_241px_175px_124px_minmax(0,1fr)_16px]",Je=k({__name:"MyOrdersTable",props:L({orders:{type:Array,required:!0},pagination:{type:Object,default:null}},{page:{default:1},pageModifiers:{}}),emits:["update:page"],setup(a){const{t:n}=$(),p=T(a,"page"),_=I(null);C(p,()=>{N(()=>_.value?.scrollIntoView({behavior:"smooth",block:"start"}))});const d={paid:"text-success",unpaid:"text-error",pending:"text-warning",cancelled:"text-neutral-400"};return(h,b)=>{const m=M,v=D,c=B;return i(),u("div",{ref_key:"rootEl",ref:_,class:"scroll-mt-20 rounded-xl border border-neutral-200 bg-white p-4 lg:p-6"},[e("p",Re,s(t(n)("my_orders.card_title")),1),a.orders.length?(i(),u("div",Le,[e("div",{class:w([S,"hidden border-b border-neutral-200 px-6 py-2 text-sm font-bold text-neutral-900 lg:grid lg:items-center lg:gap-4"])},[e("span",null,s(t(n)("my_orders.table.status")),1),e("span",null,s(t(n)("my_orders.table.number")),1),e("span",null,s(t(n)("my_orders.table.date")),1),e("span",null,s(t(n)("my_orders.table.price")),1),e("span",null,s(t(n)("my_orders.table.description")),1),b[1]||(b[1]=e("span",{"aria-hidden":"true"},null,-1))]),(i(!0),u(O,null,z(a.orders,l=>(i(),A(v,{key:l.id,to:{name:"profile-narudzba-id",params:{id:l.id}},class:w([S,"flex flex-col gap-2 border-b border-neutral-200 p-4 transition-colors last:border-b-0 hover:bg-slate-50 lg:grid lg:items-center lg:gap-4 lg:px-6 lg:py-3"])},{default:R(()=>[e("div",Ne,[e("span",{class:w(["text-sm font-semibold",d[l.status]])},s(t(n)(`my_orders.status.${l.status}`)),3),g(m,{name:"i-lucide-arrow-right",class:"size-4 shrink-0 text-neutral-400 lg:hidden","aria-hidden":"true"})]),e("span",Ae,s(l.number),1),e("div",De,[e("span",Be,s(l.date),1),e("span",Fe,s(l.price),1)]),e("span",Ve,s(l.description),1),g(m,{name:"i-lucide-arrow-right",class:"hidden size-4 shrink-0 text-neutral-400 lg:block","aria-hidden":"true"})]),_:2},1032,["to"]))),128))])):(i(),u("p",qe,s(t(n)("my_orders.empty")),1)),a.pagination&&a.pagination.pageCount>1?(i(),u("div",Ge,[g(c,{page:p.value,"onUpdate:page":b[0]||(b[0]=l=>p.value=l),total:a.pagination.totalCount,"items-per-page":He,"sibling-count":1,"show-edges":"",color:"neutral",variant:"ghost",size:"md",class:"flex justify-center",ui:{first:"rounded-full border border-neutral-300",prev:"rounded-full border border-neutral-300",next:"rounded-full border border-neutral-300",last:"rounded-full border border-neutral-300"}},null,8,["page","total"])])):V("",!0)],512)}}}),Ke=Object.assign(Je,{__name:"MyOrdersTable"}),Qe={0:"unpaid",1:"paid",2:"cancelled",3:"pending"},We=()=>{const{t:a}=$(),n=U(),p=I(1),_={},{data:d,error:h}=q("/api/crm/orders",{headers:{Accept:"application/json",..._},query:{page:p}},"$Em_EFTdhQx"),{intlLocale:b,formatDate:m}=Q(),v=(o,y="EUR")=>new Intl.NumberFormat(b.value,{style:"currency",currency:y||"EUR"}).format(Number(o)||0),c=o=>{const y=o.items?.[0];return y?.description?y.description:o.items?.length?a("my_orders.items_count",{count:o.items.length}):""},l=o=>({id:String(o.id),number:o.number??String(o.id),date:m(o.date_order),price:v(o.total_price,o.currency),description:c(o),status:Qe[o.status]??"unpaid"}),f=j(()=>({orders:W(d.value?.orders??[],o=>o.date_order,o=>o.status===0).map(l),pagination:d.value?.pagination?{current:d.value.pagination.current,last:d.value.pagination.last,pageCount:d.value.pagination.pageCount,totalCount:d.value.pagination.totalCount,numItemsPerPage:d.value.pagination.numItemsPerPage}:null})),x=j(()=>f.value.pagination);return C(h,o=>{o&&n.add({title:a("my_orders.load_error"),color:"error"})}),{data:f,currentPage:p,pagination:x}},Xe={class:"flex min-h-full flex-col bg-slate-50"},Ye={class:"flex flex-col gap-3 px-4 pt-4 pb-4 lg:flex-row lg:items-center lg:justify-between lg:pt-8 lg:pr-36 lg:pl-12"},Ze={class:"flex flex-col gap-3 lg:max-w-[455px]"},et={class:"text-3xl leading-9 font-semibold text-neutral-950"},tt={class:"text-base leading-6 text-neutral-600"},st={class:"flex flex-col gap-6 px-4 py-4 lg:py-6 lg:pr-36 lg:pl-12"},nt={key:0,class:"flex flex-col gap-4"},pt=k({__name:"invoices-and-orders",setup(a){const{t:n}=$();G({title:n("my_invoices.seo_title"),robots:"noindex, nofollow"});const{data:p,currentPage:_,pagination:d}=K(),{data:h,currentPage:b,pagination:m}=We();return(v,c)=>{const l=H,f=ue,x=Pe,o=ze,y=Ke;return i(),u("div",Xe,[e("div",Ye,[e("div",Ze,[e("h1",et,s(t(n)("my_invoices.title")),1),e("p",tt,s(t(n)("my_invoices.subtitle")),1)]),g(l,{color:"primary",variant:"outline",size:"md",icon:"i-lucide-shopping-cart",label:t(n)("my_invoices.new_order"),to:"shopping-cart",class:"w-full justify-center px-5 py-2 lg:w-auto lg:py-1.5"},null,8,["label"])]),e("div",st,[t(p).recent_invoices.length?(i(),u("div",nt,[g(f,{summary:t(p).summary},null,8,["summary"]),g(x,{page:t(_),"onUpdate:page":c[0]||(c[0]=r=>P(_)?_.value=r:null),invoices:t(p).recent_invoices,pagination:t(d)},null,8,["page","invoices","pagination"])])):(i(),A(o,{key:1})),g(y,{page:t(b),"onUpdate:page":c[1]||(c[1]=r=>P(b)?b.value=r:null),orders:t(h).orders,pagination:t(m)},null,8,["page","orders","pagination"])])])}}});
1export{pt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.