@accounter/client 0.0.8-alpha-20251027003629-e64c01111f4a4cec34d5ca9a84e02646b69f80b1 → 0.0.8-alpha-20251027125446-75cc2031ef62f7abf48ecfbd31f62ddbddee2bd8
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-DjollWGm.js → Checkbox-BzSHHEEI.js} +2 -2
- package/dist/assets/{Progress-AG7ZMAJu.js → Progress-CmZjJ77Z.js} +1 -1
- package/dist/assets/{Typography-Cd0kk1vc.js → Typography-CuW3aX-4.js} +1 -1
- package/dist/assets/{accordion-s9Ku08QQ.js → accordion-BZB-JxAM.js} +1 -1
- package/dist/assets/{accountant-approvals-Bqrsn1y5.js → accountant-approvals-BtF90Myx.js} +1 -1
- package/dist/assets/{all-charges-BQcsaMon.js → all-charges-X26mmfb3.js} +1 -1
- package/dist/assets/{arrow-up-down-J-i_WnHP.js → arrow-up-down-_p0E2yis.js} +1 -1
- package/dist/assets/{building-2-B92gXbOj.js → building-2-CKq13SAn.js} +1 -1
- package/dist/assets/business--pLros0g.js +27 -0
- package/dist/assets/{business-header-Cr5S_Mz7.js → business-header-C8fXEo4_.js} +1 -1
- package/dist/assets/{business-transactions-single-BD4bLNv2.js → business-transactions-single-CXmdF2-o.js} +1 -1
- package/dist/assets/{business-trip-DYkKK6Gk.js → business-trip-wd9Embtb.js} +1 -1
- package/dist/assets/{charges-filters-CoFkjW00.js → charges-filters-Fu2ZAzWC.js} +1 -1
- package/dist/assets/{charges-ledger-validation-D_cg1bn-.js → charges-ledger-validation-BXXhWS5W.js} +1 -1
- package/dist/assets/{chart-CQ9Opsuw.js → chart-3ddx32Qz.js} +1 -1
- package/dist/assets/{data-table-pagination-CN5CnGZV.js → data-table-pagination-BopLOYg9.js} +1 -1
- package/dist/assets/{editable-business-trip--kNXo9tv.js → editable-business-trip-C34Ue7Hf.js} +2 -2
- package/dist/assets/{index-BNtiIPMq.js → index-B0uGI3EC.js} +1 -1
- package/dist/assets/{index-BGHdyfCs.js → index-B6vWXPp8.js} +1 -1
- package/dist/assets/{index-n3bzj3IE.js → index-BEtUypi7.js} +2 -2
- package/dist/assets/{index-CC_fLCrA.js → index-BGW4bQ-L.js} +1 -1
- package/dist/assets/{index-Cw9zbBbJ.js → index-BpCZ3X72.js} +7 -7
- package/dist/assets/{index-C3pV-XkD.js → index-BsqMXEt3.js} +2 -2
- package/dist/assets/{index-DNTlYcfH.js → index-CkFRewFP.js} +2 -2
- package/dist/assets/{index-hr9hQe_a.js → index-Cr24h-Cl.js} +1 -1
- package/dist/assets/{index-Au8Djmrz.js → index-CuczBTlN.js} +1 -1
- package/dist/assets/{index-DzNfXERJ.js → index-CvS1Q-ya.js} +1 -1
- package/dist/assets/{index-DDGgWxhe.js → index-DA1mkO2v.js} +2 -2
- package/dist/assets/{index-DfI9E1Fb.js → index-DL8q44ap.js} +263 -258
- package/dist/assets/{index-fwXllLnH.js → index-DeQnadsl.js} +1 -1
- package/dist/assets/{index-DS_RReq_.js → index-Dia_wOFb.js} +1 -1
- package/dist/assets/{index-DepseT6D.js → index-HzZyyExI.js} +1 -1
- package/dist/assets/{index-C7al3ztL.js → index-JfxexlPg.js} +2 -2
- package/dist/assets/{index-BWpLPx22.js → index-PaJBRncn.js} +1 -1
- package/dist/assets/index-SmrmFP8m.js +1 -0
- package/dist/assets/{index-BSmbKLQe.js → index-cZSBCnNJ.js} +2 -2
- package/dist/assets/{index-CS40C1qp.js → index-dP8CSci_.js} +1 -1
- package/dist/assets/{index-Cc4HfGhd.js → index-o-HWUpBy.js} +1 -1
- package/dist/assets/{index--XWh2RKR.js → index-pjGYYOoy.js} +1 -1
- package/dist/assets/{index-C66UYUUf.js → index-szVd1r0-.js} +1 -1
- package/dist/assets/{index.es-CKlpQqlO.js → index.es-ZISWba9V.js} +1 -1
- package/dist/assets/{issue-document-B4kkfOo0.js → issue-document-B-c96E9w.js} +1 -1
- package/dist/assets/{login-page-NvQKYh34.js → login-page-C_RNlOZS.js} +1 -1
- package/dist/assets/{missing-info-charges-DrF2b0mO.js → missing-info-charges-BrFjY7yz.js} +1 -1
- package/dist/assets/{page-not-found-7AAOkZhu.js → page-not-found-s0xtsc5O.js} +1 -1
- package/dist/assets/{pencil-DNPAJOPL.js → pencil-D-2dJ444.js} +1 -1
- package/dist/assets/{report-commentary-row-CF-l1YIC.js → report-commentary-row-aIxbqTgK.js} +1 -1
- package/dist/assets/{save-D84vX5ea.js → save-DZ9jxz9u.js} +1 -1
- package/dist/assets/{sub-BbpGm1pj.js → sub-o9iEG2Bl.js} +1 -1
- package/dist/assets/subMonths-CpJ3oidH.js +1 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/clients/modify-client-dialog.tsx +27 -9
- package/src/components/common/modals/insert-business.tsx +87 -36
- package/src/components/layout/user-nav.tsx +25 -3
- package/dist/assets/business-CfqFJUkR.js +0 -32
- package/dist/assets/index-DVbMTBK4.js +0 -1
- package/dist/assets/subMonths-0tIJizDp.js +0 -1
|
@@ -2,6 +2,10 @@ import { useCallback, useContext, useState } from 'react';
|
|
|
2
2
|
import { Globe, Mail, MapPin, Phone, Plus, X } from 'lucide-react';
|
|
3
3
|
import { useForm } from 'react-hook-form';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
+
import {
|
|
6
|
+
ModifyClientDialog,
|
|
7
|
+
type ClientFormValues,
|
|
8
|
+
} from '@/components/clients/modify-client-dialog.js';
|
|
5
9
|
import { Badge } from '@/components/ui/badge.js';
|
|
6
10
|
import { Button } from '@/components/ui/button.js';
|
|
7
11
|
import {
|
|
@@ -15,6 +19,7 @@ import {
|
|
|
15
19
|
import {
|
|
16
20
|
Form,
|
|
17
21
|
FormControl,
|
|
22
|
+
FormDescription,
|
|
18
23
|
FormField,
|
|
19
24
|
FormItem,
|
|
20
25
|
FormLabel,
|
|
@@ -28,7 +33,9 @@ import {
|
|
|
28
33
|
SelectTrigger,
|
|
29
34
|
SelectValue,
|
|
30
35
|
} from '@/components/ui/select.js';
|
|
36
|
+
import { Switch } from '@/components/ui/switch.js';
|
|
31
37
|
import { Textarea } from '@/components/ui/textarea.js';
|
|
38
|
+
import { DocumentType } from '@/gql/graphql.js';
|
|
32
39
|
import { pcn874RecordEnum } from '@/helpers/index.js';
|
|
33
40
|
import { useAllCountries } from '@/hooks/use-get-countries.js';
|
|
34
41
|
import { useGetSortCodes } from '@/hooks/use-get-sort-codes.js';
|
|
@@ -48,8 +55,8 @@ const businessFormSchema = z
|
|
|
48
55
|
localName: z.string().optional(),
|
|
49
56
|
govId: z.string().optional(),
|
|
50
57
|
address: z.string().optional(),
|
|
51
|
-
generalContacts: z.array(z.
|
|
52
|
-
website: z.
|
|
58
|
+
generalContacts: z.array(z.email()),
|
|
59
|
+
website: z.url().optional().or(z.literal('')),
|
|
53
60
|
phone: z.string().optional(),
|
|
54
61
|
taxCategory: z.string().optional(),
|
|
55
62
|
sortCode: z.string().optional(),
|
|
@@ -57,8 +64,9 @@ const businessFormSchema = z
|
|
|
57
64
|
irsCode: z.int().optional(),
|
|
58
65
|
defaultDescription: z.string().optional(),
|
|
59
66
|
defaultTags: z.array(z.string()),
|
|
67
|
+
isClient: z.boolean().default(false).optional(),
|
|
60
68
|
transactionPhrases: z.array(z.string()),
|
|
61
|
-
emailAddresses: z.array(z.
|
|
69
|
+
emailAddresses: z.array(z.email()),
|
|
62
70
|
})
|
|
63
71
|
.refine(
|
|
64
72
|
data => {
|
|
@@ -117,6 +125,7 @@ export function InsertBusiness({
|
|
|
117
125
|
onAdd?: (businessId: string) => void;
|
|
118
126
|
}) {
|
|
119
127
|
const [isNewBusinessOpen, setIsNewBusinessOpen] = useState(false);
|
|
128
|
+
const [client, setClient] = useState<ClientFormValues | null>(null);
|
|
120
129
|
|
|
121
130
|
const { insertBusiness, fetching: addingInProcess } = useInsertBusiness();
|
|
122
131
|
|
|
@@ -128,6 +137,7 @@ export function InsertBusiness({
|
|
|
128
137
|
defaultTags: [],
|
|
129
138
|
transactionPhrases: description ? [description] : [],
|
|
130
139
|
emailAddresses: [],
|
|
140
|
+
locality: 'GAB',
|
|
131
141
|
},
|
|
132
142
|
});
|
|
133
143
|
|
|
@@ -135,44 +145,68 @@ export function InsertBusiness({
|
|
|
135
145
|
const newBusiness = await insertBusiness({
|
|
136
146
|
fields: convertFormDataToInsertNewBusinessInput(data),
|
|
137
147
|
});
|
|
148
|
+
if (data.isClient && newBusiness?.id) {
|
|
149
|
+
setClient({
|
|
150
|
+
businessId: newBusiness.id,
|
|
151
|
+
generatedDocumentType: DocumentType.Proforma,
|
|
152
|
+
emails: [],
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
onComplete(newBusiness?.id);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const onComplete = (businessId: string = '') => {
|
|
160
|
+
setClient(null);
|
|
138
161
|
setIsNewBusinessOpen(false);
|
|
139
162
|
form.reset();
|
|
140
|
-
onAdd?.(
|
|
163
|
+
onAdd?.(businessId);
|
|
141
164
|
};
|
|
142
165
|
|
|
143
166
|
return (
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
<
|
|
147
|
-
<
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
<
|
|
153
|
-
<
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
<
|
|
158
|
-
<
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
167
|
+
<>
|
|
168
|
+
<Dialog open={isNewBusinessOpen} onOpenChange={setIsNewBusinessOpen}>
|
|
169
|
+
<DialogTrigger asChild>
|
|
170
|
+
<Button>
|
|
171
|
+
<Plus className="size-4 mr-2" />
|
|
172
|
+
New Business
|
|
173
|
+
</Button>
|
|
174
|
+
</DialogTrigger>
|
|
175
|
+
<DialogContent className="max-w-3xl max-h-[90vh] overflow-y-auto">
|
|
176
|
+
<DialogHeader>
|
|
177
|
+
<DialogTitle>Create New Business</DialogTitle>
|
|
178
|
+
<DialogDescription>Add a new business to Accounter.</DialogDescription>
|
|
179
|
+
</DialogHeader>
|
|
180
|
+
<Form {...form}>
|
|
181
|
+
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
|
182
|
+
<ContactInformationSection form={form} />
|
|
183
|
+
|
|
184
|
+
<DefaultsSection form={form} />
|
|
185
|
+
|
|
186
|
+
<AutoMatchingSection form={form} />
|
|
187
|
+
|
|
188
|
+
<div className="flex justify-end gap-3 pt-4 border-t">
|
|
189
|
+
<Button type="button" variant="outline" onClick={() => setIsNewBusinessOpen(false)}>
|
|
190
|
+
Cancel
|
|
191
|
+
</Button>
|
|
192
|
+
<Button type="submit" disabled={addingInProcess}>
|
|
193
|
+
Create Business
|
|
194
|
+
</Button>
|
|
195
|
+
</div>
|
|
196
|
+
</form>
|
|
197
|
+
</Form>
|
|
198
|
+
</DialogContent>
|
|
199
|
+
</Dialog>
|
|
200
|
+
{client?.businessId && (
|
|
201
|
+
<ModifyClientDialog
|
|
202
|
+
businessId={client.businessId}
|
|
203
|
+
client={client}
|
|
204
|
+
onDone={() => {
|
|
205
|
+
onComplete(client.businessId);
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
)}
|
|
209
|
+
</>
|
|
176
210
|
);
|
|
177
211
|
}
|
|
178
212
|
|
|
@@ -538,12 +572,29 @@ function DefaultsSection({ form }: SectionProps) {
|
|
|
538
572
|
placeholder="Select Default Tags"
|
|
539
573
|
variant="default"
|
|
540
574
|
disabled={fetchingTags}
|
|
575
|
+
asChild
|
|
541
576
|
/>
|
|
542
577
|
</FormControl>
|
|
543
578
|
<FormMessage />
|
|
544
579
|
</FormItem>
|
|
545
580
|
)}
|
|
546
581
|
/>
|
|
582
|
+
|
|
583
|
+
<FormField
|
|
584
|
+
control={form.control}
|
|
585
|
+
name="isClient"
|
|
586
|
+
render={({ field }) => (
|
|
587
|
+
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
|
|
588
|
+
<div className="space-y-0.5">
|
|
589
|
+
<FormLabel>Client</FormLabel>
|
|
590
|
+
<FormDescription>Business is a client</FormDescription>
|
|
591
|
+
</div>
|
|
592
|
+
<FormControl>
|
|
593
|
+
<Switch checked={field.value} onCheckedChange={field.onChange} />
|
|
594
|
+
</FormControl>
|
|
595
|
+
</FormItem>
|
|
596
|
+
)}
|
|
597
|
+
/>
|
|
547
598
|
</div>
|
|
548
599
|
</div>
|
|
549
600
|
);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { useState, type JSX } from 'react';
|
|
2
|
-
import { CircleCheckBig, FileDown, User2Icon } from 'lucide-react';
|
|
1
|
+
import { useContext, useState, type JSX } from 'react';
|
|
2
|
+
import { CircleCheckBig, FileDown, Shield, User2Icon } from 'lucide-react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { UserContext } from '@/providers/index.js';
|
|
5
|
+
import { ROUTES } from '@/router/routes.js';
|
|
3
6
|
import { Tooltip } from '@mantine/core';
|
|
4
7
|
import { useDisclosure } from '@mantine/hooks';
|
|
5
8
|
import { useCornJobs } from '../../hooks/use-corn-jobs.js';
|
|
@@ -17,11 +20,14 @@ import {
|
|
|
17
20
|
} from '../ui/dropdown-menu.js';
|
|
18
21
|
|
|
19
22
|
export function UserNav(): JSX.Element {
|
|
23
|
+
const { userContext } = useContext(UserContext);
|
|
20
24
|
const [pullDocumentsOpened, { close: closePullDocuments, open: openPullDocuments }] =
|
|
21
25
|
useDisclosure(false);
|
|
22
26
|
const [balanceChargeModalOpen, setBalanceChargeModalOpen] = useState(false);
|
|
23
27
|
const { executeJobs } = useCornJobs();
|
|
24
28
|
|
|
29
|
+
const userName = userContext?.username || 'User Name';
|
|
30
|
+
|
|
25
31
|
return (
|
|
26
32
|
<>
|
|
27
33
|
<DropdownMenu>
|
|
@@ -35,11 +41,27 @@ export function UserNav(): JSX.Element {
|
|
|
35
41
|
<DropdownMenuContent className="w-56" align="end" forceMount>
|
|
36
42
|
<DropdownMenuLabel className="font-normal">
|
|
37
43
|
<div className="flex flex-col space-y-1">
|
|
38
|
-
<p className="text-sm font-medium leading-none">
|
|
44
|
+
<p className="text-sm font-medium leading-none">{userName}</p>
|
|
39
45
|
<p className="text-xs leading-none text-muted-foreground">Email</p>
|
|
40
46
|
</div>
|
|
41
47
|
</DropdownMenuLabel>
|
|
42
48
|
<DropdownMenuSeparator />
|
|
49
|
+
<DropdownMenuItem>
|
|
50
|
+
<Link
|
|
51
|
+
to={{
|
|
52
|
+
pathname: ROUTES.BUSINESSES.DETAIL(userContext?.context.adminBusinessId || ''),
|
|
53
|
+
search: '?tab=admin',
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
<Button
|
|
57
|
+
variant="ghost"
|
|
58
|
+
className="flex items-center gap-1 data-[state=active]:bg-background"
|
|
59
|
+
>
|
|
60
|
+
<Shield className="size-4" />
|
|
61
|
+
<span className="hidden sm:inline">Admin Configurations</span>
|
|
62
|
+
</Button>
|
|
63
|
+
</Link>
|
|
64
|
+
</DropdownMenuItem>
|
|
43
65
|
<DropdownMenuItem>
|
|
44
66
|
<Button variant="ghost" onClick={() => setBalanceChargeModalOpen(true)}>
|
|
45
67
|
Add Balance Charge
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import{D as xe,G as be,S as Te,H as Ne,a as we,J as Ms,r as y,j as e,K as Pe,N as Be,O as Us,n as Cs,Q as zs,i as pe,t as O,l as je,U as qs,V as Ie,W as Oe,X as De,Y as G,Z as W,_ as K,$ as H,a0 as Ae,a1 as X,a2 as j,a3 as g,a4 as f,a5 as N,v as T,a6 as I,a7 as C,a8 as Ye,B as E,a9 as Gs,aa as Le,ab as Ze,ac as V,ad as bs,ae as es,af as Ws,s as Ks,C as Hs,ag as Xs,ah as L,ai as ds,aj as Js,ak as Qs,al as Ys,am as de,an as ss,ao as q,ap as ns,aq as ts,ar as as,as as Z,at as ue,au as re,av as ie,aw as le,ax as ce,ay as oe,az as rs,aA as is,aB as Ue,aC as ae,aD as ze,aE as qe,aF as Fe,aG as Zs,aH as ee,aI as Y,aJ as en,aK as sn,aL as nn,aM as Ge,aN as tn,aO as an,aP as rn,aQ as ln,aR as cn,aS as We,aT as Ke,aU as ws,aV as on,aW as He,aX as dn,aY as Is,aZ as Ds,a_ as un,a$ as mn,b0 as As,b1 as ls,b2 as hn,b3 as us,b4 as xn,b5 as pn,b6 as jn,b7 as gn,b8 as fn,b9 as vn,ba as yn,bb as D,bc as Nn,bd as cs,be as Cn,bf as bn,bg as wn,bh as In,bi as Dn,bj as An,bk as Q,bl as Sn,bm as kn,bn as z,bo as Tn,bp as En,bq as Pn,br as Bn}from"./index-DfI9E1Fb.js";import{S as os}from"./save-D84vX5ea.js";import{B as On}from"./business-header-Cr5S_Mz7.js";import{i as Ln,D as Vn,f as Fn,E as _n,L as _e,a as Se,C as $n,A as Rn,b as ve,c as Mn,d as Xe,h as Un,e as zn,g as Ss,u as qn,G as Gn,j as ms,k as Wn,X as ks,Y as Ts,l as Kn,m as Hn,R as Xn,n as Jn,o as Qn,p as Yn}from"./chart-CQ9Opsuw.js";import{P as Zn}from"./pencil-DNPAJOPL.js";import{A as et,a as $e,b as Re,c as hs}from"./accordion-s9Ku08QQ.js";import{B as st}from"./building-2-B92gXbOj.js";import"./sequential-CAnleQny.js";/**
|
|
2
|
-
* @license lucide-react v0.546.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const nt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],xs=xe("circle-check",nt);/**
|
|
7
|
-
* @license lucide-react v0.546.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const tt=[["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=xe("dollar-sign",tt);/**
|
|
12
|
-
* @license lucide-react v0.546.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const at=[["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"}]],rt=xe("file-check",at);/**
|
|
17
|
-
* @license lucide-react v0.546.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const it=[["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"}]],lt=xe("plug",it);/**
|
|
22
|
-
* @license lucide-react v0.546.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const ct=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Es=xe("shield",ct);/**
|
|
27
|
-
* @license lucide-react v0.546.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const ot=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Me=xe("trending-up",ot);function Ps(s){switch(s){case be.Annual:return"Annual";case be.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${s}`)}}function Bs(s){switch(s){case Te.Enterprise:return"Enterprise";case Te.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${s}`)}}function dt(s){return Ne(s,"yyyy-MM-dd")}function ut({businessId:s,tagIds:n,description:t,open:a,onOpenChange:l,onClose:i}){const[{data:c,fetching:r},o]=we({pause:!0,query:Ms,variables:{businessId:s,tagsDifferentThan:n?n.map(m=>m.id):void 0,descriptionDifferentThan:t}});y.useEffect(()=>{a&&(n||t)&&!c&&o()},[a,n,t,o,c]);const d=y.useCallback(m=>{l(m),a&&!m&&i?.()},[l,i,a]),h=y.useMemo(()=>a&&(!!n||!!t)&&c&&c?.similarChargesByBusiness.length>0,[a,n,t,c]);return e.jsx(Pe,{open:h,onOpenChange:d,children:e.jsx(Be,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:m=>m.stopPropagation(),children:e.jsx(Us,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:r?e.jsx(Cs,{}):n||t?e.jsx(zs,{data:c?.similarChargesByBusiness??[],tagIds:n,description:t,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const mt="updateAdminBusiness",ht=()=>{const[{fetching:s},n]=pe(qs),t=y.useCallback(async a=>{const l=`Error updating admin business ID [${a.adminBusinessId}]`,i=`${mt}-${a.adminBusinessId}`;O.loading("Updating admin business",{id:i});try{const c=await n(a),r=je(c,l,i,"updateAdminBusiness");if(r)return O.success("Success",{id:i,description:"Admin Business Updated"}),r.updateAdminBusiness}catch(c){console.error(`${l}: ${c}`),O.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:t}},xt=Le({employerWithholdingTaxAccountNumber:V().min(1,{message:"Employer Withholding Tax Account Number is required"}),taxPrepaymentId:V().min(1,{message:"Tax Prepayment ID is required"}),nationalInsuranceEmployerId:V().min(1,{message:"National Insurance Employer ID is required"}),advanceTaxRate:bs().min(0,{message:"Advance Tax Rate must be at least 0"}).max(100,{message:"Advance Tax Rate must be at most 100"}),registrationDate:V().min(1,{message:"Registration Date is required"})});function ps(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{employerWithholdingTaxAccountNumber:s.adminInfo.employerWithholdingTaxAccountNumber??"",taxPrepaymentId:s.adminInfo.taxPrepaymentId??"",nationalInsuranceEmployerId:s.adminInfo.nationalInsuranceEmployerId??"",advanceTaxRate:s.adminInfo.advanceTaxRate??0,registrationDate:s.adminInfo.registrationDate??""}}function pt(s){return{employerWithholdingTaxAccountNumber:s.employerWithholdingTaxAccountNumber,taxPrepaymentId:s.taxPrepaymentId,nationalInsuranceEmployerId:s.nationalInsuranceEmployerId,advanceTaxRate:s.advanceTaxRate,registrationDate:s.registrationDate?dt(new Date(s.registrationDate)):void 0}}function jt({data:s,refetchBusiness:n}){const t=De(Gs,s),[a,l]=y.useState(ps(t)),{updateAdminBusiness:i,fetching:c}=ht(),r=Ie({resolver:Oe(xt),defaultValues:a}),o=async d=>{if(!t)return;const h=Ze(d,r.formState.dirtyFields);if(!h)return;const m=pt(h);await i({adminBusinessId:t.id,fields:m}),n?.()};return y.useEffect(()=>{if(t){const d=ps(t);l(d),r.reset(d)}},[t,r]),e.jsxs(G,{children:[e.jsxs(W,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Es,{className:"h-5 w-5 text-primary"}),e.jsx(K,{children:"Admin Business Configuration"})]}),e.jsx(H,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Ae,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(o),className:"space-y-6",children:[e.jsx(X,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:r.control,name:"employerWithholdingTaxAccountNumber",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Employer Withholding Tax Account Number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter account number",...d,className:I(h)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"taxPrepaymentId",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Prepayment ID"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter prepayment ID",...d,className:I(h)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"nationalInsuranceEmployerId",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"National Insurance Employer ID"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter employer ID",...d,className:I(h)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"advanceTaxRate",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Advance Tax Rate (%)"}),e.jsx(N,{children:e.jsx(T,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"Enter tax rate",...d,className:I(h)})}),e.jsx(C,{})]})}),e.jsx(j,{control:r.control,name:"registrationDate",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Registration Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...d,className:I(h)})}),e.jsx(C,{})]})})]})}),e.jsx(Ye,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:c||Object.keys(r.formState.dirtyFields).length===0||!r.formState.isValid,children:[e.jsx(os,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function gt({businessId:s}){const{userContext:n}=y.useContext(es),[t,a]=y.useState(1),[{data:l,fetching:i}]=we({query:Ws,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:Xs.Date,asc:!1},byBusinesses:[s]},page:t,limit:100}}),c=l?.allCharges?.pageInfo.totalPages??1,r=l?.allCharges?.nodes??[];return i?e.jsx("div",{children:"Loading charges..."}):e.jsxs(G,{children:[e.jsxs(W,{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(K,{children:"Charges"}),e.jsx(H,{children:"Recurring and one-time charges for this business"})]})}),c>1&&e.jsx(Ks,{className:"flex-fit",value:t,onChange:a,total:c})]}),e.jsx(X,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Hs,{data:r,isAllOpened:!1})})})]})}var ft=["type","layout","connectNulls","ref"],vt=["key"];function me(s){"@babel/helpers - typeof";return me=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},me(s)}function js(s,n){if(s==null)return{};var t=yt(s,n),a,l;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);for(l=0;l<i.length;l++)a=i[l],!(n.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(s,a)&&(t[a]=s[a])}return t}function yt(s,n){if(s==null)return{};var t={};for(var a in s)if(Object.prototype.hasOwnProperty.call(s,a)){if(n.indexOf(a)>=0)continue;t[a]=s[a]}return t}function Ce(){return Ce=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(s[a]=t[a])}return s},Ce.apply(this,arguments)}function gs(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);n&&(a=a.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),t.push.apply(t,a)}return t}function _(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?gs(Object(t),!0).forEach(function(a){M(s,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):gs(Object(t)).forEach(function(a){Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(t,a))})}return s}function te(s){return wt(s)||bt(s)||Ct(s)||Nt()}function Nt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
32
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ct(s,n){if(s){if(typeof s=="string")return Je(s,n);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(s);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Je(s,n)}}function bt(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function wt(s){if(Array.isArray(s))return Je(s)}function Je(s,n){(n==null||n>s.length)&&(n=s.length);for(var t=0,a=new Array(n);t<n;t++)a[t]=s[t];return a}function It(s,n){if(!(s instanceof n))throw new TypeError("Cannot call a class as a function")}function fs(s,n){for(var t=0;t<n.length;t++){var a=n[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(s,Ls(a.key),a)}}function Dt(s,n,t){return n&&fs(s.prototype,n),t&&fs(s,t),Object.defineProperty(s,"prototype",{writable:!1}),s}function At(s,n,t){return n=Ee(n),St(s,Os()?Reflect.construct(n,t||[],Ee(s).constructor):n.apply(s,t))}function St(s,n){if(n&&(me(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kt(s)}function kt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Os(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Os=function(){return!!s})()}function Ee(s){return Ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ee(s)}function Tt(s,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(n&&n.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),n&&Qe(s,n)}function Qe(s,n){return Qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,l){return a.__proto__=l,a},Qe(s,n)}function M(s,n,t){return n=Ls(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Ls(s){var n=Et(s,"string");return me(n)=="symbol"?n:n+""}function Et(s,n){if(me(s)!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var a=t.call(s,n);if(me(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var he=(function(s){function n(){var t;It(this,n);for(var a=arguments.length,l=new Array(a),i=0;i<a;i++)l[i]=arguments[i];return t=At(this,n,[].concat(l)),M(t,"state",{isAnimationFinished:!0,totalLength:0}),M(t,"generateSimpleStrokeDasharray",function(c,r){return"".concat(r,"px ").concat(c-r,"px")}),M(t,"getStrokeDasharray",function(c,r,o){var d=o.reduce(function(b,k){return b+k});if(!d)return t.generateSimpleStrokeDasharray(r,c);for(var h=Math.floor(c/d),m=c%d,x=r-c,A=[],u=0,p=0;u<o.length;p+=o[u],++u)if(p+o[u]>m){A=[].concat(te(o.slice(0,u)),[m-p]);break}var S=A.length%2===0?[0,x]:[x];return[].concat(te(n.repeat(o,h)),te(A),S).map(function(b){return"".concat(b,"px")}).join(", ")}),M(t,"id",qn("recharts-line-")),M(t,"pathRef",function(c){t.mainCurve=c}),M(t,"handleAnimationEnd",function(){t.setState({isAnimationFinished:!0}),t.props.onAnimationEnd&&t.props.onAnimationEnd()}),M(t,"handleAnimationStart",function(){t.setState({isAnimationFinished:!1}),t.props.onAnimationStart&&t.props.onAnimationStart()}),t}return Tt(n,s),Dt(n,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();this.setState({totalLength:a})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();a!==this.state.totalLength&&this.setState({totalLength:a})}}},{key:"getTotalLength",value:function(){var a=this.mainCurve;try{return a&&a.getTotalLength&&a.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(a,l){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.points,r=i.xAxis,o=i.yAxis,d=i.layout,h=i.children,m=Fn(h,_n);if(!m)return null;var x=function(p,S){return{x:p.x,y:p.y,value:p.value,errorVal:Ss(p.payload,S)}},A={clipPath:a?"url(#clipPath-".concat(l,")"):null};return L.createElement(_e,A,m.map(function(u){return L.cloneElement(u,{key:"bar-".concat(u.props.dataKey),data:c,xAxis:r,yAxis:o,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(a,l,i){var c=this.props.isAnimationActive;if(c&&!this.state.isAnimationFinished)return null;var r=this.props,o=r.dot,d=r.points,h=r.dataKey,m=Se(this.props,!1),x=Se(o,!0),A=d.map(function(p,S){var b=_(_(_({key:"dot-".concat(S),r:3},m),x),{},{index:S,cx:p.x,cy:p.y,value:p.value,dataKey:h,payload:p.payload,points:d});return n.renderDotItem(o,b)}),u={clipPath:a?"url(#clipPath-".concat(l?"":"dots-").concat(i,")"):null};return L.createElement(_e,Ce({className:"recharts-line-dots",key:"dots"},u),A)}},{key:"renderCurveStatically",value:function(a,l,i,c){var r=this.props,o=r.type,d=r.layout,h=r.connectNulls;r.ref;var m=js(r,ft),x=_(_(_({},Se(m,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:l?"url(#clipPath-".concat(i,")"):null,points:a},c),{},{type:o,layout:d,connectNulls:h});return L.createElement($n,Ce({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,l){var i=this,c=this.props,r=c.points,o=c.strokeDasharray,d=c.isAnimationActive,h=c.animationBegin,m=c.animationDuration,x=c.animationEasing,A=c.animationId,u=c.animateNewValues,p=c.width,S=c.height,b=this.state,k=b.prevPoints,F=b.totalLength;return L.createElement(Rn,{begin:h,duration:m,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(R){var $=R.t;if(k){var J=k.length/r.length,U=r.map(function(B,Ve){var ge=Math.floor(Ve*J);if(k[ge]){var fe=k[ge],ne=ve(fe.x,B.x),_s=ve(fe.y,B.y);return _(_({},B),{},{x:ne($),y:_s($)})}if(u){var $s=ve(p*2,B.x),Rs=ve(S/2,B.y);return _(_({},B),{},{x:$s($),y:Rs($)})}return _(_({},B),{},{x:B.x,y:B.y})});return i.renderCurveStatically(U,a,l)}var se=ve(0,F),v=se($),w;if(o){var P="".concat(o).split(/[,\s]+/gim).map(function(B){return parseFloat(B)});w=i.getStrokeDasharray(v,F,P)}else w=i.generateSimpleStrokeDasharray(F,v);return i.renderCurveStatically(r,a,l,{strokeDasharray:w})})}},{key:"renderCurve",value:function(a,l){var i=this.props,c=i.points,r=i.isAnimationActive,o=this.state,d=o.prevPoints,h=o.totalLength;return r&&c&&c.length&&(!d&&h>0||!Mn(d,c))?this.renderCurveWithAnimation(a,l):this.renderCurveStatically(c,a,l)}},{key:"render",value:function(){var a,l=this.props,i=l.hide,c=l.dot,r=l.points,o=l.className,d=l.xAxis,h=l.yAxis,m=l.top,x=l.left,A=l.width,u=l.height,p=l.isAnimationActive,S=l.id;if(i||!r||!r.length)return null;var b=this.state.isAnimationFinished,k=r.length===1,F=ds("recharts-line",o),R=d&&d.allowDataOverflow,$=h&&h.allowDataOverflow,J=R||$,U=Xe(S)?this.id:S,se=(a=Se(c,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},v=se.r,w=v===void 0?3:v,P=se.strokeWidth,B=P===void 0?2:P,Ve=Un(c)?c:{},ge=Ve.clipDot,fe=ge===void 0?!0:ge,ne=w*2+B;return L.createElement(_e,{className:F},R||$?L.createElement("defs",null,L.createElement("clipPath",{id:"clipPath-".concat(U)},L.createElement("rect",{x:R?x:x-A/2,y:$?m:m-u/2,width:R?A:A*2,height:$?u:u*2})),!fe&&L.createElement("clipPath",{id:"clipPath-dots-".concat(U)},L.createElement("rect",{x:x-ne/2,y:m-ne/2,width:A+ne,height:u+ne}))):null,!k&&this.renderCurve(J,U),this.renderErrorBar(J,U),(k||c)&&this.renderDots(J,fe,U),(!p||b)&&zn.renderCallByParent(this.props,r))}}],[{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 i=a.length%2!==0?[].concat(te(a),[0]):a,c=[],r=0;r<l;++r)c=[].concat(te(c),te(i));return c}},{key:"renderDotItem",value:function(a,l){var i;if(L.isValidElement(a))i=L.cloneElement(a,l);else if(Ln(a))i=a(l);else{var c=l.key,r=js(l,vt),o=ds("recharts-line-dot",typeof a!="boolean"?a.className:"");i=L.createElement(Vn,Ce({key:c},r,{className:o}))}return i}}])})(y.PureComponent);M(he,"displayName","Line");M(he,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Gn.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});M(he,"getComposedData",function(s){var n=s.props,t=s.xAxis,a=s.yAxis,l=s.xAxisTicks,i=s.yAxisTicks,c=s.dataKey,r=s.bandSize,o=s.displayedData,d=s.offset,h=n.layout,m=o.map(function(x,A){var u=Ss(x,c);return h==="horizontal"?{x:ms({axis:t,ticks:l,bandSize:r,entry:x,index:A}),y:Xe(u)?null:a.scale(u),value:u,payload:x}:{x:Xe(u)?null:t.scale(u),y:ms({axis:a,ticks:i,bandSize:r,entry:x,index:A}),value:u,payload:x}});return _({points:m,layout:h},d)});var Pt=Wn({chartName:"LineChart",GraphicalChild:he,axisComponents:[{axisType:"xAxis",AxisComp:ks},{axisType:"yAxis",AxisComp:Ts}],formatAxisMap:Kn});const ye=[{month:"Jan",revenue:12500,expenses:8200},{month:"Feb",revenue:15800,expenses:9100},{month:"Mar",revenue:18200,expenses:10500},{month:"Apr",revenue:16900,expenses:9800},{month:"May",revenue:21300,expenses:11200},{month:"Jun",revenue:24500,expenses:12800},{month:"Jul",revenue:22800,expenses:11900},{month:"Aug",revenue:26100,expenses:13500},{month:"Sep",revenue:28900,expenses:14200},{month:"Oct",revenue:31200,expenses:15100}];function Bt(){const s=ye.reduce((t,a)=>t+a.revenue,0),n=s/ye.length;return e.jsxs(G,{children:[e.jsxs(W,{children:[e.jsx(K,{children:"Revenue Analytics"}),e.jsx(H,{children:"Revenue and expenses over time"})]}),e.jsxs(X,{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(Me,{className:"h-3 w-3"}),e.jsx("span",{children:"+24.5% from last period"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",n.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Me,{className:"h-3 w-3"}),e.jsx("span",{children:"+18.2% growth rate"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",ye[ye.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Me,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Hn,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Xn,{width:"100%",height:"100%",children:e.jsxs(Pt,{data:ye,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Jn,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(ks,{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(Qn,{content:e.jsx(Yn,{})}),e.jsx(he,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(he,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Ot="updateBusiness",Vs=()=>{const[{fetching:s},n]=pe(Js),t=y.useCallback(async a=>{const l=`Error updating business ID [${a.businessId}]`,i=`${Ot}-${a.businessId}`;O.loading("Updating business",{id:i});try{const c=await n(a),r=je(c,l,i,"updateBusiness");if(r)return O.success("Success",{id:i,description:"Business updated"}),r.updateBusiness}catch(c){console.error(`${l}: ${c}`),O.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateBusiness:t}},Lt="insertClient",Vt=()=>{const[{fetching:s},n]=pe(Qs),t=y.useCallback(async a=>{const l=`Error creating client [${a.fields.businessId}]`,i=`${Lt}-${a.fields.businessId}`;O.loading("Creating Client...",{id:i});try{const c=await n(a),r=je(c,l,i,"insertClient");if(r)return O.success("Success",{id:i,description:`Client [${a.fields.businessId}] was created`}),r.insertClient}catch(c){console.error(`${l}: ${c}`),O.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertClient:t}},Ft="updateClient",Fs=()=>{const[{fetching:s},n]=pe(Ys),t=y.useCallback(async a=>{const l=`Error updating client ID [${a.businessId}]`,i=`${Ft}-${a.businessId}`;O.loading("Updating client",{id:i});try{const c=await n(a),r=je(c,l,i,"updateClient");if(r)return O.success("Success",{id:i,description:"Client updated"}),r.updateClient}catch(c){console.error(`${l}: ${c}`),O.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateClient:t}},_t=Le({businessId:Ue().optional(),emails:ze(qe()).optional(),generatedDocumentType:ae(Object.values(de)),greenInvoiceId:Ue().optional(),hiveId:V().optional()});function $t({client:s,businessId:n,onDone:t}){const[a,l]=y.useState(!1),[i,c]=y.useState(null),{updateClient:r}=Fs(),{insertClient:o}=Vt(),[d,h]=y.useState(""),m={businessId:n,generatedDocumentType:de.Proforma,emails:[]},x=Ie({resolver:Oe(_t),defaultValues:s||m});y.useEffect(()=>{s&&(c(s),x.reset({emails:s.emails,greenInvoiceId:s.greenInvoiceId,hiveId:s.hiveId,generatedDocumentType:s.generatedDocumentType,businessId:s.businessId}),l(!0))},[s,x]);const A=()=>{c(null),x.reset(m),l(!0)},u=()=>{if(d.trim()){const b=x.getValues("emails");x.setValue("emails",[...b??[],d.trim()],{shouldDirty:!0}),h("")}},p=b=>{const k=x.getValues("emails");x.setValue("emails",(k??[]).filter((F,R)=>R!==b),{shouldDirty:!0})},S=y.useCallback(async b=>{if(i)r({businessId:n,fields:b});else{if(!b.greenInvoiceId){x.setError("greenInvoiceId",{message:"Green Invoice ID is required"});return}o({fields:{...b,greenInvoiceId:b.greenInvoiceId,businessId:n}})}l(!1),c(null),t?.()},[i,t,r,n,o,x]);return e.jsxs(Pe,{open:a,onOpenChange:l,children:[e.jsx(ss,{asChild:!0,children:e.jsxs(E,{size:"sm",onClick:A,children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"New Client"]})}),e.jsxs(Be,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ns,{children:[e.jsx(ts,{children:i?"Edit Client":"Create New Client"}),e.jsx(as,{children:i?"Update client details":"Add a new client with all required details"})]}),e.jsx(Ae,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(S),children:[e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:x.control,name:"emails",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Emails"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add email...",value:d,onChange:k=>h(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),u())}}),e.jsx(E,{type:"button",size:"sm",onClick:u,children:e.jsx(q,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.value?.map((k,F)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[k,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>p(F),children:e.jsx(ue,{className:"size-3 cursor-pointer"})})]},F))}),e.jsx(C,{})]})}),e.jsx(j,{control:x.control,name:"generatedDocumentType",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Document Type"}),e.jsxs(re,{onValueChange:b.onChange,defaultValue:b.value,children:[e.jsx(N,{children:e.jsx(ie,{children:e.jsx(le,{})})}),e.jsx(ce,{children:Object.values(de).map(k=>e.jsx(oe,{value:k,children:rs(k)},k))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:x.control,name:"greenInvoiceId",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Green Invoice ID"}),e.jsx(N,{children:e.jsx(T,{type:"text",placeholder:"Enter Green Invoice ID",...b,required:!i})}),e.jsx(C,{})]})}),e.jsx(j,{control:x.control,name:"hiveId",render:({field:b})=>e.jsxs(g,{children:[e.jsx(f,{children:"Hive ID"}),e.jsx(N,{children:e.jsx(T,{type:"text",placeholder:"Enter Hive ID",...b,required:!i})}),e.jsx(C,{})]})})]})}),e.jsxs(is,{children:[e.jsx(E,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{type:"submit",children:i?"Update Client":"Create Client"})]})]})})]})]})}const Rt=Object.values(ln);function vs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{isClient:!!s.clientInfo?.id,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough??void 0,isDocumentsOptional:s.isDocumentsOptional??void 0,isVatOptional:s.optionalVAT??void 0,isExemptDealer:s.exemptDealer??void 0,sortCode:s.sortCode?.key?.toString()??void 0,taxCategory:s.taxCategory?.id??void 0,pcn874RecordType:s?.pcn874RecordType??void 0,irsCode:s?.irsCode??void 0,description:s.suggestions?.description??void 0,tags:s.suggestions?.tags?.map(n=>n.id)??[],phrases:s.suggestions?.phrases??[],emails:s.suggestions?.emails??[],internalLinks:s.suggestions?.emailListener?.internalEmailLinks??[],attachmentTypes:s.suggestions?.emailListener?.attachments??[],useMessageBody:s.suggestions?.emailListener?.emailBody??void 0}}function Mt(s){const t=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||t?{description:s.description,tags:s.tags?.map(i=>({id:i})),phrases:s.phrases,emails:s.emails,emailListener:t}:void 0;return{optionalVAT:s.isVatOptional,exemptDealer:s.isExemptDealer,sortCode:s.sortCode?parseInt(s.sortCode):void 0,taxCategory:s.taxCategory,pcn874RecordType:s.pcn874RecordType,irsCode:s.irsCode,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough,isDocumentsOptional:s.isDocumentsOptional,suggestions:l}}function Ut({data:s,refetchBusiness:n}){const t=De(Zs,s),[a,l]=y.useState(vs(t)),{userContext:i}=y.useContext(es),{updateBusiness:c,fetching:r}=Vs(),[o,d]=y.useState(!1),[h,m]=y.useState(void 0),x=Ie({defaultValues:a}),A=async p=>{if(!t||!i?.context.adminBusinessId)return;const S=Ze(p,x.formState.dirtyFields);if(!S)return;const b=Mt(S);await c({businessId:t.id,ownerId:i.context.adminBusinessId,fields:b}),S.tags?.length||S.description?(m({tagIds:S.tags?.map(k=>({id:k})),description:S.description}),d(!0)):n?.()};if(y.useEffect(()=>{if(t){const p=vs(t);l(p),x.reset(p)}},[t,x]),!t)return e.jsx("div",{});const u=x.watch("isClient");return e.jsxs(G,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(K,{children:"Configurations"}),e.jsx(H,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!u&&e.jsx($t,{businessId:t.id,onDone:n})]})}),e.jsx(Ae,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(A),children:[e.jsxs(X,{className:"space-y-6",children:[e.jsx(zt,{form:x}),e.jsx(Fe,{}),e.jsx(qt,{form:x}),e.jsx(Fe,{}),e.jsx(Gt,{form:x}),e.jsx(Fe,{}),e.jsx(Wt,{form:x})]}),e.jsx(Ye,{className:"flex justify-end border-t pt-6",children:e.jsxs(E,{type:"submit",disabled:r||Object.keys(x.formState.dirtyFields).length===0,children:[e.jsx(os,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(ut,{businessId:t.id,tagIds:h?.tagIds,description:h?.description,open:o,onOpenChange:d,onClose:n})]})}function zt({form:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Business Status & Behavior"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:s.control,name:"isClient",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Client"}),e.jsx(ee,{children:"Mark this business as a client"})]}),e.jsx(N,{children:e.jsx(Y,{disabled:!0,checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Active"}),e.jsx(ee,{children:"Business is currently active"})]}),e.jsx(N,{children:e.jsx(Y,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Receipt Enough"}),e.jsx(ee,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(N,{children:e.jsx(Y,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"No Docs Required"}),e.jsx(ee,{children:"Skip document validation for common charges"})]}),e.jsx(N,{children:e.jsx(Y,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is VAT Optional"}),e.jsx(ee,{children:"Mute missing VAT indicator"})]}),e.jsx(N,{children:e.jsx(Y,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:n,fieldState:t})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Exempt Dealer"}),e.jsx(ee,{children:"Business is exempt from VAT requirements"})]}),e.jsx(N,{children:e.jsx(Y,{checked:n.value,onCheckedChange:n.onChange,className:I(t)})})]})})]})]})}function qt({form:s}){const{selectableTaxCategories:n,fetching:t}=en(),{selectableSortCodes:a,fetching:l,sortCodes:i}=sn(),{selectableTags:c,fetching:r}=nn(),o=y.useCallback(d=>{if(d){const h=i.find(m=>Number(m.key)===Number(d));h&&(h.defaultIrsCode?s.setValue("irsCode",h.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,i]);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:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(N,{children:e.jsx(Ge,{onChange:m=>{o(m),d.onChange(m)},data:a,value:d.value,disabled:l,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:I(h)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(N,{children:e.jsx(Ge,{data:n,disabled:t,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:I(h)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(re,{onValueChange:d.onChange,value:d.value,children:[e.jsx(N,{children:e.jsx(ie,{className:I(h),children:e.jsx(le,{})})}),e.jsx(ce,{children:Object.entries(tn).map(([m,x])=>e.jsx(oe,{value:m,children:`${x} (${m})`},m))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(N,{children:e.jsx(an,{value:d.value??void 0,onValueChange:m=>d.onChange(m??null),hideControls:!0,decimalScale:0,className:I(h)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:I(h)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:d,fieldState:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(N,{children:e.jsx(rn,{options:Object.values(c).map(({value:m,label:x})=>({label:x,value:m})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:r,className:I(h)})}),e.jsx(C,{})]})})]})]})}function Gt({form:s}){const[n,t]=y.useState(""),[a,l]=y.useState(""),i=()=>{if(n.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,n.trim()],{shouldDirty:!0}),t("")}},c=()=>{if(a.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,a.trim()],{shouldDirty:!0}),l("")}},r=d=>{const h=s.getValues("phrases");s.setValue("phrases",h.filter((m,x)=>x!==d),{shouldDirty:!0})},o=d=>{const h=s.getValues("emails");s.setValue("emails",h.filter((m,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:h})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:n,onChange:m=>t(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),i())},className:I(h)}),e.jsx(E,{type:"button",size:"sm",onClick:i,children:e.jsx(q,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((m,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[m,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>r(x),children:e.jsx(ue,{className:"size-3 cursor-pointer",onClick:()=>r(x)})})]},x))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:d,fieldState:h})=>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:m=>l(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),c())},className:I(h)}),e.jsx(E,{type:"button",size:"sm",onClick:c,children:e.jsx(q,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((m,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[m,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(x),children:e.jsx(ue,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(C,{})]})})]})}function Wt({form:s}){const[n,t]=y.useState(""),a=()=>{if(n.trim()){const c=s.getValues("internalLinks");s.setValue("internalLinks",[...c,n.trim()],{shouldDirty:!0}),t("")}},l=c=>{const r=s.getValues("attachmentTypes");s.setValue("attachmentTypes",r?.includes(c)?r.filter(o=>o!==c):[...r,c],{shouldDirty:!0})},i=c=>{const r=s.getValues("internalLinks");s.setValue("internalLinks",r.filter((o,d)=>d!==c),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Gmail Feature Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Gmail integration settings for document processing"}),e.jsx(j,{control:s.control,name:"attachmentTypes",render:({field:c,fieldState:r})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:I(r)+" rounded-md flex flex-wrap gap-2",children:Rt.map(o=>e.jsx(Z,{variant:c.value?.includes(o)?"default":"outline",className:"cursor-pointer",onClick:()=>l(o),children:o},o))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:c,fieldState:r})=>e.jsxs(g,{children:[e.jsx(f,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"url",placeholder:"Add internal link...",value:n,onChange:o=>t(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),a())}}),e.jsx(E,{type:"button",size:"sm",onClick:a,children:e.jsx(q,{className:"h-4 w-4"})})]}),e.jsx("div",{className:I(r)+" flex flex-wrap gap-2 rounded-md",children:c.value?.map((o,d)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[o,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(d),children:e.jsx(ue,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:c,fieldState:r})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Should Use Message Body"}),e.jsx(ee,{children:"Extract information from email message body"})]}),e.jsx(N,{children:e.jsx(Y,{checked:c.value,onCheckedChange:c.onChange,className:I(r)})})]})})]})}const Kt=Le({businessName:V().min(1,"Business name is required"),locality:V().min(1,"Locality is required"),localName:V().optional(),govId:V().optional(),address:V().optional(),localAddress:V().optional(),phone:V().optional(),website:Is("Invalid URL").optional().or(Ds("")),generalContacts:ze(qe()).optional(),billingEmails:ze(qe()).optional()});function ys(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(n=>n.trim()),billingEmails:s.clientInfo?.emails}}function Ht(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 Xt({data:s,refetchBusiness:n}){const t=De(dn,s),[a,l]=y.useState(ys(t)),{userContext:i}=y.useContext(es),{updateBusiness:c,fetching:r}=Vs(),o=Ie({resolver:Oe(Kt),defaultValues:a}),{countries:d,fetching:h}=cn(),[m,x]=y.useState(""),[A,u]=y.useState(""),p=o.watch("locality"),S=o.watch("address"),b=o.watch("localAddress");y.useEffect(()=>{S!==a.address&&o.setValue("address",S,{shouldDirty:!0})},[S,a.address,o]),y.useEffect(()=>{b!==a.localAddress&&o.setValue("localAddress",b,{shouldDirty:!0})},[b,a.localAddress,o]);const k=t&&"clientInfo"in t&&!!t.clientInfo,F=p===i?.context.locality,R=v=>{m.trim()&&(o.setValue("generalContacts",[...v,m.trim()],{shouldDirty:!0}),x(""))},$=(v,w)=>{o.setValue("generalContacts",v.filter((P,B)=>B!==w),{shouldDirty:!0})},J=v=>{A.trim()&&(o.setValue("billingEmails",[...v,A.trim()],{shouldDirty:!0}),u(""))},U=(v,w)=>{o.setValue("billingEmails",v.filter((P,B)=>B!==w),{shouldDirty:!0})},se=async v=>{if(!t||!i?.context.adminBusinessId)return;const w=Ze(v,o.formState.dirtyFields);if(!w)return;const P=Ht(w);await c({businessId:t.id,ownerId:i.context.adminBusinessId,fields:P}),n?.()};return y.useEffect(()=>{if(t){const v=ys(t);l(v),o.reset(v)}},[t,o]),e.jsxs(G,{children:[e.jsxs(W,{children:[e.jsx(K,{children:"Contact Information"}),e.jsx(H,{children:"Business contact details and address information"})]}),e.jsx(Ae,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(se),children:[e.jsx(X,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:o.control,name:"businessName",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(N,{children:e.jsx(T,{...v,className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"locality",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(Ge,{onChange:v.onChange,data:d.map(P=>({value:P.code,label:P.name})),value:v.value,disabled:h,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:I(w)}}),e.jsx(C,{})]})}),F&&e.jsx(j,{control:o.control,name:"localName",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(N,{children:e.jsx(T,{...v,placeholder:"Business name in local language",className:I(w)})}),e.jsx(C,{})]})}),F&&e.jsx(j,{control:o.control,name:"govId",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(N,{children:e.jsx(T,{...v,placeholder:"Enter Government ID",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"address",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(We,{className:"h-4 w-4"}),"Address"]}),e.jsx(N,{children:e.jsx(Ke,{...v,rows:3,placeholder:"Enter business address",className:I(w)})}),e.jsx(C,{})]})}),F&&e.jsx(j,{control:o.control,name:"localAddress",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(We,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(N,{children:e.jsx(Ke,{...v,rows:3,placeholder:"Enter address in local language",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"phone",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(ws,{className:"h-4 w-4"}),"Phone"]}),e.jsx(N,{children:e.jsx(T,{...v,type:"tel",placeholder:"+1 (555) 123-4567",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"website",render:({field:v,fieldState:w})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(on,{className:"h-4 w-4"}),"Website"]}),e.jsx(N,{children:e.jsx(T,{...v,type:"url",placeholder:"https://example.com",className:I(w)})}),e.jsx(C,{})]})}),e.jsx(j,{control:o.control,name:"generalContacts",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:I(w)+" flex flex-wrap gap-2 mb-2 rounded-md",children:v.value?.map((P,B)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[P,e.jsx("button",{type:"button",onClick:()=>$(v.value??[],B),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ue,{className:"h-3 w-3"})})]},B))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:m,onChange:P=>x(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),R(v.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!m.trim(),onClick:()=>R(v.value??[]),children:e.jsx(q,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})}),k&&e.jsx(j,{control:o.control,name:"billingEmails",render:({field:v,fieldState:w})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:I(w)+" flex flex-wrap gap-2 mb-2 rounded-md",children:v.value?.map((P,B)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[P,e.jsx("button",{type:"button",onClick:()=>U(v.value??[],B),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ue,{className:"h-3 w-3"})})]},B))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:A,onChange:P=>u(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),J(v.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!A.trim(),onClick:()=>J(v.value??[]),children:e.jsx(q,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})})]})}),e.jsx(Ye,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:r||Object.keys(o.formState.dirtyFields).length===0,children:[e.jsx(os,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const Jt="createContract",Qt=()=>{const[{fetching:s},n]=pe(un),t=y.useCallback(async a=>{const l=`Error creating new contract for client[${a.input.clientId}]`,i=`${Jt}-${a.input.clientId}`;O.loading("Creating contract",{id:i});try{const c=await n(a);je(c,l,i)&&O.success("Success",{id:i,description:`Contract for client ${a.input.clientId} was successfully created`})}catch(c){console.error(`${l}: ${c}`),O.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createContract:t}},Yt="updateContract",Zt=()=>{const[{fetching:s},n]=pe(mn),t=y.useCallback(async a=>{const l=`Error updating contract ID [${a.contractId}]`,i=`${Yt}-${a.contractId}`;O.loading("Updating contract",{id:i});try{const c=await n(a),r=je(c,l,i,"updateContract");if(r)return O.success("Success",{id:i,description:"Contract updated"}),r.updateContract}catch(c){console.error(`${l}: ${c}`),O.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateContract:t}},ea=Le({id:Ue().optional(),startDate:us("Start date is required"),endDate:us("End date is required"),po:V().optional(),paymentAmount:bs().min(0,"Payment amount must be non-negative"),paymentCurrency:ae(Object.values(ls),"Currency is required"),productType:ae(Object.values(As)).optional(),msCloudLink:Is().optional().or(Ds("")),billingCycle:ae(Object.values(be)).optional(),subscriptionPlan:ae(Object.values(Te)).optional(),isActive:hn(),defaultRemark:V().optional(),defaultDocumentType:ae(Object.values(de))}),Ns={startDate:"",endDate:"",po:void 0,paymentAmount:0,paymentCurrency:ls.Usd,productType:As.Hive,msCloudLink:void 0,billingCycle:be.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:de.Proforma};function sa({clientId:s,contract:n,onDone:t}){const[a,l]=y.useState(!1),[i,c]=y.useState(null),{updateContract:r,updating:o}=Zt(),{createContract:d,creating:h}=Qt(),m=Ie({resolver:Oe(ea),defaultValues:n||Ns});y.useEffect(()=>{n&&(c(n),m.reset({startDate:n.startDate,endDate:n.endDate,po:n.po,paymentAmount:n.paymentAmount,paymentCurrency:n.paymentCurrency,productType:n.productType,msCloudLink:n.msCloudLink,billingCycle:n.billingCycle,subscriptionPlan:n.subscriptionPlan,isActive:n.isActive,defaultRemark:n.defaultRemark,defaultDocumentType:n.defaultDocumentType}),l(!0))},[n,m]);const x=()=>{c(null),m.reset(Ns),l(!0)},A=y.useCallback(async u=>{if(i)await r({contractId:i.id,input:{amount:{raw:u.paymentAmount,currency:u.paymentCurrency},billingCycle:u.billingCycle,documentType:u.defaultDocumentType,endDate:Ne(new Date(u.endDate),"yyyy-MM-dd"),isActive:u.isActive,msCloud:u.msCloudLink,plan:u.subscriptionPlan,product:u.productType,purchaseOrder:u.po,remarks:u.defaultRemark,startDate:Ne(new Date(u.startDate),"yyyy-MM-dd")}});else{if(!u.billingCycle){m.setError("billingCycle",{message:"Billing cycle is required"});return}await d({input:{clientId:s,amount:{raw:u.paymentAmount,currency:u.paymentCurrency},billingCycle:u.billingCycle,documentType:u.defaultDocumentType,endDate:Ne(new Date(u.endDate),"yyyy-MM-dd"),isActive:u.isActive,msCloud:u.msCloudLink,plan:u.subscriptionPlan,product:u.productType,purchaseOrder:u.po,remarks:u.defaultRemark,startDate:Ne(new Date(u.startDate),"yyyy-MM-dd")}})}l(!1),c(null),t?.()},[i,t,d,r,s,m]);return e.jsxs(Pe,{open:a,onOpenChange:l,children:[e.jsx(ss,{asChild:!0,children:e.jsxs(E,{size:"sm",onClick:x,children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(Be,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ns,{children:[e.jsx(ts,{children:i?"Edit Contract":"Create New Contract"}),e.jsx(as,{children:i?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(Ae,{...m,children:e.jsxs("form",{onSubmit:m.handleSubmit(A),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:e.jsx(j,{control:m.control,name:"po",render:({field:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"PO Number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"PO-2024-001",...u})}),e.jsx(C,{})]})})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:m.control,name:"startDate",render:({field:{onChange:u,...p}})=>e.jsxs(g,{children:[e.jsx(f,{children:"Start Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...p,onInput:S=>u(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:m.control,name:"endDate",render:({field:{onChange:u,...p}})=>e.jsxs(g,{children:[e.jsx(f,{children:"End Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...p,onInput:S=>u(S)})}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(j,{control:m.control,name:"paymentAmount",render:({field:u})=>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",...u,onChange:p=>{u.onChange(p?.target.value?Number(p?.target.value):void 0)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:m.control,name:"paymentCurrency",render:({field:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Currency"}),e.jsxs(re,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(N,{children:e.jsx(ie,{children:e.jsx(le,{})})}),e.jsx(ce,{children:Object.values(ls).map(p=>e.jsx(oe,{value:p,children:p},p))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:m.control,name:"productType",render:({field:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Product Type"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Cloud Services",...u})}),e.jsx(C,{})]})}),e.jsx(j,{control:m.control,name:"billingCycle",render:({field:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Billing Cycle"}),e.jsxs(re,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(N,{children:e.jsx(ie,{children:e.jsx(le,{})})}),e.jsx(ce,{children:Object.values(be).map(p=>e.jsx(oe,{value:p,children:Ps(p)},p))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:m.control,name:"subscriptionPlan",render:({field:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Subscription Plan"}),e.jsx(N,{children:e.jsxs(re,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(N,{children:e.jsx(ie,{children:e.jsx(le,{})})}),e.jsx(ce,{children:Object.values(Te).map(p=>e.jsx(oe,{value:p,children:Bs(p)},p))})]})}),e.jsx(C,{})]})}),e.jsx(j,{control:m.control,name:"isActive",render:({field:u})=>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(Y,{checked:u.value,onCheckedChange:u.onChange})})]})})]}),e.jsx(j,{control:m.control,name:"msCloudLink",render:({field:u})=>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",...u})}),e.jsx(C,{})]})}),e.jsx(j,{control:m.control,name:"defaultDocumentType",render:({field:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Document Type"}),e.jsxs(re,{onValueChange:u.onChange,defaultValue:u.value,children:[e.jsx(N,{children:e.jsx(ie,{children:e.jsx(le,{})})}),e.jsx(ce,{children:Object.values(de).map(p=>e.jsx(oe,{value:p,children:rs(p)},p))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:m.control,name:"defaultRemark",render:({field:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Remark"}),e.jsx(N,{children:e.jsx(Ke,{placeholder:"Enter default remark for this contract...",rows:3,...u})}),e.jsx(C,{})]})})]}),e.jsxs(is,{children:[e.jsx(E,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{type:"submit",disabled:h||o,children:i?"Update Contract":"Create Contract"})]})]})})]})]})}function na(s){return{id:s.id,po:s.purchaseOrder??void 0,startDate:s.startDate,endDate:s.endDate,paymentAmount:s.amount.raw,paymentCurrency:s.amount.currency,productType:s.product??void 0,billingCycle:s.billingCycle,msCloudLink:s.msCloud?.toString(),isActive:s.isActive,subscriptionPlan:s.plan??void 0,defaultRemark:s.remarks??void 0,defaultDocumentType:s.documentType??void 0}}function ta({clientId:s}){const[n,t]=y.useState(null),[{data:a,fetching:l},i]=we({query:xn,variables:{clientId:s}}),c=a?.contractsByClient??[];return l?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(G,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(K,{children:"Contracts"}),e.jsx(H,{children:"Current and past contracts sorted by start date"})]}),e.jsx(sa,{clientId:s,contract:n,onDone:i})]})}),e.jsx(X,{className:"space-y-4",children:c.map(r=>{const o=!!r.isActive;return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:r.product}),e.jsx(Z,{variant:o?"default":"secondary",children:r.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:r.id})]}),e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>t(na(r)),children:e.jsx(Zn,{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(pn,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(r.startDate).toLocaleDateString()," →"," ",new Date(r.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Number"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:r.purchaseOrder})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Payment"}),e.jsx("p",{className:"text-sm font-medium",children:jn(r.amount.raw,r.amount.currency)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Billing Cycle"}),e.jsx("p",{className:"text-sm font-medium",children:Ps(r.billingCycle)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscription Plan"}),e.jsx("p",{className:"text-sm font-medium",children:r.plan?Bs(r.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Document Type"}),e.jsx("p",{className:"text-sm font-medium",children:rs(r.documentType)})]})]}),r.remarks&&e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remark"}),e.jsx("p",{className:"text-sm",children:r.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.msCloud&&e.jsx(E,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:r.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(gn,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(fn,{className:"h-3 w-3 ml-1"})]})})})]},r.id)})})]})}function aa({businessId:s}){return e.jsxs(G,{children:[e.jsx(W,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(K,{children:"Documents"}),e.jsx(H,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(X,{children:e.jsx(vn,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const ra=[{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 ia({data:s}){const n=De(Cn,s),[{data:t,fetching:a},l]=we({query:yn,variables:{clientId:n?.id??""},pause:!n?.clientInfo?.greenInvoiceId||!n?.id}),{updateClient:i}=Fs(),c=y.useCallback((o,d)=>{if(!n?.id)return;const h={};h[d]=o,i({businessId:n?.id,fields:h})},[n?.id,i]);y.useEffect(()=>{n?.clientInfo?.greenInvoiceId&&n?.id&&l()},[n?.clientInfo?.greenInvoiceId,n?.id,l]);const r=t?.greenInvoiceClient;return e.jsxs(G,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(K,{children:"Integrations"}),e.jsx(H,{children:"Connected external services and providers"})]}),e.jsxs(E,{size:"sm",children:[e.jsx(q,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(X,{className:"space-y-6",children:e.jsxs(et,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[a?e.jsxs($e,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx(D,{className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-6 w-32"}),e.jsx(D,{className:"h-5 w-5 rounded-full"})]}),e.jsx(D,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-8 w-24"}),e.jsx(D,{className:"h-8 w-8"})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-32"}),e.jsx(D,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{className:"h-3 w-24"}),e.jsx(D,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs($e,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-600 flex items-center justify-center text-white font-bold",children:"GI"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Green Invoice"}),e.jsx(xs,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Israeli invoicing system integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(la,{id:n?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async o=>c(o,"greenInvoiceId")}),e.jsx(hs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Re,{children:r&&e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Business Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Integration ID"}),e.jsx("p",{className:"text-sm font-mono",children:n?.clientInfo?.greenInvoiceId})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Business Name"}),e.jsx("p",{className:"text-sm",children:r.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Country"}),e.jsx("p",{className:"text-sm",children:r.country})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"text-sm font-mono",children:r.taxId})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Contact Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.emails?.map((o,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:o},d))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(ws,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:r.phone})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Mobile"}),e.jsx("p",{className:"text-sm font-mono",children:r.mobile})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Fax"}),e.jsx("p",{className:"text-sm font-mono",children:r.fax})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),"Address"]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Street Address"}),e.jsx("p",{className:"text-sm",children:r.address})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"City"}),e.jsx("p",{className:"text-sm",children:r.city})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Zip Code"}),e.jsx("p",{className:"text-sm font-mono",children:r.zip})]})]})]})]})})]}),ra.map(o=>e.jsxs($e,{value:o.id,className:"rounded-lg border",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:o.name}),o.status==="connected"?e.jsx(xs,{className:"h-4 w-4 text-green-600"}):e.jsx(Nn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(cs,{className:"h-4 w-4"})}),e.jsx(hs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Re,{children:e.jsx("div",{className:"px-4 pb-4 pt-2 border-t",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last sync: "}),e.jsx("span",{className:"font-medium",children:o.lastSync})]})})})]},o.id))]})})]})}function la({id:s,provider:n,updateClient:t}){const[a,l]=y.useState(!1),[i,c]=y.useState(s),r=y.useCallback(async()=>{await t(i),l(!1)},[i,t]);return e.jsxs(Pe,{open:a,onOpenChange:l,children:[e.jsx(ss,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",onClick:o=>o.stopPropagation(),children:[e.jsx(cs,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(Be,{onClick:o=>o.stopPropagation(),children:[e.jsxs(ns,{children:[e.jsxs(ts,{children:["Configure ",n]}),e.jsxs(as,{children:["Update your ",n," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(bn,{htmlFor:"id",children:[n," ID"]}),e.jsx(T,{id:"id",value:i,onChange:o=>c(o.target.value),placeholder:`Enter ${n} ID`})]})}),e.jsxs(is,{children:[e.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{onClick:r,disabled:!i,children:"Save Changes"})]})]})]})}function ca({businessId:s}){return e.jsxs(G,{children:[e.jsx(W,{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(K,{children:"Transactions"}),e.jsx(H,{children:"Complete transaction history for this business"})]})})}),e.jsx(X,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(wn,{businessID:s,filter:{}})})})]})}function oa({data:s,refetchBusiness:n}){const t=De(Tn,s),[a,l]=In(),i=a.get("tab")||"contact",c=d=>{l({tab:d})};if(!t)return e.jsx("div",{children:"Business not found"});const r="clientInfo"in t&&!!t.clientInfo,o="adminInfo"in t&&!!t.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(On,{data:t}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(Dn,{value:i,onValueChange:c,className:"w-full",children:[e.jsxs(An,{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(Q,{value:"contact",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:"Contact"})]}),e.jsxs(Q,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(cs,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(Q,{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(Q,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Sn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(Q,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(kn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(rt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(Q,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(lt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),o&&e.jsxs(Q,{value:"admin",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:"Admin"})]})]}),e.jsx(z,{value:"contact",className:"mt-0",children:e.jsx(Xt,{data:t,refetchBusiness:n})}),e.jsx(z,{value:"config",className:"mt-0",children:e.jsx(Ut,{data:t,refetchBusiness:n})}),e.jsx(z,{value:"charges",className:"mt-0",children:e.jsx(gt,{businessId:t.id})}),e.jsx(z,{value:"transactions",className:"mt-0",children:e.jsx(ca,{businessId:t.id})}),e.jsx(z,{value:"documents",className:"mt-0",children:e.jsx(aa,{businessId:t.id})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(z,{value:"contracts",className:"mt-0",children:e.jsx(ta,{clientId:t.id})}),e.jsx(z,{value:"integrations",className:"mt-0",children:e.jsx(ia,{data:t})}),e.jsx(z,{value:"charts",className:"mt-0",children:e.jsx(Bt,{})})]}),o&&e.jsx(z,{value:"admin",className:"mt-0",children:e.jsx(jt,{data:t})})]})})]})}function fa(s){return`/businesses/${s}`}const va=()=>{const{businessId:s}=En();let n;try{n=Pn()}catch{}const[{data:t,fetching:a},l]=we({query:Bn,pause:!s||!!n,variables:{businessId:s??""}}),i=n||t;return!n&&a&&!i?.business?e.jsx(Cs,{}):!s||!i?.business?e.jsx("div",{children:"Business not found"}):e.jsx(oa,{data:i.business,refetchBusiness:async()=>l()})};export{va as BusinessScreen,fa as getBusinessHref};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{cZ as k,r as m,u as R,d0 as V,j as e,c_ as q,bz as Q,B as I,c$ as z,V as G,cd as K,dh as X,aL as J,di as Z,bO as y,bP as A,bT as F,bU as B,H as S,ch as E,a as P,f7 as W,Y as U,n as $,Z as Y,_ as ee,at as ae,a1 as O,f8 as se,F as te,ae as re,aP as ne,c as oe,$ as le,e8 as ie,f9 as ce,b1 as de}from"./index-DfI9E1Fb.js";import{k as ue,B as N,X as H,Y as me,l as pe,m as xe,n as ge,o as he,p as fe,q as be,r as je}from"./chart-CQ9Opsuw.js";import{s as ye}from"./sub-BbpGm1pj.js";import"./sequential-CAnleQny.js";import"./subMonths-0tIJizDp.js";var ve=ue({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:me}],formatAxisMap:pe});function _(s){return!s||k(s)?null:encodeURIComponent(JSON.stringify(s))}const L="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:n,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=G({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=K(),{selectableFinancialEntities:f,fetching:v}=X(),{selectableTags:p,fetching:j}=J(),M=a=>{n(a),c()},C=g("excludedTags"),l=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),o=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(Z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:l,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:i})=>e.jsx(E,{...a,data:o,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,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-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:n,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=R();m.useEffect(()=>{const p=_(s),j=h(L);p!==j&&f(L,p)},[s,h,f]);const v=m.useCallback(p=>{V(p,s)||(n(p),b(!!p))},[s,n]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(q,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(Q,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(z,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:n,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=P({query:W,variables:{transactionIDs:n}}),g=m.useMemo(()=>t?.transactionsByIDs?n.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,n]);return e.jsx(U,{className:"mt-5 w-full",children:r?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{children:e.jsxs(ee,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(ae,{className:"h-4 w-4"})})]})}),e.jsx(O,{children:e.jsx(se,{transactionsProps:g})})]})})};function Be(s){const n=new URLSearchParams,c=_(s);return c&&n.append(L,c),`/reports/balance${n.size>0?`?${n}`:""}`}const w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,n,c){switch(c){case x.MONTHLY:{const t=String(n).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=n%2===0?n-1:n,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(n/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=n>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,n){switch(n){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=ie(de.Usd),De=()=>{const{setFiltersContext:s}=m.useContext(te),{userContext:n}=m.useContext(re),{get:c}=R(),t=m.useMemo(()=>{const l={ownerId:n?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(ye(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(L);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(o){console.log("Error parsing balance report filters from URL:",o)}return l},[n?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:l,fromDate:d,toDate:o}=r;return{ownerId:l,fromDate:d,toDate:o}},[r]),[{data:j,fetching:M}]=P({query:ce,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ne,{options:Object.entries(w).map(([l,d])=>({label:d.label,value:l})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(l=>({...l,ownerId:n?.context.adminBusinessId}))},[n]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const l=new Map;j.transactionsForBalanceReport.map(o=>{if(o.counterparty?.id&&(!o.isFee&&n?.context.financialAccountsBusinessesIds?.includes(o.counterparty.id)||r.excludedCounterparties?.includes(o.counterparty.id))||r.includedTags.length>0&&(!o.charge?.tags||o.charge.tags.length===0||!o.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&o.charge?.tags.length&&o.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(o.year,o.month,r.period);l.has(a)||l.set(a,{income:0,expense:0,delta:0,transactions:[]});const i=l.get(a);o.amountUsd.raw>0?i.income+=o.amountUsd.raw:i.expense+=o.amountUsd.raw,i.delta+=o.amountUsd.raw,i.transactions.push(o)});let d=0;return Array.from(l.entries()).sort((o,a)=>o[0].localeCompare(a[0])).map(([o,a])=>(d+=a.delta,{period:o,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((i,u)=>Math.abs(u.amountUsd.raw)-Math.abs(i.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,n?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{className:"w-full",children:[e.jsx(Y,{children:e.jsx(le,{children:"Click specific period to expand it's transactions data"})}),e.jsx(O,{children:e.jsx(xe,{config:w,className:"h-150 w-full",children:e.jsxs(ve,{accessibilityLayer:!0,data:C,onClick:l=>h(l.activeLabel),children:[e.jsx(ge,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:l=>Me(l,r.period)}),e.jsx(he,{content:e.jsx(fe,{formatter:(l,d,o,a)=>{const i=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${i} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${i}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]})}})}),e.jsx(be,{content:e.jsx(je,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(l=>l.period===b)?.transactions.map(l=>l.id)??[]})]})})};export{De as BalanceReport,Be as getBalanceReportHref};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{fv as n}from"./index-DfI9E1Fb.js";function a(o,s,t){return n(o,-s,t)}export{a as s};
|