@accounter/client 0.0.8-alpha-20251029124401-d15137847e8450b1ecf3e3cfa6b68dda7239ca45 → 0.0.8-alpha-20251029124558-c1dac18cef0a90c88021bcb6e06319cc55ec33d9
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-Cxbop3qM.js → Checkbox-w99PhJ6L.js} +2 -2
- package/dist/assets/{MultiSelect-D1XVjXLN.js → MultiSelect-9BbcXHjB.js} +1 -1
- package/dist/assets/{Pagination-DMimIHM4.js → Pagination-BVQu3Yj6.js} +1 -1
- package/dist/assets/{Progress-CP4jnh2x.js → Progress-BKRQuJXK.js} +1 -1
- package/dist/assets/{Table-DTU12O53.js → Table-CR8S5Pp5.js} +1 -1
- package/dist/assets/{Typography-IL0wuZeq.js → Typography-D1_XzAPj.js} +1 -1
- package/dist/assets/{YearPickerInput-CPL_XozD.js → YearPickerInput-dCiPlZqk.js} +1 -1
- package/dist/assets/{accordion-DKLV9b0H.js → accordion-QkFWsf0a.js} +1 -1
- package/dist/assets/{accountant-approvals-CdX2nUgB.js → accountant-approvals-AD_TNBTH.js} +1 -1
- package/dist/assets/{accounter-table-CeZ4q0re.js → accounter-table-CBigzB_s.js} +1 -1
- package/dist/assets/{addDays-sGeEkIxC.js → addDays-CjlJbHpj.js} +1 -1
- package/dist/assets/{all-charges-BJvp1ecZ.js → all-charges-BdHR-QjC.js} +1 -1
- package/dist/assets/{arrow-up-down-DkEXGAin.js → arrow-up-down-Cq3mRkaO.js} +1 -1
- package/dist/assets/{building-2-BcYhLAVP.js → building-2-BE02hpsM.js} +1 -1
- package/dist/assets/{business-CO7M6XNI.js → business-CX0D-23F.js} +17 -7
- package/dist/assets/business-extended-info-BRde-LSv.js +13 -0
- package/dist/assets/{business-header-BG2B-PcM.js → business-header-CMH3yBZc.js} +1 -1
- package/dist/assets/business-ledger-filters-DQ4D4mv8.js +1 -0
- package/dist/assets/business-ledger-single-BSeNj9f2.js +1 -0
- package/dist/assets/business-trip-CX-3yJmB.js +1 -0
- package/dist/assets/{charge-Bm0hPNT7.js → charge-BzCN_Szu.js} +1 -1
- package/dist/assets/{charges-filters-DjnsiGzC.js → charges-filters-C7YlWAFn.js} +1 -1
- package/dist/assets/{charges-ledger-validation-CoHDjCf2.js → charges-ledger-validation-DqM92cc-.js} +1 -1
- package/dist/assets/charges-table-BOnvwci9.js +62 -0
- package/dist/assets/{chart-SbwWAyei.js → chart-OVHXA3Uy.js} +1 -1
- package/dist/assets/{data-table-pagination-DtnUvTOC.js → data-table-pagination-BLbPHs4o.js} +1 -1
- package/dist/assets/download-csv-button-C5J9ow3I.js +1 -0
- package/dist/assets/{editable-business-trip-xFRu5fSA.js → editable-business-trip-Ito1rWaY.js} +1 -1
- package/dist/assets/{funnel-WdA7f2As.js → funnel-IYKnhWOy.js} +1 -1
- package/dist/assets/{index-BOhdfO95.js → index-2j4tFkfX.js} +1 -1
- package/dist/assets/{index-VzPCd0L-.js → index-4YPOH-A_.js} +2 -2
- package/dist/assets/index-B3W0RNqC.js +1 -0
- package/dist/assets/{index-Vq1FAgYe.js → index-BOmTn4-L.js} +1 -1
- package/dist/assets/{index-BaEmw40f.js → index-C8HkbFzQ.js} +1 -1
- package/dist/assets/{index-9JObwNSb.js → index-CP5LZIWs.js} +1 -1
- package/dist/assets/{index-Ct0AJEN9.js → index-CY5Ok8zP.js} +2 -2
- package/dist/assets/{index-DPvrbbz9.js → index-CcJvt1sI.js} +119 -119
- package/dist/assets/{index-BIdEjDD3.js → index-Cn-lknzD.js} +1 -1
- package/dist/assets/{index-Ey6XKYuP.js → index-CnlrBGcj.js} +2 -2
- package/dist/assets/{index-1loWF1jV.js → index-D1Hpe746.js} +1 -1
- package/dist/assets/{index-BxnmQCT9.js → index-D31j2-8X.js} +1 -1
- package/dist/assets/{index-mN2sZqiu.js → index-D68aCDMG.js} +7 -7
- package/dist/assets/index-DE0nwhFR.js +1 -0
- package/dist/assets/{index-CwbqTlM4.js → index-DGxxgGxy.js} +2 -2
- package/dist/assets/{index-W6Xv87pg.js → index-DKVhuSlP.js} +1 -1
- package/dist/assets/{index-DjQIiDMo.js → index-DeFWFAwx.js} +1 -1
- package/dist/assets/{index-Bw5hpWBz.js → index-DjPei962.js} +2 -2
- package/dist/assets/{index-CdAUtS2Q.js → index-Dvp0RPEc.js} +1 -1
- package/dist/assets/{index-CfsTscFv.js → index-a32atud-.js} +1 -1
- package/dist/assets/{index-CXH_lcpK.js → index-kSig9eXf.js} +2 -2
- package/dist/assets/index-ofME77ND.js +6 -0
- package/dist/assets/{index-Bm3ZL2dx.js → index-ofu4jqHf.js} +1 -1
- package/dist/assets/{index--LMZMPY_.js → index-qLJISPWb.js} +1 -1
- package/dist/assets/{index-p1BcqxXQ.js → index-smNUtwvf.js} +1 -1
- package/dist/assets/{index.es-C3XngPKv.js → index.es-D7_nzQqR.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-BHY3QQup.js → insert-business-trip-modal-D08ePEzY.js} +2 -2
- package/dist/assets/issue-document-D2L9kG1u.js +1 -0
- package/dist/assets/{list-plus-ZvPwjqZn.js → list-plus-Cv8qnwZd.js} +1 -1
- package/dist/assets/{login-page-CsXdm3AZ.js → login-page-sUXp3XoV.js} +1 -1
- package/dist/assets/{match-document-modal-Cqimg0VE.js → match-document-modal-D2TgC0aR.js} +4 -4
- package/dist/assets/{missing-info-charges-DxLGt6Xs.js → missing-info-charges-BJnQHRZs.js} +1 -1
- package/dist/assets/{modal-Nvfe-DMu.js → modal-DOtlViK5.js} +1 -1
- package/dist/assets/{page-layout-SHFb6rY4.js → page-layout-BNHKLJFL.js} +1 -1
- package/dist/assets/{page-not-found-BZ6s-Q5n.js → page-not-found-j9vQhz-c.js} +1 -1
- package/dist/assets/{panel-top-open-C3Q9X7Tg.js → panel-top-open-DQ1wo5PZ.js} +1 -1
- package/dist/assets/{pencil-CPPx1BhC.js → pencil-BWTnh6hj.js} +1 -1
- package/dist/assets/{report-commentary-row-DpYgprQr.js → report-commentary-row-DBOCwi7X.js} +1 -1
- package/dist/assets/{save-D-W46u2J.js → save-DuIXDTLc.js} +1 -1
- package/dist/assets/{similar-transactions-modal-zQY2R-sr.js → similar-transactions-modal-DDVojjq0.js} +1 -1
- package/dist/assets/sub-CIKovQuv.js +1 -0
- package/dist/assets/subMonths-GbNm9rnx.js +1 -0
- package/dist/assets/{summary-DwX_dmjr.js → summary-BV3HUEgI.js} +1 -1
- package/dist/assets/{toggle-expansion-button-Bh24n-cz.js → toggle-expansion-button-Bdpb_YfG.js} +1 -1
- package/dist/assets/tooltip-Cy3vJ3fy.js +1 -0
- package/dist/assets/{use-url-query-COmN7DHP.js → use-url-query-D-GsTMWL.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/business/balance-section.tsx +26 -0
- package/src/components/business/index.tsx +31 -1
- package/src/components/business/ledger-section.tsx +49 -0
- package/src/components/business/transactions-section.tsx +24 -2
- package/src/components/{business-transactions → business-ledger}/business-extended-info.tsx +25 -27
- package/src/components/{business-transactions/business-transactions-filters.tsx → business-ledger/business-ledger-filters.tsx} +12 -12
- package/src/components/{business-transactions/business-transactions-single.tsx → business-ledger/business-ledger-single.tsx} +13 -13
- package/src/components/{business-transactions → business-ledger}/download-csv.tsx +25 -25
- package/src/components/{business-transactions → business-ledger}/index.tsx +15 -15
- package/src/components/charges/charge-extended-info.tsx +45 -4
- package/src/components/layout/sidelinks.tsx +2 -2
- package/src/components/ledger-table/columns.tsx +4 -4
- package/src/components/ledger-table/index.tsx +141 -181
- package/src/components/reports/conto/custom-node.tsx +1 -1
- package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
- package/src/components/transactions-table/columns.tsx +9 -9
- package/src/components/transactions-table/index.tsx +45 -21
- package/src/gql/gql.ts +30 -12
- package/src/gql/graphql.ts +181 -406
- package/src/router/config.tsx +14 -14
- package/src/router/routes.ts +2 -2
- package/dist/assets/business-extended-info-MUfOmQ_B.js +0 -13
- package/dist/assets/business-transactions-filters-Cijy7ryl.js +0 -1
- package/dist/assets/business-transactions-single-DZqMwNkv.js +0 -1
- package/dist/assets/business-trip-C7G814AY.js +0 -1
- package/dist/assets/charges-table-C_4dY1Ic.js +0 -62
- package/dist/assets/download-csv-button-D9_6J2pA.js +0 -1
- package/dist/assets/index-Bx-qi8fd.js +0 -1
- package/dist/assets/index-D3-tv-Kb.js +0 -1
- package/dist/assets/index-DFgRsYAU.js +0 -6
- package/dist/assets/issue-document-BpzcqnRu.js +0 -1
- package/dist/assets/sub-7frHBT3Y.js +0 -1
- package/dist/assets/subMonths-CY79vHaS.js +0 -1
- package/dist/assets/tooltip-BaULIFLC.js +0 -1
- package/src/app.tsx +0 -108
|
@@ -1,27 +1,37 @@
|
|
|
1
|
-
import{v as
|
|
1
|
+
import{v as se,w as be,S as Se,x as pe,u as te,y as Rs,r as b,j as e,D as Ge,z as We,E as Ms,c as ps,g as Ie,t as M,i as De,U as $s,G as Te,H as Ke,J as Ce,K as z,N as q,O as js,P as G,Q as W,V as Be,W as K,X as j,Y as g,Z as f,_ as N,I as T,$ as k,a0 as C,a1 as re,a2 as He,B as P,a3 as Us,a4 as Xe,a5 as Je,a6 as _,a7 as gs,a8 as Qe,a9 as zs,aa as qs,ab as V,ac as ts,ad as Gs,ae as Ws,af as Ks,ag as ee,ah as Q,ai as Hs,aj as Xs,ak as Js,al as Ve,am as je,an as ge,ao as fe,ap as ve,aq as Qs,ar as ye,as as Ys,at as Zs,au as Y,av as Z,aw as le,ax as et,ay as st,az as _e,aA as Re,aB as fs,aC as tt,aD as Me,aE as nt,aF as $e,aG as vs,aH as ns,aI as ys,aJ as at,aK as it,aL as Ye,aM as Ns,aN as Ze,aO as bs,aP as Cs,aQ as ws,aR as ks,aS as Ss,aT as As,aU as rt,aV as ue,aW as lt,aX as as,aY as ct,aZ as ot,a_ as dt,a$ as mt,b0 as ut,b1 as ht,b2 as xt,b3 as pt,b4 as A,b5 as jt,b6 as es,b7 as gt,b8 as ft,b9 as vt,ba as yt,bb as Nt,F as bt,bc as Ct,bd as wt,be as H,bf as kt,bg as St,bh as $,bi as At,a as It,b as Dt,bj as Tt}from"./index-CcJvt1sI.js";import{S as ss}from"./save-DuIXDTLc.js";import{B as Bt}from"./business-extended-info-BRde-LSv.js";import{B as Et}from"./business-header-CMH3yBZc.js";import{S as Pt,C as Lt,L as Ot}from"./charges-table-BOnvwci9.js";import{P as Ft}from"./Pagination-BVQu3Yj6.js";import{i as Vt,D as _t,f as Rt,E as Mt,L as Pe,a as we,C as $t,A as Ut,b as he,c as zt,d as Ue,h as qt,e as Gt,g as Is,u as Wt,G as Kt,j as is,k as Ht,X as Ds,Y as Ts,l as Xt,m as Jt,R as Qt,n as Yt,o as Zt,p as en}from"./chart-OVHXA3Uy.js";import{P as sn}from"./pencil-BWTnh6hj.js";import{E as tn,T as nn}from"./index-ofME77ND.js";import{A as an,a as Le,b as Oe,c as rs}from"./accordion-QkFWsf0a.js";import{B as rn}from"./building-2-BE02hpsM.js";import"./download-csv-button-C5J9ow3I.js";import"./Table-CR8S5Pp5.js";import"./toggle-expansion-button-Bdpb_YfG.js";import"./panel-top-open-DQ1wo5PZ.js";import"./summary-BV3HUEgI.js";import"./create-event-handler-BiA-1lGu.js";import"./list-plus-Cv8qnwZd.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-DDVojjq0.js";import"./addDays-CjlJbHpj.js";import"./tooltip-Cy3vJ3fy.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const ln=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],cn=se("chart-line",ln);/**
|
|
7
7
|
* @license lucide-react v0.548.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const on=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ls=se("circle-check",on);/**
|
|
12
12
|
* @license lucide-react v0.548.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const dn=[["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=se("dollar-sign",dn);/**
|
|
17
17
|
* @license lucide-react v0.548.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const mn=[["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"}]],un=se("file-check",mn);/**
|
|
22
22
|
* @license lucide-react v0.548.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
27
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nn(s,t){if(s){if(typeof s=="string")return ze(s,t);var n=Object.prototype.toString.call(s).slice(8,-1);if(n==="Object"&&s.constructor&&(n=s.constructor.name),n==="Map"||n==="Set")return Array.from(s);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ze(s,t)}}function bn(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Cn(s){if(Array.isArray(s))return ze(s)}function ze(s,t){(t==null||t>s.length)&&(t=s.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=s[n];return a}function wn(s,t){if(!(s instanceof t))throw new TypeError("Cannot call a class as a function")}function ms(s,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(s,Os(a.key),a)}}function An(s,t,n){return t&&ms(s.prototype,t),n&&ms(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function Sn(s,t,n){return t=ke(t),kn(s,Ps()?Reflect.construct(t,n||[],ke(s).constructor):t.apply(s,n))}function kn(s,t){if(t&&(re(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return In(s)}function In(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ps(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ps=function(){return!!s})()}function ke(s){return ke=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ke(s)}function Dn(s,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(t&&t.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),t&&Ge(s,t)}function Ge(s,t){return Ge=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,l){return a.__proto__=l,a},Ge(s,t)}function $(s,t,n){return t=Os(t),t in s?Object.defineProperty(s,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[t]=n,s}function Os(s){var t=Tn(s,"string");return re(t)=="symbol"?t:t+""}function Tn(s,t){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var a=n.call(s,t);if(re(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var le=(function(s){function t(){var n;wn(this,t);for(var a=arguments.length,l=new Array(a),o=0;o<a;o++)l[o]=arguments[o];return n=Sn(this,t,[].concat(l)),$(n,"state",{isAnimationFinished:!0,totalLength:0}),$(n,"generateSimpleStrokeDasharray",function(r,i){return"".concat(i,"px ").concat(r-i,"px")}),$(n,"getStrokeDasharray",function(r,i,c){var d=c.reduce(function(O,m){return O+m});if(!d)return n.generateSimpleStrokeDasharray(i,r);for(var u=Math.floor(r/d),h=r%d,x=i-r,p=[],w=0,I=0;w<c.length;I+=c[w],++w)if(I+c[w]>h){p=[].concat(ne(c.slice(0,w)),[h-I]);break}var E=p.length%2===0?[0,x]:[x];return[].concat(ne(t.repeat(c,u)),ne(p),E).map(function(O){return"".concat(O,"px")}).join(", ")}),$(n,"id",$t("recharts-line-")),$(n,"pathRef",function(r){n.mainCurve=r}),$(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),$(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Dn(t,s),An(t,[{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,l){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,r=o.points,i=o.xAxis,c=o.yAxis,d=o.layout,u=o.children,h=Ot(u,Lt);if(!h)return null;var x=function(I,E){return{x:I.x,y:I.y,value:I.value,errorVal:Is(I.payload,E)}},p={clipPath:a?"url(#clipPath-".concat(l,")"):null};return V.createElement(Pe,p,h.map(function(w){return V.cloneElement(w,{key:"bar-".concat(w.props.dataKey),data:r,xAxis:i,yAxis:c,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(a,l,o){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.dot,d=i.points,u=i.dataKey,h=we(this.props,!1),x=we(c,!0),p=d.map(function(I,E){var O=R(R(R({key:"dot-".concat(E),r:3},h),x),{},{index:E,cx:I.x,cy:I.y,value:I.value,dataKey:u,payload:I.payload,points:d});return t.renderDotItem(c,O)}),w={clipPath:a?"url(#clipPath-".concat(l?"":"dots-").concat(o,")"):null};return V.createElement(Pe,ve({className:"recharts-line-dots",key:"dots"},w),p)}},{key:"renderCurveStatically",value:function(a,l,o,r){var i=this.props,c=i.type,d=i.layout,u=i.connectNulls;i.ref;var h=os(i,gn),x=R(R(R({},we(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:l?"url(#clipPath-".concat(o,")"):null,points:a},r),{},{type:c,layout:d,connectNulls:u});return V.createElement(Ft,ve({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,l){var o=this,r=this.props,i=r.points,c=r.strokeDasharray,d=r.isAnimationActive,u=r.animationBegin,h=r.animationDuration,x=r.animationEasing,p=r.animationId,w=r.animateNewValues,I=r.width,E=r.height,O=this.state,m=O.prevPoints,v=O.totalLength;return V.createElement(Vt,{begin:u,duration:h,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(L){var F=L.t;if(m){var X=m.length/i.length,U=i.map(function(B,Be){var ce=Math.floor(Be*X);if(m[ce]){var oe=m[ce],te=me(oe.x,B.x),Fs=me(oe.y,B.y);return R(R({},B),{},{x:te(F),y:Fs(F)})}if(w){var Vs=me(I*2,B.x),_s=me(E/2,B.y);return R(R({},B),{},{x:Vs(F),y:_s(F)})}return R(R({},B),{},{x:B.x,y:B.y})});return o.renderCurveStatically(U,a,l)}var se=me(0,v),y=se(F),S;if(c){var D="".concat(c).split(/[,\s]+/gim).map(function(B){return parseFloat(B)});S=o.getStrokeDasharray(y,v,D)}else S=o.generateSimpleStrokeDasharray(v,y);return o.renderCurveStatically(i,a,l,{strokeDasharray:S})})}},{key:"renderCurve",value:function(a,l){var o=this.props,r=o.points,i=o.isAnimationActive,c=this.state,d=c.prevPoints,u=c.totalLength;return i&&r&&r.length&&(!d&&u>0||!_t(d,r))?this.renderCurveWithAnimation(a,l):this.renderCurveStatically(r,a,l)}},{key:"render",value:function(){var a,l=this.props,o=l.hide,r=l.dot,i=l.points,c=l.className,d=l.xAxis,u=l.yAxis,h=l.top,x=l.left,p=l.width,w=l.height,I=l.isAnimationActive,E=l.id;if(o||!i||!i.length)return null;var O=this.state.isAnimationFinished,m=i.length===1,v=ts("recharts-line",c),L=d&&d.allowDataOverflow,F=u&&u.allowDataOverflow,X=L||F,U=Ue(E)?this.id:E,se=(a=we(r,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},y=se.r,S=y===void 0?3:y,D=se.strokeWidth,B=D===void 0?2:D,Be=Rt(r)?r:{},ce=Be.clipDot,oe=ce===void 0?!0:ce,te=S*2+B;return V.createElement(Pe,{className:v},L||F?V.createElement("defs",null,V.createElement("clipPath",{id:"clipPath-".concat(U)},V.createElement("rect",{x:L?x:x-p/2,y:F?h:h-w/2,width:L?p:p*2,height:F?w:w*2})),!oe&&V.createElement("clipPath",{id:"clipPath-dots-".concat(U)},V.createElement("rect",{x:x-te/2,y:h-te/2,width:p+te,height:w+te}))):null,!m&&this.renderCurve(X,U),this.renderErrorBar(X,U),(m||r)&&this.renderDots(X,oe,U),(!I||O)&&Mt.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(a,l){return a.animationId!==l.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,prevPoints:l.curPoints}:a.points!==l.curPoints?{curPoints:a.points}:null}},{key:"repeat",value:function(a,l){for(var o=a.length%2!==0?[].concat(ne(a),[0]):a,r=[],i=0;i<l;++i)r=[].concat(ne(r),ne(o));return r}},{key:"renderDotItem",value:function(a,l){var o;if(V.isValidElement(a))o=V.cloneElement(a,l);else if(Bt(a))o=a(l);else{var r=l.key,i=os(l,fn),c=ts("recharts-line-dot",typeof a!="boolean"?a.className:"");o=V.createElement(Pt,ve({key:r},i,{className:c}))}return o}}])})(b.PureComponent);$(le,"displayName","Line");$(le,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Ut.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});$(le,"getComposedData",function(s){var t=s.props,n=s.xAxis,a=s.yAxis,l=s.xAxisTicks,o=s.yAxisTicks,r=s.dataKey,i=s.bandSize,c=s.displayedData,d=s.offset,u=t.layout,h=c.map(function(x,p){var w=Is(x,r);return u==="horizontal"?{x:is({axis:n,ticks:l,bandSize:i,entry:x,index:p}),y:Ue(w)?null:a.scale(w),value:w,payload:x}:{x:Ue(w)?null:n.scale(w),y:is({axis:a,ticks:o,bandSize:i,entry:x,index:p}),value:w,payload:x}});return R({points:h,layout:u},d)});var En=zt({chartName:"LineChart",GraphicalChild:le,axisComponents:[{axisType:"xAxis",AxisComp:Ds},{axisType:"yAxis",AxisComp:Ts}],formatAxisMap:Gt});const ue=[{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 Bn(){const s=ue.reduce((n,a)=>n+a.revenue,0),t=s/ue.length;return e.jsxs(G,{children:[e.jsxs(q,{children:[e.jsx(W,{children:"Revenue Analytics"}),e.jsx(K,{children:"Revenue and expenses over time"})]}),e.jsxs(H,{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(Ae,{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(Fe,{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(Ae,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",t.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{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(Ae,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",ue[ue.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(qt,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Wt,{width:"100%",height:"100%",children:e.jsxs(En,{data:ue,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Kt,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ds,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ts,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ht,{content:e.jsx(Xt,{})}),e.jsx(le,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(le,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Pn="updateBusiness",Ls=()=>{const[{fetching:s},t]=Ie(qs),n=b.useCallback(async a=>{const l=`Error updating business ID [${a.businessId}]`,o=`${Pn}-${a.businessId}`;M.loading("Updating business",{id:o});try{const r=await t(a),i=De(r,l,o,"updateBusiness");if(i)return M.success("Success",{id:o,description:"Business updated"}),i.updateBusiness}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateBusiness:n}},On=Object.values(et);function us(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(t=>t.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 Ln(s){const n=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,l=s.description||s.tags||s.phrases||s.emails||n?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:n}: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:l}}function Fn({data:s,refetchBusiness:t}){const n=Ce(Ks,s),[a,l]=b.useState(us(n)),{userContext:o}=b.useContext(Qe),{updateBusiness:r,fetching:i}=Ls(),[c,d]=b.useState(!1),[u,h]=b.useState(void 0),x=Te({defaultValues:a}),p=async I=>{if(!n||!o?.context.adminBusinessId)return;const E=Je(I,x.formState.dirtyFields);if(!E)return;const O=Ln(E);await r({businessId:n.id,ownerId:o.context.adminBusinessId,fields:O}),E.tags?.length||E.description?(h({tagIds:E.tags?.map(m=>({id:m})),description:E.description}),d(!0)):t?.()};if(b.useEffect(()=>{if(n){const I=us(n);l(I),x.reset(I)}},[n,x]),!n)return e.jsx("div",{});const w=x.watch("isClient");return e.jsxs(G,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Configurations"}),e.jsx(K,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!w&&e.jsx(Ws,{businessId:n.id,onDone:t})]})}),e.jsx(Ee,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(p),children:[e.jsxs(H,{className:"space-y-6",children:[e.jsx(Vn,{form:x}),e.jsx(ae,{}),e.jsx(_n,{form:x}),e.jsx(ae,{}),e.jsx(Rn,{form:x}),e.jsx(ae,{}),e.jsx(Mn,{form:x})]}),e.jsx(He,{className:"flex justify-end border-t pt-6",children:e.jsxs(P,{type:"submit",disabled:i||Object.keys(x.formState.dirtyFields).length===0,children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(dn,{businessId:n.id,tagIds:u?.tagIds,description:u?.description,open:c,onOpenChange:d,onClose:t})]})}function Vn({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:t,fieldState:n})=>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(ee,{children:"Mark this business as a client"})]}),e.jsx(N,{children:e.jsx(Q,{disabled:!0,checked:t.value,onCheckedChange:t.onChange,className:A(n)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:t,fieldState:n})=>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(ee,{children:"Business is currently active"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:A(n)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:t,fieldState:n})=>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(ee,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:A(n)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:t,fieldState:n})=>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(ee,{children:"Skip document validation for common charges"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:A(n)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:t,fieldState:n})=>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(ee,{children:"Mute missing VAT indicator"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:A(n)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:t,fieldState:n})=>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(ee,{children:"Business is exempt from VAT requirements"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:A(n)})})]})})]})]})}function _n({form:s}){const{selectableTaxCategories:t,fetching:n}=Hs(),{selectableSortCodes:a,fetching:l,sortCodes:o}=Xs(),{selectableTags:r,fetching:i}=Js(),c=b.useCallback(d=>{if(d){const u=o.find(h=>Number(h.key)===Number(d));u&&(u.defaultIrsCode?s.setValue("irsCode",u.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,o]);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:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(N,{children:e.jsx(Ve,{onChange:h=>{c(h),d.onChange(h)},data:a,value:d.value,disabled:l,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:A(u)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(N,{children:e.jsx(Ve,{data:t,disabled:n,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:A(u)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(xe,{onValueChange:d.onChange,value:d.value,children:[e.jsx(N,{children:e.jsx(pe,{className:A(u),children:e.jsx(je,{})})}),e.jsx(ge,{children:Object.entries(Qs).map(([h,x])=>e.jsx(fe,{value:h,children:`${x} (${h})`},h))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(N,{children:e.jsx(Ys,{value:d.value??void 0,onValueChange:h=>d.onChange(h??null),hideControls:!0,decimalScale:0,className:A(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:A(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(N,{children:e.jsx(Zs,{options:Object.values(r).map(({value:h,label:x})=>({label:x,value:h})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:i,className:A(u)})}),e.jsx(C,{})]})})]})]})}function Rn({form:s}){const[t,n]=b.useState(""),[a,l]=b.useState(""),o=()=>{if(t.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,t.trim()],{shouldDirty:!0}),n("")}},r=()=>{if(a.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,a.trim()],{shouldDirty:!0}),l("")}},i=d=>{const u=s.getValues("phrases");s.setValue("phrases",u.filter((h,x)=>x!==d),{shouldDirty:!0})},c=d=>{const u=s.getValues("emails");s.setValue("emails",u.filter((h,x)=>x!==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:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:t,onChange:h=>n(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),o())},className:A(u)}),e.jsx(P,{type:"button",size:"sm",onClick:o,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[h,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(x),children:e.jsx(ie,{className:"size-3 cursor-pointer",onClick:()=>i(x)})})]},x))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:d,fieldState:u})=>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:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),r())},className:A(u)}),e.jsx(P,{type:"button",size:"sm",onClick:r,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[h,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>c(x),children:e.jsx(ie,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(C,{})]})})]})}function Mn({form:s}){const[t,n]=b.useState(""),a=()=>{if(t.trim()){const r=s.getValues("internalLinks");s.setValue("internalLinks",[...r,t.trim()],{shouldDirty:!0}),n("")}},l=r=>{const i=s.getValues("attachmentTypes");s.setValue("attachmentTypes",i?.includes(r)?i.filter(c=>c!==r):[...i,r],{shouldDirty:!0})},o=r=>{const i=s.getValues("internalLinks");s.setValue("internalLinks",i.filter((c,d)=>d!==r),{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:r,fieldState:i})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:A(i)+" rounded-md flex flex-wrap gap-2",children:On.map(c=>e.jsx(Z,{variant:r.value?.includes(c)?"default":"outline",className:"cursor-pointer",onClick:()=>l(c),children:c},c))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:r,fieldState:i})=>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:t,onChange:c=>n(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())}}),e.jsx(P,{type:"button",size:"sm",onClick:a,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:A(i)+" flex flex-wrap gap-2 rounded-md",children:r.value?.map((c,d)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[c,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(ie,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:r,fieldState:i})=>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(ee,{children:"Extract information from email message body"})]}),e.jsx(N,{children:e.jsx(Q,{checked:r.value,onCheckedChange:r.onChange,className:A(i)})})]})})]})}const $n=Xe({businessName:_().min(1,"Business name is required"),locality:_().min(1,"Locality is required"),localName:_().optional(),govId:_().optional(),address:_().optional(),localAddress:_().optional(),phone:_().optional(),website:vs("Invalid URL").optional().or(ys("")),generalContacts:$e(ns()).optional(),billingEmails:$e(ns()).optional()});function hs(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(t=>t.trim()),billingEmails:s.clientInfo?.emails}}function Un(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 zn({data:s,refetchBusiness:t}){const n=Ce(nt,s),[a,l]=b.useState(hs(n)),{userContext:o}=b.useContext(Qe),{updateBusiness:r,fetching:i}=Ls(),c=Te({resolver:Ke($n),defaultValues:a}),{countries:d,fetching:u}=st(),[h,x]=b.useState(""),[p,w]=b.useState(""),I=c.watch("locality"),E=c.watch("address"),O=c.watch("localAddress");b.useEffect(()=>{E!==a.address&&c.setValue("address",E,{shouldDirty:!0})},[E,a.address,c]),b.useEffect(()=>{O!==a.localAddress&&c.setValue("localAddress",O,{shouldDirty:!0})},[O,a.localAddress,c]);const m=n&&"clientInfo"in n&&!!n.clientInfo,v=I===o?.context.locality,L=y=>{h.trim()&&(c.setValue("generalContacts",[...y,h.trim()],{shouldDirty:!0}),x(""))},F=(y,S)=>{c.setValue("generalContacts",y.filter((D,B)=>B!==S),{shouldDirty:!0})},X=y=>{p.trim()&&(c.setValue("billingEmails",[...y,p.trim()],{shouldDirty:!0}),w(""))},U=(y,S)=>{c.setValue("billingEmails",y.filter((D,B)=>B!==S),{shouldDirty:!0})},se=async y=>{if(!n||!o?.context.adminBusinessId)return;const S=Je(y,c.formState.dirtyFields);if(!S)return;const D=Un(S);await r({businessId:n.id,ownerId:o.context.adminBusinessId,fields:D}),t?.()};return b.useEffect(()=>{if(n){const y=hs(n);l(y),c.reset(y)}},[n,c]),e.jsxs(G,{children:[e.jsxs(q,{children:[e.jsx(W,{children:"Contact Information"}),e.jsx(K,{children:"Business contact details and address information"})]}),e.jsx(Ee,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(se),children:[e.jsx(H,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:c.control,name:"businessName",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(N,{children:e.jsx(T,{...y,className:A(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"locality",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(Ve,{onChange:y.onChange,data:d.map(D=>({value:D.code,label:D.name})),value:y.value,disabled:u,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:A(S)}}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"localName",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(N,{children:e.jsx(T,{...y,placeholder:"Business name in local language",className:A(S)})}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"govId",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(N,{children:e.jsx(T,{...y,placeholder:"Enter Government ID",className:A(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"address",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Address"]}),e.jsx(N,{children:e.jsx(Re,{...y,rows:3,placeholder:"Enter business address",className:A(S)})}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"localAddress",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(N,{children:e.jsx(Re,{...y,rows:3,placeholder:"Enter address in local language",className:A(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"phone",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Phone"]}),e.jsx(N,{children:e.jsx(T,{...y,type:"tel",placeholder:"+1 (555) 123-4567",className:A(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"website",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"h-4 w-4"}),"Website"]}),e.jsx(N,{children:e.jsx(T,{...y,type:"url",placeholder:"https://example.com",className:A(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"generalContacts",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:A(S)+" flex flex-wrap gap-2 mb-2 rounded-md",children:y.value?.map((D,B)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[D,e.jsx("button",{type:"button",onClick:()=>F(y.value??[],B),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ie,{className:"h-3 w-3"})})]},B))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:h,onChange:D=>x(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),L(y.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(P,{type:"button",variant:"outline",size:"icon",disabled:!h.trim(),onClick:()=>L(y.value??[]),children:e.jsx(Y,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})}),m&&e.jsx(j,{control:c.control,name:"billingEmails",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:A(S)+" flex flex-wrap gap-2 mb-2 rounded-md",children:y.value?.map((D,B)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[D,e.jsx("button",{type:"button",onClick:()=>U(y.value??[],B),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ie,{className:"h-3 w-3"})})]},B))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:p,onChange:D=>w(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),X(y.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(P,{type:"button",variant:"outline",size:"icon",disabled:!p.trim(),onClick:()=>X(y.value??[]),children:e.jsx(Y,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})})]})}),e.jsx(He,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(P,{type:"submit",disabled:i||Object.keys(c.formState.dirtyFields).length===0,children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const Gn="createContract",qn=()=>{const[{fetching:s},t]=Ie(at),n=b.useCallback(async a=>{const l=`Error creating new contract for client[${a.input.clientId}]`,o=`${Gn}-${a.input.clientId}`;M.loading("Creating contract",{id:o});try{const r=await t(a);De(r,l,o)&&M.success("Success",{id:o,description:`Contract for client ${a.input.clientId} was successfully created`})}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{creating:s,createContract:n}},Wn="updateContract",Kn=()=>{const[{fetching:s},t]=Ie(it),n=b.useCallback(async a=>{const l=`Error updating contract ID [${a.contractId}]`,o=`${Wn}-${a.contractId}`;M.loading("Updating contract",{id:o});try{const r=await t(a),i=De(r,l,o,"updateContract");if(i)return M.success("Success",{id:o,description:"Contract updated"}),i.updateContract}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{updating:s,updateContract:n}},Hn=Xe({id:ct().optional(),startDate:as("Start date is required"),endDate:as("End date is required"),pos:$e(_()),paymentAmount:gs().min(0,"Payment amount must be non-negative"),paymentCurrency:de(Object.values(Ze),"Currency is required"),productType:de(Object.values(Ns)).optional(),msCloudLink:vs().optional().or(ys("")),billingCycle:de(Object.values(ye)).optional(),subscriptionPlan:de(Object.values(Se)).optional(),isActive:lt(),defaultRemark:_().optional(),defaultDocumentType:de(Object.values(Ye)),operationsLimit:rt().min(0,"Operations limit must be non-negative")}),xs={startDate:"",endDate:"",pos:[],paymentAmount:0,paymentCurrency:Ze.Usd,productType:Ns.Hive,msCloudLink:void 0,billingCycle:ye.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:Ye.Proforma,operationsLimit:0};function Xn({clientId:s,contract:t,onDone:n}){const[a,l]=b.useState(!1),[o,r]=b.useState(null),[i,c]=b.useState(""),{updateContract:d,updating:u}=Kn(),{createContract:h,creating:x}=qn(),p=Te({resolver:Ke(Hn),defaultValues:t||xs}),w=()=>{const m=i.trim();if(m){const v=p.getValues("pos");v.includes(m)||p.setValue("pos",[...v,m],{shouldDirty:!0}),c("")}},I=m=>{const v=p.getValues("pos");p.setValue("pos",v.filter((L,F)=>F!==m),{shouldDirty:!0})};b.useEffect(()=>{t&&(r(t),p.reset({startDate:t.startDate,endDate:t.endDate,pos:t.pos,paymentAmount:t.paymentAmount,paymentCurrency:t.paymentCurrency,productType:t.productType,msCloudLink:t.msCloudLink,billingCycle:t.billingCycle,subscriptionPlan:t.subscriptionPlan,isActive:t.isActive,defaultRemark:t.defaultRemark,defaultDocumentType:t.defaultDocumentType,operationsLimit:t.operationsLimit}),l(!0))},[t,p]);const E=()=>{r(null),p.reset(xs),l(!0)},O=b.useCallback(async m=>{if(o)await d({contractId:o.id,input:{amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:he(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:he(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}});else{if(!m.billingCycle){p.setError("billingCycle",{message:"Billing cycle is required"});return}await h({input:{clientId:s,amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:he(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:he(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}})}l(!1),r(null),n?.()},[o,n,h,d,s,p]);return e.jsxs(qe,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{size:"sm",onClick:E,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(We,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(ws,{children:o?"Edit Contract":"Create New Contract"}),e.jsx(As,{children:o?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(Ee,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(O),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"operationsLimit",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Operations Limit"}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:"500",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"pos",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Purchase Orders"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add PO...",value:i,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),w())}}),e.jsx(P,{type:"button",size:"sm",onClick:w,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:m.value?.map((v,L)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[v,L===m.value.length-1&&e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>I(L),children:e.jsx(ie,{className:"size-3 cursor-pointer flex-shrink-0"})})]},v))}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"startDate",render:({field:{onChange:m,...v}})=>e.jsxs(g,{children:[e.jsx(f,{children:"Start Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...v,onInput:L=>m(L)})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"endDate",render:({field:{onChange:m,...v}})=>e.jsxs(g,{children:[e.jsx(f,{children:"End Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...v,onInput:L=>m(L)})}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(j,{control:p.control,name:"paymentAmount",render:({field:m})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsx(f,{children:"Payment Amount"}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:"24000",...m,onChange:v=>{m.onChange(v?.target.value?Number(v?.target.value):void 0)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"paymentCurrency",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Currency"}),e.jsxs(xe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(pe,{children:e.jsx(je,{})})}),e.jsx(ge,{children:Object.values(Ze).map(v=>e.jsx(fe,{value:v,children:v},v))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"productType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Product Type"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Cloud Services",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"billingCycle",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Billing Cycle"}),e.jsxs(xe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(pe,{children:e.jsx(je,{})})}),e.jsx(ge,{children:Object.values(ye).map(v=>e.jsx(fe,{value:v,children:Es(v)},v))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"subscriptionPlan",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Subscription Plan"}),e.jsx(N,{children:e.jsxs(xe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(pe,{children:e.jsx(je,{})})}),e.jsx(ge,{children:Object.values(Se).map(v=>e.jsx(fe,{value:v,children:Bs(v)},v))})]})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.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(N,{children:e.jsx(Q,{checked:m.value,onCheckedChange:m.onChange})})]})})]}),e.jsx(j,{control:p.control,name:"msCloudLink",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"MS Cloud Link"}),e.jsx(N,{children:e.jsx(T,{type:"url",placeholder:"https://portal.azure.com/contract-id",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"defaultDocumentType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Document Type"}),e.jsxs(xe,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(pe,{children:e.jsx(je,{})})}),e.jsx(ge,{children:Object.values(Ye).map(v=>e.jsx(fe,{value:v,children:Ss(v)},v))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"defaultRemark",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Remark"}),e.jsx(N,{children:e.jsx(Re,{placeholder:"Enter default remark for this contract...",rows:3,...m})}),e.jsx(C,{})]})})]}),e.jsxs(ks,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(P,{type:"submit",disabled:x||u,children:o?"Update Contract":"Create Contract"})]})]})})]})]})}function Jn(s){return{id:s.id,pos:s.purchaseOrders??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,operationsLimit:s.operationsLimit}}function Qn({clientId:s}){const[t,n]=b.useState(null),[{data:a,fetching:l},o]=be({query:ot,variables:{clientId:s}}),r=a?.contractsByClient??[];return l?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(G,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Contracts"}),e.jsx(K,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Xn,{clientId:s,contract:t,onDone:o})]})}),e.jsx(H,{className:"space-y-4",children:r.map(i=>{const c=!!i.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:i.product}),e.jsx(Z,{variant:c?"default":"secondary",children:i.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:i.id})]}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>n(Jn(i)),children:e.jsx(Jt,{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(dt,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(i.startDate).toLocaleDateString()," →"," ",new Date(i.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Numbers"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:i.purchaseOrders.toReversed()[0]??""}),i.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:i.purchaseOrders.toReversed().slice(1).map(d=>e.jsx("span",{className:"text-xs font-thin font-mono",children:d},d))})]}),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:mt(i.amount.raw,i.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:Es(i.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:i.plan?Bs(i.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Operations Limit"}),e.jsx("p",{className:"text-sm font-medium",children:i.operationsLimit.toLocaleString()})]}),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:Ss(i.documentType)})]})]}),i.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:i.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.msCloud&&e.jsx(P,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ut,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(Qt,{className:"h-3 w-3 ml-1"})]})})})]},i.id)})})]})}function Yn({businessId:s}){return e.jsxs(G,{children:[e.jsx(q,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Documents"}),e.jsx(K,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(H,{children:e.jsx(ht,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const Zn=[{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 ea({data:s}){const t=Ce(gt,s),[{data:n,fetching:a},l]=be({query:xt,variables:{clientId:t?.id??""},pause:!t?.clientInfo?.greenInvoiceId||!t?.id}),{updateClient:o}=pt(),r=b.useCallback((c,d)=>{if(!t?.id)return;const u={};u[d]=c,o({businessId:t?.id,fields:u})},[t?.id,o]);b.useEffect(()=>{t?.clientInfo?.greenInvoiceId&&t?.id&&l()},[t?.clientInfo?.greenInvoiceId,t?.id,l]);const i=n?.greenInvoiceClient;return e.jsxs(G,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Integrations"}),e.jsx(K,{children:"Connected external services and providers"})]}),e.jsxs(P,{size:"sm",children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(H,{className:"space-y-6",children:e.jsxs(Yt,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[a?e.jsxs(Oe,{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(k,{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(k,{className:"h-6 w-32"}),e.jsx(k,{className:"h-5 w-5 rounded-full"})]}),e.jsx(k,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-8 w-24"}),e.jsx(k,{className:"h-8 w-8"})]})]})}),e.jsx(Le,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{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(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{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(k,{className:"h-3 w-32"}),e.jsx(k,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(k,{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(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{className:"h-3 w-24"}),e.jsx(k,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Oe,{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(ls,{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(sa,{id:t?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async c=>r(c,"greenInvoiceId")}),e.jsx(rs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Le,{children:i&&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:t?.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:i.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:i.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:i.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(Me,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.emails?.map((c,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:c},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(fs,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:i.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:i.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:i.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(_e,{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:i.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:i.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:i.zip})]})]})]})]})})]}),Zn.map(c=>e.jsxs(Oe,{value:c.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:c.name}),c.status==="connected"?e.jsx(ls,{className:"h-4 w-4 text-green-600"}):e.jsx(jt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(es,{className:"h-4 w-4"})}),e.jsx(rs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Le,{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:c.lastSync})]})})})]},c.id))]})})]})}function sa({id:s,provider:t,updateClient:n}){const[a,l]=b.useState(!1),[o,r]=b.useState(s),i=b.useCallback(async()=>{await n(o),l(!1)},[o,n]);return e.jsxs(qe,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",onClick:c=>c.stopPropagation(),children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(We,{onClick:c=>c.stopPropagation(),children:[e.jsxs(Cs,{children:[e.jsxs(ws,{children:["Configure ",t]}),e.jsxs(As,{children:["Update your ",t," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ft,{htmlFor:"id",children:[t," ID"]}),e.jsx(T,{id:"id",value:o,onChange:c=>r(c.target.value),placeholder:`Enter ${t} ID`})]})}),e.jsxs(ks,{children:[e.jsx(P,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(P,{onClick:i,disabled:!o,children:"Save Changes"})]})]})]})}function ta({businessId:s}){return e.jsxs(G,{children:[e.jsx(q,{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(W,{children:"Transactions"}),e.jsx(K,{children:"Complete transaction history for this business"})]})})}),e.jsx(H,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Zt,{businessID:s,filter:{}})})})]})}function na({data:s,refetchBusiness:t}){const n=Ce(wt,s),[a,l]=vt(),o=a.get("tab")||"contact",r=d=>{l({tab:d})};if(!n)return e.jsx("div",{children:"Business not found"});const i="clientInfo"in n&&!!n.clientInfo,c="adminInfo"in n&&!!n.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(It,{data:n}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(yt,{value:o,onValueChange:r,className:"w-full",children:[e.jsxs(Nt,{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(J,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(en,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(J,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(es,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(J,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ae,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(J,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(bt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(J,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ct,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs(J,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(an,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(J,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ln,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),c&&e.jsxs(J,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(js,{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(zn,{data:n,refetchBusiness:t})}),e.jsx(z,{value:"config",className:"mt-0",children:e.jsx(Fn,{data:n,refetchBusiness:t})}),e.jsx(z,{value:"charges",className:"mt-0",children:e.jsx(jn,{businessId:n.id})}),e.jsx(z,{value:"transactions",className:"mt-0",children:e.jsx(ta,{businessId:n.id})}),e.jsx(z,{value:"documents",className:"mt-0",children:e.jsx(Yn,{businessId:n.id})}),i&&e.jsxs(e.Fragment,{children:[e.jsx(z,{value:"contracts",className:"mt-0",children:e.jsx(Qn,{clientId:n.id})}),e.jsx(z,{value:"integrations",className:"mt-0",children:e.jsx(ea,{data:n})}),e.jsx(z,{value:"charts",className:"mt-0",children:e.jsx(Bn,{})})]}),c&&e.jsx(z,{value:"admin",className:"mt-0",children:e.jsx(pn,{data:n})})]})})]})}const Sa=()=>{const{businessId:s}=At();let t;try{t=St()}catch{}const[{data:n,fetching:a},l]=be({query:kt,pause:!s||!!t,variables:{businessId:s??""}}),o=t||n;return!t&&a&&!o?.business?e.jsx(ps,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(na,{data:o.business,refetchBusiness:async()=>l()})};export{Sa as BusinessScreen};
|
|
26
|
+
*/const hn=[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]],xn=se("notebook",hn);/**
|
|
27
|
+
* @license lucide-react v0.548.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 pn=[["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"}]],jn=se("plug",pn);/**
|
|
32
|
+
* @license lucide-react v0.548.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 gn=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Fe=se("trending-up",gn);function Bs(s){switch(s){case be.Annual:return"Annual";case be.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${s}`)}}function Es(s){switch(s){case Se.Enterprise:return"Enterprise";case Se.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${s}`)}}function fn(s){return pe(s,"yyyy-MM-dd")}function vn({businessId:s,tagIds:t,description:n,open:a,onOpenChange:l,onClose:o}){const[{data:r,fetching:i},c]=te({pause:!0,query:Rs,variables:{businessId:s,tagsDifferentThan:t?t.map(h=>h.id):void 0,descriptionDifferentThan:n}});b.useEffect(()=>{a&&(t||n)&&!r&&c()},[a,t,n,c,r]);const d=b.useCallback(h=>{l(h),a&&!h&&o?.()},[l,o,a]),u=b.useMemo(()=>a&&(!!t||!!n)&&r&&r?.similarChargesByBusiness.length>0,[a,t,n,r]);return e.jsx(Ge,{open:u,onOpenChange:d,children:e.jsx(We,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:h=>h.stopPropagation(),children:e.jsx(Ms,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:i?e.jsx(ps,{}):t||n?e.jsx(Pt,{data:r?.similarChargesByBusiness??[],tagIds:t,description:n,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const yn="updateAdminBusiness",Nn=()=>{const[{fetching:s},t]=Ie($s),n=b.useCallback(async a=>{const l=`Error updating admin business ID [${a.adminBusinessId}]`,o=`${yn}-${a.adminBusinessId}`;M.loading("Updating admin business",{id:o});try{const r=await t(a),i=De(r,l,o,"updateAdminBusiness");if(i)return M.success("Success",{id:o,description:"Admin Business Updated"}),i.updateAdminBusiness}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateAdminBusiness:n}},bn=Xe({withholdingTaxBookNumber:_().min(1,{message:"Withholding Tax Book Number is required"}),withholdingTaxFileNumber:_().min(1,{message:"Withholding Tax File Number is required"}),socialSecurityEmployerId:_().min(1,{message:"National Insurance Employer ID is required"}),taxAdvancesRate:gs().min(0,{message:"Advance Tax Rate must be at least 0"}).max(100,{message:"Advance Tax Rate must be at most 100"}),taxAdvancesId:_().min(1,{message:"Tax Advances ID is required"}),registrationDate:_().min(1,{message:"Business Registration Start Date is required"})});function cs(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{withholdingTaxBookNumber:s.adminInfo.withholdingTaxBookNumber??"",withholdingTaxFileNumber:s.adminInfo.withholdingTaxFileNumber??"",socialSecurityEmployerId:s.adminInfo.socialSecurityEmployerId??"",taxAdvancesRate:s.adminInfo.taxAdvancesRate??0,taxAdvancesId:s.adminInfo.taxAdvancesId??"",registrationDate:s.adminInfo.registrationDate??""}}function Cn(s){return{withholdingTaxBookNumber:s.withholdingTaxBookNumber,withholdingTaxFileNumber:s.withholdingTaxFileNumber,socialSecurityEmployerId:s.socialSecurityEmployerId,taxAdvancesRate:s.taxAdvancesRate,taxAdvancesId:s.taxAdvancesId,registrationDate:s.registrationDate?fn(new Date(s.registrationDate)):void 0}}function wn({data:s,refetchBusiness:t}){const n=Ce(Us,s),[a,l]=b.useState(cs(n)),{updateAdminBusiness:o,fetching:r}=Nn(),i=Te({resolver:Ke(bn),defaultValues:a}),c=async d=>{if(!n)return;const u=Je(d,i.formState.dirtyFields);if(!u)return;const h=Cn(u);await o({adminBusinessId:n.id,fields:h}),t?.()};return b.useEffect(()=>{if(n){const d=cs(n);l(d),i.reset(d)}},[n,i]),e.jsxs(z,{children:[e.jsxs(q,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"h-5 w-5 text-primary"}),e.jsx(G,{children:"Admin Business Configuration"})]}),e.jsx(W,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Be,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-6",children:[e.jsx(K,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Withholding Tax"}),e.jsx(j,{control:i.control,name:"withholdingTaxBookNumber",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Book Number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter book number",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:i.control,name:"withholdingTaxFileNumber",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"File Number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter file number",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(re,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Tax Advances"}),e.jsx(j,{control:i.control,name:"taxAdvancesId",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Identification number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter tax advances ID",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:i.control,name:"taxAdvancesRate",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Rate (%)"}),e.jsx(N,{children:e.jsx(T,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"Enter tax rate",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(re,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Social Security"}),e.jsx(j,{control:i.control,name:"socialSecurityEmployerId",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Employer Identifier"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter employer ID",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(re,{className:"md:col-span-2"}),e.jsx(j,{control:i.control,name:"registrationDate",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Registration Start Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...d,className:k(u)})}),e.jsx(C,{})]})})]})}),e.jsx(He,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(P,{type:"submit",disabled:r||Object.keys(i.formState.dirtyFields).length===0||!i.formState.isValid,children:[e.jsx(ss,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function kn({businessId:s}){return e.jsxs(z,{children:[e.jsx(q,{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(G,{children:"Balance"}),e.jsx(W,{children:"Business balance overview"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Bt,{businessID:s,filter:{}})})})]})}function Sn({businessId:s}){const{userContext:t}=b.useContext(Qe),[n,a]=b.useState(1),[{data:l,fetching:o}]=te({query:zs,variables:{filters:{byOwners:t?.context.adminBusinessId?[t.context.adminBusinessId]:void 0,sortBy:{field:qs.Date,asc:!1},byBusinesses:[s]},page:n,limit:100}}),r=l?.allCharges?.pageInfo.totalPages??1,i=l?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(z,{children:[e.jsxs(q,{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(G,{children:"Charges"}),e.jsx(W,{children:"Recurring and one-time charges for this business"})]})}),r>1&&e.jsx(Ft,{className:"flex-fit",value:n,onChange:a,total:r})]}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Lt,{data:i,isAllOpened:!1})})})]})}var An=["type","layout","connectNulls","ref"],In=["key"];function ce(s){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ce(s)}function os(s,t){if(s==null)return{};var n=Dn(s,t),a,l;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(l=0;l<o.length;l++)a=o[l],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(s,a)&&(n[a]=s[a])}return n}function Dn(s,t){if(s==null)return{};var n={};for(var a in s)if(Object.prototype.hasOwnProperty.call(s,a)){if(t.indexOf(a)>=0)continue;n[a]=s[a]}return n}function Ne(){return Ne=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(s[a]=n[a])}return s},Ne.apply(this,arguments)}function ds(s,t){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);t&&(a=a.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),n.push.apply(n,a)}return n}function R(s){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ds(Object(n),!0).forEach(function(a){U(s,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):ds(Object(n)).forEach(function(a){Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(n,a))})}return s}function ie(s){return Pn(s)||En(s)||Bn(s)||Tn()}function Tn(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
37
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bn(s,t){if(s){if(typeof s=="string")return ze(s,t);var n=Object.prototype.toString.call(s).slice(8,-1);if(n==="Object"&&s.constructor&&(n=s.constructor.name),n==="Map"||n==="Set")return Array.from(s);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ze(s,t)}}function En(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Pn(s){if(Array.isArray(s))return ze(s)}function ze(s,t){(t==null||t>s.length)&&(t=s.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=s[n];return a}function Ln(s,t){if(!(s instanceof t))throw new TypeError("Cannot call a class as a function")}function ms(s,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(s,Ls(a.key),a)}}function On(s,t,n){return t&&ms(s.prototype,t),n&&ms(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function Fn(s,t,n){return t=Ae(t),Vn(s,Ps()?Reflect.construct(t,n||[],Ae(s).constructor):t.apply(s,n))}function Vn(s,t){if(t&&(ce(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _n(s)}function _n(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ps(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ps=function(){return!!s})()}function Ae(s){return Ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ae(s)}function Rn(s,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(t&&t.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),t&&qe(s,t)}function qe(s,t){return qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,l){return a.__proto__=l,a},qe(s,t)}function U(s,t,n){return t=Ls(t),t in s?Object.defineProperty(s,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[t]=n,s}function Ls(s){var t=Mn(s,"string");return ce(t)=="symbol"?t:t+""}function Mn(s,t){if(ce(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var a=n.call(s,t);if(ce(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var oe=(function(s){function t(){var n;Ln(this,t);for(var a=arguments.length,l=new Array(a),o=0;o<a;o++)l[o]=arguments[o];return n=Fn(this,t,[].concat(l)),U(n,"state",{isAnimationFinished:!0,totalLength:0}),U(n,"generateSimpleStrokeDasharray",function(r,i){return"".concat(i,"px ").concat(r-i,"px")}),U(n,"getStrokeDasharray",function(r,i,c){var d=c.reduce(function(L,m){return L+m});if(!d)return n.generateSimpleStrokeDasharray(i,r);for(var u=Math.floor(r/d),h=r%d,x=i-r,p=[],w=0,I=0;w<c.length;I+=c[w],++w)if(I+c[w]>h){p=[].concat(ie(c.slice(0,w)),[h-I]);break}var B=p.length%2===0?[0,x]:[x];return[].concat(ie(t.repeat(c,u)),ie(p),B).map(function(L){return"".concat(L,"px")}).join(", ")}),U(n,"id",Wt("recharts-line-")),U(n,"pathRef",function(r){n.mainCurve=r}),U(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),U(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Rn(t,s),On(t,[{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,l){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,r=o.points,i=o.xAxis,c=o.yAxis,d=o.layout,u=o.children,h=Rt(u,Mt);if(!h)return null;var x=function(I,B){return{x:I.x,y:I.y,value:I.value,errorVal:Is(I.payload,B)}},p={clipPath:a?"url(#clipPath-".concat(l,")"):null};return V.createElement(Pe,p,h.map(function(w){return V.cloneElement(w,{key:"bar-".concat(w.props.dataKey),data:r,xAxis:i,yAxis:c,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(a,l,o){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.dot,d=i.points,u=i.dataKey,h=we(this.props,!1),x=we(c,!0),p=d.map(function(I,B){var L=R(R(R({key:"dot-".concat(B),r:3},h),x),{},{index:B,cx:I.x,cy:I.y,value:I.value,dataKey:u,payload:I.payload,points:d});return t.renderDotItem(c,L)}),w={clipPath:a?"url(#clipPath-".concat(l?"":"dots-").concat(o,")"):null};return V.createElement(Pe,Ne({className:"recharts-line-dots",key:"dots"},w),p)}},{key:"renderCurveStatically",value:function(a,l,o,r){var i=this.props,c=i.type,d=i.layout,u=i.connectNulls;i.ref;var h=os(i,An),x=R(R(R({},we(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:l?"url(#clipPath-".concat(o,")"):null,points:a},r),{},{type:c,layout:d,connectNulls:u});return V.createElement($t,Ne({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,l){var o=this,r=this.props,i=r.points,c=r.strokeDasharray,d=r.isAnimationActive,u=r.animationBegin,h=r.animationDuration,x=r.animationEasing,p=r.animationId,w=r.animateNewValues,I=r.width,B=r.height,L=this.state,m=L.prevPoints,v=L.totalLength;return V.createElement(Ut,{begin:u,duration:h,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var F=O.t;if(m){var J=m.length/i.length,X=i.map(function(E,Ee){var de=Math.floor(Ee*J);if(m[de]){var me=m[de],ae=he(me.x,E.x),Fs=he(me.y,E.y);return R(R({},E),{},{x:ae(F),y:Fs(F)})}if(w){var Vs=he(I*2,E.x),_s=he(B/2,E.y);return R(R({},E),{},{x:Vs(F),y:_s(F)})}return R(R({},E),{},{x:E.x,y:E.y})});return o.renderCurveStatically(X,a,l)}var ne=he(0,v),y=ne(F),S;if(c){var D="".concat(c).split(/[,\s]+/gim).map(function(E){return parseFloat(E)});S=o.getStrokeDasharray(y,v,D)}else S=o.generateSimpleStrokeDasharray(v,y);return o.renderCurveStatically(i,a,l,{strokeDasharray:S})})}},{key:"renderCurve",value:function(a,l){var o=this.props,r=o.points,i=o.isAnimationActive,c=this.state,d=c.prevPoints,u=c.totalLength;return i&&r&&r.length&&(!d&&u>0||!zt(d,r))?this.renderCurveWithAnimation(a,l):this.renderCurveStatically(r,a,l)}},{key:"render",value:function(){var a,l=this.props,o=l.hide,r=l.dot,i=l.points,c=l.className,d=l.xAxis,u=l.yAxis,h=l.top,x=l.left,p=l.width,w=l.height,I=l.isAnimationActive,B=l.id;if(o||!i||!i.length)return null;var L=this.state.isAnimationFinished,m=i.length===1,v=ts("recharts-line",c),O=d&&d.allowDataOverflow,F=u&&u.allowDataOverflow,J=O||F,X=Ue(B)?this.id:B,ne=(a=we(r,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},y=ne.r,S=y===void 0?3:y,D=ne.strokeWidth,E=D===void 0?2:D,Ee=qt(r)?r:{},de=Ee.clipDot,me=de===void 0?!0:de,ae=S*2+E;return V.createElement(Pe,{className:v},O||F?V.createElement("defs",null,V.createElement("clipPath",{id:"clipPath-".concat(X)},V.createElement("rect",{x:O?x:x-p/2,y:F?h:h-w/2,width:O?p:p*2,height:F?w:w*2})),!me&&V.createElement("clipPath",{id:"clipPath-dots-".concat(X)},V.createElement("rect",{x:x-ae/2,y:h-ae/2,width:p+ae,height:w+ae}))):null,!m&&this.renderCurve(J,X),this.renderErrorBar(J,X),(m||r)&&this.renderDots(J,me,X),(!I||L)&&Gt.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(a,l){return a.animationId!==l.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,prevPoints:l.curPoints}:a.points!==l.curPoints?{curPoints:a.points}:null}},{key:"repeat",value:function(a,l){for(var o=a.length%2!==0?[].concat(ie(a),[0]):a,r=[],i=0;i<l;++i)r=[].concat(ie(r),ie(o));return r}},{key:"renderDotItem",value:function(a,l){var o;if(V.isValidElement(a))o=V.cloneElement(a,l);else if(Vt(a))o=a(l);else{var r=l.key,i=os(l,In),c=ts("recharts-line-dot",typeof a!="boolean"?a.className:"");o=V.createElement(_t,Ne({key:r},i,{className:c}))}return o}}])})(b.PureComponent);U(oe,"displayName","Line");U(oe,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Kt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});U(oe,"getComposedData",function(s){var t=s.props,n=s.xAxis,a=s.yAxis,l=s.xAxisTicks,o=s.yAxisTicks,r=s.dataKey,i=s.bandSize,c=s.displayedData,d=s.offset,u=t.layout,h=c.map(function(x,p){var w=Is(x,r);return u==="horizontal"?{x:is({axis:n,ticks:l,bandSize:i,entry:x,index:p}),y:Ue(w)?null:a.scale(w),value:w,payload:x}:{x:Ue(w)?null:n.scale(w),y:is({axis:a,ticks:o,bandSize:i,entry:x,index:p}),value:w,payload:x}});return R({points:h,layout:u},d)});var $n=Ht({chartName:"LineChart",GraphicalChild:oe,axisComponents:[{axisType:"xAxis",AxisComp:Ds},{axisType:"yAxis",AxisComp:Ts}],formatAxisMap:Xt});const xe=[{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 Un(){const s=xe.reduce((n,a)=>n+a.revenue,0),t=s/xe.length;return e.jsxs(z,{children:[e.jsxs(q,{children:[e.jsx(G,{children:"Revenue Analytics"}),e.jsx(W,{children:"Revenue and expenses over time"})]}),e.jsxs(K,{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(Fe,{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:["$",t.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{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:["$",xe[xe.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Jt,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Qt,{width:"100%",height:"100%",children:e.jsxs($n,{data:xe,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Yt,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ds,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ts,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Zt,{content:e.jsx(en,{})}),e.jsx(oe,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(oe,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const zn="updateBusiness",Os=()=>{const[{fetching:s},t]=Ie(Gs),n=b.useCallback(async a=>{const l=`Error updating business ID [${a.businessId}]`,o=`${zn}-${a.businessId}`;M.loading("Updating business",{id:o});try{const r=await t(a),i=De(r,l,o,"updateBusiness");if(i)return M.success("Success",{id:o,description:"Business updated"}),i.updateBusiness}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateBusiness:n}},qn=Object.values(et);function us(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(t=>t.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 Gn(s){const n=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,l=s.description||s.tags||s.phrases||s.emails||n?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:n}: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:l}}function Wn({data:s,refetchBusiness:t}){const n=Ce(Ks,s),[a,l]=b.useState(us(n)),{userContext:o}=b.useContext(Qe),{updateBusiness:r,fetching:i}=Os(),[c,d]=b.useState(!1),[u,h]=b.useState(void 0),x=Te({defaultValues:a}),p=async I=>{if(!n||!o?.context.adminBusinessId)return;const B=Je(I,x.formState.dirtyFields);if(!B)return;const L=Gn(B);await r({businessId:n.id,ownerId:o.context.adminBusinessId,fields:L}),B.tags?.length||B.description?(h({tagIds:B.tags?.map(m=>({id:m})),description:B.description}),d(!0)):t?.()};if(b.useEffect(()=>{if(n){const I=us(n);l(I),x.reset(I)}},[n,x]),!n)return e.jsx("div",{});const w=x.watch("isClient");return e.jsxs(z,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Configurations"}),e.jsx(W,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!w&&e.jsx(Ws,{businessId:n.id,onDone:t})]})}),e.jsx(Be,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(p),children:[e.jsxs(K,{className:"space-y-6",children:[e.jsx(Kn,{form:x}),e.jsx(re,{}),e.jsx(Hn,{form:x}),e.jsx(re,{}),e.jsx(Xn,{form:x}),e.jsx(re,{}),e.jsx(Jn,{form:x})]}),e.jsx(He,{className:"flex justify-end border-t pt-6",children:e.jsxs(P,{type:"submit",disabled:i||Object.keys(x.formState.dirtyFields).length===0,children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(vn,{businessId:n.id,tagIds:u?.tagIds,description:u?.description,open:c,onOpenChange:d,onClose:t})]})}function Kn({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:t,fieldState:n})=>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(ee,{children:"Mark this business as a client"})]}),e.jsx(N,{children:e.jsx(Q,{disabled:!0,checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:t,fieldState:n})=>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(ee,{children:"Business is currently active"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:t,fieldState:n})=>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(ee,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:t,fieldState:n})=>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(ee,{children:"Skip document validation for common charges"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:t,fieldState:n})=>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(ee,{children:"Mute missing VAT indicator"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:t,fieldState:n})=>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(ee,{children:"Business is exempt from VAT requirements"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})})]})]})}function Hn({form:s}){const{selectableTaxCategories:t,fetching:n}=Hs(),{selectableSortCodes:a,fetching:l,sortCodes:o}=Xs(),{selectableTags:r,fetching:i}=Js(),c=b.useCallback(d=>{if(d){const u=o.find(h=>Number(h.key)===Number(d));u&&(u.defaultIrsCode?s.setValue("irsCode",u.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,o]);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:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(N,{children:e.jsx(Ve,{onChange:h=>{c(h),d.onChange(h)},data:a,value:d.value,disabled:l,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:k(u)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(N,{children:e.jsx(Ve,{data:t,disabled:n,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:k(u)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(je,{onValueChange:d.onChange,value:d.value,children:[e.jsx(N,{children:e.jsx(ge,{className:k(u),children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.entries(Qs).map(([h,x])=>e.jsx(ye,{value:h,children:`${x} (${h})`},h))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(N,{children:e.jsx(Ys,{value:d.value??void 0,onValueChange:h=>d.onChange(h??null),hideControls:!0,decimalScale:0,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(N,{children:e.jsx(Zs,{options:Object.values(r).map(({value:h,label:x})=>({label:x,value:h})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:i,className:k(u)})}),e.jsx(C,{})]})})]})]})}function Xn({form:s}){const[t,n]=b.useState(""),[a,l]=b.useState(""),o=()=>{if(t.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,t.trim()],{shouldDirty:!0}),n("")}},r=()=>{if(a.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,a.trim()],{shouldDirty:!0}),l("")}},i=d=>{const u=s.getValues("phrases");s.setValue("phrases",u.filter((h,x)=>x!==d),{shouldDirty:!0})},c=d=>{const u=s.getValues("emails");s.setValue("emails",u.filter((h,x)=>x!==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:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:t,onChange:h=>n(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),o())},className:k(u)}),e.jsx(P,{type:"button",size:"sm",onClick:o,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[h,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(x),children:e.jsx(le,{className:"size-3 cursor-pointer",onClick:()=>i(x)})})]},x))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:d,fieldState:u})=>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:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),r())},className:k(u)}),e.jsx(P,{type:"button",size:"sm",onClick:r,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[h,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>c(x),children:e.jsx(le,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(C,{})]})})]})}function Jn({form:s}){const[t,n]=b.useState(""),a=()=>{if(t.trim()){const r=s.getValues("internalLinks");s.setValue("internalLinks",[...r,t.trim()],{shouldDirty:!0}),n("")}},l=r=>{const i=s.getValues("attachmentTypes");s.setValue("attachmentTypes",i?.includes(r)?i.filter(c=>c!==r):[...i,r],{shouldDirty:!0})},o=r=>{const i=s.getValues("internalLinks");s.setValue("internalLinks",i.filter((c,d)=>d!==r),{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:r,fieldState:i})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:k(i)+" rounded-md flex flex-wrap gap-2",children:qn.map(c=>e.jsx(Z,{variant:r.value?.includes(c)?"default":"outline",className:"cursor-pointer",onClick:()=>l(c),children:c},c))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:r,fieldState:i})=>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:t,onChange:c=>n(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())}}),e.jsx(P,{type:"button",size:"sm",onClick:a,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:k(i)+" flex flex-wrap gap-2 rounded-md",children:r.value?.map((c,d)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[c,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(le,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:r,fieldState:i})=>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(ee,{children:"Extract information from email message body"})]}),e.jsx(N,{children:e.jsx(Q,{checked:r.value,onCheckedChange:r.onChange,className:k(i)})})]})})]})}const Qn=Xe({businessName:_().min(1,"Business name is required"),locality:_().min(1,"Locality is required"),localName:_().optional(),govId:_().optional(),address:_().optional(),localAddress:_().optional(),phone:_().optional(),website:vs("Invalid URL").optional().or(ys("")),generalContacts:$e(ns()).optional(),billingEmails:$e(ns()).optional()});function hs(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(t=>t.trim()),billingEmails:s.clientInfo?.emails}}function Yn(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 Zn({data:s,refetchBusiness:t}){const n=Ce(nt,s),[a,l]=b.useState(hs(n)),{userContext:o}=b.useContext(Qe),{updateBusiness:r,fetching:i}=Os(),c=Te({resolver:Ke(Qn),defaultValues:a}),{countries:d,fetching:u}=st(),[h,x]=b.useState(""),[p,w]=b.useState(""),I=c.watch("locality"),B=c.watch("address"),L=c.watch("localAddress");b.useEffect(()=>{B!==a.address&&c.setValue("address",B,{shouldDirty:!0})},[B,a.address,c]),b.useEffect(()=>{L!==a.localAddress&&c.setValue("localAddress",L,{shouldDirty:!0})},[L,a.localAddress,c]);const m=n&&"clientInfo"in n&&!!n.clientInfo,v=I===o?.context.locality,O=y=>{h.trim()&&(c.setValue("generalContacts",[...y,h.trim()],{shouldDirty:!0}),x(""))},F=(y,S)=>{c.setValue("generalContacts",y.filter((D,E)=>E!==S),{shouldDirty:!0})},J=y=>{p.trim()&&(c.setValue("billingEmails",[...y,p.trim()],{shouldDirty:!0}),w(""))},X=(y,S)=>{c.setValue("billingEmails",y.filter((D,E)=>E!==S),{shouldDirty:!0})},ne=async y=>{if(!n||!o?.context.adminBusinessId)return;const S=Je(y,c.formState.dirtyFields);if(!S)return;const D=Yn(S);await r({businessId:n.id,ownerId:o.context.adminBusinessId,fields:D}),t?.()};return b.useEffect(()=>{if(n){const y=hs(n);l(y),c.reset(y)}},[n,c]),e.jsxs(z,{children:[e.jsxs(q,{children:[e.jsx(G,{children:"Contact Information"}),e.jsx(W,{children:"Business contact details and address information"})]}),e.jsx(Be,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(ne),children:[e.jsx(K,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:c.control,name:"businessName",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(N,{children:e.jsx(T,{...y,className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"locality",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(Ve,{onChange:y.onChange,data:d.map(D=>({value:D.code,label:D.name})),value:y.value,disabled:u,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:k(S)}}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"localName",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(N,{children:e.jsx(T,{...y,placeholder:"Business name in local language",className:k(S)})}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"govId",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(N,{children:e.jsx(T,{...y,placeholder:"Enter Government ID",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"address",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Address"]}),e.jsx(N,{children:e.jsx(Re,{...y,rows:3,placeholder:"Enter business address",className:k(S)})}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"localAddress",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(N,{children:e.jsx(Re,{...y,rows:3,placeholder:"Enter address in local language",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"phone",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Phone"]}),e.jsx(N,{children:e.jsx(T,{...y,type:"tel",placeholder:"+1 (555) 123-4567",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"website",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"h-4 w-4"}),"Website"]}),e.jsx(N,{children:e.jsx(T,{...y,type:"url",placeholder:"https://example.com",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"generalContacts",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:k(S)+" flex flex-wrap gap-2 mb-2 rounded-md",children:y.value?.map((D,E)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[D,e.jsx("button",{type:"button",onClick:()=>F(y.value??[],E),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(le,{className:"h-3 w-3"})})]},E))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:h,onChange:D=>x(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),O(y.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(P,{type:"button",variant:"outline",size:"icon",disabled:!h.trim(),onClick:()=>O(y.value??[]),children:e.jsx(Y,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})}),m&&e.jsx(j,{control:c.control,name:"billingEmails",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:k(S)+" flex flex-wrap gap-2 mb-2 rounded-md",children:y.value?.map((D,E)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[D,e.jsx("button",{type:"button",onClick:()=>X(y.value??[],E),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(le,{className:"h-3 w-3"})})]},E))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:p,onChange:D=>w(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),J(y.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(P,{type:"button",variant:"outline",size:"icon",disabled:!p.trim(),onClick:()=>J(y.value??[]),children:e.jsx(Y,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})})]})}),e.jsx(He,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(P,{type:"submit",disabled:i||Object.keys(c.formState.dirtyFields).length===0,children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const ea="createContract",sa=()=>{const[{fetching:s},t]=Ie(at),n=b.useCallback(async a=>{const l=`Error creating new contract for client[${a.input.clientId}]`,o=`${ea}-${a.input.clientId}`;M.loading("Creating contract",{id:o});try{const r=await t(a);De(r,l,o)&&M.success("Success",{id:o,description:`Contract for client ${a.input.clientId} was successfully created`})}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{creating:s,createContract:n}},ta="updateContract",na=()=>{const[{fetching:s},t]=Ie(it),n=b.useCallback(async a=>{const l=`Error updating contract ID [${a.contractId}]`,o=`${ta}-${a.contractId}`;M.loading("Updating contract",{id:o});try{const r=await t(a),i=De(r,l,o,"updateContract");if(i)return M.success("Success",{id:o,description:"Contract updated"}),i.updateContract}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{updating:s,updateContract:n}},aa=Xe({id:ct().optional(),startDate:as("Start date is required"),endDate:as("End date is required"),pos:$e(_()),paymentAmount:gs().min(0,"Payment amount must be non-negative"),paymentCurrency:ue(Object.values(Ze),"Currency is required"),productType:ue(Object.values(Ns)).optional(),msCloudLink:vs().optional().or(ys("")),billingCycle:ue(Object.values(be)).optional(),subscriptionPlan:ue(Object.values(Se)).optional(),isActive:lt(),defaultRemark:_().optional(),defaultDocumentType:ue(Object.values(Ye)),operationsLimit:rt().min(0,"Operations limit must be non-negative")}),xs={startDate:"",endDate:"",pos:[],paymentAmount:0,paymentCurrency:Ze.Usd,productType:Ns.Hive,msCloudLink:void 0,billingCycle:be.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:Ye.Proforma,operationsLimit:0};function ia({clientId:s,contract:t,onDone:n}){const[a,l]=b.useState(!1),[o,r]=b.useState(null),[i,c]=b.useState(""),{updateContract:d,updating:u}=na(),{createContract:h,creating:x}=sa(),p=Te({resolver:Ke(aa),defaultValues:t||xs}),w=()=>{const m=i.trim();if(m){const v=p.getValues("pos");v.includes(m)||p.setValue("pos",[...v,m],{shouldDirty:!0}),c("")}},I=m=>{const v=p.getValues("pos");p.setValue("pos",v.filter((O,F)=>F!==m),{shouldDirty:!0})};b.useEffect(()=>{t&&(r(t),p.reset({startDate:t.startDate,endDate:t.endDate,pos:t.pos,paymentAmount:t.paymentAmount,paymentCurrency:t.paymentCurrency,productType:t.productType,msCloudLink:t.msCloudLink,billingCycle:t.billingCycle,subscriptionPlan:t.subscriptionPlan,isActive:t.isActive,defaultRemark:t.defaultRemark,defaultDocumentType:t.defaultDocumentType,operationsLimit:t.operationsLimit}),l(!0))},[t,p]);const B=()=>{r(null),p.reset(xs),l(!0)},L=b.useCallback(async m=>{if(o)await d({contractId:o.id,input:{amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:pe(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:pe(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}});else{if(!m.billingCycle){p.setError("billingCycle",{message:"Billing cycle is required"});return}await h({input:{clientId:s,amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:pe(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:pe(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}})}l(!1),r(null),n?.()},[o,n,h,d,s,p]);return e.jsxs(Ge,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{size:"sm",onClick:B,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(We,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(ws,{children:o?"Edit Contract":"Create New Contract"}),e.jsx(ks,{children:o?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(Be,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(L),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"operationsLimit",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Operations Limit"}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:"500",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"pos",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Purchase Orders"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add PO...",value:i,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),w())}}),e.jsx(P,{type:"button",size:"sm",onClick:w,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:m.value?.map((v,O)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[v,O===m.value.length-1&&e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>I(O),children:e.jsx(le,{className:"size-3 cursor-pointer flex-shrink-0"})})]},v))}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"startDate",render:({field:{onChange:m,...v}})=>e.jsxs(g,{children:[e.jsx(f,{children:"Start Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...v,onInput:O=>m(O)})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"endDate",render:({field:{onChange:m,...v}})=>e.jsxs(g,{children:[e.jsx(f,{children:"End Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...v,onInput:O=>m(O)})}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(j,{control:p.control,name:"paymentAmount",render:({field:m})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsx(f,{children:"Payment Amount"}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:"24000",...m,onChange:v=>{m.onChange(v?.target.value?Number(v?.target.value):void 0)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"paymentCurrency",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Currency"}),e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(Ze).map(v=>e.jsx(ye,{value:v,children:v},v))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"productType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Product Type"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Cloud Services",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"billingCycle",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Billing Cycle"}),e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(be).map(v=>e.jsx(ye,{value:v,children:Bs(v)},v))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"subscriptionPlan",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Subscription Plan"}),e.jsx(N,{children:e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(Se).map(v=>e.jsx(ye,{value:v,children:Es(v)},v))})]})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.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(N,{children:e.jsx(Q,{checked:m.value,onCheckedChange:m.onChange})})]})})]}),e.jsx(j,{control:p.control,name:"msCloudLink",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"MS Cloud Link"}),e.jsx(N,{children:e.jsx(T,{type:"url",placeholder:"https://portal.azure.com/contract-id",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"defaultDocumentType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Document Type"}),e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(Ye).map(v=>e.jsx(ye,{value:v,children:Ss(v)},v))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"defaultRemark",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Remark"}),e.jsx(N,{children:e.jsx(Re,{placeholder:"Enter default remark for this contract...",rows:3,...m})}),e.jsx(C,{})]})})]}),e.jsxs(As,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(P,{type:"submit",disabled:x||u,children:o?"Update Contract":"Create Contract"})]})]})})]})]})}function ra(s){return{id:s.id,pos:s.purchaseOrders??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,operationsLimit:s.operationsLimit}}function la({clientId:s}){const[t,n]=b.useState(null),[{data:a,fetching:l},o]=te({query:ot,variables:{clientId:s}}),r=a?.contractsByClient??[];return l?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(z,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Contracts"}),e.jsx(W,{children:"Current and past contracts sorted by start date"})]}),e.jsx(ia,{clientId:s,contract:t,onDone:o})]})}),e.jsx(K,{className:"space-y-4",children:r.map(i=>{const c=!!i.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:i.product}),e.jsx(Z,{variant:c?"default":"secondary",children:i.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:i.id})]}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>n(ra(i)),children:e.jsx(sn,{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(dt,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(i.startDate).toLocaleDateString()," →"," ",new Date(i.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Numbers"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:i.purchaseOrders.toReversed()[0]??""}),i.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:i.purchaseOrders.toReversed().slice(1).map(d=>e.jsx("span",{className:"text-xs font-thin font-mono",children:d},d))})]}),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:mt(i.amount.raw,i.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:Bs(i.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:i.plan?Es(i.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Operations Limit"}),e.jsx("p",{className:"text-sm font-medium",children:i.operationsLimit.toLocaleString()})]}),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:Ss(i.documentType)})]})]}),i.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:i.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.msCloud&&e.jsx(P,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ut,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(tn,{className:"h-3 w-3 ml-1"})]})})})]},i.id)})})]})}function ca({businessId:s}){return e.jsxs(z,{children:[e.jsx(q,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(G,{children:"Documents"}),e.jsx(W,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(K,{children:e.jsx(ht,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const oa=[{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 da({data:s}){const t=Ce(gt,s),[{data:n,fetching:a},l]=te({query:xt,variables:{clientId:t?.id??""},pause:!t?.clientInfo?.greenInvoiceId||!t?.id}),{updateClient:o}=pt(),r=b.useCallback((c,d)=>{if(!t?.id)return;const u={};u[d]=c,o({businessId:t?.id,fields:u})},[t?.id,o]);b.useEffect(()=>{t?.clientInfo?.greenInvoiceId&&t?.id&&l()},[t?.clientInfo?.greenInvoiceId,t?.id,l]);const i=n?.greenInvoiceClient;return e.jsxs(z,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Integrations"}),e.jsx(W,{children:"Connected external services and providers"})]}),e.jsxs(P,{size:"sm",children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(K,{className:"space-y-6",children:e.jsxs(an,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[a?e.jsxs(Le,{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(A,{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(A,{className:"h-6 w-32"}),e.jsx(A,{className:"h-5 w-5 rounded-full"})]}),e.jsx(A,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-8 w-24"}),e.jsx(A,{className:"h-8 w-8"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{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(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{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(A,{className:"h-3 w-32"}),e.jsx(A,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{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(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Le,{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(ls,{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(ma,{id:t?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async c=>r(c,"greenInvoiceId")}),e.jsx(rs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Oe,{children:i&&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:t?.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:i.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:i.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:i.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(Me,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.emails?.map((c,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:c},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(fs,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:i.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:i.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:i.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(_e,{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:i.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:i.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:i.zip})]})]})]})]})})]}),oa.map(c=>e.jsxs(Le,{value:c.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:c.name}),c.status==="connected"?e.jsx(ls,{className:"h-4 w-4 text-green-600"}):e.jsx(jt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(es,{className:"h-4 w-4"})}),e.jsx(rs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Oe,{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:c.lastSync})]})})})]},c.id))]})})]})}function ma({id:s,provider:t,updateClient:n}){const[a,l]=b.useState(!1),[o,r]=b.useState(s),i=b.useCallback(async()=>{await n(o),l(!1)},[o,n]);return e.jsxs(Ge,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",onClick:c=>c.stopPropagation(),children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(We,{onClick:c=>c.stopPropagation(),children:[e.jsxs(Cs,{children:[e.jsxs(ws,{children:["Configure ",t]}),e.jsxs(ks,{children:["Update your ",t," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ft,{htmlFor:"id",children:[t," ID"]}),e.jsx(T,{id:"id",value:o,onChange:c=>r(c.target.value),placeholder:`Enter ${t} ID`})]})}),e.jsxs(As,{children:[e.jsx(P,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(P,{onClick:i,disabled:!o,children:"Save Changes"})]})]})]})}function ua({businessId:s}){const[{data:t,fetching:n}]=te({query:vt,variables:{businessId:s}});return n?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(z,{children:[e.jsx(q,{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(G,{children:"Ledger Records"}),e.jsx(W,{children:"Complete ledger history for this business"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ot,{ledgerRecordsData:t?.ledgerRecordsByFinancialEntity??[]})})})]})}function ha({businessId:s}){const[{data:t,fetching:n}]=te({query:yt,variables:{businessId:s}});return n?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(z,{children:[e.jsx(q,{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(G,{children:"Transactions"}),e.jsx(W,{children:"Complete transaction history for this business"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(nn,{transactionsProps:t?.transactionsByFinancialEntity??[]})})})]})}function xa({data:s,refetchBusiness:t}){const n=Ce(At,s),[a,l]=Nt(),{setFiltersContext:o}=b.useContext(bt);o(null);const r=a.get("tab")||"contact",i=u=>{l({tab:u})};if(!n)return e.jsx("div",{children:"Business not found"});const c="clientInfo"in n&&!!n.clientInfo,d="adminInfo"in n&&!!n.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Et,{data:n}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(Ct,{value:r,onValueChange:i,className:"w-full",children:[e.jsxs(wt,{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(H,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(rn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(H,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(es,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(H,{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(H,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(kt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(H,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(St,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(H,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(H,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(cn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),c&&e.jsxs(e.Fragment,{children:[e.jsxs(H,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(H,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(jn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(H,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(js,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx($,{value:"contact",className:"mt-0",children:e.jsx(Zn,{data:n,refetchBusiness:t})}),e.jsx($,{value:"config",className:"mt-0",children:e.jsx(Wn,{data:n,refetchBusiness:t})}),e.jsx($,{value:"charges",className:"mt-0",children:e.jsx(Sn,{businessId:n.id})}),e.jsx($,{value:"transactions",className:"mt-0",children:e.jsx(ha,{businessId:n.id})}),e.jsx($,{value:"documents",className:"mt-0",children:e.jsx(ca,{businessId:n.id})}),e.jsx($,{value:"ledger",className:"mt-0",children:e.jsx(ua,{businessId:n.id})}),e.jsx($,{value:"balance",className:"mt-0",children:e.jsx(kn,{businessId:n.id})}),c&&e.jsxs(e.Fragment,{children:[e.jsx($,{value:"contracts",className:"mt-0",children:e.jsx(la,{clientId:n.id})}),e.jsx($,{value:"integrations",className:"mt-0",children:e.jsx(da,{data:n})}),e.jsx($,{value:"charts",className:"mt-0",children:e.jsx(Un,{})})]}),d&&e.jsx($,{value:"admin",className:"mt-0",children:e.jsx(wn,{data:n})})]})})]})}const Va=()=>{const{businessId:s}=It();let t;try{t=Dt()}catch{}const[{data:n,fetching:a},l]=te({query:Tt,pause:!s||!!t,variables:{businessId:s??""}}),o=t||n;return!t&&a&&!o?.business?e.jsx(ps,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(xa,{data:o.business,refetchBusiness:async()=>l()})};export{Va as BusinessScreen};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{v as T,bA as G,r as D,bC as J,ab as V,bE as H,j as e,cO as K,x as v,u as Y,dS as q,aN as o,c as Q,T as W,B as X,bU as P,R as b,a$ as A,bn as Z}from"./index-CcJvt1sI.js";import{D as ee}from"./download-csv-button-C5J9ow3I.js";import{T as ne}from"./Table-CR8S5Pp5.js";/**
|
|
2
|
+
* @license lucide-react v0.548.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 te=[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"m17 7 5 5-5 5",key:"1xlxn0"}],["path",{d:"m7 7-5 5 5 5",key:"19njba"}],["path",{d:"M8 12h.01",key:"czm47f"}]],se=T("chevrons-left-right-ellipsis",te);/**
|
|
7
|
+
* @license lucide-react v0.548.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 re=[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]],ae=T("chevrons-right-left",re);var oe=G((n,{color:s})=>({root:{backgroundColor:n.fn.themeColor(s,n.colorScheme==="dark"?5:2),color:n.colorScheme==="dark"?n.colors.dark[9]:"inherit"}})),ce=Object.defineProperty,C=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,O=(n,s,t)=>s in n?ce(n,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[s]=t,ie=(n,s)=>{for(var t in s||(s={}))M.call(s,t)&&O(n,t,s[t]);if(C)for(var t of C(s))U.call(s,t)&&O(n,t,s[t]);return n},le=(n,s)=>{var t={};for(var a in n)M.call(n,a)&&s.indexOf(a)<0&&(t[a]=n[a]);if(n!=null&&C)for(var a of C(n))s.indexOf(a)<0&&U.call(n,a)&&(t[a]=n[a]);return t};const de={color:"yellow"},p=D.forwardRef((n,s)=>{const t=J("Mark",de,n),{color:a,className:i,unstyled:u,variant:h}=t,x=le(t,["color","className","unstyled","variant"]),{classes:f,cx:l}=oe({color:a},{unstyled:u,name:"Mark",variant:h});return V.createElement(H,ie({component:"mark",ref:s,className:l(f.root,i)},x))});p.displayName="@mantine/core/Mark";const ue=({ledgerRecords:n,businessName:s,fromDate:t,toDate:a})=>{const i=D.useCallback(async()=>{const u=me(n);return{fileName:`business_${s}_ledger_records${t?`_${t}`:""}${a?`_${a}`:""}`,fileContent:u}},[n,s,t,a]);return e.jsx(ee,{createFileVariables:i})},me=n=>{let s="";const t=Array.from(new Set(n.filter(a=>a.foreignAmount?.currency).map(a=>a.foreignAmount.currency)));s+=`Sorting Date,Date,Amount,Amount Balance,${he(t)}Reference,Details,Counter Account\r
|
|
12
|
+
`;for(const a of n){const i=fe(a,t);s+=i}return s};function he(n){let s="";return n.map(t=>{const a=K(t);s+=`${t}(${a}) Amount,${t}(${a}) Balance,`}),s}function xe(n,s){let t="";return s.map(a=>{n.foreignAmount&&n.foreignAmount.currency===a?t+=`${n.foreignAmount.raw},${n[`${a.toLowerCase()}Balance`]??0},`:t+=",,"}),t}function fe(n,s){let t="";const a=n.invoiceDate?v(new Date(n.invoiceDate),"yyy-MM-dd"):null,i=n.invoiceDate?v(new Date(n.invoiceDate),"dd/MM/yy"):null,u=n.amount.raw,{ilsBalance:h,reference:x,details:f}=n,l=n.counterAccount?.name??"";return t+=`${a},${i},${u},${h},${xe(n,s)}${S(x??"")},${S(f??"")},${S(l)},\r
|
|
13
|
+
`,t}function S(n){return n===""?"":Number.isNaN(Number(n))?String(n).replace(/"/g,'""').replace(/,/g,"."):Number(n).toFixed(2).toString()}function Ae({businessID:n,filter:s}){const[t,a]=D.useState(!1),{fromDate:i,ownerIds:u,toDate:h}=s??{},[{data:x,fetching:f}]=Y({query:q,variables:{filters:{fromDate:i,ownerIds:u,toDate:h,businessIDs:[n]}}}),l=x?.businessTransactionsFromLedgerRecords.__typename==="CommonError"?[]:x?.businessTransactionsFromLedgerRecords.businessTransactions.sort((r,g)=>r.invoiceDate>g.invoiceDate?1:-1)??[],j=[];for(let r=0;r<l.length;r++){const{__typename:g,...c}=l[r],z=r===0?c.amount.raw:(j[r-1].ilsBalance??0)+c.amount.raw,I={};Object.values(o).map(y=>{if(y!==o.Ils){const L=`${y.toLowerCase()}Balance`;I[L]=r===0?(c.foreignAmount?.currency===y?c.foreignAmount?.raw:0)??0:(j[r-1]?.[L]??0)+(c.foreignAmount?.currency===y?c.foreignAmount?.raw:0)}}),j.push({...c,ilsBalance:z,...I})}const m=new Set(l.filter(r=>r.foreignAmount?.currency).map(r=>r.foreignAmount.currency)),B=t||m.has(o.Eur),E=t||m.has(o.Usd),_=t||m.has(o.Gbp),k=t||m.has(o.Cad),N=t||m.has(o.Jpy),$=t||m.has(o.Aud),F=t||m.has(o.Sek),R=l[0]?.business.name??"unknown";return e.jsx("div",{className:"flex flex-row gap-5",children:f?e.jsx(Q,{}):e.jsxs(ne,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex: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:"Business Name"}),e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount Balance"}),B&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"EUR Amount"}),e.jsx("th",{children:"EUR Balance"})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"USD Amount"}),e.jsx("th",{children:"USD Balance"})]}),_&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"GBP Amount"}),e.jsx("th",{children:"GBP Balance"})]}),k&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"CAD Amount"}),e.jsx("th",{children:"CAD Balance"})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"JPY Amount"}),e.jsx("th",{children:"JPY Balance"})]}),$&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"AUD Amount"}),e.jsx("th",{children:"AUD Balance"})]}),F&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"SEK Amount"}),e.jsx("th",{children:"SEK Balance"})]}),e.jsx("th",{children:e.jsx(W,{label:"Expand all currencies",children:e.jsx(X,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(r=>!r),children:t?e.jsx(ae,{className:"size-5"}):e.jsx(se,{className:"size-5"})})})}),t&&e.jsx(e.Fragment,{children:w.map(r=>e.jsxs(e.Fragment,{children:[e.jsxs("th",{children:[r," Amount"]}),e.jsxs("th",{children:[r," Balance"]})]}))}),e.jsx("th",{children:"Reference"}),e.jsx("th",{children:"Details"}),e.jsx("th",{children:"Counter Account"}),e.jsx("th",{children:e.jsx(ue,{ledgerRecords:j,businessName:R,fromDate:s?.fromDate??void 0,toDate:s?.toDate??void 0})})]})}),e.jsx("tbody",{children:j.map((r,g)=>e.jsxs("tr",{className:"cursor-pointer",onClick:c=>{c.stopPropagation(),window.open(b.CHARGES.DETAIL(r.chargeId),"_blank","noreferrer")},children:[e.jsx("td",{children:e.jsx(P,{to:b.BUSINESSES.DETAIL(r.business.id),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:r.business.name})}),e.jsx("td",{children:r.invoiceDate?v(new Date(r.invoiceDate),"dd/MM/yy"):null}),e.jsx("td",{style:{whiteSpace:"nowrap"},children:r.amount&&r.amount.raw!==0&&e.jsx(p,{color:r.amount.raw>0?"green":"red",children:r.amount.formatted})}),e.jsx("td",{children:r.ilsBalance===0?A(r.ilsBalance,o.Ils):e.jsx(p,{color:r.ilsBalance>0?"green":"red",children:A(r.ilsBalance,o.Ils)})}),B&&e.jsx(d,{data:r,currency:o.Eur}),E&&e.jsx(d,{data:r,currency:o.Usd}),_&&e.jsx(d,{data:r,currency:o.Gbp}),k&&e.jsx(d,{data:r,currency:o.Cad}),N&&e.jsx(d,{data:r,currency:o.Jpy}),$&&e.jsx(d,{data:r,currency:o.Aud}),F&&e.jsx(d,{data:r,currency:o.Sek}),e.jsx("td",{}),t&&e.jsx(je,{data:r}),e.jsx("td",{children:r.reference}),e.jsx("td",{children:r.details}),e.jsx("td",{children:r.counterAccount&&e.jsx(P,{to:b.BUSINESSES.DETAIL(r.counterAccount.id),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:r.counterAccount.name})}),e.jsx("td",{})]},g))})]})})}function d({currency:n,data:s}){const t=s.foreignAmount&&s.foreignAmount.currency===n?s.foreignAmount:null,a=`${n.toLowerCase()}Balance`;return e.jsxs(e.Fragment,{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:!!t&&t.raw!==0&&e.jsx(p,{color:t.raw>0?"green":"red",children:t.formatted})}),e.jsx("td",{children:(s[a]??0)!==0&&(s[a]===0?A(s[a],n):e.jsx(p,{color:s[a]>0?"green":"red",children:A(s[a],n)}))})]})}const w=Object.values(o).filter(n=>!Z.includes(n));function je({data:n}){return e.jsx(e.Fragment,{children:w.map(s=>e.jsx(d,{currency:s,data:n},s))})}export{Ae as B,ae as C,p as M,se as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{J as l,j as e,av as t,x as m,
|
|
1
|
+
import{J as l,j as e,av as t,x as m,bk as x}from"./index-CcJvt1sI.js";import{B as o}from"./building-2-BE02hpsM.js";function h({data:n}){const s=l(x,n);if(!s||s.__typename!=="LtdFinancialEntity")return e.jsx("div",{});const{isActive:i,adminInfo:r,clientInfo:a}=s,d=!!r?.id,c=!!a?.id;return 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(o,{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:s.name}),i?e.jsx(t,{variant:"secondary",children:"Active"}):e.jsx(t,{variant:"destructive",children:"Inactive"}),d&&e.jsx(t,{variant:"outline",children:"Admin"}),c&&e.jsx(t,{variant:"outline",children:"Client"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["Business ID: ",s.id]})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-6 text-sm",children:[s.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:s.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:m(s.createdAt,"MMM yyyy")})]})]})]})})})}export{h as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as x,bo as v,j as e,bp as C,B as S,G as I,bq as F,a8 as B,br as m,bs as y,bt as j,x as f,bu as E,bv as N}from"./index-CcJvt1sI.js";import{u as w}from"./use-url-query-D-GsTMWL.js";import{P as L}from"./modal-DOtlViK5.js";import{F as R}from"./funnel-IYKnhWOy.js";import{M as D}from"./MultiSelect-9BbcXHjB.js";function A({filter:r,setFilter:b,closeModal:u,single:l=!1}){const{control:n,handleSubmit:p}=I({defaultValues:{...r}}),{selectableBusinesses:d,fetching:i}=F(),{userContext:g}=x.useContext(B),h=s=>{b(s),u()};function o(){b({businessIDs:l?r.businessIDs:void 0}),u()}return e.jsxs(e.Fragment,{children:[i?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:p(h),children:[e.jsx(m,{name:"ownerIds",control:n,defaultValue:r.ownerIds,render:({field:s,fieldState:a})=>e.jsx(D,{...s,data:d,value:s.value??(g?.context.adminBusinessId?[g.context.adminBusinessId]:void 0),disabled:i,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),!l&&e.jsx(m,{name:"businessIDs",control:n,defaultValue:r.businessIDs,render:({field:s,fieldState:a})=>e.jsx(D,{...s,data:d,value:s.value??void 0,disabled:i,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(m,{name:"fromDate",control:n,defaultValue:r.fromDate,rules:{pattern:{value:y,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:a})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:a.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"toDate",control:n,defaultValue:r.toDate,rules:{pattern:{value:y,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:a})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:a.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"type",control:n,defaultValue:null,render:({field:s,fieldState:a})=>e.jsx(E,{...s,onChange:t=>s.onChange(t==="NULL"?null:t),data:[{value:"NULL",label:"All"},{value:"BUSINESS",label:"Business"},{value:"TAX_CATEGORY",label:"Tax Category"}],error:a.error?.message,label:"Type"})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",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:o,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:u,children:"Cancel"})]})]})]})}function V({filter:r,setFilter:b}){const[u,l]=x.useState(!1),[n,p]=x.useState(!v(r)),{get:d,set:i}=w();function g(o){return Object.entries(o??{}).filter(([a,t])=>t!==void 0&&Array.isArray(t)&&t.length>0).length>0}function h(o){o.fromDate?.trim()===""&&(o.fromDate=void 0),o.toDate?.trim()===""&&(o.toDate=void 0),N(o,r)||(b(o),p(g(o)))}return x.useEffect(()=>{const o=v(r)?null:encodeURIComponent(JSON.stringify(r)),s=d("ledgerRecordsFilters");o!==s&&i("ledgerRecordsFilters",o)},[r,d,i]),e.jsxs(e.Fragment,{children:[e.jsx(L,{opened:u,onClose:()=>l(!1),content:e.jsx(A,{single:!0,filter:r,setFilter:h,closeModal:()=>l(!1)})}),e.jsx(C,{inline:!0,size:16,disabled:!n,children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:e.jsx(R,{className:"size-5"})})})]})}export{V as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as S,r as c,F as w,u as C,j as n,c as x,aN as o,bm as y}from"./index-CcJvt1sI.js";import{u as h}from"./use-url-query-D-GsTMWL.js";import{a as F}from"./accounter-table-CBigzB_s.js";import{M as p,B as R}from"./business-extended-info-BRde-LSv.js";import{B as v}from"./business-ledger-filters-DQ4D4mv8.js";import"./Pagination-BVQu3Yj6.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-CR8S5Pp5.js";import"./download-csv-button-C5J9ow3I.js";import"./modal-DOtlViK5.js";import"./funnel-IYKnhWOy.js";import"./MultiSelect-9BbcXHjB.js";const $=({businessId:t})=>{const{businessId:r}=S(),{get:s}=h(),{setFiltersContext:u}=c.useContext(w),l=t||r,[m,d]=c.useState(s("ledgerRecordsFilters")?{...JSON.parse(decodeURIComponent(s("ledgerRecordsFilters"))),businessIDs:l?[l]:[]}:{businessIDs:l?[l]:[]}),[{data:a,fetching:f}]=C({query:y,variables:{filters:m}});c.useEffect(()=>{u(n.jsx(v,{filter:m,setFilter:d}))},[a,m,u,d]);const b=c.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:a?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?a.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((e,g)=>e.business.name.localeCompare(g.business.name)):[],[a?.businessTransactionsSumFromLedgerRecords]);return f?n.jsx(x,{}):n.jsx(F,{moreInfo:e=>n.jsx(R,{businessID:e.business.id,filter:m}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:b,columns:[{title:"Business Name",value:e=>e.business.name},{title:"Debit",value:e=>e.debit.formatted,style:{whiteSpace:"nowrap"}},{title:"Credit",value:e=>e.credit.formatted,style:{whiteSpace:"nowrap"}},{title:"Total",value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?n.jsx(p,{color:e.total.raw>0?"green":"red",children:e.total.formatted}):e.total.formatted,style:{whiteSpace:"nowrap"}},...i(o.Eur),...i(o.Usd),...i(o.Gbp),...i(o.Cad),...i(o.Jpy),...i(o.Aud),...i(o.Sek)]})};function i(t){return[{title:`${t} Debit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.debit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Credit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.credit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:r=>{const s=r.foreignCurrenciesSum.find(u=>u.currency===t);return s?.total?.raw&&(s.total.raw<-1e-4||s.total.raw>1e-4)?n.jsx(p,{color:s.total.raw>0?"green":"red",children:s.total.formatted}):s?.total?.formatted},style:{whiteSpace:"nowrap"}}]}export{$ as BusinessLedgerRecordsSingle};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p,r as n,F as u,u as m,j as s,c,bz as x}from"./index-CcJvt1sI.js";import{P as d,C as l,E as b}from"./editable-business-trip-Ito1rWaY.js";import{P as f}from"./page-layout-BNHKLJFL.js";import"./list-plus-Cv8qnwZd.js";import"./summary-BV3HUEgI.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-CR8S5Pp5.js";import"./toggle-expansion-button-Bdpb_YfG.js";import"./panel-top-open-DQ1wo5PZ.js";import"./MultiSelect-9BbcXHjB.js";import"./similar-transactions-modal-DDVojjq0.js";import"./tooltip-Cy3vJ3fy.js";const L=({businessTripId:o})=>{const{businessTripId:a}=p(),{setFiltersContext:i}=n.useContext(u),e=o??a??"",[{data:r,fetching:t}]=m({query:x,variables:{businessTripId:e}});return n.useEffect(()=>{i(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(d,{filename:"business_trip_report"})}))},[r,t,i]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(f,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(b,{tripId:e,isExtended:!0})})})};export{L as BusinessTrip};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as I,b as x,r as a,u as D,j as e,c as f,C as j}from"./index-
|
|
1
|
+
import{a as I,b as x,r as a,u as D,j as e,c as f,C as j}from"./index-CcJvt1sI.js";import{C as v}from"./charges-table-BOnvwci9.js";import{E as M,I as E,M as S}from"./match-document-modal-D2TgC0aR.js";import"./toggle-expansion-button-Bdpb_YfG.js";import"./panel-top-open-DQ1wo5PZ.js";import"./index-ofME77ND.js";import"./similar-transactions-modal-DDVojjq0.js";import"./addDays-CjlJbHpj.js";import"./list-plus-Cv8qnwZd.js";import"./tooltip-Cy3vJ3fy.js";import"./Table-CR8S5Pp5.js";import"./summary-BV3HUEgI.js";import"./create-event-handler-BiA-1lGu.js";import"./YearPickerInput-dCiPlZqk.js";import"./insert-business-trip-modal-D08ePEzY.js";import"./accounter-table-CBigzB_s.js";import"./Pagination-BVQu3Yj6.js";import"./modal-DOtlViK5.js";const J=({chargeId:u})=>{const{chargeId:g}=I(),r=u||g;let t;try{t=x()}catch{}const[o,i]=a.useState(void 0),[s,n]=a.useState(void 0),[c,d]=a.useState(void 0),[{data:p,fetching:l},m]=D({query:j,pause:!r||!!t,variables:{chargeId:r??""}});a.useEffect(()=>{r&&!t&&m()},[r,t,m]);const h=t||p,C=!t&&l;return r?e.jsxs(e.Fragment,{children:[C?e.jsx(f,{}):e.jsx(v,{setEditChargeId:i,setInsertDocument:n,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),o&&e.jsx(M,{chargeId:o?.id,close:()=>i(void 0),onChange:o.onChange}),s&&e.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>n(void 0)}),c&&e.jsx(S,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>d(void 0)})]}):e.jsx("div",{children:"Charge not found"})};export{J as Charge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,
|
|
1
|
+
import{r as i,bo as B,bv as H,j as e,bp as W,B as z,a8 as G,G as U,x as N,aa as D,cQ as _,ak as Q,V as X,cR as q,br as h,ec as J,bs as P,bt as O,bu as L,e3 as A,ah as m,ha as Y,b8 as Z,X as x,Y as p,Z as j,_ as g,df as K,dg as $,dh as ee}from"./index-CcJvt1sI.js";import{u as se}from"./use-url-query-D-GsTMWL.js";import{P as ae}from"./modal-DOtlViK5.js";import{P as te}from"./Pagination-BVQu3Yj6.js";import{F as ne}from"./funnel-IYKnhWOy.js";import{s as oe}from"./sub-CIKovQuv.js";import{M as k}from"./MultiSelect-9BbcXHjB.js";function re(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const le=[{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:b}=i.useContext(G),o=U({defaultValues:{byOwners:b?.context.adminBusinessId?[b.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:l,handleSubmit:T,watch:C}=o,[y,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=_(),{selectableTags:v,fetching:I}=Q(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const V=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),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(X,{...o,children:e.jsxs("form",{onSubmit:T(V),children:[e.jsxs(q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,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:l,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:l,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:v,itemComponent:J,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(r,f,M)=>M.label?.toLowerCase().includes(r.toLowerCase().trim())||M.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:P,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"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:l,defaultValue:a.toAnyDate,rules:{pattern:{value:P,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"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:l,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(L,{...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:l,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(L,{...s,data:le,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(m,{defaultChecked:a.sortBy?.asc??!1,checked:y??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:y?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:l,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(k,{...s,value:s.value??[],data:Y,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(Z,{children:"Missing Information:"}),e.jsx(x,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Invoice"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Receipts"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Documents"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs(K,{children:[e.jsx($,{children:e.jsx(m,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(ee,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(x,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without Transactions"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Unbalanced businesses"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(p,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(j,{children:"Without ledger"})}),e.jsx(g,{children:e.jsx(m,{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 ge({filter:a={},setFilter:w,activePage:d,setPage:b,totalPages:o=1,initiallyOpened:l=!1}){const[T,C]=i.useState(l),[y,F]=i.useState(!B(a)),{get:c,set:u}=se();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=re(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),b(1))},[a,c,u,b]);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(ae,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(te,{className:"flex-auto",value:d,onChange:b,total:o}),e.jsx(W,{inline:!0,size:16,disabled:!y,children:e.jsx(z,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{ge as C,ce as c};
|