ruạṛ
import{u as g,aX as Y,c as e,H as y,j as c,c3 as J,cc as H,bk as T,h as d,a$ as Z,cr as K,z as W,x as ee,M as se,d as q,d0 as te,aY as ae,bv as v,a_ as ne,bD as le,aq as ie,d1 as ce,p as _,ae as re,s as E,d2 as oe,d3 as de,d4 as me,ay as w,d5 as ue,d6 as L,bF as j,ax as G,aS as O,bc as M,r as k,e as A,$ as S,U as he,a1 as Q,bp as U,bN as D,a as pe,bO as fe,d7 as ye,bq as ge,A as z,b0 as X,T as _e,c$ as be,cQ as ve,aa as xe,a5 as Ne,V as R,W as Ce,bt as we,S as Se,bQ as Te,bR as Pe,a9 as Ee}from"./bundle.9abe88c8.js";import{I as b}from"./InfoCard-3b3f3798.js";import{C as ke,c as Ae}from"./ConfirmActionModal-1bb60c06.js";import{E as Be}from"./EmailRecord-9930c242.js";import{P as Ie}from"./PreviousNextNavigation-f6f14b66.js";function Me(o){var r;const{t}=g(),{client:s}=o,l=Y();return e(y,{children:s&&e("div",{className:"col-span-12 md:col-span-6 lg:col-span-3",children:e(b,{title:t("address"),value:c(y,{children:[c("p",{className:"break-all",children:[s.address1.length>0&&s.address1,s.address1.length>0&&e("br",{}),s.address2]}),c("p",{className:"break-all",children:[s.city.length>0&&s.city," ",s.state," ",s.postal_code.length>0&&s.postal_code]}),e("p",{className:"break-all",children:(r=l(s.country_id))==null?void 0:r.name})]}),withoutTruncate:!0,className:"h-full"})})})}function Re(o){const[t]=g(),s=J(),{client:l}=o;return e(y,{children:l&&e("div",{className:"col-span-12 md:col-span-6 lg:col-span-3",children:e(b,{title:t("contacts"),value:e("div",{className:"space-y-2",children:l.contacts.map((r,i)=>{var n,m;return!!(r.first_name||r.last_name||r.phone||r.email)&&c("div",{className:"flex justify-between items-center",children:[c("div",{className:"flex flex-col space-y-1",children:[c("p",{className:"font-semibold",style:{color:s},children:[r.first_name," ",r.last_name]}),e("p",{children:r.phone}),!!r.email&&c("div",{className:"flex space-x-1",children:[e("span",{children:r.email}),e(H,{text:r.email})]}),c("div",{className:"flex items-center space-x-2",children:[e(T,{className:"cursor-pointer",to:d(`${(n=l.contacts[i])==null?void 0:n.link}?silent=true&client_hash=:clientHash`,{clientHash:l.client_hash}),external:!0,children:t("client_portal")}),e(Z,{message:t("copy_link"),placement:"top",width:"auto",centerVertically:!0,children:e(H,{text:d(`${(m=l.contacts[i])==null?void 0:m.link}?silent=true`),iconColor:s})})]})]}),r.is_locked&&e(K,{})]},i)})}),className:"h-full"})})})}function De(o){var p;const[t]=g(),{client:s}=o,l=W(),r=ee();se();const i=q(),n=te(),m=ae();return e(y,{children:s&&e("div",{className:"col-span-12 md:col-span-6 lg:col-span-3",children:e(b,{title:t("details"),value:c(y,{children:[c("div",{className:"space-y-2 mb-4",children:[e(v,{leftSide:t("status"),noExternalPadding:!0,noVerticalPadding:!0,children:e(ne,{entity:s})}),e(v,{leftSide:t("number"),noExternalPadding:!0,noVerticalPadding:!0,children:s.number})]}),s.group_settings_id&&e(v,{leftSide:t("group"),noExternalPadding:!0,children:e(T,{to:d("/settings/group_settings/:id/edit",{id:s.group_settings_id}),children:(p=s.group_settings)==null?void 0:p.name})}),e(T,{to:s.website,external:!0,children:s.website}),s.vat_number.length>1&&c("p",{children:[t("vat_number"),": ",s.vat_number]}),s.phone.length>1&&c("p",{children:[t("phone"),": ",s.phone]}),parseFloat(s.settings.default_task_rate)>0&&c("p",{className:"space-x-1",children:[c("span",{children:[t("task_rate"),":"]}),e("span",{children:s.settings.default_task_rate?i(s.settings.default_task_rate,s.country_id,s.settings.currency_id):i(r.settings.default_task_rate,s.country_id,r.settings.currency_id)})]}),!1,e("div",{className:"flex flex-col space-y-1 mt-2",children:["client1","client2","client3","client4"].map(h=>{const u=n(h).label(),f=s[`custom_value${h.slice(-1)}`];return!!(u&&f)&&c("div",{className:"flex space-x-2",children:[e("span",{className:"font-medium",style:{color:l.$3,colorScheme:l.$0},children:u}),e("span",{children:m(h,f)})]},h)})})]}),className:"h-full"})})})}function $e(o){const[t]=g(),{client:s}=o,l=q();return e(y,{children:s&&e("div",{className:"col-span-12 md:col-span-6 lg:col-span-3",children:e(b,{title:t("standing"),value:c("div",{className:"flex flex-col space-y-2",children:[e(v,{leftSide:e("span",{className:"font-bold",children:t("paid_to_date")}),pushContentToRight:!0,noExternalPadding:!0,noVerticalPadding:!0,children:l(s.paid_to_date,s.country_id,s.settings.currency_id)}),e(v,{leftSide:e("span",{className:"font-bold",children:t("outstanding")}),pushContentToRight:!0,noExternalPadding:!0,noVerticalPadding:!0,children:l(s.balance,s.country_id,s.settings.currency_id)}),e(v,{leftSide:e("span",{className:"font-bold",children:t("credit_balance")}),pushContentToRight:!0,noExternalPadding:!0,noVerticalPadding:!0,children:l(s.credit_balance,s.country_id,s.settings.currency_id)}),s.payment_balance>0&&e(v,{leftSide:e("span",{className:"font-bold",children:t("payment_balance")}),pushContentToRight:!0,noExternalPadding:!0,noVerticalPadding:!0,children:l(s.payment_balance,s.country_id,s.settings.currency_id)})]}),className:"h-full"})})})}const Ve=le.div` &:hover { background-color: ${o=>o.theme.hoverBgColor}; } `;function Fe(o){const[t]=g(),{client:s}=o,{isAdmin:l}=ie(),r=W(),{data:i}=ce(),[n,m]=_.useState(),[p,h]=_.useState(!1),[u,f]=_.useState(""),P=re(Ae),x=a=>n==null?void 0:n.find(({id:N})=>N===a),C=a=>!!(a&&(a==="d14dd26a37cecc30fdd65700bfb55b23"||a==="d14dd26a47cecc30fdd65700bfb67b34")),B=()=>{u&&!p&&(M.processing(),h(!0),k("DELETE",A("/api/v1/client_gateway_tokens/:id",{id:u})).then(()=>{M.success("success"),S(["clients"]),f(""),P(!1)}).finally(()=>h(!1)))},I=a=>{k("POST",A("/api/v1/client_gateway_tokens/:id/setAsDefault",{id:a})).then(()=>{M.success("success"),S(["clients"])})};return _.useEffect(()=>{i&&m(i.data.data)},[i]),_.useEffect(()=>{u&&P(!0)},[u]),c(y,{children:[e(ke,{onClick:()=>B(),onClose:()=>f(""),disabledButton:p}),e("div",{className:"col-span-12 md:col-span-12 lg:col-span-6 xl:col-span-4",children:e(b,{title:t("payment_methods"),className:"max-h-96 overflow-y-auto h-full",children:s.gateway_tokens.map(a=>{var N,$,V,F;return c("div",{className:E("flex flex-col space-y-1.5 border-b py-4",{"h-22":!a.is_default,"h-20":a.is_default}),children:[c("div",{className:"flex items-center justify-between h-12",children:[c("div",{className:"flex flex-col space-y-1.5",children:[c("div",{className:"inline-flex items-center space-x-1",children:[e("div",{children:e(oe,{fontSize:22})}),c("div",{className:"inline-flex items-center",children:[e("span",{children:t("gateway")}),e(de,{size:20}),e(T,{to:d("/settings/gateways/:id/edit",{id:a.company_gateway_id}),children:(N=x(a.company_gateway_id))==null?void 0:N.label})]})]}),c("div",{className:"flex items-center space-x-2",children:[e(me,{name:a.meta.brand}),c("div",{className:"flex items-center",children:[e("span",{className:"mt-1",children:"****"}),e("span",{className:"ml-1",children:a.meta.last4})]}),c("span",{children:[a.meta.exp_month,"/",a.meta.exp_year]})]})]}),c("div",{className:E("flex flex-col items-end h-full",{"justify-center":!C(($=x(a.company_gateway_id))==null?void 0:$.gateway_key)&&a.is_default,"justify-between":C((V=x(a.company_gateway_id))==null?void 0:V.gateway_key)&&a.is_default}),children:[C((F=x(a.company_gateway_id))==null?void 0:F.gateway_key)&&e(T,{external:!0,to:d("https://dashboard.stripe.com/customers/:customerReference",{customerReference:a.gateway_customer_reference}),children:e(w,{element:ue,size:18})}),a.is_default&&c("div",{className:"inline-flex items-center rounded-full py-1 px-3 text-xs space-x-1",style:{backgroundColor:r.$5},children:[e("span",{children:t("default")}),l&&e(L,{className:"rounded-bl-none rounded-tl-none h-full px-1 border-gray-200 border-l-1 border-y-0 border-r-0",customLabel:e("div",{className:"cursor-pointer",children:e(w,{element:j,style:{width:"1.1rem",height:"1.1rem"}})}),minWidth:"9rem",maxWidth:"11rem",children:e(G,{icon:e(w,{element:O}),onClick:()=>f(a.id),children:t("delete")})})]})]})]}),!a.is_default&&e("div",{className:"flex items-center justify-start",children:c(Ve,{className:"inline-flex items-center text-xs cursor-pointer border rounded-full py-1 px-3 self-start space-x-1",style:{borderColor:r.$5},onClick:()=>I(a.id),theme:{hoverBgColor:r.$5},children:[e("span",{children:t("save_as_default")}),l&&e(L,{className:"rounded-bl-none rounded-tl-none h-full px-1 border-gray-200 border-l-1 border-y-0 border-r-0",customLabel:e("div",{className:"cursor-pointer",children:e(w,{element:j,style:{width:"1.1rem",height:"1.1rem"}})}),minWidth:"9rem",maxWidth:"11rem",children:e(G,{icon:e(w,{element:O}),onClick:()=>f(a.id),children:t("delete")})})]})})]},a.id)})})})]})}function He(o){const[t]=g(),s=he(),l=Q(),r=U(),{id:i}=D(),{client:n,isPurgeOrMergeActionCalled:m}=o,{data:p}=pe({queryKey:["/api/v1/documents",i,"client"],queryFn:()=>k("POST",A("/api/v1/clients/:id/documents",{id:i})).then(u=>u.data.data),staleTime:1/0,enabled:!!i&&!m});let h=[{name:t("invoices"),href:d("/clients/:id",{id:i})},{name:t("quotes"),href:d("/clients/:id/quotes",{id:i})},{name:t("payments"),href:d("/clients/:id/payments",{id:i})},{name:t("recurring_invoices"),href:d("/clients/:id/recurring_invoices",{id:i})},{name:t("credits"),href:d("/clients/:id/credits",{id:i})},{name:t("projects"),href:d("/clients/:id/projects",{id:i})},{name:t("tasks"),href:d("/clients/:id/tasks",{id:i})},{name:t("expenses"),href:d("/clients/:id/expenses",{id:i})},{name:t("recurring_expenses"),href:d("/clients/:id/recurring_expenses",{id:i})},{name:t("activity"),href:d("/clients/:id/activities",{id:i})},{name:t("documents"),href:d("/clients/:id/documents",{id:i}),enabled:l("view_client")||l("edit_client")||r(n),formatName:()=>e(fe,{numberOfDocuments:p==null?void 0:p.length})}];return ye.forEach(u=>{s(u.bitmask)||(h=h.filter(f=>f.name!==t(u.label)))}),h}function Le(){const[o]=g(),t=ge(),{id:s}=D(),[l,r]=_.useState([]),i=async()=>{const n=await t.fetchQuery(["/api/v1/clients",s,"emailHistory"],()=>k("POST",A("/api/v1/emails/clientHistory/:id",{id:s})).then(m=>m.data),{staleTime:1/0});r(n)};return _.useEffect(()=>{i()},[]),e(y,{children:!!l.length&&e("div",{className:"col-span-12 md:col-span-12 lg:col-span-6 xl:col-span-4",children:e(b,{title:o("email_history"),className:"max-h-96 overflow-y-auto h-full",value:l.map((n,m)=>n&&e(Be,{emailRecord:n,index:m,withBottomBorder:!0,withEntityNavigationIcon:!0},m))})})})}function je(o){const[t]=g(),{client:s}=o,l=z();return e(y,{children:!!(s&&s.public_notes)&&e("div",{className:"col-span-12 md:col-span-6 lg:col-span-6 xl:col-span-3",children:e(b,{title:t("public_notes"),value:e("div",{className:"whitespace-normal max-h-56 overflow-y-auto",children:e("article",{className:E("prose prose-sm",{"prose-invert":l.dark_mode}),dangerouslySetInnerHTML:{__html:X(s.public_notes)}})}),className:"h-full"})})})}function Ge(o){const[t]=g(),{client:s}=o,l=z();return e(y,{children:!!(s&&s.private_notes)&&e("div",{className:"col-span-12 md:col-span-6 lg:col-span-6 xl:col-span-3",children:e(b,{title:t("private_notes"),value:e("div",{className:"whitespace-normal max-h-56 overflow-y-auto",children:e("article",{className:E("prose prose-sm",{"prose-invert":l.dark_mode}),dangerouslySetInnerHTML:{__html:X(s.private_notes)}})}),className:"h-full"})})})}function ze(){const{documentTitle:o,setDocumentTitle:t}=_e("view_client"),[s]=g(),[l,r]=_.useState(!1),{id:i}=D(),{data:n,isLoading:m}=be({id:i,enabled:!!i&&!l}),p=[{name:s("clients"),href:"/clients"},{name:o,href:d("/clients/:id",{id:i})}],h=He({client:n,isPurgeOrMergeActionCalled:l}),u=ve({setIsPurgeOrMergeActionCalled:r}),f=xe(),P=Q(),x=U();_.useEffect(()=>(t((n==null?void 0:n.display_name)||"view_client"),()=>{r(!1)}),[n]);const{changeTemplateVisible:C,setChangeTemplateVisible:B,changeTemplateResources:I,changeTemplateEntityContext:a}=Ne();return R({on:"App\\Events\\Invoice\\InvoiceWasPaid",callback:()=>S(["invoices"])}),R({on:"App\\Events\\Payment\\PaymentWasUpdated",callback:()=>S(["payments"])}),R({on:["App\\Events\\Credit\\CreditWasCreated","App\\Events\\Credit\\CreditWasUpdated"],callback:()=>S(["credits"])}),c(Ce,{title:o,breadcrumbs:p,navigationTopRight:n&&(P("edit_client")||x(n))&&e(we,{resource:n,actions:u,saveButtonLabel:s("edit"),onSaveClick:()=>f(d("/clients/:id/edit",{id:i})),cypressRef:"clientActionDropdown"}),afterBreadcrumbs:e(Ie,{entity:"client"}),children:[m&&e(Se,{}),n&&c(y,{children:[c("div",{className:"grid grid-cols-12 lg:space-y-0 gap-4",children:[e(De,{client:n}),e(Me,{client:n}),e(Re,{client:n}),e($e,{client:n}),n.gateway_tokens.length>0&&e(Fe,{client:n}),e(Le,{}),e(je,{client:n}),e(Ge,{client:n})]}),e(Te,{tabs:h,className:"mt-6"}),e("div",{className:"my-4",children:e(Pe,{context:{isPurgeOrMergeActionCalled:l,displayName:n.display_name}})}),e(Ee,{entity:(a==null?void 0:a.entity)??"client",entities:I,visible:C,setVisible:B,labelFn:N=>`${s("number")}: ${N.number}`,bulkUrl:(a==null?void 0:a.endpoint)??"/api/v1/clients/bulk"})]})]})}export{ze as default};
cải xoăn