@accounter/client 0.0.8-alpha-20251023070808-bdd9d09db3d693f2c0061a2bbd66a4bfe5224012 → 0.0.8-alpha-20251023071148-6bed0891f04559f888e1e0d8bb275809dc36bf3b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/assets/{Checkbox-Bm30-WRa.js → Checkbox-lfqFDKZM.js} +2 -2
- package/dist/assets/{Progress-DxcT-wYo.js → Progress-DvGsu87E.js} +1 -1
- package/dist/assets/{Typography-CZLHs9y2.js → Typography-BX4mj53o.js} +1 -1
- package/dist/assets/{accordion-_VaDHoQb.js → accordion-lOk81yKP.js} +1 -1
- package/dist/assets/accountant-approvals-DWLEu1Um.js +1 -0
- package/dist/assets/{all-charges-DS-mdep6.js → all-charges-DhPxcK73.js} +1 -1
- package/dist/assets/{arrow-up-down-Bt3_puEZ.js → arrow-up-down-CFrneqND.js} +1 -1
- package/dist/assets/building-2-Bqvbwz7Q.js +6 -0
- package/dist/assets/business--eNnF4xF.js +42 -0
- package/dist/assets/business-header-DjutqTRC.js +1 -0
- package/dist/assets/{business-transactions-single-Canul8rR.js → business-transactions-single-CJ5pLN-D.js} +1 -1
- package/dist/assets/{business-trip-x8lljSMP.js → business-trip-Jlc0bfXC.js} +1 -1
- package/dist/assets/charges-filters-C-H07qp1.js +1 -0
- package/dist/assets/{charges-ledger-validation-wla_aWIc.js → charges-ledger-validation-Bln73m_U.js} +1 -1
- package/dist/assets/{chart-2uS7cQLX.js → chart-Wut6cPCx.js} +1 -1
- package/dist/assets/{data-table-pagination-CQQBbtVE.js → data-table-pagination-BnQGVnmE.js} +1 -1
- package/dist/assets/{editable-business-trip-D50scoPo.js → editable-business-trip-CjJg13b0.js} +2 -2
- package/dist/assets/index-BE5nnZYY.js +9 -0
- package/dist/assets/index-BQrSA2Kk.js +1 -0
- package/dist/assets/{index-CDHKPA0l.js → index-BX3VSsge.js} +1 -1
- package/dist/assets/{index-D_PykgGt.js → index-BagyRbeI.js} +2 -2
- package/dist/assets/index-BkeJsHyM.js +1 -0
- package/dist/assets/{index-BJ63UrPP.js → index-BoSqeUi7.js} +6 -6
- package/dist/assets/index-BtAgm6J8.js +1 -0
- package/dist/assets/index-BwIQ8ifH.js +1 -0
- package/dist/assets/index-Bxlzprxi.js +1 -0
- package/dist/assets/index-C--YkrHw.js +1 -0
- package/dist/assets/{index-BNPAKzBY.js → index-C2INIVq3.js} +1 -1
- package/dist/assets/{index-BsGG-RLV.js → index-CN7VPpiB.js} +13 -13
- package/dist/assets/index-CQXFj3Uj.css +1 -0
- package/dist/assets/{index-IN8Kpfsx.js → index-CVz9TqoS.js} +2 -2
- package/dist/assets/index-CalcGztb.js +1 -0
- package/dist/assets/{index-BTiGhl3N.js → index-Csqyxwgx.js} +2 -2
- package/dist/assets/{index-Dkqd5T8J.js → index-DjSJrgv5.js} +2 -2
- package/dist/assets/{index-CqZy7PVr.js → index-DquDHLbE.js} +1 -1
- package/dist/assets/index-Dr2UkUOm.js +1 -0
- package/dist/assets/index-E2rO9Bsf.js +1 -0
- package/dist/assets/index-Ggixi4PP.js +1 -0
- package/dist/assets/index-WCosiqtQ.js +1 -0
- package/dist/assets/index-vsZbkVMv.js +1 -0
- package/dist/assets/{index-B20Tn_iF.js → index-y8Z-aJKc.js} +2 -2
- package/dist/assets/{index.es-DKjfxgqg.js → index.es-D8leRAY2.js} +1 -1
- package/dist/assets/{issue-document-BFOjGS-U.js → issue-document-DKE0dzdE.js} +1 -1
- package/dist/assets/login-page-BYwtRBMd.js +1 -0
- package/dist/assets/{missing-info-charges-BnYMeatL.js → missing-info-charges-CgMJ4Bu3.js} +1 -1
- package/dist/assets/page-not-found-Cfte6bjZ.js +1 -0
- package/dist/assets/{pencil-DC6M9VTY.js → pencil-CUSCcyVn.js} +1 -1
- package/dist/assets/report-commentary-row-B-uxVnyO.js +1 -0
- package/dist/assets/save-qyt28nOG.js +6 -0
- package/dist/assets/sub-LLu8afpC.js +1 -0
- package/dist/assets/subMonths-C1UIPrOU.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +2 -2
- package/src/components/business/business-header.tsx +21 -2
- package/src/components/businesses/index.tsx +45 -36
- package/src/components/common/forms/index.ts +0 -1
- package/src/gql/gql.ts +6 -30
- package/src/gql/graphql.ts +7 -30
- package/dist/assets/accountant-approvals-C7GnMLyl.js +0 -1
- package/dist/assets/business-Db4PzgLz.js +0 -42
- package/dist/assets/charges-filters-DkO9FBdC.js +0 -1
- package/dist/assets/index-BP2Hv2J-.js +0 -1
- package/dist/assets/index-BaDl3RPI.js +0 -1
- package/dist/assets/index-BmSAw35b.js +0 -1
- package/dist/assets/index-Bskia9ol.js +0 -1
- package/dist/assets/index-C4JVZBO-.js +0 -1
- package/dist/assets/index-CzzfC-dD.css +0 -1
- package/dist/assets/index-D2w9iaKk.js +0 -1
- package/dist/assets/index-D5CFY1GF.js +0 -1
- package/dist/assets/index-DBjj2AmF.js +0 -1
- package/dist/assets/index-DJ33tRZ1.js +0 -1
- package/dist/assets/index-DKS2QKOQ.js +0 -1
- package/dist/assets/index-DOKYSdGb.js +0 -1
- package/dist/assets/index-Dk4NeG4m.js +0 -1
- package/dist/assets/index-OqG78rNq.js +0 -9
- package/dist/assets/login-page-CpRailN7.js +0 -1
- package/dist/assets/page-not-found-BLrYvmf4.js +0 -1
- package/dist/assets/report-commentary-row-DJPRyQur.js +0 -1
- package/dist/assets/save-Dr3CNkcl.js +0 -11
- package/dist/assets/similar-charges-by-business-modal-CCw5opHn.js +0 -1
- package/dist/assets/sub-DKnwnbwx.js +0 -1
- package/dist/assets/subMonths-B44KizJf.js +0 -1
- package/src/components/businesses/all-businesses-row.tsx +0 -87
- package/src/components/businesses/cells/hebrew-name.tsx +0 -31
- package/src/components/businesses/cells/index.ts +0 -2
- package/src/components/businesses/cells/name.tsx +0 -31
- package/src/components/common/forms/business-card.tsx +0 -234
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as s,F as h,u as v,U as C,ai as A,a as F,j as e,c as P,L as b,fr as y}from"./index-BsGG-RLV.js";import{C as j}from"./charges-filters-DkO9FBdC.js";import{P as D}from"./Progress-DxcT-wYo.js";import"./sub-DKnwnbwx.js";import"./subMonths-B44KizJf.js";const w=()=>{const{setFiltersContext:c}=s.useContext(h),{get:i}=v(),{userContext:p}=s.useContext(C),[a,x]=s.useState(i("chargesFilters")?JSON.parse(decodeURIComponent(i("chargesFilters"))):{byOwners:p?.context.adminBusinessId?[p?.context.adminBusinessId]:[],sortBy:{field:A.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:r,fetching:u}]=F({query:y,variables:{filters:a,page:1,limit:999999}}),t=r?.allCharges?.nodes.length??0;let o=0,l=0,n=0;r?.allCharges?.nodes.map(f=>{switch(f.accountantApproval){case"APPROVED":o+=1;break;case"PENDING":l+=1;break;case"UNAPPROVED":n+=1;break}});const d=100*o/t,g=100*l/t,m=100*n/t;return s.useEffect(()=>{c(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(j,{filter:a,setFilter:x,activePage:1,setPage:()=>{},totalPages:1})}))},[r,u,a,c,x]),e.jsx(P,{title:"Accountant Approvals Status",children:u?e.jsx(b,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"mx-10 mt-5 flex flex-col gap-5",children:[`Total charges: ${t}`,e.jsx(D,{color:"green",radius:"xl",size:"xl",sections:[{value:d,color:"green",label:`${d.toFixed(1)}% (${o})`},{value:g,color:"orange",label:`${g.toFixed(1)}% (${l})`},{value:m,color:"red",label:`${m.toFixed(1)}% (${n})`}]})]})})};export{w as AccountantApprovals};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import{V as ee,W as Ce,X as Se,Y as ie,p as be,r as N,t as B,s as we,Z as Ms,k as Ie,_ as Ee,D as je,j as e,$ as W,a0 as K,a1 as H,a2 as X,l as De,a3 as Q,a4 as j,a5 as g,a6 as f,a7 as y,Q as T,a8 as I,a9 as C,aa as Qe,B as E,ab as Us,ac as Pe,o as Ye,ad as V,ae as Cs,af as q,ag as zs,U as Ze,a as Oe,ah as qs,O as Gs,C as Ws,ai as Ks,aj as L,ak as ds,al as Hs,am as Xs,an as ue,ao as Je,ap as es,aq as G,ar as ss,as as ns,at as ts,au as as,av as he,aw as le,ax as ce,ay as oe,az as de,aA as me,aB as rs,aC as is,aD as Re,aE as re,aF as Me,aG as Ue,aH as Le,aI as Qs,aJ as se,aK as J,aL as Ys,aM as Zs,aN as Js,aO as ze,aP as en,aQ as sn,aR as nn,aS as tn,aT as an,aU as qe,aV as rn,aW as Ge,aX as ln,aY as bs,aZ as ws,a_ as cn,a$ as on,b0 as Is,b1 as ls,b2 as dn,b3 as ms,b4 as mn,b5 as un,b6 as hn,b7 as xn,b8 as pn,b9 as jn,ba as gn,bb as D,bc as fn,bd as cs,be as vn,bf as yn,bg as Nn,bh as Cn,bi as bn,bj as wn,bk as Z,bl as In,bm as Dn,bn as z,bo as An,bp as kn,bq as Sn,w as Tn,br as En}from"./index-BsGG-RLV.js";import{S as os,B as Ds}from"./save-Dr3CNkcl.js";import{i as Pn,D as On,f as Bn,E as Ln,L as Ve,a as Ae,C as Vn,A as _n,b as ve,c as Fn,d as We,h as $n,e as Rn,g as As,u as Mn,G as Un,j as us,k as zn,X as ks,Y as Ss,l as qn,m as Gn,R as Wn,n as Kn,o as Hn,p as Xn}from"./chart-2uS7cQLX.js";import{u as Ts,S as Qn}from"./similar-charges-by-business-modal-CCw5opHn.js";import{P as Yn}from"./pencil-DC6M9VTY.js";import{A as Zn,a as _e,b as Fe,c as hs}from"./accordion-_VaDHoQb.js";import"./sequential-CAnleQny.js";/**
|
|
2
|
-
* @license lucide-react v0.546.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Jn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],xs=ee("circle-check",Jn);/**
|
|
7
|
-
* @license lucide-react v0.546.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const et=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ke=ee("dollar-sign",et);/**
|
|
12
|
-
* @license lucide-react v0.546.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const st=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],nt=ee("file-check",st);/**
|
|
17
|
-
* @license lucide-react v0.546.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const tt=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Ke=ee("map-pin",tt);/**
|
|
22
|
-
* @license lucide-react v0.546.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const at=[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]],Es=ee("phone",at);/**
|
|
27
|
-
* @license lucide-react v0.546.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const rt=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],it=ee("plug",rt);/**
|
|
32
|
-
* @license lucide-react v0.546.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const lt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Ps=ee("shield",lt);/**
|
|
37
|
-
* @license lucide-react v0.546.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const ct=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],$e=ee("trending-up",ct);function Os(s){switch(s){case Ce.Annual:return"Annual";case Ce.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${s}`)}}function Bs(s){switch(s){case Se.Enterprise:return"Enterprise";case Se.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${s}`)}}function ot(s){return ie(s,"yyyy-MM-dd")}const dt="updateAdminBusiness",mt=()=>{const[{fetching:s},n]=be(Ms),t=N.useCallback(async a=>{const i=`Error updating admin business ID [${a.adminBusinessId}]`,l=`${dt}-${a.adminBusinessId}`;B.loading("Updating admin business",{id:l});try{const c=await n(a),r=we(c,i,l,"updateAdminBusiness");if(r)return B.success("Success",{id:l,description:"Admin Business Updated"}),r.updateAdminBusiness}catch(c){console.error(`${i}: ${c}`),B.error("Error",{id:l,description:i,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:t}},ut=Pe({employerWithholdingTaxAccountNumber:V().min(1,{message:"Employer Withholding Tax Account Number is required"}),taxPrepaymentId:V().min(1,{message:"Tax Prepayment ID is required"}),nationalInsuranceEmployerId:V().min(1,{message:"National Insurance Employer ID is required"}),advanceTaxRate:Cs().min(0,{message:"Advance Tax Rate must be at least 0"}).max(100,{message:"Advance Tax Rate must be at most 100"}),registrationDate:V().min(1,{message:"Registration Date is required"})});function ps(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{employerWithholdingTaxAccountNumber:s.adminInfo.employerWithholdingTaxAccountNumber??"",taxPrepaymentId:s.adminInfo.taxPrepaymentId??"",nationalInsuranceEmployerId:s.adminInfo.nationalInsuranceEmployerId??"",advanceTaxRate:s.adminInfo.advanceTaxRate??0,registrationDate:s.adminInfo.registrationDate??""}}function ht(s){return{employerWithholdingTaxAccountNumber:s.employerWithholdingTaxAccountNumber,taxPrepaymentId:s.taxPrepaymentId,nationalInsuranceEmployerId:s.nationalInsuranceEmployerId,advanceTaxRate:s.advanceTaxRate,registrationDate:s.registrationDate?ot(new Date(s.registrationDate)):void 0}}function xt({data:s,refetchBusiness:n}){const t=je(Us,s),[a,i]=N.useState(ps(t)),{updateAdminBusiness:l,fetching:c}=mt(),r=Ie({resolver:Ee(ut),defaultValues:a}),o=async d=>{if(!t)return;const x=Ye(d,r.formState.dirtyFields);if(!x)return;const u=ht(x);await l({adminBusinessId:t.id,fields:u}),n?.()};return N.useEffect(()=>{if(t){const d=ps(t);i(d),r.reset(d)}},[t,r]),e.jsxs(W,{children:[e.jsxs(K,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ps,{className:"h-5 w-5 text-primary"}),e.jsx(H,{children:"Admin Business Configuration"})]}),e.jsx(X,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(De,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(o),className:"space-y-6",children:[e.jsx(Q,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:r.control,name:"employerWithholdingTaxAccountNumber",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Employer Withholding Tax Account Number"}),e.jsx(y,{children:e.jsx(T,{placeholder:"Enter account number",...d,className:I(x)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"taxPrepaymentId",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Prepayment ID"}),e.jsx(y,{children:e.jsx(T,{placeholder:"Enter prepayment ID",...d,className:I(x)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"nationalInsuranceEmployerId",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"National Insurance Employer ID"}),e.jsx(y,{children:e.jsx(T,{placeholder:"Enter employer ID",...d,className:I(x)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"advanceTaxRate",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Advance Tax Rate (%)"}),e.jsx(y,{children:e.jsx(T,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"Enter tax rate",...d,className:I(x)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"registrationDate",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Registration Date"}),e.jsx(y,{children:e.jsx(T,{type:"date",...d,className:I(x)})}),e.jsx(C,{})]})})]})}),e.jsx(Qe,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:c||Object.keys(r.formState.dirtyFields).length===0||!r.formState.isValid,children:[e.jsx(os,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function pt({data:s}){const n=je(zs,s);return!n||n.__typename!=="LtdFinancialEntity"?e.jsx("div",{}):e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border bg-card/95 backdrop-blur supports-[backdrop-filter]:bg-card/60",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs("div",{className:"flex h-16 items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-accent",children:e.jsx(Ds,{className:"h-5 w-5 text-accent-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:n.name}),e.jsx(q,{variant:"secondary",children:"Active"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["Business ID: ",n.id]})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-6 text-sm",children:[n.governmentId&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"font-medium text-foreground",children:n.governmentId})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Since"}),e.jsx("p",{className:"font-medium text-foreground",children:ie(n.createdAt,"MMM yyyy")})]})]})]})})})}function jt({businessId:s}){const{userContext:n}=N.useContext(Ze),[t,a]=N.useState(1),[{data:i,fetching:l}]=Oe({query:qs,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:Ks.Date,asc:!1},byBusinesses:[s]},page:t,limit:100}}),c=i?.allCharges?.pageInfo.totalPages??1,r=i?.allCharges?.nodes??[];return l?e.jsx("div",{children:"Loading charges..."}):e.jsxs(W,{children:[e.jsxs(K,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(H,{children:"Charges"}),e.jsx(X,{children:"Recurring and one-time charges for this business"})]})}),c>1&&e.jsx(Gs,{className:"flex-fit",value:t,onChange:a,total:c})]}),e.jsx(Q,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ws,{data:r,isAllOpened:!1})})})]})}var gt=["type","layout","connectNulls","ref"],ft=["key"];function xe(s){"@babel/helpers - typeof";return xe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},xe(s)}function js(s,n){if(s==null)return{};var t=vt(s,n),a,i;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(s);for(i=0;i<l.length;i++)a=l[i],!(n.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(s,a)&&(t[a]=s[a])}return t}function vt(s,n){if(s==null)return{};var t={};for(var a in s)if(Object.prototype.hasOwnProperty.call(s,a)){if(n.indexOf(a)>=0)continue;t[a]=s[a]}return t}function Ne(){return Ne=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(s[a]=t[a])}return s},Ne.apply(this,arguments)}function gs(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);n&&(a=a.filter(function(i){return Object.getOwnPropertyDescriptor(s,i).enumerable})),t.push.apply(t,a)}return t}function F(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?gs(Object(t),!0).forEach(function(a){M(s,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):gs(Object(t)).forEach(function(a){Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(t,a))})}return s}function ae(s){return bt(s)||Ct(s)||Nt(s)||yt()}function yt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
42
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nt(s,n){if(s){if(typeof s=="string")return He(s,n);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(s);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return He(s,n)}}function Ct(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function bt(s){if(Array.isArray(s))return He(s)}function He(s,n){(n==null||n>s.length)&&(n=s.length);for(var t=0,a=new Array(n);t<n;t++)a[t]=s[t];return a}function wt(s,n){if(!(s instanceof n))throw new TypeError("Cannot call a class as a function")}function fs(s,n){for(var t=0;t<n.length;t++){var a=n[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(s,Vs(a.key),a)}}function It(s,n,t){return n&&fs(s.prototype,n),t&&fs(s,t),Object.defineProperty(s,"prototype",{writable:!1}),s}function Dt(s,n,t){return n=Te(n),At(s,Ls()?Reflect.construct(n,t||[],Te(s).constructor):n.apply(s,t))}function At(s,n){if(n&&(xe(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kt(s)}function kt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ls(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ls=function(){return!!s})()}function Te(s){return Te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Te(s)}function St(s,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(n&&n.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),n&&Xe(s,n)}function Xe(s,n){return Xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,i){return a.__proto__=i,a},Xe(s,n)}function M(s,n,t){return n=Vs(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Vs(s){var n=Tt(s,"string");return xe(n)=="symbol"?n:n+""}function Tt(s,n){if(xe(s)!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var a=t.call(s,n);if(xe(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var pe=(function(s){function n(){var t;wt(this,n);for(var a=arguments.length,i=new Array(a),l=0;l<a;l++)i[l]=arguments[l];return t=Dt(this,n,[].concat(i)),M(t,"state",{isAnimationFinished:!0,totalLength:0}),M(t,"generateSimpleStrokeDasharray",function(c,r){return"".concat(r,"px ").concat(c-r,"px")}),M(t,"getStrokeDasharray",function(c,r,o){var d=o.reduce(function(b,S){return b+S});if(!d)return t.generateSimpleStrokeDasharray(r,c);for(var x=Math.floor(c/d),u=c%d,h=r-c,A=[],m=0,p=0;m<o.length;p+=o[m],++m)if(p+o[m]>u){A=[].concat(ae(o.slice(0,m)),[u-p]);break}var k=A.length%2===0?[0,h]:[h];return[].concat(ae(n.repeat(o,x)),ae(A),k).map(function(b){return"".concat(b,"px")}).join(", ")}),M(t,"id",Mn("recharts-line-")),M(t,"pathRef",function(c){t.mainCurve=c}),M(t,"handleAnimationEnd",function(){t.setState({isAnimationFinished:!0}),t.props.onAnimationEnd&&t.props.onAnimationEnd()}),M(t,"handleAnimationStart",function(){t.setState({isAnimationFinished:!1}),t.props.onAnimationStart&&t.props.onAnimationStart()}),t}return St(n,s),It(n,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();this.setState({totalLength:a})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();a!==this.state.totalLength&&this.setState({totalLength:a})}}},{key:"getTotalLength",value:function(){var a=this.mainCurve;try{return a&&a.getTotalLength&&a.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(a,i){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.points,r=l.xAxis,o=l.yAxis,d=l.layout,x=l.children,u=Bn(x,Ln);if(!u)return null;var h=function(p,k){return{x:p.x,y:p.y,value:p.value,errorVal:As(p.payload,k)}},A={clipPath:a?"url(#clipPath-".concat(i,")"):null};return L.createElement(Ve,A,u.map(function(m){return L.cloneElement(m,{key:"bar-".concat(m.props.dataKey),data:c,xAxis:r,yAxis:o,layout:d,dataPointFormatter:h})}))}},{key:"renderDots",value:function(a,i,l){var c=this.props.isAnimationActive;if(c&&!this.state.isAnimationFinished)return null;var r=this.props,o=r.dot,d=r.points,x=r.dataKey,u=Ae(this.props,!1),h=Ae(o,!0),A=d.map(function(p,k){var b=F(F(F({key:"dot-".concat(k),r:3},u),h),{},{index:k,cx:p.x,cy:p.y,value:p.value,dataKey:x,payload:p.payload,points:d});return n.renderDotItem(o,b)}),m={clipPath:a?"url(#clipPath-".concat(i?"":"dots-").concat(l,")"):null};return L.createElement(Ve,Ne({className:"recharts-line-dots",key:"dots"},m),A)}},{key:"renderCurveStatically",value:function(a,i,l,c){var r=this.props,o=r.type,d=r.layout,x=r.connectNulls;r.ref;var u=js(r,gt),h=F(F(F({},Ae(u,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:i?"url(#clipPath-".concat(l,")"):null,points:a},c),{},{type:o,layout:d,connectNulls:x});return L.createElement(Vn,Ne({},h,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,i){var l=this,c=this.props,r=c.points,o=c.strokeDasharray,d=c.isAnimationActive,x=c.animationBegin,u=c.animationDuration,h=c.animationEasing,A=c.animationId,m=c.animateNewValues,p=c.width,k=c.height,b=this.state,S=b.prevPoints,_=b.totalLength;return L.createElement(_n,{begin:x,duration:u,isActive:d,easing:h,from:{t:0},to:{t:1},key:"line-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(R){var $=R.t;if(S){var Y=S.length/r.length,U=r.map(function(O,Be){var ge=Math.floor(Be*Y);if(S[ge]){var fe=S[ge],te=ve(fe.x,O.x),Fs=ve(fe.y,O.y);return F(F({},O),{},{x:te($),y:Fs($)})}if(m){var $s=ve(p*2,O.x),Rs=ve(k/2,O.y);return F(F({},O),{},{x:$s($),y:Rs($)})}return F(F({},O),{},{x:O.x,y:O.y})});return l.renderCurveStatically(U,a,i)}var ne=ve(0,_),v=ne($),w;if(o){var P="".concat(o).split(/[,\s]+/gim).map(function(O){return parseFloat(O)});w=l.getStrokeDasharray(v,_,P)}else w=l.generateSimpleStrokeDasharray(_,v);return l.renderCurveStatically(r,a,i,{strokeDasharray:w})})}},{key:"renderCurve",value:function(a,i){var l=this.props,c=l.points,r=l.isAnimationActive,o=this.state,d=o.prevPoints,x=o.totalLength;return r&&c&&c.length&&(!d&&x>0||!Fn(d,c))?this.renderCurveWithAnimation(a,i):this.renderCurveStatically(c,a,i)}},{key:"render",value:function(){var a,i=this.props,l=i.hide,c=i.dot,r=i.points,o=i.className,d=i.xAxis,x=i.yAxis,u=i.top,h=i.left,A=i.width,m=i.height,p=i.isAnimationActive,k=i.id;if(l||!r||!r.length)return null;var b=this.state.isAnimationFinished,S=r.length===1,_=ds("recharts-line",o),R=d&&d.allowDataOverflow,$=x&&x.allowDataOverflow,Y=R||$,U=We(k)?this.id:k,ne=(a=Ae(c,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},v=ne.r,w=v===void 0?3:v,P=ne.strokeWidth,O=P===void 0?2:P,Be=$n(c)?c:{},ge=Be.clipDot,fe=ge===void 0?!0:ge,te=w*2+O;return L.createElement(Ve,{className:_},R||$?L.createElement("defs",null,L.createElement("clipPath",{id:"clipPath-".concat(U)},L.createElement("rect",{x:R?h:h-A/2,y:$?u:u-m/2,width:R?A:A*2,height:$?m:m*2})),!fe&&L.createElement("clipPath",{id:"clipPath-dots-".concat(U)},L.createElement("rect",{x:h-te/2,y:u-te/2,width:A+te,height:m+te}))):null,!S&&this.renderCurve(Y,U),this.renderErrorBar(Y,U),(S||c)&&this.renderDots(Y,fe,U),(!p||b)&&Rn.renderCallByParent(this.props,r))}}],[{key:"getDerivedStateFromProps",value:function(a,i){return a.animationId!==i.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,prevPoints:i.curPoints}:a.points!==i.curPoints?{curPoints:a.points}:null}},{key:"repeat",value:function(a,i){for(var l=a.length%2!==0?[].concat(ae(a),[0]):a,c=[],r=0;r<i;++r)c=[].concat(ae(c),ae(l));return c}},{key:"renderDotItem",value:function(a,i){var l;if(L.isValidElement(a))l=L.cloneElement(a,i);else if(Pn(a))l=a(i);else{var c=i.key,r=js(i,ft),o=ds("recharts-line-dot",typeof a!="boolean"?a.className:"");l=L.createElement(On,Ne({key:c},r,{className:o}))}return l}}])})(N.PureComponent);M(pe,"displayName","Line");M(pe,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Un.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});M(pe,"getComposedData",function(s){var n=s.props,t=s.xAxis,a=s.yAxis,i=s.xAxisTicks,l=s.yAxisTicks,c=s.dataKey,r=s.bandSize,o=s.displayedData,d=s.offset,x=n.layout,u=o.map(function(h,A){var m=As(h,c);return x==="horizontal"?{x:us({axis:t,ticks:i,bandSize:r,entry:h,index:A}),y:We(m)?null:a.scale(m),value:m,payload:h}:{x:We(m)?null:t.scale(m),y:us({axis:a,ticks:l,bandSize:r,entry:h,index:A}),value:m,payload:h}});return F({points:u,layout:x},d)});var Et=zn({chartName:"LineChart",GraphicalChild:pe,axisComponents:[{axisType:"xAxis",AxisComp:ks},{axisType:"yAxis",AxisComp:Ss}],formatAxisMap:qn});const ye=[{month:"Jan",revenue:12500,expenses:8200},{month:"Feb",revenue:15800,expenses:9100},{month:"Mar",revenue:18200,expenses:10500},{month:"Apr",revenue:16900,expenses:9800},{month:"May",revenue:21300,expenses:11200},{month:"Jun",revenue:24500,expenses:12800},{month:"Jul",revenue:22800,expenses:11900},{month:"Aug",revenue:26100,expenses:13500},{month:"Sep",revenue:28900,expenses:14200},{month:"Oct",revenue:31200,expenses:15100}];function Pt(){const s=ye.reduce((t,a)=>t+a.revenue,0),n=s/ye.length;return e.jsxs(W,{children:[e.jsxs(K,{children:[e.jsx(H,{children:"Revenue Analytics"}),e.jsx(X,{children:"Revenue and expenses over time"})]}),e.jsxs(Q,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3 mb-6",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Total Revenue"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",s.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx($e,{className:"h-3 w-3"}),e.jsx("span",{children:"+24.5% from last period"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",n.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx($e,{className:"h-3 w-3"}),e.jsx("span",{children:"+18.2% growth rate"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",ye[ye.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx($e,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Gn,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Wn,{width:"100%",height:"100%",children:e.jsxs(Et,{data:ye,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Kn,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(ks,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ss,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Hn,{content:e.jsx(Xn,{})}),e.jsx(pe,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(pe,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Ot="insertClient",Bt=()=>{const[{fetching:s},n]=be(Hs),t=N.useCallback(async a=>{const i=`Error creating client [${a.fields.businessId}]`,l=`${Ot}-${a.fields.businessId}`;B.loading("Creating Client...",{id:l});try{const c=await n(a),r=we(c,i,l,"insertClient");if(r)return B.success("Success",{id:l,description:`Client [${a.fields.businessId}] was created`}),r.insertClient}catch(c){console.error(`${i}: ${c}`),B.error("Error",{id:l,description:i,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertClient:t}},Lt="updateClient",_s=()=>{const[{fetching:s},n]=be(Xs),t=N.useCallback(async a=>{const i=`Error updating client ID [${a.businessId}]`,l=`${Lt}-${a.businessId}`;B.loading("Updating client",{id:l});try{const c=await n(a),r=we(c,i,l,"updateClient");if(r)return B.success("Success",{id:l,description:"Client updated"}),r.updateClient}catch(c){console.error(`${i}: ${c}`),B.error("Error",{id:l,description:i,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateClient:t}},Vt=Pe({id:Re().optional(),emails:Me(Ue()).optional(),generatedDocumentType:re(Object.values(ue)),greenInvoiceId:Re().optional(),hiveId:V().optional()});function _t({client:s,businessId:n,onDone:t}){const[a,i]=N.useState(!1),[l,c]=N.useState(null),{updateClient:r}=_s(),{insertClient:o}=Bt(),[d,x]=N.useState(""),u={id:n,generatedDocumentType:ue.Proforma,emails:[]},h=Ie({resolver:Ee(Vt),defaultValues:s||u});N.useEffect(()=>{s&&(c(s),h.reset({emails:s.emails,greenInvoiceId:s.greenInvoiceId,hiveId:s.hiveId,generatedDocumentType:s.generatedDocumentType,id:s.id}),i(!0))},[s,h]);const A=()=>{c(null),h.reset(u),i(!0)},m=()=>{if(d.trim()){const b=h.getValues("emails");h.setValue("emails",[...b??[],d.trim()],{shouldDirty:!0}),x("")}},p=b=>{const S=h.getValues("emails");h.setValue("emails",(S??[]).filter((_,R)=>R!==b),{shouldDirty:!0})},k=N.useCallback(async b=>{if(l)r({businessId:n,fields:b});else{if(!b.greenInvoiceId){h.setError("greenInvoiceId",{message:"Green Invoice ID is required"});return}o({fields:{...b,greenInvoiceId:b.greenInvoiceId,businessId:n}})}i(!1),c(null),t?.()},[l,t,r,n,o,h]);return e.jsxs(Je,{open:a,onOpenChange:i,children:[e.jsx(es,{asChild:!0,children:e.jsxs(E,{size:"sm",onClick:A,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"New Client"]})}),e.jsxs(ss,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ns,{children:[e.jsx(ts,{children:l?"Edit Client":"Create New Client"}),e.jsx(as,{children:l?"Update client details":"Add a new client with all required details"})]}),e.jsx(De,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(k),children:[e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:h.control,name:"emails",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Emails"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add email...",value:d,onChange:S=>x(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),m())}}),e.jsx(E,{type:"button",size:"sm",onClick:m,children:e.jsx(G,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.value?.map((S,_)=>e.jsxs(q,{variant:"secondary",className:"gap-1",children:[S,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>p(_),children:e.jsx(he,{className:"size-3 cursor-pointer"})})]},_))}),e.jsx(C,{})]})}),e.jsx(j,{control:h.control,name:"generatedDocumentType",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Document Type"}),e.jsxs(le,{onValueChange:b.onChange,defaultValue:b.value,children:[e.jsx(y,{children:e.jsx(ce,{children:e.jsx(oe,{})})}),e.jsx(de,{children:Object.values(ue).map(S=>e.jsx(me,{value:S,children:rs(S)},S))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:h.control,name:"greenInvoiceId",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Green Invoice ID"}),e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:"Enter Green Invoice ID",...b,required:!l})}),e.jsx(C,{})]})}),e.jsx(j,{control:h.control,name:"hiveId",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Hive ID"}),e.jsx(y,{children:e.jsx(T,{type:"text",placeholder:"Enter Hive ID",...b,required:!l})}),e.jsx(C,{})]})})]})}),e.jsxs(is,{children:[e.jsx(E,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(E,{type:"submit",children:l?"Update Client":"Create Client"})]})]})})]})]})}const Ft=Object.values(tn);function vs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{isClient:!!s.clientInfo?.id,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough??void 0,isDocumentsOptional:s.isDocumentsOptional??void 0,isVatOptional:s.optionalVAT??void 0,isExemptDealer:s.exemptDealer??void 0,sortCode:s.sortCode?.key?.toString()??void 0,taxCategory:s.taxCategory?.id??void 0,pcn874RecordType:s?.pcn874RecordType??void 0,irsCode:s?.irsCode??void 0,description:s.suggestions?.description??void 0,tags:s.suggestions?.tags?.map(n=>n.id)??[],phrases:s.suggestions?.phrases??[],emails:s.suggestions?.emails??[],internalLinks:s.suggestions?.emailListener?.internalEmailLinks??[],attachmentTypes:s.suggestions?.emailListener?.attachments??[],useMessageBody:s.suggestions?.emailListener?.emailBody??void 0}}function $t(s){const t=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,i=s.description||s.tags||s.phrases||s.emails||t?{description:s.description,tags:s.tags?.map(l=>({id:l})),phrases:s.phrases,emails:s.emails,emailListener:t}:void 0;return{optionalVAT:s.isVatOptional,exemptDealer:s.isExemptDealer,sortCode:s.sortCode?parseInt(s.sortCode):void 0,taxCategory:s.taxCategory,pcn874RecordType:s.pcn874RecordType,irsCode:s.irsCode,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough,isDocumentsOptional:s.isDocumentsOptional,suggestions:i}}function Rt({data:s,refetchBusiness:n}){const t=je(Qs,s),[a,i]=N.useState(vs(t)),{userContext:l}=N.useContext(Ze),{updateBusiness:c,fetching:r}=Ts(),[o,d]=N.useState(!1),[x,u]=N.useState(void 0),h=Ie({defaultValues:a}),A=async p=>{if(!t||!l?.context.adminBusinessId)return;const k=Ye(p,h.formState.dirtyFields);if(!k)return;const b=$t(k);await c({businessId:t.id,ownerId:l.context.adminBusinessId,fields:b}),k.tags?.length||k.description?(u({tagIds:k.tags?.map(S=>({id:S})),description:k.description}),d(!0)):n?.()};if(N.useEffect(()=>{if(t){const p=vs(t);i(p),h.reset(p)}},[t,h]),!t)return e.jsx("div",{});const m=h.watch("isClient");return e.jsxs(W,{children:[e.jsx(K,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(H,{children:"Configurations"}),e.jsx(X,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!m&&e.jsx(_t,{businessId:t.id,onDone:n})]})}),e.jsx(De,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(A),children:[e.jsxs(Q,{className:"space-y-6",children:[e.jsx(Mt,{form:h}),e.jsx(Le,{}),e.jsx(Ut,{form:h}),e.jsx(Le,{}),e.jsx(zt,{form:h}),e.jsx(Le,{}),e.jsx(qt,{form:h})]}),e.jsx(Qe,{className:"flex justify-end border-t pt-6",children:e.jsxs(E,{type:"submit",disabled:r||Object.keys(h.formState.dirtyFields).length===0,children:[e.jsx(os,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(Qn,{businessId:t.id,tagIds:x?.tagIds,description:x?.description,open:o,onOpenChange:d,onClose:n})]})}function Mt({form:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Business Status & Behavior"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:s.control,name:"isClient",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Client"}),e.jsx(se,{children:"Mark this business as a client"})]}),e.jsx(y,{children:e.jsx(J,{disabled:!0,checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Active"}),e.jsx(se,{children:"Business is currently active"})]}),e.jsx(y,{children:e.jsx(J,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Receipt Enough"}),e.jsx(se,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(y,{children:e.jsx(J,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"No Docs Required"}),e.jsx(se,{children:"Skip document validation for common charges"})]}),e.jsx(y,{children:e.jsx(J,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is VAT Optional"}),e.jsx(se,{children:"Mute missing VAT indicator"})]}),e.jsx(y,{children:e.jsx(J,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Exempt Dealer"}),e.jsx(se,{children:"Business is exempt from VAT requirements"})]}),e.jsx(y,{children:e.jsx(J,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})})]})]})}function Ut({form:s}){const{selectableTaxCategories:n,fetching:t}=Ys(),{selectableSortCodes:a,fetching:i,sortCodes:l}=Zs(),{selectableTags:c,fetching:r}=Js(),o=N.useCallback(d=>{if(d){const x=l.find(u=>Number(u.key)===Number(d));x&&(x.defaultIrsCode?s.setValue("irsCode",x.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,l]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Default Settings"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:s.control,name:"sortCode",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(y,{children:e.jsx(ze,{onChange:u=>{o(u),d.onChange(u)},data:a,value:d.value,disabled:i,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:I(x)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(y,{children:e.jsx(ze,{data:n,disabled:t,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:I(x)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(le,{onValueChange:d.onChange,value:d.value,children:[e.jsx(y,{children:e.jsx(ce,{className:I(x),children:e.jsx(oe,{})})}),e.jsx(de,{children:Object.entries(en).map(([u,h])=>e.jsx(me,{value:u,children:`${h} (${u})`},u))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(y,{children:e.jsx(sn,{value:d.value??void 0,onValueChange:u=>d.onChange(u??null),hideControls:!0,decimalScale:0,className:I(x)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(y,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:I(x)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(y,{children:e.jsx(nn,{options:Object.values(c).map(({value:u,label:h})=>({label:h,value:u})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:r,className:I(x)})}),e.jsx(C,{})]})})]})]})}function zt({form:s}){const[n,t]=N.useState(""),[a,i]=N.useState(""),l=()=>{if(n.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,n.trim()],{shouldDirty:!0}),t("")}},c=()=>{if(a.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,a.trim()],{shouldDirty:!0}),i("")}},r=d=>{const x=s.getValues("phrases");s.setValue("phrases",x.filter((u,h)=>h!==d),{shouldDirty:!0})},o=d=>{const x=s.getValues("emails");s.setValue("emails",x.filter((u,h)=>h!==d),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Auto-matching Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure patterns for automatic matching of bank transactions and documents"}),e.jsx(j,{control:s.control,name:"phrases",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:n,onChange:u=>t(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),l())},className:I(x)}),e.jsx(E,{type:"button",size:"sm",onClick:l,children:e.jsx(G,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,h)=>e.jsxs(q,{variant:"secondary",className:"gap-1",children:[u,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>r(h),children:e.jsx(he,{className:"size-3 cursor-pointer",onClick:()=>r(h)})})]},h))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:d,fieldState:x})=>e.jsxs(g,{children:[e.jsx(f,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"email",placeholder:"Add email...",value:a,onChange:u=>i(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),c())},className:I(x)}),e.jsx(E,{type:"button",size:"sm",onClick:c,children:e.jsx(G,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,h)=>e.jsxs(q,{variant:"secondary",className:"gap-1",children:[u,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(h),children:e.jsx(he,{className:"size-3 cursor-pointer"})})]},h))}),e.jsx(C,{})]})})]})}function qt({form:s}){const[n,t]=N.useState(""),a=()=>{if(n.trim()){const c=s.getValues("internalLinks");s.setValue("internalLinks",[...c,n.trim()],{shouldDirty:!0}),t("")}},i=c=>{const r=s.getValues("attachmentTypes");s.setValue("attachmentTypes",r?.includes(c)?r.filter(o=>o!==c):[...r,c],{shouldDirty:!0})},l=c=>{const r=s.getValues("internalLinks");s.setValue("internalLinks",r.filter((o,d)=>d!==c),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Gmail Feature Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Gmail integration settings for document processing"}),e.jsx(j,{control:s.control,name:"attachmentTypes",render:({field:c,fieldState:r})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:I(r)+" rounded-md flex flex-wrap gap-2",children:Ft.map(o=>e.jsx(q,{variant:c.value?.includes(o)?"default":"outline",className:"cursor-pointer",onClick:()=>i(o),children:o},o))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:c,fieldState:r})=>e.jsxs(g,{children:[e.jsx(f,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"url",placeholder:"Add internal link...",value:n,onChange:o=>t(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),a())}}),e.jsx(E,{type:"button",size:"sm",onClick:a,children:e.jsx(G,{className:"h-4 w-4"})})]}),e.jsx("div",{className:I(r)+" flex flex-wrap gap-2 rounded-md",children:c.value?.map((o,d)=>e.jsxs(q,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[o,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>l(d),children:e.jsx(he,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:c,fieldState:r})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Should Use Message Body"}),e.jsx(se,{children:"Extract information from email message body"})]}),e.jsx(y,{children:e.jsx(J,{checked:c.value,onCheckedChange:c.onChange,className:I(r)})})]})})]})}const Gt=Pe({businessName:V().min(1,"Business name is required"),locality:V().min(1,"Locality is required"),localName:V().optional(),govId:V().optional(),address:V().optional(),localAddress:V().optional(),phone:V().optional(),website:bs("Invalid URL").optional().or(ws("")),generalContacts:Me(Ue()).optional(),billingEmails:Me(Ue()).optional()});function ys(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(n=>n.trim()),billingEmails:s.clientInfo?.emails}}function Wt(s){return{name:s.businessName,country:s.locality,hebrewName:s.localName,governmentId:s.govId,address:s.address,phoneNumber:s.phone,website:s.website,email:s.generalContacts?.join(", ")}}function Kt({data:s,refetchBusiness:n}){const t=je(ln,s),[a,i]=N.useState(ys(t)),{userContext:l}=N.useContext(Ze),{updateBusiness:c,fetching:r}=Ts(),o=Ie({resolver:Ee(Gt),defaultValues:a}),{countries:d,fetching:x}=an(),[u,h]=N.useState(""),[A,m]=N.useState(""),p=o.watch("locality"),k=o.watch("address"),b=o.watch("localAddress");N.useEffect(()=>{k!==a.address&&o.setValue("address",k,{shouldDirty:!0})},[k,a.address,o]),N.useEffect(()=>{b!==a.localAddress&&o.setValue("localAddress",b,{shouldDirty:!0})},[b,a.localAddress,o]);const S=t&&"clientInfo"in t&&!!t.clientInfo,_=p===l?.context.locality,R=v=>{u.trim()&&(o.setValue("generalContacts",[...v,u.trim()],{shouldDirty:!0}),h(""))},$=(v,w)=>{o.setValue("generalContacts",v.filter((P,O)=>O!==w),{shouldDirty:!0})},Y=v=>{A.trim()&&(o.setValue("billingEmails",[...v,A.trim()],{shouldDirty:!0}),m(""))},U=(v,w)=>{o.setValue("billingEmails",v.filter((P,O)=>O!==w),{shouldDirty:!0})},ne=async v=>{if(!t||!l?.context.adminBusinessId)return;const w=Ye(v,o.formState.dirtyFields);if(!w)return;const P=Wt(w);await c({businessId:t.id,ownerId:l.context.adminBusinessId,fields:P}),n?.()};return N.useEffect(()=>{if(t){const v=ys(t);i(v),o.reset(v)}},[t,o]),e.jsxs(W,{children:[e.jsxs(K,{children:[e.jsx(H,{children:"Contact Information"}),e.jsx(X,{children:"Business contact details and address information"})]}),e.jsx(De,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(ne),children:[e.jsx(Q,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:o.control,name:"businessName",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(y,{children:e.jsx(T,{...v,className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"locality",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(ze,{onChange:v.onChange,data:d.map(P=>({value:P.code,label:P.name})),value:v.value,disabled:x,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:I(w)}}),e.jsx(C,{})]})}),_&&e.jsx(j,{control:o.control,name:"localName",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(y,{children:e.jsx(T,{...v,placeholder:"Business name in local language",className:I(w)})}),e.jsx(C,{})]})}),_&&e.jsx(j,{control:o.control,name:"govId",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(y,{children:e.jsx(T,{...v,placeholder:"Enter Government ID",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"address",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"Address"]}),e.jsx(y,{children:e.jsx(qe,{...v,rows:3,placeholder:"Enter business address",className:I(w)})}),e.jsx(C,{})]})}),_&&e.jsx(j,{control:o.control,name:"localAddress",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(y,{children:e.jsx(qe,{...v,rows:3,placeholder:"Enter address in local language",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"phone",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Es,{className:"h-4 w-4"}),"Phone"]}),e.jsx(y,{children:e.jsx(T,{...v,type:"tel",placeholder:"+1 (555) 123-4567",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"website",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),"Website"]}),e.jsx(y,{children:e.jsx(T,{...v,type:"url",placeholder:"https://example.com",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"generalContacts",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:I(w)+" flex flex-wrap gap-2 mb-2 rounded-md",children:v.value?.map((P,O)=>e.jsxs(q,{variant:"secondary",className:"gap-1 pr-1",children:[P,e.jsx("button",{type:"button",onClick:()=>$(v.value??[],O),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(he,{className:"h-3 w-3"})})]},O))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:u,onChange:P=>h(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),R(v.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!u.trim(),onClick:()=>R(v.value??[]),children:e.jsx(G,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})}),S&&e.jsx(j,{control:o.control,name:"billingEmails",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Ge,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:I(w)+" flex flex-wrap gap-2 mb-2 rounded-md",children:v.value?.map((P,O)=>e.jsxs(q,{variant:"secondary",className:"gap-1 pr-1",children:[P,e.jsx("button",{type:"button",onClick:()=>U(v.value??[],O),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(he,{className:"h-3 w-3"})})]},O))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:A,onChange:P=>m(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),Y(v.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!A.trim(),onClick:()=>Y(v.value??[]),children:e.jsx(G,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})})]})}),e.jsx(Qe,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:r||Object.keys(o.formState.dirtyFields).length===0,children:[e.jsx(os,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const Ht="createContract",Xt=()=>{const[{fetching:s},n]=be(cn),t=N.useCallback(async a=>{const i=`Error creating new contract for client[${a.input.clientId}]`,l=`${Ht}-${a.input.clientId}`;B.loading("Creating contract",{id:l});try{const c=await n(a);we(c,i,l)&&B.success("Success",{id:l,description:`Contract for client ${a.input.clientId} was successfully created`})}catch(c){console.error(`${i}: ${c}`),B.error("Error",{id:l,description:i,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createContract:t}},Qt="updateContract",Yt=()=>{const[{fetching:s},n]=be(on),t=N.useCallback(async a=>{const i=`Error updating contract ID [${a.contractId}]`,l=`${Qt}-${a.contractId}`;B.loading("Updating contract",{id:l});try{const c=await n(a),r=we(c,i,l,"updateContract");if(r)return B.success("Success",{id:l,description:"Contract updated"}),r.updateContract}catch(c){console.error(`${i}: ${c}`),B.error("Error",{id:l,description:i,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateContract:t}},Zt=Pe({id:Re().optional(),startDate:ms("Start date is required"),endDate:ms("End date is required"),po:V().optional(),paymentAmount:Cs().min(0,"Payment amount must be non-negative"),paymentCurrency:re(Object.values(ls),"Currency is required"),productType:re(Object.values(Is)).optional(),msCloudLink:bs().optional().or(ws("")),billingCycle:re(Object.values(Ce)).optional(),subscriptionPlan:re(Object.values(Se)).optional(),isActive:dn(),defaultRemark:V().optional(),defaultDocumentType:re(Object.values(ue))}),Ns={startDate:"",endDate:"",po:void 0,paymentAmount:0,paymentCurrency:ls.Usd,productType:Is.Hive,msCloudLink:void 0,billingCycle:Ce.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:ue.Proforma};function Jt({clientId:s,contract:n,onDone:t}){const[a,i]=N.useState(!1),[l,c]=N.useState(null),{updateContract:r,updating:o}=Yt(),{createContract:d,creating:x}=Xt(),u=Ie({resolver:Ee(Zt),defaultValues:n||Ns});N.useEffect(()=>{n&&(c(n),u.reset({startDate:n.startDate,endDate:n.endDate,po:n.po,paymentAmount:n.paymentAmount,paymentCurrency:n.paymentCurrency,productType:n.productType,msCloudLink:n.msCloudLink,billingCycle:n.billingCycle,subscriptionPlan:n.subscriptionPlan,isActive:n.isActive,defaultRemark:n.defaultRemark,defaultDocumentType:n.defaultDocumentType}),i(!0))},[n,u]);const h=()=>{c(null),u.reset(Ns),i(!0)},A=N.useCallback(async m=>{if(l)await r({contractId:l.id,input:{amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:ie(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrder:m.po,remarks:m.defaultRemark,startDate:ie(new Date(m.startDate),"yyyy-MM-dd")}});else{if(!m.billingCycle){u.setError("billingCycle",{message:"Billing cycle is required"});return}await d({input:{clientId:s,amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:ie(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrder:m.po,remarks:m.defaultRemark,startDate:ie(new Date(m.startDate),"yyyy-MM-dd")}})}i(!1),c(null),t?.()},[l,t,d,r,s,u]);return e.jsxs(Je,{open:a,onOpenChange:i,children:[e.jsx(es,{asChild:!0,children:e.jsxs(E,{size:"sm",onClick:h,children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(ss,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ns,{children:[e.jsx(ts,{children:l?"Edit Contract":"Create New Contract"}),e.jsx(as,{children:l?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(De,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(A),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:e.jsx(j,{control:u.control,name:"po",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"PO Number"}),e.jsx(y,{children:e.jsx(T,{placeholder:"PO-2024-001",...m})}),e.jsx(C,{})]})})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:u.control,name:"startDate",render:({field:{onChange:m,...p}})=>e.jsxs(g,{children:[e.jsx(f,{children:"Start Date"}),e.jsx(y,{children:e.jsx(T,{type:"date",...p,onInput:k=>m(k)})}),e.jsx(C,{})]})}),e.jsx(j,{control:u.control,name:"endDate",render:({field:{onChange:m,...p}})=>e.jsxs(g,{children:[e.jsx(f,{children:"End Date"}),e.jsx(y,{children:e.jsx(T,{type:"date",...p,onInput:k=>m(k)})}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(j,{control:u.control,name:"paymentAmount",render:({field:m})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsx(f,{children:"Payment Amount"}),e.jsx(y,{children:e.jsx(T,{type:"number",placeholder:"24000",...m,onChange:p=>{m.onChange(p?.target.value?Number(p?.target.value):void 0)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:u.control,name:"paymentCurrency",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Currency"}),e.jsxs(le,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(ce,{children:e.jsx(oe,{})})}),e.jsx(de,{children:Object.values(ls).map(p=>e.jsx(me,{value:p,children:p},p))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:u.control,name:"productType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Product Type"}),e.jsx(y,{children:e.jsx(T,{placeholder:"Cloud Services",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:u.control,name:"billingCycle",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Billing Cycle"}),e.jsxs(le,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(ce,{children:e.jsx(oe,{})})}),e.jsx(de,{children:Object.values(Ce).map(p=>e.jsx(me,{value:p,children:Os(p)},p))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:u.control,name:"subscriptionPlan",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Subscription Plan"}),e.jsx(y,{children:e.jsxs(le,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(ce,{children:e.jsx(oe,{})})}),e.jsx(de,{children:Object.values(Se).map(p=>e.jsx(me,{value:p,children:Bs(p)},p))})]})}),e.jsx(C,{})]})}),e.jsx(j,{control:u.control,name:"isActive",render:({field:m})=>e.jsxs(g,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{className:"text-base",children:"Active Status"})}),e.jsx(y,{children:e.jsx(J,{checked:m.value,onCheckedChange:m.onChange})})]})})]}),e.jsx(j,{control:u.control,name:"msCloudLink",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"MS Cloud Link"}),e.jsx(y,{children:e.jsx(T,{type:"url",placeholder:"https://portal.azure.com/contract-id",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:u.control,name:"defaultDocumentType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Document Type"}),e.jsxs(le,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(ce,{children:e.jsx(oe,{})})}),e.jsx(de,{children:Object.values(ue).map(p=>e.jsx(me,{value:p,children:rs(p)},p))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:u.control,name:"defaultRemark",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Remark"}),e.jsx(y,{children:e.jsx(qe,{placeholder:"Enter default remark for this contract...",rows:3,...m})}),e.jsx(C,{})]})})]}),e.jsxs(is,{children:[e.jsx(E,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(E,{type:"submit",disabled:x||o,children:l?"Update Contract":"Create Contract"})]})]})})]})]})}function ea(s){return{id:s.id,po:s.purchaseOrder??void 0,startDate:s.startDate,endDate:s.endDate,paymentAmount:s.amount.raw,paymentCurrency:s.amount.currency,productType:s.product??void 0,billingCycle:s.billingCycle,msCloudLink:s.msCloud?.toString(),isActive:s.isActive,subscriptionPlan:s.plan??void 0,defaultRemark:s.remarks??void 0,defaultDocumentType:s.documentType??void 0}}function sa({clientId:s}){const[n,t]=N.useState(null),[{data:a,fetching:i},l]=Oe({query:mn,variables:{clientId:s}}),c=a?.contractsByClient??[];return i?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(W,{children:[e.jsx(K,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(H,{children:"Contracts"}),e.jsx(X,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Jt,{clientId:s,contract:n,onDone:l})]})}),e.jsx(Q,{className:"space-y-4",children:c.map(r=>{const o=!!r.isActive;return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:r.product}),e.jsx(q,{variant:o?"default":"secondary",children:r.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:r.id})]}),e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>t(ea(r)),children:e.jsx(Yn,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(un,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(r.startDate).toLocaleDateString()," →"," ",new Date(r.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Number"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:r.purchaseOrder})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Payment"}),e.jsx("p",{className:"text-sm font-medium",children:hn(r.amount.raw,r.amount.currency)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Billing Cycle"}),e.jsx("p",{className:"text-sm font-medium",children:Os(r.billingCycle)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscription Plan"}),e.jsx("p",{className:"text-sm font-medium",children:r.plan?Bs(r.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Document Type"}),e.jsx("p",{className:"text-sm font-medium",children:rs(r.documentType)})]})]}),r.remarks&&e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remark"}),e.jsx("p",{className:"text-sm",children:r.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.msCloud&&e.jsx(E,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:r.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(xn,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(pn,{className:"h-3 w-3 ml-1"})]})})})]},r.id)})})]})}function na({businessId:s}){return e.jsxs(W,{children:[e.jsx(K,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(H,{children:"Documents"}),e.jsx(X,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(Q,{children:e.jsx(jn,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const ta=[{id:"hive",name:"Hive",description:"Schema registry, analytics, metrics and gateway for GraphQL federation and other GraphQL APIs",status:"disconnected",lastSync:"Never"},{id:"slack",name:"Slack",description:"Team communication and notifications",status:"disconnected",lastSync:"Never"},{id:"retool",name:"Retool",description:"Internal tools and dashboards",status:"disconnected",lastSync:"Never"},{id:"linear",name:"Linear",description:"Issue tracking and project management",status:"disconnected",lastSync:"Never"},{id:"workflowy",name:"Workflowy",description:"Task management and note taking",status:"disconnected",lastSync:"Never"}];function aa({data:s}){const n=je(vn,s),[{data:t,fetching:a},i]=Oe({query:gn,variables:{clientId:n?.id??""},pause:!n?.clientInfo?.greenInvoiceId||!n?.id}),{updateClient:l}=_s(),c=N.useCallback((o,d)=>{if(!n?.id)return;const x={};x[d]=o,l({businessId:n?.id,fields:x})},[n?.id,l]);N.useEffect(()=>{n?.clientInfo?.greenInvoiceId&&n?.id&&i()},[n?.clientInfo?.greenInvoiceId,n?.id,i]);const r=t?.greenInvoiceClient;return e.jsxs(W,{children:[e.jsx(K,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(H,{children:"Integrations"}),e.jsx(X,{children:"Connected external services and providers"})]}),e.jsxs(E,{size:"sm",children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(Q,{className:"space-y-6",children:e.jsxs(Zn,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[a?e.jsxs(_e,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx(D,{className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-32"}),e.jsx(D,{className:"h-5 w-5 rounded-full"})]}),e.jsx(D,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-8 w-24"}),e.jsx(D,{className:"h-8 w-8"})]})]})}),e.jsx(Fe,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-32"}),e.jsx(D,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(_e,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-600 flex items-center justify-center text-white font-bold",children:"GI"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Green Invoice"}),e.jsx(xs,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Israeli invoicing system integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ra,{id:n?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async o=>c(o,"greenInvoiceId")}),e.jsx(hs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Fe,{children:r&&e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Business Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Integration ID"}),e.jsx("p",{className:"text-sm font-mono",children:n?.clientInfo?.greenInvoiceId})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Business Name"}),e.jsx("p",{className:"text-sm",children:r.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Country"}),e.jsx("p",{className:"text-sm",children:r.country})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"text-sm font-mono",children:r.taxId})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Contact Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Ge,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.emails?.map((o,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:o},d))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Es,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:r.phone})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Mobile"}),e.jsx("p",{className:"text-sm font-mono",children:r.mobile})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Fax"}),e.jsx("p",{className:"text-sm font-mono",children:r.fax})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[e.jsx(Ke,{className:"h-3.5 w-3.5"}),"Address"]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Street Address"}),e.jsx("p",{className:"text-sm",children:r.address})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"City"}),e.jsx("p",{className:"text-sm",children:r.city})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Zip Code"}),e.jsx("p",{className:"text-sm font-mono",children:r.zip})]})]})]})]})})]}),ta.map(o=>e.jsxs(_e,{value:o.id,className:"rounded-lg border",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:o.name}),o.status==="connected"?e.jsx(xs,{className:"h-4 w-4 text-green-600"}):e.jsx(fn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(cs,{className:"h-4 w-4"})}),e.jsx(hs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Fe,{children:e.jsx("div",{className:"px-4 pb-4 pt-2 border-t",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last sync: "}),e.jsx("span",{className:"font-medium",children:o.lastSync})]})})})]},o.id))]})})]})}function ra({id:s,provider:n,updateClient:t}){const[a,i]=N.useState(!1),[l,c]=N.useState(s),r=N.useCallback(async()=>{await t(l),i(!1)},[l,t]);return e.jsxs(Je,{open:a,onOpenChange:i,children:[e.jsx(es,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",onClick:o=>o.stopPropagation(),children:[e.jsx(cs,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(ss,{onClick:o=>o.stopPropagation(),children:[e.jsxs(ns,{children:[e.jsxs(ts,{children:["Configure ",n]}),e.jsxs(as,{children:["Update your ",n," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(yn,{htmlFor:"id",children:[n," ID"]}),e.jsx(T,{id:"id",value:l,onChange:o=>c(o.target.value),placeholder:`Enter ${n} ID`})]})}),e.jsxs(is,{children:[e.jsx(E,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(E,{onClick:r,disabled:!l,children:"Save Changes"})]})]})]})}function ia({businessId:s}){return e.jsxs(W,{children:[e.jsx(K,{className:"flex w-full justify-between items-center",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(H,{children:"Transactions"}),e.jsx(X,{children:"Complete transaction history for this business"})]})})}),e.jsx(Q,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Nn,{businessID:s,filter:{}})})})]})}function la({data:s,refetchBusiness:n}){const t=je(An,s),[a,i]=Cn(),l=a.get("tab")||"contact",c=d=>{i({tab:d})};if(!t)return e.jsx("div",{children:"Business not found"});const r="clientInfo"in t&&!!t.clientInfo,o="adminInfo"in t&&!!t.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(pt,{data:t}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(bn,{value:l,onValueChange:c,className:"w-full",children:[e.jsxs(wn,{className:"grid w-full lg:grid-cols-8 sm:grid-cols-4 grid-cols-8 mb-6 h-auto gap-1 bg-muted/50 p-1",children:[e.jsxs(Z,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ds,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(Z,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(cs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(Z,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ke,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(Z,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(In,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(Z,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Dn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(nt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(Z,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(it,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),o&&e.jsxs(Z,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ps,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx(z,{value:"contact",className:"mt-0",children:e.jsx(Kt,{data:t,refetchBusiness:n})}),e.jsx(z,{value:"config",className:"mt-0",children:e.jsx(Rt,{data:t,refetchBusiness:n})}),e.jsx(z,{value:"charges",className:"mt-0",children:e.jsx(jt,{businessId:t.id})}),e.jsx(z,{value:"transactions",className:"mt-0",children:e.jsx(ia,{businessId:t.id})}),e.jsx(z,{value:"documents",className:"mt-0",children:e.jsx(na,{businessId:t.id})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(z,{value:"contracts",className:"mt-0",children:e.jsx(sa,{clientId:t.id})}),e.jsx(z,{value:"integrations",className:"mt-0",children:e.jsx(aa,{data:t})}),e.jsx(z,{value:"charts",className:"mt-0",children:e.jsx(Pt,{})})]}),o&&e.jsx(z,{value:"admin",className:"mt-0",children:e.jsx(xt,{data:t})})]})})]})}function pa(s){return`/businesses/${s}`}const ja=()=>{const{businessId:s}=kn();let n;try{n=Sn()}catch{}const[{data:t,fetching:a},i]=Oe({query:En,pause:!s||!!n,variables:{businessId:s??""}}),l=n||t;return!n&&a&&!l?.business?e.jsx(Tn,{}):!s||!l?.business?e.jsx("div",{children:"Business not found"}):e.jsx(la,{data:l.business,refetchBusiness:async()=>i()})};export{ja as BusinessScreen,pa as getBusinessHref};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d0 as B,r as i,u as W,d3 as H,j as e,d1 as U,O as z,bC as G,B as _,d2 as X,U as q,k as J,Y as N,ai as D,dk as K,aN as Q,l as Y,dl as Z,bR as h,cj as k,fs as $,bW as M,bX as L,bS as P,eA as A,aK as x,ft as ee,bf as se,a4 as m,a5 as j,a6 as g,a7 as p,dM as ae,dN as te,dO as ne}from"./index-BsGG-RLV.js";import{s as oe}from"./sub-DKnwnbwx.js";function le(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const re=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ce=[{label:"All",value:A.All},{label:"Income",value:A.Income},{label:"Expense",value:A.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:y}=i.useContext(q),o=J({defaultValues:{byOwners:y?.context.adminBusinessId?[y.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(oe(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:r,handleSubmit:T,watch:C}=o,[b,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=K(),{selectableTags:v,fetching:I}=Q(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const V=s=>{b!=null&&s.sortBy?.field&&(s.sortBy.asc=b),w(s),d()};function R(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(Y,{...o,children:e.jsxs("form",{onSubmit:T(V),children:[e.jsxs(Z,{cols:2,children:[e.jsx(h,{name:"byOwners",control:r,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:S,value:s.value??[],disabled:t,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byBusinesses",control:r,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:S,value:s.value??[],disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byTags",control:r,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:v,itemComponent:$,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(l,f,O)=>O.label?.toLowerCase().includes(l.toLowerCase().trim())||O.description?.toLowerCase().includes(l.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:r,defaultValue:a.fromAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(L,{...s,onChange:l=>{const f=l?typeof l=="string"?l:N(l,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"toAnyDate",control:r,defaultValue:a.toAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(L,{...s,onChange:l=>{const f=l?typeof l=="string"?l:N(l,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(P,{...s,data:ce,value:s.value??A.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"sortBy.field",control:r,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(P,{...s,data:re,label:"Field to sort by",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,rightSectionProps:{style:{width:"5rem"}},withinPortal:!0,rightSection:e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(x,{defaultChecked:a.sortBy?.asc??!1,checked:b??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:b?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:r,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(k,{...s,value:s.value??[],data:ee,disabled:t,label:"Accountant Status",placeholder:"All",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4 rounded-lg border p-3 shadow-sm space-y-2",children:[e.jsx(se,{children:"Missing Information:"}),e.jsx(m,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(g,{children:"Without Invoice"})}),e.jsx(p,{children:e.jsx(x,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(m,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(g,{children:"Without Receipts"})}),e.jsx(p,{children:e.jsx(x,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(m,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(g,{children:"Without Documents"})}),e.jsx(p,{children:e.jsx(x,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(m,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(g,{children:"With Open Documents"})}),e.jsx(p,{children:e.jsxs(ae,{children:[e.jsx(te,{children:e.jsx(x,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(ne,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(m,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(g,{children:"Without Transactions"})}),e.jsx(p,{children:e.jsx(x,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(m,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(g,{children:"Unbalanced businesses"})}),e.jsx(p,{children:e.jsx(x,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(m,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(g,{children:"Without ledger"})}),e.jsx(p,{children:e.jsx(x,{defaultChecked:a.withoutLedger??!1,onCheckedChange:s.onChange})})]})})]})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:t||I,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:R,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:d,children:"Cancel"})]})]})})]})}function he({filter:a={},setFilter:w,activePage:d,setPage:y,totalPages:o=1,initiallyOpened:r=!1}){const[T,C]=i.useState(r),[b,F]=i.useState(!B(a)),{get:c,set:u}=W();i.useEffect(()=>{const t=d>1?d.toFixed(0):null,v=c("page");t!==v&&u("page",t)},[d,c,u]),i.useEffect(()=>{const t=le(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),y(1))},[a,c,u,y]);const S=i.useCallback(t=>{H(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(U,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(z,{className:"flex-auto",value:d,onChange:y,total:o}),e.jsx(G,{inline:!0,size:16,disabled:!b,children:e.jsx(_,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(X,{className:"size-5"})})})]})}export{he as C,ce as c,le as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as v,fY as B,r as u,t as m,s as F,aM as H,j as e,a4 as C,a5 as j,a6 as f,a7 as p,Q as L,a8 as y,a9 as S,bR as K,bS as Q,aQ as V,aK as _,ao as D,ap as E,B as h,ar as M,as as R,at as A,k,l as $,fZ as z,ca as G,a as O,f_ as Y,L as P,F as Z,dm as J,c as W,dq as X,dr as ee,ds as T,dt as se,du as b,dv as te,dw as w,f$ as ae,dC as re,dD as oe,dE as ne}from"./index-BsGG-RLV.js";import{D as ie}from"./data-table-pagination-CQQBbtVE.js";import{A as N}from"./arrow-up-down-Bt3_puEZ.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(B),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=H();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(L,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(S,{})]})}),e.jsx(K,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(Q,{...o,onChange:U=>{o.onChange(Number(U))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(V,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(S,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(_,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=k({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx($,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(z),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(G,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{children:"Edit Tax Category"})}),e.jsx(he,{taxCategoryId:s,close:()=>a(!1),onAdd:n})]})]})}function he({taxCategoryId:s,close:n,onAdd:t}){const[{data:a,fetching:d}]=O({query:Y,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx(P,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=k({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx($,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=O({query:ae}),{setFiltersContext:d}=u.useContext(Z),r=s?.taxCategories??[],i=J({data:r,columns:I,getCoreRowModel:ne(),getPaginationRowModel:oe(),getSortedRowModel:re(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ie,{table:i})})}))},[d,i,l]),u.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(W,{title:`Tax Categories (${r.length})`,description:"All tax categories",headerActions:e.jsx(le,{onAdd:()=>a()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(P,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(X,{children:[e.jsx(ee,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(se,{children:c.isPlaceholder?null:b(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(te,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:I.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:b(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as c,a as N,i as k,j as e,e as w,U as E,k as z,l as D,m as L,n as A,o as T,p as O,q as P,t as B,s as R,v as U,w as $,x as q,B as C,y as S,z as H,D as v,G as _,H as Q,P as F,b as I,J as V,K as G,N as J,u as M,O as K,Q as W,F as X,T as Y,c as Z,L as ee,R as se,S as te}from"./index-BsGG-RLV.js";import{C as ne,M as ie}from"./Checkbox-Bm30-WRa.js";import{u as ae,S as re}from"./similar-charges-by-business-modal-CCw5opHn.js";function oe({businessID:t,updateBusiness:n}){const[r,u]=c.useState(void 0),[{data:o,fetching:i},l]=N({query:k,variables:{id:t}});return c.useEffect(()=>{i?u(void 0):o&&o.business.__typename==="LtdFinancialEntity"&&u(o.business)},[o,i]),c.useEffect(()=>{r&&n(r)},[r,n]),e.jsx("div",{className:"flex flex-col gap-5",children:r?e.jsx(le,{business:r,refetchBusiness:l}):i?e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx("p",{children:"Error fetching extended information for this business"})})}function le({business:t,refetchBusiness:n}){const[r,u]=c.useState(!1),[o,i]=c.useState(!1),[l,d]=c.useState(void 0),{userContext:g}=c.useContext(E),{updateBusiness:f,fetching:a}=ae(),x=z({defaultValues:{...t,taxCategory:t.taxCategory?.id,sortCode:t?.sortCode?.key,irsCode:t?.irsCode}}),{handleSubmit:p,formState:{dirtyFields:h}}=x,b=async j=>{if(!t||!g?.context.adminBusinessId)return;const s=T(j,h);s&&Object.keys(s).length>0&&(s.sortCode&&=parseInt(s.sortCode.toString()),s.suggestions?.tags&&(s.suggestions.tags=s.suggestions.tags.map(m=>({id:m.id}))),s.suggestions?.phrases&&(s.suggestions.phrases=j.suggestions.phrases.map(m=>m)),s.suggestions?.emails&&(s.suggestions.emails=j.suggestions.emails.map(m=>m)),s.suggestions?.emailListener&&(s.suggestions.emailListener.attachments&&=j.suggestions.emailListener.attachments.map(m=>m),s.suggestions.emailListener.internalEmailLinks&&=j.suggestions.emailListener.internalEmailLinks.map(m=>m)),await f({businessId:t.id,ownerId:g.context.adminBusinessId,fields:s}),s.suggestions?.tags?.length||s.suggestions?.description?(d({tagIds:s.suggestions?.tags?.map(m=>({id:m.id})),description:s.suggestions?.description??void 0}),i(!0)):n())};return e.jsxs(e.Fragment,{children:[r&&e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),e.jsx("div",{className:"flex flex-row gap-5",children:e.jsx(D,{...x,children:e.jsxs("form",{onSubmit:p(b),children:[e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Business:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["ID: ",t.id,e.jsx(L,{content:t.id})]})]}),e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsx(A,{isInsert:!1,formManager:x,setFetching:u})}),e.jsx("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:e.jsx("button",{type:"submit",onClick:()=>p(b),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:a||Object.keys(h).length===0,children:"Update"})})]})})}),e.jsx(re,{businessId:t.id,tagIds:l?.tagIds,description:l?.description,open:o,onOpenChange:i,onClose:n})]})}const ce="mergeBusinesses",de=()=>{const[{fetching:t},n]=O(P),r=c.useCallback(async u=>{const o=`Error merging into business ID [${u.targetBusinessId}]`,i=`${ce}-${u.targetBusinessId}`;B.loading("Merging Businesses",{id:i});try{const l=await n(u),d=R(l,o,i);if(d)return B.success("Success",{id:i,description:"Businesses merged"}),d.mergeBusinesses.id}catch(l){console.error(`${o}: ${l}`),B.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[n]);return{fetching:t,mergeBusinesses:r}};function ue({businessIds:t,onDone:n,resetMerge:r}){const{mergeBusinesses:u,fetching:o}=de(),i=Array.from(new Set(t)),[{data:l,fetching:d}]=N({query:U,variables:{businessIds:i}}),[g,f]=c.useState(l?.businesses[0]),a=l?.businesses.length!==i.length&&"Some businesses were not Found"||void 0,x=l?.businesses||[],p=c.useCallback(async()=>{if(!g){B.error("Error",{description:"No main business selected"});return}if(i.length<2){B.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await u({targetBusinessId:g.id,businessIdsToMerge:i.filter(h=>h!==g.id)}),r(),n()},[g,i,u,n,r]);return e.jsxs(e.Fragment,{children:[d&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx($,{})}),!d&&a&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:a})}),!d&&!a&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),x.map(h=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(ne,{checked:h.id===g?.id,size:"xl",onClick:()=>{f(h)}})})},h.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),x.map(h=>e.jsx("td",{children:h.name},h.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:d||o,onClick:p,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:n,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{r(),n()},children:"Reset Merge"})]})]})]})}function ge(t){const[n,{close:r,open:u}]=q(!1),{selected:o,resetMerge:i}=t,l=new Set(o.map(({id:x})=>x)),d=l.size>=1,[g,f]=c.useState(d?"default":"outline");c.useEffect(()=>{f(d?"default":"outline")},[d]);const a=c.useCallback(()=>{r(),o.map(({onChange:x})=>x())},[o,r]);return e.jsxs(e.Fragment,{children:[e.jsx(C,{onClick:()=>{d&&u()},disabled:!d,variant:g,className:S("size-7.5",d?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(ie,{className:"size-5"})}),e.jsx(H,{opened:n,onClose:r,size:"auto",centered:!0,children:e.jsx(ue,{businessIds:Array.from(l),onDone:a,resetMerge:i})})]})}const me=({data:t})=>{const n=v(_,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.hebrewName})})},xe=({data:t})=>{const n=v(Q,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.name})})},he=({data:t,isAllOpened:n,toggleMergeBusiness:r,isSelectedForMerge:u})=>{const[o,i]=c.useState(!1),[l,d]=c.useState(v(J,t));return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx(xe,{data:l}),e.jsx(me,{data:l}),e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>{i(g=>!g)},children:n||o?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})}),r&&e.jsx(V,{toggleMergeSelected:()=>r(()=>{}),mergeSelected:u})]})})]}),(n||o)&&e.jsx("tr",{children:e.jsx("td",{colSpan:12,children:e.jsx(G,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(oe,{businessID:l.id,updateBusiness:d})})})})]})};function fe({activePage:t,setPage:n,totalPages:r=1,businessName:u,setBusinessName:o}){const{get:i,set:l}=M(),[d,g]=c.useState(u);c.useEffect(()=>{const a=t>1?t.toFixed(0):void 0,x=i("page");a!==x&&a!=="1"&&l("page",a)},[t,i,l]),c.useEffect(()=>{const a=setTimeout(()=>{o(d)},600);return()=>{clearTimeout(a)}},[d,o]);const f=a=>{g(a)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(K,{className:"flex-auto",value:t,onChange:n,total:r}),e.jsx(W,{className:"w-72",placeholder:"Business Name",defaultValue:u??void 0,onChange:a=>f(a.target.value===""?void 0:a.target.value)})]})}const Be=()=>{const{get:t}=M(),[n,r]=c.useState(!1),[u,o]=c.useState(t("page")?Number(t("page")):1),[i,l]=c.useState(t("name")?t("page"):void 0),{setFiltersContext:d}=c.useContext(X),[{data:g,fetching:f}]=N({query:te,variables:{page:u,limit:100,name:i}}),[a,x]=c.useState([]),p=c.useCallback((s,m)=>{a.map(y=>y.id).includes(s)?x(a.filter(y=>y.id!==s)):x([...a,{id:s,onChange:m}])},[a]);function h(){x([])}c.useEffect(()=>{d(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(fe,{activePage:u,setPage:o,businessName:i,setBusinessName:l,totalPages:g?.allBusinesses?.pageInfo.totalPages}),e.jsx(Y,{label:"Expand all businesses",children:e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(s=>!s),children:n?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})})}),e.jsx(ge,{selected:a,resetMerge:h})]}))},[g,u,i,n,d,o,l,r,a]);const b=g?.allBusinesses?.nodes.filter(s=>s.__typename==="LtdFinancialEntity").sort((s,m)=>s.name.toLowerCase()>m.name.toLowerCase()?1:-1)??[],j=new Set(a.map(s=>s.id));return e.jsx(Z,{title:`Businesses (${b.length})`,description:"All businesses",children:f?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(ee,{className:S("h-10 w-10 animate-spin mr-2")})}):e.jsxs(se,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.jsxs("tr",{className:"px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl",children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Hebrew Name"}),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:b.map(s=>e.jsx(he,{data:s,isAllOpened:n,toggleMergeBusiness:p?m=>p(s.id,m):void 0,isSelectedForMerge:j.has(s.id)??!1},s.id))})]})})};export{Be as Businesses};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,d0 as w,u as P,d3 as K,j as e,d1 as A,bC as O,B as d,d2 as U,U as z,k as B,Y as b,dk as _,l as H,dl as L,bR as D,cj as M,bW as I,bX as k,a4 as q,a5 as G,a6 as J,a7 as Q,aK as X,bx as W,F as Y,a as Z,dm as $,c as ee,L as te,dn as se,dp as ae,dq as ne,dr as le,ds as S,dt as re,du as T,dv as ie,dw as R,dx as oe,dy as de,dz as ce,dA as me,dB as ue,dC as ge,dD as xe,dE as he}from"./index-BsGG-RLV.js";import{D as je}from"./data-table-pagination-CQQBbtVE.js";import{s as pe}from"./sub-DKnwnbwx.js";import{A as v}from"./arrow-up-down-Bt3_puEZ.js";import"./subMonths-B44KizJf.js";function fe({filter:t,setFilter:s,closeModal:h}){const{userContext:j}=l.useContext(z),x=B({defaultValues:{ownerIDs:j?.context.adminBusinessId?[j.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(pe(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=x,{selectableFinancialEntities:r,fetching:c}=_(),C=a=>{s(a),h()};function m(){s({}),h()}return e.jsxs(e.Fragment,{children:[c?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(H,{...x,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(L,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:c,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:c,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(k,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(k,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(q,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(G,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(J,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(X,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:c,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:m,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:h,children:"Cancel"})]})]})})]})}function ve({filter:t={},setFilter:s,initiallyOpened:h=!1}){const[j,x]=l.useState(h),[o,y]=l.useState(!w(t)),{get:r,set:c}=P();l.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=r("documentsFilters");m!==a&&c("documentsFilters",m)},[t,r,c]);const C=l.useCallback(m=>{K(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(A,{opened:j,onClose:()=>x(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>x(!1)}),modalSize:"xl"}),e.jsx(O,{inline:!0,size:16,disabled:!o,children:e.jsx(d,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(U,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(d,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:b(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(W,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],we=()=>{const[t,s]=l.useState(null),[h,j]=l.useState(!1),{get:x}=P(),o=x("documentsFilters"),y=l.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[r,c]=l.useState(y),[C,m]=l.useState([]),[a,g]=l.useState({}),{setFiltersContext:i}=l.useContext(Y),[{data:p,fetching:F},N]=Z({query:ue,variables:{filters:r??{}},pause:!0});l.useEffect(()=>{r&&N()},[r,N]);const f=$({data:p?.documentsByFilters??[],columns:E,getCoreRowModel:he(),getPaginationRowModel:xe(),onSortingChange:m,getSortedRowModel:ge(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),V=f.getState().pagination.pageIndex;return l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(je,{table:f}),e.jsx(ve,{filter:r,setFilter:c,initiallyOpened:!r})]}))},[f,F,r,i,c,y,V]),e.jsx(ee,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(d,{className:"ml-auto",children:"Columns"})}),e.jsx(ce,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(me,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(d,{onClick:()=>j(!0),children:"Upload Documents"})]}),children:F?e.jsx(te,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(se,{open:h,onOpenChange:j,onChange:N}),t&&e.jsx(A,{modalSize:"45%",content:e.jsx(ae,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(ne,{children:[e.jsx(le,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(re,{children:u.isPlaceholder?null:T(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ie,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(R,{children:T(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(R,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{we as DocumentsReport,E as columns};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as h,j as e,d1 as u,eL as f,B as y,d2 as R,bp as D,F as T,a as E,c as b,L as w,R as F,eN as g}from"./index-BsGG-RLV.js";import{d as v}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-DJPRyQur.js";function B({year:i,setYear:m,referenceYears:x,setReferenceYears:j}){const[c,o]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:c,onClose:()=>o(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(i,0,1),onChange:n=>n&&m(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(l=>l.getFullYear()).filter(l=>i!==l)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(!0),children:e.jsx(R,{className:"size-5"})})]})}const Y=()=>{const{year:i}=D(),{setFiltersContext:m}=h.useContext(T),[x,j]=h.useState(i?Number(i):new Date().getFullYear()),[c,o]=h.useState([]),[{data:n,fetching:l}]=E({query:v(g),variables:{reportYear:x,referenceYears:c}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:c,setReferenceYears:o})}))},[x,l,m,c,o]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(b,{title:"Tax Report",children:l?e.jsx(w,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(F,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{Y as TaxReport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as M,dG as Q,t as C,r as s,p as Y,s as J,dH as K,dI as U,D as F,dJ as E,j as e,ao as R,ap as q,B as v,aq as W,ar as G,as as X,at as _,aw as Z,ax as ee,ay as se,az as te,aA as ne,dK as ae,dL as re,dM as z,dN as H,ca as ce,dO as $,dP as ie,$ as k,a3 as A,L as B,dQ as le,g as oe,a0 as de,a1 as ue,dR as me,bm as he,b9 as xe,dS as je,Y as P,dT as L,k as pe,bP as fe,W as ge,l as ye,bf as ve,de as De,dq as be,dr as Ce,ds as O,dt as g,dv as Ne,dw as y,av as we,c4 as Ie,F as Me,w as Te}from"./index-BsGG-RLV.js";import{s as V}from"./subMonths-B44KizJf.js";const Se=()=>{const[{data:u,fetching:o,error:c},x]=M({query:Q});c&&(console.error(`Error fetching contracts: ${c}`),C.error("Error",{description:"Unable to fetch contracts"}));const a=s.useMemo(()=>u?.allOpenContracts?.slice().sort((t,d)=>t.client.originalBusiness.name>d.client.originalBusiness.name?1:-1)??[],[u]),i=s.useMemo(()=>a.map(t=>({value:t.id,label:t.client.originalBusiness.name})),[a]);return{fetching:o,refresh:()=>x(),openContracts:a,selectableOpenContracts:i}},Fe="IssueMonthlyDocuments",Ee=()=>{const[{fetching:u},o]=Y(K),c=s.useCallback(async x=>{const a="Error issuing monthly documents",i=Fe;C.loading("Issuing documents",{id:i});try{const t=await o(x),d=J(t,a,i);if(d?.issueGreenInvoiceDocuments?.success){C.success("Success",{id:i,description:"Documents issued successfully"});return}d?.issueGreenInvoiceDocuments?.errors&&console.error(d.issueGreenInvoiceDocuments.errors),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}catch(t){console.error(`${a}: ${t}`),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[o]);return{fetching:u,issueDocuments:c}};function Pe({issueMonth:u,contracts:o,onAdd:c}){const[x,a]=s.useState(!1),[i,t]=s.useState(""),[{data:d},h]=M({query:U,variables:{issueMonth:u,clientId:i}}),j=s.useCallback(n=>{t(n),h()},[h,t]);return s.useEffect(()=>{i!==""&&d&&(c(F(E,d.clientMonthlyChargeDraft)),a(!1))},[i,d,c]),e.jsxs(R,{open:x,onOpenChange:a,children:[e.jsx(q,{asChild:!0,children:e.jsx(v,{variant:"outline",size:"icon",children:e.jsx(W,{})})}),e.jsxs(G,{className:"w-[400px] max-w-screen-md",children:[e.jsx(X,{children:e.jsx(_,{children:"Select document recipient"})}),e.jsxs(Z,{onValueChange:j,children:[e.jsx(ee,{children:e.jsx(se,{placeholder:"Recipient"})}),e.jsx(te,{children:o.map(n=>e.jsx(ne,{value:n.client.originalBusiness.id,children:n.client.originalBusiness.name},n.client.originalBusiness.id))})]})]})]})}function ke({onApprove:u,draft:o}){const[c,x]=s.useState(!1),[a,i]=s.useState(!1),[t,d]=s.useState(null),{previewDocument:h,fetching:j}=ae(),[n,N]=s.useState(re(o)),T=s.useCallback((l,p)=>{N(f=>({...f,[l]:p}))},[]);s.useEffect(()=>{i(!1)},[n]);const D=s.useCallback(async()=>{try{const l=await h({input:n});if(!l)throw new Error("No preview data returned");d(l),i(!0)}catch(l){console.error("Failed to generate preview:",l)}},[n,h]);s.useEffect(()=>{c&&!t&&D()},[c,t,D]);const w=n.income?.reduce((l,p)=>{const f=p.price*p.quantity,r=f*((p.vatRate||0)/100);return l+f+r},0)||0,I=()=>{u(n),x(!1)};return e.jsxs(R,{open:c,onOpenChange:x,children:[e.jsx(q,{asChild:!0,type:"button",children:e.jsxs(z,{children:[e.jsx(H,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>x(l=>!l),type:"button",children:e.jsx(ce,{className:"size-5"})})}),e.jsx($,{children:e.jsx("p",{children:"Edit document"})})]})}),e.jsx(G,{className:"w-7xl sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:e.jsx("div",{className:"min-h-screen bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Edit Document"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Modify and preview your accounting document before issuing"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ie,{formData:n,updateFormData:T}),e.jsx(k,{children:e.jsxs(A,{className:"pt-6",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(v,{onClick:D,disabled:j||a,variant:"outline",className:"flex-1 bg-transparent",children:j?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-4 h-4 mr-2"}),"Preview"]})}),e.jsxs(v,{onClick:I,className:"flex-1",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Accept Changes"]})]}),w>0&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 rounded-lg",children:e.jsxs("div",{className:"flex justify-between items-center font-medium text-blue-900",children:[e.jsx("span",{children:"Total Document Amount:"}),e.jsxs("span",{children:[w.toFixed(2)," ",n.currency]})]})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(k,{className:"h-fit",children:[e.jsx(de,{children:e.jsx(ue,{children:"Document Preview"})}),e.jsx(A,{children:e.jsx("div",{className:"border-2 border-dashed border-gray-200 rounded-lg min-h-[600px] flex items-center justify-center bg-gray-50",children:j?e.jsxs("div",{className:"text-center",children:[e.jsx(B,{className:"w-8 h-8 animate-spin mx-auto mb-4 text-gray-400"}),e.jsx("p",{className:"text-gray-500",children:"Generating document preview..."})]}):t?e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"bg-white shadow-lg rounded-lg overflow-hidden",children:e.jsx("div",{className:"aspect-[8.5/11] bg-white border",children:e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(me,{src:t}),!a&&e.jsx("p",{className:"text-xs text-amber-600 mt-3 bg-amber-50 px-2 py-1 rounded",children:"Preview may be outdated"})]})})})})}):e.jsxs("div",{className:"text-center",children:[e.jsx(he,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"text-gray-500 mb-2",children:"No preview available"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Click Preview to generate document"})]})})})]}),n.client?.id&&e.jsx(xe,{businessId:n.client?.id,linkedDocumentIds:n.linkedDocumentIds??[]}),e.jsx(je,{documentType:n.type})]})]})]})})})]})}const Ae=({drafts:u})=>{const[o,c]=s.useState(u.map(r=>F(E,r))),x=P(V(new Date,1),"yyyy-MM-dd"),[a,i]=s.useState(x),[{data:t},d]=M({query:L,variables:{issueMonth:a},pause:!0});s.useEffect(()=>{t?.clientMonthlyChargesDrafts&&c(t.clientMonthlyChargesDrafts.map(r=>F(E,r)))},[t,c]),s.useEffect(()=>{d()},[a,d]);const h=pe({values:{generateDocumentsInfo:o}}),{issueDocuments:j}=Ee(),{openContracts:n}=Se(),{fields:N,append:T,remove:D,update:w}=fe({control:h.control,name:"generateDocumentsInfo"}),I=h.watch("generateDocumentsInfo"),l=s.useMemo(()=>N.map((r,m)=>({...r,...I[m],id:r.client?.id})),[N,I]),p=s.useCallback(r=>{j(r)},[j]),f=s.useMemo(()=>n.filter(r=>r.billingCycle===ge.Monthly&&!l.some(m=>m.client?.id===r.client.originalBusiness.id)),[l,n]);return e.jsx("div",{className:"p-2",children:e.jsx(ye,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(p),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(ve,{children:"Issue Month:"}),e.jsx(De,{value:new Date(a),onChange:r=>{const m=new Date(r.getFullYear(),r.getMonth(),15);i(P(m,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(be,{children:[e.jsx(Ce,{children:e.jsxs(O,{children:[e.jsx(g,{children:"Name"}),e.jsx(g,{children:"Document"}),e.jsx(g,{children:"Amount"}),e.jsx(g,{children:"Remark"}),e.jsx(g,{children:"Recipients"}),e.jsx(g,{})]})}),e.jsx(Ne,{children:l.map(({id:r,...m},S)=>e.jsxs(O,{children:[e.jsx(y,{children:m.client?.name}),e.jsx(y,{children:m.type}),e.jsxs(y,{children:[m.income?.[0]?.price," ",m.income?.[0]?.currency]}),e.jsx(y,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:m.remarks})}),e.jsx(y,{children:e.jsx("div",{className:"flex flex-col",children:m.client?.emails?.map(b=>e.jsx("span",{className:"text-sm text-gray-500",children:b},b))})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(z,{children:[e.jsx(H,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>D(S),children:e.jsx(we,{size:16})})}),e.jsx($,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(ke,{draft:m,onApprove:b=>{h.setValue(`generateDocumentsInfo.${S}`,b,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),w(S,{...b})}})]})})]},r))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(Pe,{contracts:f,onAdd:T,issueMonth:a}),e.jsx(Ie,{onConfirm:h.handleSubmit(p),title:`Are you sure you want to issue ${l.length} documents?`,children:e.jsx(v,{children:"Issue"})})]})]})})})},Re=()=>{const{setFiltersContext:u}=s.useContext(Me),[{data:o,fetching:c}]=M({query:L,variables:{issueMonth:P(V(new Date,1),"yyyy-MM-dd")}});return s.useEffect(()=>{o?.clientMonthlyChargesDrafts||u(null)},[o,u]),c?e.jsx(Te,{}):e.jsx(Ae,{drafts:o?.clientMonthlyChargesDrafts??[]})};export{Re as IssueDocuments};
|