ruạṛ
import{u as p,A as P,f as A,c as o,bk as E,m as O,dD as x,p as D,j as F,H as k,ax as u,ay as d,aS as T,dE as q,bc as m,r as y,e as w,$ as b,bq as S,dF as B,dG as M,dH as I,aG as g,aA as K,dI as L,dJ as z,bN as R,cl as j,a1 as H,k as G,h as Q}from"./bundle.9abe88c8.js";import{D as $}from"./DataTableColumnsPicker-72027136.js";const v=["name","linked_to","size","width","height","private","created_at"];function U(){return["name","linked_to","size","width","height","private","created_at","hash","id","type"]}function V(){var t;const[e]=p(),s=P(),{dateFormat:l}=A(),a=[{column:"name",id:"name",label:e("name")},{column:"linked_to",id:"link",label:e("linked_to"),format:n=>{if(n){const i=n.split("/")[1];return o(E,{to:n,children:e(i.slice(0,-1))})}}},{column:"size",id:"size",label:e("size"),format:n=>`${n} KB`},{column:"width",id:"width",label:e("width")},{column:"height",id:"height",label:e("height")},{column:"private",id:"is_public",label:e("private"),format:n=>e(n?"no":"yes")},{column:"created_at",id:"created_at",label:e("created_at"),format:n=>O(n,l)},{column:"hash",id:"hash",label:e("hash")},{column:"type",id:"type",label:e("type")}],c=((t=s==null?void 0:s.react_table_columns)==null?void 0:t.clientDocument)||v;return a.filter(n=>c.includes(n.column)).sort((n,i)=>c.indexOf(n.column)-c.indexOf(i.column))}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function W(){const[e]=p();return[{label:e("public"),value:"public",color:"white",backgroundColor:"#6B7280",queryKey:"type"},{label:e("private"),value:"private",color:"white",backgroundColor:"#93C5FD",queryKey:"type"},{label:e("image"),value:"image",color:"white",backgroundColor:"#1D4ED8",queryKey:"type"},{label:e("pdf"),value:"pdf",color:"white",backgroundColor:"#22C55E",queryKey:"type"},{label:e("other"),value:"other",color:"white",backgroundColor:"#9CA3AF",queryKey:"type"}]}function J(e){const[s]=p(),{document:l}=e,a=x(),[c,t]=D.useState(""),[n,i]=D.useState(!1),h=(f,r)=>{m.processing(),y("DELETE",w("/api/v1/documents/:id",{id:c}),{},{headers:{"X-Api-Password":f}}).then(()=>{m.success("deleted_document"),b(["clients"])}).catch(_=>{var C;((C=_.response)==null?void 0:C.status)===412&&(a(r),i(!0))})};return F(k,{children:[o(u,{onClick:()=>{t(l.id),i(!0)},icon:o(d,{element:T}),children:s("delete")}),o(q,{show:n,onClose:i,onSave:h})]})}function N(){const[e]=p(),s=S(),l=L(),a=(t,n)=>{m.processing(),s.fetchQuery(["/api/v1/documents",t.hash],()=>y("GET",w("/documents/:hash",{hash:t.hash}),{headers:z()},{responseType:"arraybuffer"}),{staleTime:1/0}).then(i=>{const h=new Blob([i.data],{type:i.headers["content-type"]}),f=URL.createObjectURL(h);if(n){window.open(f);return}const r=document.createElement("a");r.download=t.name,r.href=f,r.target="_blank",document.body.appendChild(r),r.click(),document.body.removeChild(r),m.dismiss()})};return[t=>o(u,{onClick:()=>a(t,!0),icon:o(d,{element:B}),children:e("view")}),t=>!!t.is_public&&o(u,{onClick:()=>l(t.id,!1).then(()=>b(["clients"])),icon:o(d,{element:M}),children:e("set_private")}),t=>!t.is_public&&o(u,{onClick:()=>l(t.id,!0).then(()=>b(["clients"])),icon:o(d,{element:I}),children:e("set_public")}),t=>o(u,{onClick:()=>a(t,!1),icon:o(d,{element:g}),children:e("download")}),()=>o(K,{withoutPadding:!0}),t=>o(J,{document:t})]}function X(){const[e]=p(),s=a=>{m.processing(),y("POST",w("/api/v1/documents/bulk?per_page=100"),{action:"download",ids:a}).then(()=>m.success("exported_data"))};return[({selectedResources:a,setSelected:c})=>o(u,{onClick:()=>{s(a.map(({id:t})=>t)),c([])},icon:o(d,{element:g}),children:e("download")})]}function ee(){const{id:e}=R(),s=j(),{isPurgeOrMergeActionCalled:l}=s,a=H(),c=W(),t=V(),n=N(),i=U(),h=X();return o(k,{children:o(G,{resource:"document",methodType:"POST",queryIdentificator:"/api/v1/documents",endpoint:Q("/api/v1/clients/:id/documents",{id:e}),columns:t,customFilters:c,customActions:n,customBulkActions:h,customFilterPlaceholder:"type",withResourcefulActions:!0,leftSideChevrons:o($,{table:"clientDocument",columns:i,defaultColumns:v}),showEdit:()=>!1,showRestore:()=>!1,showArchive:()=>!1,showDelete:()=>!1,disableQuery:l,withoutDefaultBulkActions:!0,withoutStatusFilter:!0,hideEditableOptions:!a("edit_expense")})})}export{ee as default};
cải xoăn