Files
docker-invoiceninja/docker/app/public/bundle.1adb2a11.js
2024-10-19 18:17:42 +00:00

7 lines
4.1 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{c as e,H as T,bC as j,z as w,u as z,bp as k,p as u,r as E,du as I,e as H,j as f,ac as N,f9 as U,fa as L,fb as M,fc as $,fd as F,S as B,O,bO as A,de as G,bi as Q,Z as q,bo as V,h as S,bP as Z,T as J,bq as K,bQ as W,bx as X,bR as Y,ax as ee,fe as se}from"./bundle.3e24044b.js";import{P as te,a as ne,b as ae,r as re}from"./bundle.15f4bb12.js";import{a as C}from"./bundle.6bc2c301.js";function R(s){const{children:c,renderBasePanel:o}=s;return o?e(te,{defaultSize:50,minSize:25,children:c}):e(T,{children:c})}function oe(s){const{children:c,renderBasePanelGroup:o}=s;return o?e(ne,{direction:"horizontal",className:"gap-4 mt-4",children:c}):e("div",{className:"flex flex-col gap-4",children:c})}const ce=j(ae)`
background-color: ${s=>s.theme.backgroundColor};
&:hover {
background-color: ${s=>s.theme.hoverColor};
}
`;function ie(s){const c=w(),{renderBasePanelResizeHandler:o}=s;return o?e(ce,{className:"flex items-center",theme:{hoverColor:"#3366CC",backgroundColor:c.$5},style:{width:"2.5px"}}):e(T,{})}function le(s){var l;const[c]=z(),o=k(),{documents:a}=s,x=u.useRef(null),[p,d]=u.useState(""),[h,y]=u.useState(!1),[i,m]=u.useState(0),[g,b]=u.useState(!1),n=()=>{var r;const t=(r=a[i])==null?void 0:r.type;return t==="png"||t==="jpg"||t==="gif"||t==="webp"||t==="tiff"},P=()=>{var r;return((r=a[i])==null?void 0:r.type)==="pdf"};return u.useEffect(()=>{var t;return a.length&&(y(!0),b(!1),a[i]?o.fetchQuery(["/api/v1/documents",(t=a[i])==null?void 0:t.hash],()=>{var r;return E("GET",H("/documents/:hash",{hash:(r=a[i])==null?void 0:r.hash}),{headers:I()},{responseType:"arraybuffer"})},{staleTime:1/0}).then(r=>{const v=new Blob([r.data],{type:r.headers["content-type"]});n()?d(URL.createObjectURL(v)):!C&&x.current&&P()?x.current.src=URL.createObjectURL(v):b(!0)}).finally(()=>y(!1)):m(0)),()=>{d(""),y(!1),b(!1)}},[a,i]),C?e("p",{children:"Unable to preview PDF.  "}):f(T,{children:[a.length?f("div",{className:"flex flex-col",children:[!h&&f("div",{className:"flex self-end pb-1",children:[e(N,{className:"cursor-pointer",element:U,size:25,onClick:()=>m(0)}),e(N,{className:"cursor-pointer",element:L,size:25,onClick:()=>i!==0&&m(t=>t-1)}),e(N,{className:"cursor-pointer",element:M,size:25,onClick:()=>i!==a.length-1&&m(t=>t+1)}),e(N,{className:"cursor-pointer",element:$,size:25,onClick:()=>m(a.length-1)})]}),n()&&!h&&!g&&e("img",{className:"w-full",src:p}),e("iframe",{ref:x,width:"100%",height:h||!P()||g?0:1500}),g&&e("div",{className:"flex h-full justify-center items-center",children:e(F,{type:(l=a[i])==null?void 0:l.type,size:150})})]}):f("div",{className:"flex justify-center",children:[c("no_records_found"),"."]}),h&&e("div",{className:"flex justify-center items-center h-full",children:e(B,{})})]})}function fe(){const[s]=z(),{documentTitle:c}=O("edit_expense"),{id:o}=A(),a=G(),x=w(),{data:p}=Q({id:o}),d=re.useMediaQuery({query:"(min-width: 1024px)"}),h=q(),y=V(),i=[{name:s("expenses"),href:"/expenses"},{name:s("edit_expense"),href:S("/expenses/:id/edit",{id:o})}],m=[{name:s("edit"),href:S("/expenses/:id/edit",{id:o})},{name:s("documents"),href:S("/expenses/:id/documents",{id:o}),formatName:()=>e(Z,{numberOfDocuments:n==null?void 0:n.documents.length})}],[g,b]=u.useState(),[n,P]=u.useState(),[l,t]=u.useState(!1),[r,v]=u.useState("by_rate"),D=se({setErrors:b});return u.useEffect(()=>{p&&(P(p),v(p.calculate_tax_by_amount?"by_amount":"by_rate"))},[p]),e(J,{title:c,breadcrumbs:i,...(h("edit_expense")||y(n))&&n&&{navigationTopRight:e(K,{resource:n,onSaveClick:()=>D(n),actions:a,disableSaveButton:!n,cypressRef:"expenseActionDropdown"})},children:n?f("div",{className:"space-y-4",children:[e(W,{tabs:m,rightSide:f("div",{className:"flex items-center justify-end space-x-3",children:[e("span",{className:"text-sm",children:s("preview")}),e(X,{checked:l,onValueChange:_=>t(_)})]})}),f(oe,{renderBasePanelGroup:l&&d,children:[e(R,{renderBasePanel:l&&d,children:e(Y,{context:{errors:g,setErrors:b,expense:n,setExpense:P,taxInputType:r,setTaxInputType:v,isPreviewMode:l}})}),e(ie,{renderBasePanelResizeHandler:l&&d}),l&&!d&&e(ee,{className:"pt-4",withoutPadding:!0,borderColor:x.$5}),e(R,{renderBasePanel:l&&d,children:l&&e(le,{documents:n.documents})})]})]}):e(B,{})})}export{fe as default};