import{_ as y}from"./AppLayout.vue_vue_type_script_setup_true_lang-C-UlPCqH.js";import{d as v,o as n,a as l,b as p,e as b,h as g,w as x,f as t,F as d,n as c,t as r,j as i,q as C,D as u}from"./app-D9-EssCM.js";import"./index-CcjNLu6f.js";import"./index-CMWG4mbA.js";import"./useForwardExpose-MNmriUeS.js";import"./VisuallyHidden-DG35s1YI.js";import"./RovingFocusGroup-Diffidi3.js";import"./useArrowNavigation-C6Y-ieo6.js";import"./x-DwmBYYXD.js";import"./_plugin-vue_export-helper-DmjF0He4.js";const D={class:"space-y-6 p-4"},T={class:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between"},S={class:"flex items-center gap-2"},I=["value"],w=["value"],z=["value"],k=["value"],N=["href"],P={class:"rounded border p-4"},F={class:"overflow-x-auto"},V={class:"min-w-full text-sm"},j={class:"p-2"},A={class:"p-2"},B={class:"p-2"},L={class:"p-2"},U={class:"p-2 text-right"},$={class:"p-2 text-right"},q={class:"inline-flex items-center gap-2"},H=["href"],M=["href"],E={class:"flex flex-wrap items-center gap-2"},J=["href","innerHTML"],te=v({__name:"Documents",props:{availableCompanies:{},selectedCompanyId:{},selectedDocumentType:{},statementPdfUrl:{},search:{},documents:{}},setup(m){const a=m;function h(o){const s=o.target.value,e={};s&&(e.company_id=s),a.selectedDocumentType&&(e.document_type=a.selectedDocumentType),a.search&&(e.search=a.search),u.get("/client-zone/documents",e,{preserveState:!0,replace:!0})}function f(o){const s=o.target.value,e={};a.selectedCompanyId&&(e.company_id=String(a.selectedCompanyId)),a.selectedDocumentType&&(e.document_type=a.selectedDocumentType),s.trim()&&(e.search=s.trim()),u.get("/client-zone/documents",e,{preserveState:!0,replace:!0})}function _(o){const s=o.target.value,e={};a.selectedCompanyId&&(e.company_id=String(a.selectedCompanyId)),s&&(e.document_type=s),a.search&&(e.search=a.search),u.get("/client-zone/documents",e,{preserveState:!0,replace:!0})}return(o,s)=>(n(),l(d,null,[p(b(g),{title:"Client Documents"}),p(y,{breadcrumbs:[{title:"Client Zone",href:"/client-zone"},{title:"Documents",href:"/client-zone/documents"}]},{default:x(()=>[t("div",D,[t("div",T,[s[2]||(s[2]=t("h1",{class:"text-2xl font-semibold"},"Documents",-1)),t("div",S,[t("input",{type:"search",value:o.search,onChange:f,placeholder:"Search documents...",class:"rounded border px-3 py-2 text-sm"},null,40,I),t("select",{class:"rounded border px-3 py-2 text-sm",value:o.selectedCompanyId??"",onChange:h},[s[0]||(s[0]=t("option",{value:""},"All available companies",-1)),(n(!0),l(d,null,c(o.availableCompanies,e=>(n(),l("option",{key:e.id,value:e.id},r(e.name),9,z))),128))],40,w),t("select",{class:"rounded border px-3 py-2 text-sm",value:o.selectedDocumentType??"",onChange:_},[...s[1]||(s[1]=[t("option",{value:""},"All document types",-1),t("option",{value:"invoice"},"Invoice",-1),t("option",{value:"quote"},"Quote",-1),t("option",{value:"jobcard"},"Jobcard",-1),t("option",{value:"credit-note"},"Credit Note",-1)])],40,k),o.statementPdfUrl?(n(),l("a",{key:0,href:o.statementPdfUrl,class:"rounded bg-slate-700 px-4 py-2 text-sm text-white hover:bg-slate-800"}," Statement PDF ",8,N)):i("",!0)])]),t("div",P,[t("div",F,[t("table",V,[s[3]||(s[3]=t("thead",null,[t("tr",{class:"border-b bg-gray-50"},[t("th",{class:"p-2 text-left"},"Type"),t("th",{class:"p-2 text-left"},"Number"),t("th",{class:"p-2 text-left"},"Status"),t("th",{class:"p-2 text-left"},"Company"),t("th",{class:"p-2 text-right"},"Total"),t("th",{class:"p-2 text-right"},"Actions")])],-1)),t("tbody",null,[(n(!0),l(d,null,c(o.documents.data,e=>(n(),l("tr",{key:`${e.type}-${e.id}`,class:"border-b"},[t("td",j,r(e.type),1),t("td",A,r(e.number),1),t("td",B,r(e.status),1),t("td",L,r(e.company_name),1),t("td",U,r(e.total),1),t("td",$,[t("div",q,[e.view_url?(n(),l("a",{key:0,href:e.view_url,class:"rounded bg-slate-100 px-3 py-1.5 text-slate-800 hover:bg-slate-200"},"View",8,H)):i("",!0),e.download_pdf_url?(n(),l("a",{key:1,href:e.download_pdf_url,class:"rounded bg-blue-600 px-3 py-1.5 text-white hover:bg-blue-700"},"PDF",8,M)):i("",!0)])])]))),128))])])])]),t("div",E,[(n(!0),l(d,null,c(o.documents.links,e=>(n(),l("a",{key:e.label,href:e.url||"#",class:C(["rounded border px-3 py-1.5 text-sm",[e.active?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-700",e.url?"":"pointer-events-none opacity-50"]]),innerHTML:e.label},null,10,J))),128))])])]),_:1})],64))}});export{te as default};
