1import{a as S,j as e,ak as b,aB as z,aS as G,aT as W,u as X,U as v,r as d,q as Y,G as A,H as $,aI as K,b as c,al as l,a8 as Z,h as N,L as D,aU as O,aV as ee,aW as w}from"./index-DXw5IyQz.js";import{F as se}from"./finance-overview-C9sspyqH.js";import{I as te,a as Q}from"./invoice-form-BWB23gC0.js";import{I as ae}from"./invoice-viewer-D2S7Sd3y.js";import{Q as ne,a as R}from"./quote-form-DC8ZVFcK.js";import{Q as re}from"./quote-viewer-B0cgyLF5.js";import{C as ie}from"./chart-no-axes-column-C2mfkFpo.js";import{C as ce}from"./circle-x-COQYfgi3.js";import"./arrow-up-DRY0AI3U.js";import"./alert-dialog-CI-PteSA.js";import"./square-pen-BoI3BkyJ.js";import"./send-DyoKc_iB.js";import"./zod-D_wtpnXc.js";import"./form-CQh6qnB5.js";import"./info-D32EcuXd.js";import"./folder-plus-EfDKUDog.js";import"./save-DOssrFtg.js";import"./download-_Wn09zp8.js";import"./copy-D9-6WI1c.js";import"./format-Co3WRPUI.js";import"./nl-BBnlNZVY.js";import"./image-CUF_npZZ.js";import"./settings-CA-45kva.js";import"./minus-BGfznyJK.js";import"./pen-line-Dc2-1mZs.js";import"./pencil-DH5RU6b9.js";import"./accordion-C8lK9f1z.js";import"./separator-C5h-Ftoo.js";const oe=({activeTabId:n,onTabChange:o,userRole:t})=>{const[,x]=S(),i=t==="CUSTOMER",m=t==="EMPLOYEE",p=t==="PAINTER",r=h=>{o(h),x(`/finances/${h}`,{replace:!0})};return i||m||p?e.jsxs("div",{className:"inline-flex h-9 items-center justify-center rounded-md bg-muted p-1 pb-1.5 text-muted-foreground w-full md:w-[400px] grid grid-cols-2","data-role":"standard-tabs",children:[e.jsxs("button",{type:"button",className:`flex items-center justify-center w-full h-8 px-3 py-1.5 text-sm rounded-sm 2 ${n==="quotes"?"bg-background text-foreground shadow-sm":"hover:bg-background/50 hover:text-foreground"}`,onClick:()=>r("quotes"),"data-tab":"quotes",children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Offertes"})]}),e.jsxs("button",{type:"button",className:`flex items-center justify-center w-full h-8 px-3 py-1.5 text-sm rounded-sm 3 ${n==="invoices"?"bg-background text-foreground shadow-sm":"hover:bg-background/50 hover:text-foreground"}`,onClick:()=>r("invoices"),"data-tab":"invoices",children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Facturen"})]})]}):e.jsxs("div",{className:"inline-flex h-9 items-center justify-center rounded-md bg-muted p-1 pb-1.5 text-muted-foreground w-full md:w-[550px] grid grid-cols-3","data-role":"standard-tabs",children:[e.jsxs("button",{type:"button",className:`flex items-center justify-center w-full h-8 px-3 py-1.5 text-sm rounded-sm 4 ${n==="overview"?"bg-background text-foreground shadow-sm":"hover:bg-background/50 hover:text-foreground"}`,onClick:()=>r("overview"),"data-tab":"overview",children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Overzicht"})]}),e.jsxs("button",{type:"button",className:`flex items-center justify-center w-full h-8 px-3 py-1.5 text-sm rounded-sm 5 ${n==="quotes"?"bg-background text-foreground shadow-sm":"hover:bg-background/50 hover:text-foreground"}`,onClick:()=>r("quotes"),"data-tab":"quotes",children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Offertes"})]}),e.jsxs("button",{type:"button",className:`flex items-center justify-center w-full h-8 px-3 py-1.5 text-sm rounded-sm 6 ${n==="invoices"?"bg-background text-foreground shadow-sm":"hover:bg-background/50 hover:text-foreground"}`,onClick:()=>r("invoices"),"data-tab":"invoices",children:[e.jsx(z,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Facturen"})]})]})};function L(n,o){console.log(`Event emitter: Quote status changed voor quote ${n} naar ${o}`),G.emit(W.QUOTE_STATUS_CHANGED,n,o)}function De(){const[,n]=S(),[o]=S(),{user:t}=X();t==null||t.role,v.CUSTOMER,t==null||t.role;const x=(t==null?void 0:t.role)==="BUSINESS",[i,m]=d.useState(x?"overview":"quotes"),[p,r]=d.useState("list"),[h,u]=d.useState("list"),[a,C]=d.useState(null),[j,y]=d.useState(null),[P,B]=d.useState(null),H=(t==null?void 0:t.role)===v.PAINTER;t==null||t.role,v.CUSTOMER;const V=(t==null?void 0:t.role)===v.ADMIN;d.useEffect(()=>{o==="/finances"&&x&&(console.log("BUSINESS user gaat naar /finances, start met overview tab"),n("/finances/overview",{replace:!0}))},[o,n,x]),d.useEffect(()=>{console.log("Finances page - URL gewijzigd:",o);const s=o.split("/"),f=new URLSearchParams(o.split("?")[1]||"");if(s.length>=3&&s[1]==="finances"){const k=s[2];if(k==="overview")console.log("Finances page - Overview sectie gedetecteerd in URL"),m("overview");else if(k==="quotes")if(console.log("Finances page - Quotes sectie gedetecteerd in URL"),m("quotes"),s.length>=4){if(s[3]==="new")r("create");else if(!isNaN(Number(s[3]))){const F=Number(s[3]);C(F),s.length>=5?s[4]==="edit"?r("edit"):s[4]==="accept"?r("accept"):s[4]==="reject"?r("reject"):s[4]==="convert"?r("convert"):s[4]==="pay"?r("pay"):s[4]==="download"?r("download"):r("detail"):r("detail")}}else r("list"),C(null);else if(k==="invoices")if(console.log("Finances page - Invoices sectie gedetecteerd in URL"),m("invoices"),s.length>=4){if(s[3]==="new")u("create");else if(!isNaN(Number(s[3]))){const F=Number(s[3]);y(F),s.length>=5?s[4]==="edit"?u("edit"):s[4]==="pay"?u("pay"):u("detail"):u("detail")}}else u("list"),y(null)}const q=f.get("projectId");q&&!isNaN(Number(q))&&B(Number(q))},[o]);const I=(s,f)=>{if(P)return P},_=H||V,{toast:g}=Y(),E=A({mutationFn:async s=>await $("PATCH",`/api/quotes/${s}/status`,{status:w.ACCEPTED}),onSuccess:(s,f)=>{L(f,w.ACCEPTED),g({title:"Offerte geaccepteerd",description:"De offerte is succesvol geaccepteerd. De vakman wordt hiervan op de hoogte gebracht.",variant:"default"}),n("/finances/quotes",{replace:!0})},onError:s=>{console.error("[QUOTE ACCEPT] Fout bij accepteren offerte:",s),g({title:"Fout bij accepteren",description:s.message||"Er is een fout opgetreden bij het accepteren van de offerte. Probeer het later nog eens.",variant:"destructive"})}}),T=A({mutationFn:async s=>await $("PATCH",`/api/quotes/${s}/status`,{status:w.REJECTED}),onSuccess:(s,f)=>{L(f,w.REJECTED),g({title:"Offerte afgewezen",description:"De offerte is succesvol afgewezen. De vakman wordt hiervan op de hoogte gebracht.",variant:"default"}),n("/finances/quotes",{replace:!0})},onError:s=>{console.error("[QUOTE REJECT] Fout bij afwijzen offerte:",s),g({title:"Fout bij afwijzen",description:s.message||"Er is een fout opgetreden bij het afwijzen van de offerte. Probeer het later nog eens.",variant:"destructive"})}}),U=()=>
6{if(i==="overview")return e.jsx(se,{});if(i==="quotes")switch(p){case"create":return e.jsx(R,{mode:"create",projectId:I()});case"edit":return a?e.jsx(R,{mode:"edit",quoteId:a}):null;case"detail":return a?e.jsx(re,{quoteId:a}):null;case"download":return a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Offerte downloaden"}),e.jsxs("p",{className:"text-gray-600",children:["Download offerte #",a," als PDF"]})]}),e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(l,{href:`/finances/quotes/${a}`,children:"Terug naar offerte"})})]}),e.jsxs(N,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-4 text-blue-600",children:[e.jsx(b,{className:"h-12 w-12"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-medium",children:"PDF downloaden"}),e.jsx("p",{className:"text-gray-600",children:"De download wordt voorbereid..."})]})]}),e.jsx("div",{className:"mt-6 flex space-x-4",children:e.jsx(c,{asChild:!0,className:"bg-blue-600 hover:bg-blue-700",children:e.jsxs(l,{href:`/finances/quotes/${a}`,children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),"Terug naar offerte"]})})})]})]}):null;case"convert":return a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Offerte omzetten naar factuur"}),e.jsxs("p",{className:"text-gray-600",children:["Maak een factuur op basis van offerte #",a]})]}),e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(l,{href:`/finances/quotes/${a}`,children:"Terug naar offerte"})})]}),e.jsxs(N,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-4 text-green-600",children:[e.jsx(O,{className:"h-12 w-12"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-medium",children:"Offerte accepteren en omzetten"}),e.jsx("p",{className:"text-gray-600",children:"De offerte wordt gemarkeerd als geaccepteerd en omgezet naar een nieuwe factuur."})]})]}),e.jsxs("div",{className:"mt-6 flex space-x-4",children:[e.jsx(c,{asChild:!0,className:"bg-green-600 hover:bg-green-700",children:e.jsxs(l,{href:`/finances/invoices/new?fromQuote=${a}`,children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Offerte omzetten naar factuur"]})}),e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(l,{href:"/finances/quotes",children:"Annuleren"})})]})]})]}):null;case"accept":return a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Offerte accepteren"}),e.jsxs("p",{className:"text-gray-600",children:["Offerte #",a," accepteren"]})]}),e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(l,{href:`/finances/quotes/${a}`,children:"Terug naar offerte"})})]}),e.jsxs(N,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-4 text-green-600",children:[e.jsx(O,{className:"h-12 w-12"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-medium",children:"Offerte accepteren"}),e.jsx("p",{className:"text-gray-600",children:"Door de offerte te accepteren gaat u akkoord met de voorwaarden en het vermelde bedrag."})]})]}),e.jsxs("div",{className:"mt-6 flex space-x-4",children:[e.jsx(c,{className:"bg-green-600 hover:bg-green-700",onClick:()=>a&&E.mutate(a),disabled:E.isPending,children:E.isPending?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"mr-2 h-4 w-4 animate-spin"}),"Even geduld..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"Bevestig acceptatie"]})}),e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(l,{href:`/finances/quotes/${a}`,children:"Annuleren"})})]})]})]}):null;case"reject":return a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"Offerte afwijzen"}),e.jsxs("p",{className:"text-gray-600",children:["Offerte #",a," afwijzen"]})]}),e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(l,{href:`/finances/quotes/${a}`,children:"Terug naar offerte"})})]}),e.jsxs(N,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center space-x-4 text-red-600",children:[e.jsx(M,{className:"h-12 w-12"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-medium",children:"Offerte afwijzen"}),e.jsx("p",{className:"text-gray-600",children:"Wilt u deze offerte afwijzen? Deze actie kan niet ongedaan worden gemaakt."})]})]}),e.jsxs("div",{className:"mt-6 flex space-x-4",children:[e.jsx(c,{variant:"destructive",onClick:()=>a&&T.mutate(a),disabled:T.isPending,children:T.isPending?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"mr-2 h-4 w-4 animate-spin"}),"Even geduld..."]}):e.jsxs(e.Fragment,{children:[e.jsx(M,{className:"mr-2 h-4 w-4"}),"Bevestig afwijzing"]})}),e.jsx(c,{variant:"outline",asChild:!0,children:e.jsx(l,{href:`/finances/quotes/${a}`,children:"Annuleren"})})]})]})]}):null;default:return e.jsx(ne,{})}else if(i==="invoices")switch(h){case"create":return e.jsx(Q,{mode:"create",projectId:I()});case"edit":return j?e.jsx(Q,{mode:"edit",invoiceId:j}):null;case"detail":return j?e.jsx(ae,{invoiceId:j}):null;case"pay":return e.jsxs("div",{children:["Betaalpagina voor factuur ",j]});default:return e.jsx(te,{})}return null},J=_&&(i==="quotes"&&p==="list"||i==="invoices"&&h==="list");return e.jsxs("div",{className:"flex flex-col min-h-screen bg-[#f8f9fa]",children:[e.jsx(K,{}),e.jsx("main",{className:"flex-1 overflow-y-auto px-4 app-content",style:{paddingTop:"calc(4.625rem + env(safe-area-inset-top) + 30px)"},children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-800",children:"Financiën"}),e.jsx("p",{className:"text-gray-600",children:"Beheer uw offertes, facturen en betalingen op één plek"})]}),J&&e.jsx(c,{asChild:!0,className:"bg-primary hover:bg-primary/90",children:e.jsxs(l,{href:i==="quotes"?"/finances/quotes/new":"/finances/invoices/new",children:[e.jsx(Z,{className:"mr-2 h-4 w-4"}),i==="quotes"?"Nieuwe offerte":"Nieuwe factuur"]})})]}),e.jsxs("div",{className:"w-full",children:[e.jsx(oe,{activeTabId:i,onTabChange:s=>{m(s),s==="quotes"?(r("list"),C(null)):s==="invoices"&&(u("list"),y(null))},userRole:(t==null?void 0:t.role)||""}),e.jsxs("div",{className:"w-full mt-6",children:[i==="quotes"&&U(),i==="invoices"&&U()]})]})]})})]})}function le(n){return e.jsx(O,{...n})}function M(n){return e.jsx(ce,{...n})}export{De 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.