@accounter/client 0.0.8-alpha-20251027125446-75cc2031ef62f7abf48ecfbd31f62ddbddee2bd8 → 0.0.8-alpha-20251027135337-f79bd33d242a52dedb78869440eb1332cecb516f
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-BzSHHEEI.js → Checkbox-DpgoGNEh.js} +2 -2
- package/dist/assets/{Progress-CmZjJ77Z.js → Progress-CYZqv7SW.js} +1 -1
- package/dist/assets/{Typography-CuW3aX-4.js → Typography-CkIoreka.js} +1 -1
- package/dist/assets/{accordion-BZB-JxAM.js → accordion-CaHOdrRP.js} +1 -1
- package/dist/assets/accountant-approvals-DSj77RHk.js +1 -0
- package/dist/assets/{all-charges-X26mmfb3.js → all-charges-7emf__4c.js} +1 -1
- package/dist/assets/{arrow-up-down-_p0E2yis.js → arrow-up-down-B0c1T401.js} +1 -1
- package/dist/assets/{building-2-CKq13SAn.js → building-2-Cgw5U9px.js} +1 -1
- package/dist/assets/business-gIm-2ScS.js +37 -0
- package/dist/assets/{business-header-C8fXEo4_.js → business-header-Dr-cPjxi.js} +1 -1
- package/dist/assets/{business-transactions-single-CXmdF2-o.js → business-transactions-single-CyFYlmJ1.js} +1 -1
- package/dist/assets/{business-trip-wd9Embtb.js → business-trip-gN2mmMZs.js} +1 -1
- package/dist/assets/{charges-filters-Fu2ZAzWC.js → charges-filters-BFXTNJlR.js} +1 -1
- package/dist/assets/{charges-ledger-validation-BXXhWS5W.js → charges-ledger-validation-PLL72LF_.js} +1 -1
- package/dist/assets/{chart-3ddx32Qz.js → chart-CW1hdLVW.js} +1 -1
- package/dist/assets/{data-table-pagination-BopLOYg9.js → data-table-pagination-DGMzd5Ur.js} +1 -1
- package/dist/assets/{editable-business-trip-C34Ue7Hf.js → editable-business-trip-DO2VVnpQ.js} +2 -2
- package/dist/assets/{index-DeQnadsl.js → index-1WpeqtCj.js} +1 -1
- package/dist/assets/{index-HzZyyExI.js → index-B9J1vUWt.js} +1 -1
- package/dist/assets/{index-BGW4bQ-L.js → index-BKOjJ4S2.js} +1 -1
- package/dist/assets/{index-dP8CSci_.js → index-BNVZgIhA.js} +1 -1
- package/dist/assets/{index-DA1mkO2v.js → index-BgaZ9SWH.js} +1 -1
- package/dist/assets/{index-o-HWUpBy.js → index-C1Lhx64B.js} +1 -1
- package/dist/assets/{index-szVd1r0-.js → index-C3mMRi14.js} +1 -1
- package/dist/assets/{index-cZSBCnNJ.js → index-CNYfsMvN.js} +2 -2
- package/dist/assets/{index-B0uGI3EC.js → index-CWKSy3gx.js} +1 -1
- package/dist/assets/{index-BpCZ3X72.js → index-ClQMK6pH.js} +1 -1
- package/dist/assets/{index-CuczBTlN.js → index-CwSHI3TR.js} +1 -1
- package/dist/assets/{index-Cr24h-Cl.js → index-DIilK_xX.js} +1 -1
- package/dist/assets/index-DLcR6D3A.js +1 -0
- package/dist/assets/{index-CvS1Q-ya.js → index-DVls0wZI.js} +1 -1
- package/dist/assets/{index-BEtUypi7.js → index-DkoK59wU.js} +2 -2
- package/dist/assets/{index-BsqMXEt3.js → index-DmeswmlH.js} +2 -2
- package/dist/assets/{index-CkFRewFP.js → index-DnJZ0kU3.js} +2 -2
- package/dist/assets/{index-Dia_wOFb.js → index-DpWWjU9o.js} +1 -1
- package/dist/assets/{index-pjGYYOoy.js → index-DuovWEWg.js} +1 -1
- package/dist/assets/{index-PaJBRncn.js → index-DxWD905F.js} +1 -1
- package/dist/assets/{index-B6vWXPp8.js → index-DzpHfxyz.js} +1 -1
- package/dist/assets/{index-DL8q44ap.js → index-Mle6gZrH.js} +258 -263
- package/dist/assets/{index-JfxexlPg.js → index-df1n76_f.js} +2 -2
- package/dist/assets/index-wCrXjHTc.css +1 -0
- package/dist/assets/{index.es-ZISWba9V.js → index.es-CItPkO4N.js} +1 -1
- package/dist/assets/{issue-document-B-c96E9w.js → issue-document-OO4Zci4E.js} +1 -1
- package/dist/assets/{login-page-C_RNlOZS.js → login-page-BSQTX6W0.js} +1 -1
- package/dist/assets/{missing-info-charges-BrFjY7yz.js → missing-info-charges-opuTpAg9.js} +1 -1
- package/dist/assets/{page-not-found-s0xtsc5O.js → page-not-found-CajD8Y-I.js} +1 -1
- package/dist/assets/{pencil-D-2dJ444.js → pencil-30Ac_SOe.js} +1 -1
- package/dist/assets/{report-commentary-row-aIxbqTgK.js → report-commentary-row-CMQfSAqR.js} +1 -1
- package/dist/assets/{save-DZ9jxz9u.js → save-CepuoEj-.js} +1 -1
- package/dist/assets/sub-CHPOWTq8.js +1 -0
- package/dist/assets/subMonths-CnpmFwyh.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/business/financial-account-section.tsx +658 -0
- package/src/components/business/index.tsx +26 -10
- package/src/components/clients/modify-client-dialog.tsx +9 -27
- package/src/components/common/modals/insert-business.tsx +36 -87
- package/src/components/layout/user-nav.tsx +3 -25
- package/dist/assets/accountant-approvals-BtF90Myx.js +0 -1
- package/dist/assets/business--pLros0g.js +0 -27
- package/dist/assets/index-DtE5Y1ZB.css +0 -1
- package/dist/assets/index-SmrmFP8m.js +0 -1
- package/dist/assets/sub-o9iEG2Bl.js +0 -1
- package/dist/assets/subMonths-CpJ3oidH.js +0 -1
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Plug,
|
|
9
9
|
Settings,
|
|
10
10
|
Shield,
|
|
11
|
+
Wallet,
|
|
11
12
|
// TrendingUp,
|
|
12
13
|
} from 'lucide-react';
|
|
13
14
|
import { useSearchParams } from 'react-router-dom';
|
|
@@ -22,6 +23,7 @@ import { ConfigurationsSection } from './configurations-section.jsx';
|
|
|
22
23
|
import { ContactInfoSection } from './contact-info-section.jsx';
|
|
23
24
|
import { ContractsSection } from './contracts-section.jsx';
|
|
24
25
|
import { DocumentsSection } from './documents-section.jsx';
|
|
26
|
+
import { FinancialAccountsSection } from './financial-account-section.js';
|
|
25
27
|
import { IntegrationsSection } from './integrations-section.jsx';
|
|
26
28
|
import { TransactionsSection } from './transactions-section.js';
|
|
27
29
|
|
|
@@ -135,13 +137,22 @@ export default function Business({ data, refetchBusiness }: Props): ReactElement
|
|
|
135
137
|
</>
|
|
136
138
|
)}
|
|
137
139
|
{isAdmin && (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
<>
|
|
141
|
+
<TabsTrigger
|
|
142
|
+
value="accounts"
|
|
143
|
+
className="flex items-center gap-2 data-[state=active]:bg-background"
|
|
144
|
+
>
|
|
145
|
+
<Wallet className="h-4 w-4" />
|
|
146
|
+
<span className="hidden sm:inline">Accounts</span>
|
|
147
|
+
</TabsTrigger>
|
|
148
|
+
<TabsTrigger
|
|
149
|
+
value="admin"
|
|
150
|
+
className="flex items-center gap-2 data-[state=active]:bg-background"
|
|
151
|
+
>
|
|
152
|
+
<Shield className="h-4 w-4" />
|
|
153
|
+
<span className="hidden sm:inline">Admin</span>
|
|
154
|
+
</TabsTrigger>
|
|
155
|
+
</>
|
|
145
156
|
)}
|
|
146
157
|
</TabsList>
|
|
147
158
|
|
|
@@ -182,9 +193,14 @@ export default function Business({ data, refetchBusiness }: Props): ReactElement
|
|
|
182
193
|
)}
|
|
183
194
|
|
|
184
195
|
{isAdmin && (
|
|
185
|
-
|
|
186
|
-
<
|
|
187
|
-
|
|
196
|
+
<>
|
|
197
|
+
<TabsContent value="accounts" className="mt-0">
|
|
198
|
+
<FinancialAccountsSection />
|
|
199
|
+
</TabsContent>
|
|
200
|
+
<TabsContent value="admin" className="mt-0">
|
|
201
|
+
<AdminBusinessSection data={business} />
|
|
202
|
+
</TabsContent>
|
|
203
|
+
</>
|
|
188
204
|
)}
|
|
189
205
|
</Tabs>
|
|
190
206
|
</main>
|
|
@@ -49,10 +49,9 @@ interface Props {
|
|
|
49
49
|
businessId: string;
|
|
50
50
|
client?: ClientFormValues | null;
|
|
51
51
|
onDone?: () => void;
|
|
52
|
-
showTrigger?: boolean;
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
export function ModifyClientDialog({ client, businessId, onDone
|
|
54
|
+
export function ModifyClientDialog({ client, businessId, onDone }: Props) {
|
|
56
55
|
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
57
56
|
const [editingClient, setEditingClient] = useState<ClientFormValues | null>(null);
|
|
58
57
|
|
|
@@ -139,23 +138,13 @@ export function ModifyClientDialog({ client, businessId, onDone, showTrigger = t
|
|
|
139
138
|
);
|
|
140
139
|
|
|
141
140
|
return (
|
|
142
|
-
<Dialog
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}}
|
|
150
|
-
>
|
|
151
|
-
{showTrigger && (
|
|
152
|
-
<DialogTrigger asChild>
|
|
153
|
-
<Button size="sm" onClick={handleNew}>
|
|
154
|
-
<Plus className="h-4 w-4 mr-2" />
|
|
155
|
-
New Client
|
|
156
|
-
</Button>
|
|
157
|
-
</DialogTrigger>
|
|
158
|
-
)}
|
|
141
|
+
<Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
|
|
142
|
+
<DialogTrigger asChild>
|
|
143
|
+
<Button size="sm" onClick={handleNew}>
|
|
144
|
+
<Plus className="h-4 w-4 mr-2" />
|
|
145
|
+
New Client
|
|
146
|
+
</Button>
|
|
147
|
+
</DialogTrigger>
|
|
159
148
|
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
|
160
149
|
<DialogHeader>
|
|
161
150
|
<DialogTitle>{editingClient ? 'Edit Client' : 'Create New Client'}</DialogTitle>
|
|
@@ -274,14 +263,7 @@ export function ModifyClientDialog({ client, businessId, onDone, showTrigger = t
|
|
|
274
263
|
</div>
|
|
275
264
|
</div>
|
|
276
265
|
<DialogFooter>
|
|
277
|
-
<Button
|
|
278
|
-
type="button"
|
|
279
|
-
variant="outline"
|
|
280
|
-
onClick={() => {
|
|
281
|
-
setIsDialogOpen(false);
|
|
282
|
-
onDone?.();
|
|
283
|
-
}}
|
|
284
|
-
>
|
|
266
|
+
<Button type="button" variant="outline" onClick={() => setIsDialogOpen(false)}>
|
|
285
267
|
Cancel
|
|
286
268
|
</Button>
|
|
287
269
|
<Button type="submit">{editingClient ? 'Update Client' : 'Create Client'}</Button>
|
|
@@ -2,10 +2,6 @@ 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';
|
|
9
5
|
import { Badge } from '@/components/ui/badge.js';
|
|
10
6
|
import { Button } from '@/components/ui/button.js';
|
|
11
7
|
import {
|
|
@@ -19,7 +15,6 @@ import {
|
|
|
19
15
|
import {
|
|
20
16
|
Form,
|
|
21
17
|
FormControl,
|
|
22
|
-
FormDescription,
|
|
23
18
|
FormField,
|
|
24
19
|
FormItem,
|
|
25
20
|
FormLabel,
|
|
@@ -33,9 +28,7 @@ import {
|
|
|
33
28
|
SelectTrigger,
|
|
34
29
|
SelectValue,
|
|
35
30
|
} from '@/components/ui/select.js';
|
|
36
|
-
import { Switch } from '@/components/ui/switch.js';
|
|
37
31
|
import { Textarea } from '@/components/ui/textarea.js';
|
|
38
|
-
import { DocumentType } from '@/gql/graphql.js';
|
|
39
32
|
import { pcn874RecordEnum } from '@/helpers/index.js';
|
|
40
33
|
import { useAllCountries } from '@/hooks/use-get-countries.js';
|
|
41
34
|
import { useGetSortCodes } from '@/hooks/use-get-sort-codes.js';
|
|
@@ -55,8 +48,8 @@ const businessFormSchema = z
|
|
|
55
48
|
localName: z.string().optional(),
|
|
56
49
|
govId: z.string().optional(),
|
|
57
50
|
address: z.string().optional(),
|
|
58
|
-
generalContacts: z.array(z.email()),
|
|
59
|
-
website: z.url().optional().or(z.literal('')),
|
|
51
|
+
generalContacts: z.array(z.string().email()),
|
|
52
|
+
website: z.string().url().optional().or(z.literal('')),
|
|
60
53
|
phone: z.string().optional(),
|
|
61
54
|
taxCategory: z.string().optional(),
|
|
62
55
|
sortCode: z.string().optional(),
|
|
@@ -64,9 +57,8 @@ const businessFormSchema = z
|
|
|
64
57
|
irsCode: z.int().optional(),
|
|
65
58
|
defaultDescription: z.string().optional(),
|
|
66
59
|
defaultTags: z.array(z.string()),
|
|
67
|
-
isClient: z.boolean().default(false).optional(),
|
|
68
60
|
transactionPhrases: z.array(z.string()),
|
|
69
|
-
emailAddresses: z.array(z.email()),
|
|
61
|
+
emailAddresses: z.array(z.string().email()),
|
|
70
62
|
})
|
|
71
63
|
.refine(
|
|
72
64
|
data => {
|
|
@@ -125,7 +117,6 @@ export function InsertBusiness({
|
|
|
125
117
|
onAdd?: (businessId: string) => void;
|
|
126
118
|
}) {
|
|
127
119
|
const [isNewBusinessOpen, setIsNewBusinessOpen] = useState(false);
|
|
128
|
-
const [client, setClient] = useState<ClientFormValues | null>(null);
|
|
129
120
|
|
|
130
121
|
const { insertBusiness, fetching: addingInProcess } = useInsertBusiness();
|
|
131
122
|
|
|
@@ -137,7 +128,6 @@ export function InsertBusiness({
|
|
|
137
128
|
defaultTags: [],
|
|
138
129
|
transactionPhrases: description ? [description] : [],
|
|
139
130
|
emailAddresses: [],
|
|
140
|
-
locality: 'GAB',
|
|
141
131
|
},
|
|
142
132
|
});
|
|
143
133
|
|
|
@@ -145,68 +135,44 @@ export function InsertBusiness({
|
|
|
145
135
|
const newBusiness = await insertBusiness({
|
|
146
136
|
fields: convertFormDataToInsertNewBusinessInput(data),
|
|
147
137
|
});
|
|
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);
|
|
161
138
|
setIsNewBusinessOpen(false);
|
|
162
139
|
form.reset();
|
|
163
|
-
onAdd?.(
|
|
140
|
+
onAdd?.(newBusiness?.id ?? '');
|
|
164
141
|
};
|
|
165
142
|
|
|
166
143
|
return (
|
|
167
|
-
|
|
168
|
-
<
|
|
169
|
-
<
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
<
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
<
|
|
181
|
-
<form
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
</Dialog>
|
|
200
|
-
{client?.businessId && (
|
|
201
|
-
<ModifyClientDialog
|
|
202
|
-
businessId={client.businessId}
|
|
203
|
-
client={client}
|
|
204
|
-
onDone={() => {
|
|
205
|
-
onComplete(client.businessId);
|
|
206
|
-
}}
|
|
207
|
-
/>
|
|
208
|
-
)}
|
|
209
|
-
</>
|
|
144
|
+
<Dialog open={isNewBusinessOpen} onOpenChange={setIsNewBusinessOpen}>
|
|
145
|
+
<DialogTrigger asChild>
|
|
146
|
+
<Button>
|
|
147
|
+
<Plus className="size-4 mr-2" />
|
|
148
|
+
New Business
|
|
149
|
+
</Button>
|
|
150
|
+
</DialogTrigger>
|
|
151
|
+
<DialogContent className="max-w-3xl max-h-[90vh] overflow-y-auto">
|
|
152
|
+
<DialogHeader>
|
|
153
|
+
<DialogTitle>Create New Business</DialogTitle>
|
|
154
|
+
<DialogDescription>Add a new business to Accounter.</DialogDescription>
|
|
155
|
+
</DialogHeader>
|
|
156
|
+
<Form {...form}>
|
|
157
|
+
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
|
158
|
+
<ContactInformationSection form={form} />
|
|
159
|
+
|
|
160
|
+
<DefaultsSection form={form} />
|
|
161
|
+
|
|
162
|
+
<AutoMatchingSection form={form} />
|
|
163
|
+
|
|
164
|
+
<div className="flex justify-end gap-3 pt-4 border-t">
|
|
165
|
+
<Button type="button" variant="outline" onClick={() => setIsNewBusinessOpen(false)}>
|
|
166
|
+
Cancel
|
|
167
|
+
</Button>
|
|
168
|
+
<Button type="submit" disabled={addingInProcess}>
|
|
169
|
+
Create Business
|
|
170
|
+
</Button>
|
|
171
|
+
</div>
|
|
172
|
+
</form>
|
|
173
|
+
</Form>
|
|
174
|
+
</DialogContent>
|
|
175
|
+
</Dialog>
|
|
210
176
|
);
|
|
211
177
|
}
|
|
212
178
|
|
|
@@ -572,29 +538,12 @@ function DefaultsSection({ form }: SectionProps) {
|
|
|
572
538
|
placeholder="Select Default Tags"
|
|
573
539
|
variant="default"
|
|
574
540
|
disabled={fetchingTags}
|
|
575
|
-
asChild
|
|
576
541
|
/>
|
|
577
542
|
</FormControl>
|
|
578
543
|
<FormMessage />
|
|
579
544
|
</FormItem>
|
|
580
545
|
)}
|
|
581
546
|
/>
|
|
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
|
-
/>
|
|
598
547
|
</div>
|
|
599
548
|
</div>
|
|
600
549
|
);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CircleCheckBig, FileDown,
|
|
3
|
-
import { Link } from 'react-router-dom';
|
|
4
|
-
import { UserContext } from '@/providers/index.js';
|
|
5
|
-
import { ROUTES } from '@/router/routes.js';
|
|
1
|
+
import { useState, type JSX } from 'react';
|
|
2
|
+
import { CircleCheckBig, FileDown, User2Icon } from 'lucide-react';
|
|
6
3
|
import { Tooltip } from '@mantine/core';
|
|
7
4
|
import { useDisclosure } from '@mantine/hooks';
|
|
8
5
|
import { useCornJobs } from '../../hooks/use-corn-jobs.js';
|
|
@@ -20,14 +17,11 @@ import {
|
|
|
20
17
|
} from '../ui/dropdown-menu.js';
|
|
21
18
|
|
|
22
19
|
export function UserNav(): JSX.Element {
|
|
23
|
-
const { userContext } = useContext(UserContext);
|
|
24
20
|
const [pullDocumentsOpened, { close: closePullDocuments, open: openPullDocuments }] =
|
|
25
21
|
useDisclosure(false);
|
|
26
22
|
const [balanceChargeModalOpen, setBalanceChargeModalOpen] = useState(false);
|
|
27
23
|
const { executeJobs } = useCornJobs();
|
|
28
24
|
|
|
29
|
-
const userName = userContext?.username || 'User Name';
|
|
30
|
-
|
|
31
25
|
return (
|
|
32
26
|
<>
|
|
33
27
|
<DropdownMenu>
|
|
@@ -41,27 +35,11 @@ export function UserNav(): JSX.Element {
|
|
|
41
35
|
<DropdownMenuContent className="w-56" align="end" forceMount>
|
|
42
36
|
<DropdownMenuLabel className="font-normal">
|
|
43
37
|
<div className="flex flex-col space-y-1">
|
|
44
|
-
<p className="text-sm font-medium leading-none">
|
|
38
|
+
<p className="text-sm font-medium leading-none">User Name</p>
|
|
45
39
|
<p className="text-xs leading-none text-muted-foreground">Email</p>
|
|
46
40
|
</div>
|
|
47
41
|
</DropdownMenuLabel>
|
|
48
42
|
<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>
|
|
65
43
|
<DropdownMenuItem>
|
|
66
44
|
<Button variant="ghost" onClick={() => setBalanceChargeModalOpen(true)}>
|
|
67
45
|
Add Balance Charge
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,F as h,u as v,af as C,ah as A,a as F,j as e,c as P,L as b,fr as y}from"./index-DL8q44ap.js";import{C as j}from"./charges-filters-Fu2ZAzWC.js";import{P as D}from"./Progress-CmZjJ77Z.js";import"./sub-o9iEG2Bl.js";import"./subMonths-CpJ3oidH.js";const w=()=>{const{setFiltersContext:c}=a.useContext(h),{get:i}=v(),{userContext:p}=a.useContext(C),[s,x]=a.useState(i("chargesFilters")?JSON.parse(decodeURIComponent(i("chargesFilters"))):{byOwners:p?.context.adminBusinessId?[p?.context.adminBusinessId]:[],sortBy:{field:A.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:r,fetching:u}]=F({query:y,variables:{filters:s,page:1,limit:999999}}),t=r?.allCharges?.nodes.length??0;let o=0,l=0,n=0;r?.allCharges?.nodes.map(f=>{switch(f.accountantApproval){case"APPROVED":o+=1;break;case"PENDING":l+=1;break;case"UNAPPROVED":n+=1;break}});const d=100*o/t,g=100*l/t,m=100*n/t;return a.useEffect(()=>{c(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(j,{filter:s,setFilter:x,activePage:1,setPage:()=>{},totalPages:1})}))},[r,u,s,c,x]),e.jsx(P,{title:"Accountant Approvals Status",children:u?e.jsx(b,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"mx-10 mt-5 flex flex-col gap-5",children:[`Total charges: ${t}`,e.jsx(D,{color:"green",radius:"xl",size:"xl",sections:[{value:d,color:"green",label:`${d.toFixed(1)}% (${o})`},{value:g,color:"orange",label:`${g.toFixed(1)}% (${l})`},{value:m,color:"red",label:`${m.toFixed(1)}% (${n})`}]})]})})};export{w as AccountantApprovals};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import{D as ve,G as fe,S as Ie,H as me,a as Ne,J as Rs,r as N,j as e,K as Ge,N as qe,O as Ms,n as ps,Q as $s,i as De,t as _,l as Se,U as Us,V as ke,W as We,X as be,Y as G,Z as q,_ as js,$ as W,a0 as K,a1 as Te,a2 as H,a3 as g,a4 as f,a5 as y,a6 as v,v as T,a7 as w,a8 as b,a9 as Ke,B as E,aa as zs,ab as He,ac as Xe,ad as V,ae as gs,af as Je,ag as Gs,s as qs,C as Ws,ah as Ks,ai as B,aj as ss,ak as Hs,al as Xs,am as Pe,an as Js,ao as Y,ap as Q,aq as Qs,ar as Ys,as as Zs,at as Fe,au as ue,av as he,aw as xe,ax as pe,ay as en,az as je,aA as sn,aB as nn,aC as Z,aD as ee,aE as ye,aF as tn,aG as an,aH as _e,aI as Re,aJ as fs,aK as rn,aL as Me,aM as ln,aN as ns,aO as ys,aP as ts,aQ as vs,aR as cn,aS as on,aT as Qe,aU as Ns,aV as Ye,aW as bs,aX as Cs,aY as ws,aZ as Is,a_ as As,a$ as Ds,b0 as ce,b1 as dn,b2 as as,b3 as mn,b4 as un,b5 as hn,b6 as xn,b7 as pn,b8 as jn,b9 as gn,ba as fn,bb as yn,bc as I,bd as vn,be as Ze,bf as Nn,bg as bn,bh as Cn,bi as wn,bj as In,bk as An,bl as J,bm as Dn,bn as Sn,bo as z,bp as kn,bq as Tn,br as En,bs as Pn}from"./index-DL8q44ap.js";import{S as es}from"./save-DZ9jxz9u.js";import{B as Bn}from"./business-header-C8fXEo4_.js";import{i as On,D as Ln,f as Vn,E as Fn,L as Be,a as Ce,C as _n,A as Rn,b as oe,c as Mn,d as $e,h as $n,e as Un,g as Ss,u as zn,G as Gn,j as rs,k as qn,X as ks,Y as Ts,l as Wn,m as Kn,R as Hn,n as Xn,o as Jn,p as Qn}from"./chart-3ddx32Qz.js";import{P as Yn}from"./pencil-D-2dJ444.js";import{A as Zn,a as Oe,b as Le,c as is}from"./accordion-BZB-JxAM.js";import{B as et}from"./building-2-CKq13SAn.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 st=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ls=ve("circle-check",st);/**
|
|
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 nt=[["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"}]],we=ve("dollar-sign",nt);/**
|
|
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 tt=[["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"}]],at=ve("file-check",tt);/**
|
|
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 rt=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],it=ve("plug",rt);/**
|
|
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 lt=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Ve=ve("trending-up",lt);function Es(s){switch(s){case fe.Annual:return"Annual";case fe.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${s}`)}}function Ps(s){switch(s){case Ie.Enterprise:return"Enterprise";case Ie.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${s}`)}}function ct(s){return me(s,"yyyy-MM-dd")}function ot({businessId:s,tagIds:n,description:t,open:a,onOpenChange:l,onClose:o}){const[{data:i,fetching:r},c]=Ne({pause:!0,query:Rs,variables:{businessId:s,tagsDifferentThan:n?n.map(u=>u.id):void 0,descriptionDifferentThan:t}});N.useEffect(()=>{a&&(n||t)&&!i&&c()},[a,n,t,c,i]);const d=N.useCallback(u=>{l(u),a&&!u&&o?.()},[l,o,a]),h=N.useMemo(()=>a&&(!!n||!!t)&&i&&i?.similarChargesByBusiness.length>0,[a,n,t,i]);return e.jsx(Ge,{open:h,onOpenChange:d,children:e.jsx(qe,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:u=>u.stopPropagation(),children:e.jsx(Ms,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:r?e.jsx(ps,{}):n||t?e.jsx($s,{data:i?.similarChargesByBusiness??[],tagIds:n,description:t,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const dt="updateAdminBusiness",mt=()=>{const[{fetching:s},n]=De(Us),t=N.useCallback(async a=>{const l=`Error updating admin business ID [${a.adminBusinessId}]`,o=`${dt}-${a.adminBusinessId}`;_.loading("Updating admin business",{id:o});try{const i=await n(a),r=Se(i,l,o,"updateAdminBusiness");if(r)return _.success("Success",{id:o,description:"Admin Business Updated"}),r.updateAdminBusiness}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:t}},ut=He({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:gs().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 cs(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{employerWithholdingTaxAccountNumber:s.adminInfo.employerWithholdingTaxAccountNumber??"",taxPrepaymentId:s.adminInfo.taxPrepaymentId??"",nationalInsuranceEmployerId:s.adminInfo.nationalInsuranceEmployerId??"",advanceTaxRate:s.adminInfo.advanceTaxRate??0,registrationDate:s.adminInfo.registrationDate??""}}function ht(s){return{employerWithholdingTaxAccountNumber:s.employerWithholdingTaxAccountNumber,taxPrepaymentId:s.taxPrepaymentId,nationalInsuranceEmployerId:s.nationalInsuranceEmployerId,advanceTaxRate:s.advanceTaxRate,registrationDate:s.registrationDate?ct(new Date(s.registrationDate)):void 0}}function xt({data:s,refetchBusiness:n}){const t=be(zs,s),[a,l]=N.useState(cs(t)),{updateAdminBusiness:o,fetching:i}=mt(),r=ke({resolver:We(ut),defaultValues:a}),c=async d=>{if(!t)return;const h=Xe(d,r.formState.dirtyFields);if(!h)return;const u=ht(h);await o({adminBusinessId:t.id,fields:u}),n?.()};return N.useEffect(()=>{if(t){const d=cs(t);l(d),r.reset(d)}},[t,r]),e.jsxs(G,{children:[e.jsxs(q,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"h-5 w-5 text-primary"}),e.jsx(W,{children:"Admin Business Configuration"})]}),e.jsx(K,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Te,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(c),className:"space-y-6",children:[e.jsx(H,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(g,{control:r.control,name:"employerWithholdingTaxAccountNumber",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Employer Withholding Tax Account Number"}),e.jsx(v,{children:e.jsx(T,{placeholder:"Enter account number",...d,className:w(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:r.control,name:"taxPrepaymentId",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Tax Prepayment ID"}),e.jsx(v,{children:e.jsx(T,{placeholder:"Enter prepayment ID",...d,className:w(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:r.control,name:"nationalInsuranceEmployerId",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"National Insurance Employer ID"}),e.jsx(v,{children:e.jsx(T,{placeholder:"Enter employer ID",...d,className:w(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:r.control,name:"advanceTaxRate",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Advance Tax Rate (%)"}),e.jsx(v,{children:e.jsx(T,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"Enter tax rate",...d,className:w(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:r.control,name:"registrationDate",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Registration Date"}),e.jsx(v,{children:e.jsx(T,{type:"date",...d,className:w(h)})}),e.jsx(b,{})]})})]})}),e.jsx(Ke,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:i||Object.keys(r.formState.dirtyFields).length===0||!r.formState.isValid,children:[e.jsx(es,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function pt({businessId:s}){const{userContext:n}=N.useContext(Je),[t,a]=N.useState(1),[{data:l,fetching:o}]=Ne({query:Gs,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:Ks.Date,asc:!1},byBusinesses:[s]},page:t,limit:100}}),i=l?.allCharges?.pageInfo.totalPages??1,r=l?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(G,{children:[e.jsxs(q,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Charges"}),e.jsx(K,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(qs,{className:"flex-fit",value:t,onChange:a,total:i})]}),e.jsx(H,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ws,{data:r,isAllOpened:!1})})})]})}var jt=["type","layout","connectNulls","ref"],gt=["key"];function ae(s){"@babel/helpers - typeof";return ae=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},ae(s)}function os(s,n){if(s==null)return{};var t=ft(s,n),a,l;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(l=0;l<o.length;l++)a=o[l],!(n.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(s,a)&&(t[a]=s[a])}return t}function ft(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 ge(){return ge=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},ge.apply(this,arguments)}function ds(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 L(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?ds(Object(t),!0).forEach(function(a){R(s,a,t[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):ds(Object(t)).forEach(function(a){Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(t,a))})}return s}function te(s){return bt(s)||Nt(s)||vt(s)||yt()}function yt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
27
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vt(s,n){if(s){if(typeof s=="string")return Ue(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 Ue(s,n)}}function Nt(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function bt(s){if(Array.isArray(s))return Ue(s)}function Ue(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 Ct(s,n){if(!(s instanceof n))throw new TypeError("Cannot call a class as a function")}function ms(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,Os(a.key),a)}}function wt(s,n,t){return n&&ms(s.prototype,n),t&&ms(s,t),Object.defineProperty(s,"prototype",{writable:!1}),s}function It(s,n,t){return n=Ae(n),At(s,Bs()?Reflect.construct(n,t||[],Ae(s).constructor):n.apply(s,t))}function At(s,n){if(n&&(ae(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Dt(s)}function Dt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Bs(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Bs=function(){return!!s})()}function Ae(s){return Ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ae(s)}function St(s,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(n&&n.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),n&&ze(s,n)}function ze(s,n){return ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,l){return a.__proto__=l,a},ze(s,n)}function R(s,n,t){return n=Os(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Os(s){var n=kt(s,"string");return ae(n)=="symbol"?n:n+""}function kt(s,n){if(ae(s)!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var a=t.call(s,n);if(ae(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var re=(function(s){function n(){var t;Ct(this,n);for(var a=arguments.length,l=new Array(a),o=0;o<a;o++)l[o]=arguments[o];return t=It(this,n,[].concat(l)),R(t,"state",{isAnimationFinished:!0,totalLength:0}),R(t,"generateSimpleStrokeDasharray",function(i,r){return"".concat(r,"px ").concat(i-r,"px")}),R(t,"getStrokeDasharray",function(i,r,c){var d=c.reduce(function(P,O){return P+O});if(!d)return t.generateSimpleStrokeDasharray(r,i);for(var h=Math.floor(i/d),u=i%d,x=r-i,A=[],m=0,p=0;m<c.length;p+=c[m],++m)if(p+c[m]>u){A=[].concat(te(c.slice(0,m)),[u-p]);break}var D=A.length%2===0?[0,x]:[x];return[].concat(te(n.repeat(c,h)),te(A),D).map(function(P){return"".concat(P,"px")}).join(", ")}),R(t,"id",zn("recharts-line-")),R(t,"pathRef",function(i){t.mainCurve=i}),R(t,"handleAnimationEnd",function(){t.setState({isAnimationFinished:!0}),t.props.onAnimationEnd&&t.props.onAnimationEnd()}),R(t,"handleAnimationStart",function(){t.setState({isAnimationFinished:!1}),t.props.onAnimationStart&&t.props.onAnimationStart()}),t}return St(n,s),wt(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 o=this.props,i=o.points,r=o.xAxis,c=o.yAxis,d=o.layout,h=o.children,u=Vn(h,Fn);if(!u)return null;var x=function(p,D){return{x:p.x,y:p.y,value:p.value,errorVal:Ss(p.payload,D)}},A={clipPath:a?"url(#clipPath-".concat(l,")"):null};return B.createElement(Be,A,u.map(function(m){return B.cloneElement(m,{key:"bar-".concat(m.props.dataKey),data:i,xAxis:r,yAxis:c,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(a,l,o){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var r=this.props,c=r.dot,d=r.points,h=r.dataKey,u=Ce(this.props,!1),x=Ce(c,!0),A=d.map(function(p,D){var P=L(L(L({key:"dot-".concat(D),r:3},u),x),{},{index:D,cx:p.x,cy:p.y,value:p.value,dataKey:h,payload:p.payload,points:d});return n.renderDotItem(c,P)}),m={clipPath:a?"url(#clipPath-".concat(l?"":"dots-").concat(o,")"):null};return B.createElement(Be,ge({className:"recharts-line-dots",key:"dots"},m),A)}},{key:"renderCurveStatically",value:function(a,l,o,i){var r=this.props,c=r.type,d=r.layout,h=r.connectNulls;r.ref;var u=os(r,jt),x=L(L(L({},Ce(u,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:l?"url(#clipPath-".concat(o,")"):null,points:a},i),{},{type:c,layout:d,connectNulls:h});return B.createElement(_n,ge({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,l){var o=this,i=this.props,r=i.points,c=i.strokeDasharray,d=i.isAnimationActive,h=i.animationBegin,u=i.animationDuration,x=i.animationEasing,A=i.animationId,m=i.animateNewValues,p=i.width,D=i.height,P=this.state,O=P.prevPoints,M=P.totalLength;return B.createElement(Rn,{begin:h,duration:u,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function($){var F=$.t;if(O){var X=O.length/r.length,U=r.map(function(k,Ee){var ie=Math.floor(Ee*X);if(O[ie]){var le=O[ie],ne=oe(le.x,k.x),Vs=oe(le.y,k.y);return L(L({},k),{},{x:ne(F),y:Vs(F)})}if(m){var Fs=oe(p*2,k.x),_s=oe(D/2,k.y);return L(L({},k),{},{x:Fs(F),y:_s(F)})}return L(L({},k),{},{x:k.x,y:k.y})});return o.renderCurveStatically(U,a,l)}var se=oe(0,M),j=se(F),C;if(c){var S="".concat(c).split(/[,\s]+/gim).map(function(k){return parseFloat(k)});C=o.getStrokeDasharray(j,M,S)}else C=o.generateSimpleStrokeDasharray(M,j);return o.renderCurveStatically(r,a,l,{strokeDasharray:C})})}},{key:"renderCurve",value:function(a,l){var o=this.props,i=o.points,r=o.isAnimationActive,c=this.state,d=c.prevPoints,h=c.totalLength;return r&&i&&i.length&&(!d&&h>0||!Mn(d,i))?this.renderCurveWithAnimation(a,l):this.renderCurveStatically(i,a,l)}},{key:"render",value:function(){var a,l=this.props,o=l.hide,i=l.dot,r=l.points,c=l.className,d=l.xAxis,h=l.yAxis,u=l.top,x=l.left,A=l.width,m=l.height,p=l.isAnimationActive,D=l.id;if(o||!r||!r.length)return null;var P=this.state.isAnimationFinished,O=r.length===1,M=ss("recharts-line",c),$=d&&d.allowDataOverflow,F=h&&h.allowDataOverflow,X=$||F,U=$e(D)?this.id:D,se=(a=Ce(i,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},j=se.r,C=j===void 0?3:j,S=se.strokeWidth,k=S===void 0?2:S,Ee=$n(i)?i:{},ie=Ee.clipDot,le=ie===void 0?!0:ie,ne=C*2+k;return B.createElement(Be,{className:M},$||F?B.createElement("defs",null,B.createElement("clipPath",{id:"clipPath-".concat(U)},B.createElement("rect",{x:$?x:x-A/2,y:F?u:u-m/2,width:$?A:A*2,height:F?m:m*2})),!le&&B.createElement("clipPath",{id:"clipPath-dots-".concat(U)},B.createElement("rect",{x:x-ne/2,y:u-ne/2,width:A+ne,height:m+ne}))):null,!O&&this.renderCurve(X,U),this.renderErrorBar(X,U),(O||i)&&this.renderDots(X,le,U),(!p||P)&&Un.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 o=a.length%2!==0?[].concat(te(a),[0]):a,i=[],r=0;r<l;++r)i=[].concat(te(i),te(o));return i}},{key:"renderDotItem",value:function(a,l){var o;if(B.isValidElement(a))o=B.cloneElement(a,l);else if(On(a))o=a(l);else{var i=l.key,r=os(l,gt),c=ss("recharts-line-dot",typeof a!="boolean"?a.className:"");o=B.createElement(Ln,ge({key:i},r,{className:c}))}return o}}])})(N.PureComponent);R(re,"displayName","Line");R(re,"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});R(re,"getComposedData",function(s){var n=s.props,t=s.xAxis,a=s.yAxis,l=s.xAxisTicks,o=s.yAxisTicks,i=s.dataKey,r=s.bandSize,c=s.displayedData,d=s.offset,h=n.layout,u=c.map(function(x,A){var m=Ss(x,i);return h==="horizontal"?{x:rs({axis:t,ticks:l,bandSize:r,entry:x,index:A}),y:$e(m)?null:a.scale(m),value:m,payload:x}:{x:$e(m)?null:t.scale(m),y:rs({axis:a,ticks:o,bandSize:r,entry:x,index:A}),value:m,payload:x}});return L({points:u,layout:h},d)});var Tt=qn({chartName:"LineChart",GraphicalChild:re,axisComponents:[{axisType:"xAxis",AxisComp:ks},{axisType:"yAxis",AxisComp:Ts}],formatAxisMap:Wn});const de=[{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 Et(){const s=de.reduce((t,a)=>t+a.revenue,0),n=s/de.length;return e.jsxs(G,{children:[e.jsxs(q,{children:[e.jsx(W,{children:"Revenue Analytics"}),e.jsx(K,{children:"Revenue and expenses over time"})]}),e.jsxs(H,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3 mb-6",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(we,{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(Ve,{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(we,{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(Ve,{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(we,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",de[de.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Ve,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Kn,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Hn,{width:"100%",height:"100%",children:e.jsxs(Tt,{data:de,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Xn,{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(Jn,{content:e.jsx(Qn,{})}),e.jsx(re,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(re,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Pt="updateBusiness",Ls=()=>{const[{fetching:s},n]=De(Hs),t=N.useCallback(async a=>{const l=`Error updating business ID [${a.businessId}]`,o=`${Pt}-${a.businessId}`;_.loading("Updating business",{id:o});try{const i=await n(a),r=Se(i,l,o,"updateBusiness");if(r)return _.success("Success",{id:o,description:"Business updated"}),r.updateBusiness}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateBusiness:t}},Bt=Object.values(tn);function us(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{isClient:!!s.clientInfo?.id,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough??void 0,isDocumentsOptional:s.isDocumentsOptional??void 0,isVatOptional:s.optionalVAT??void 0,isExemptDealer:s.exemptDealer??void 0,sortCode:s.sortCode?.key?.toString()??void 0,taxCategory:s.taxCategory?.id??void 0,pcn874RecordType:s?.pcn874RecordType??void 0,irsCode:s?.irsCode??void 0,description:s.suggestions?.description??void 0,tags:s.suggestions?.tags?.map(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 Ot(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(o=>({id:o})),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 Lt({data:s,refetchBusiness:n}){const t=be(Js,s),[a,l]=N.useState(us(t)),{userContext:o}=N.useContext(Je),{updateBusiness:i,fetching:r}=Ls(),[c,d]=N.useState(!1),[h,u]=N.useState(void 0),x=ke({defaultValues:a}),A=async p=>{if(!t||!o?.context.adminBusinessId)return;const D=Xe(p,x.formState.dirtyFields);if(!D)return;const P=Ot(D);await i({businessId:t.id,ownerId:o.context.adminBusinessId,fields:P}),D.tags?.length||D.description?(u({tagIds:D.tags?.map(O=>({id:O})),description:D.description}),d(!0)):n?.()};if(N.useEffect(()=>{if(t){const p=us(t);l(p),x.reset(p)}},[t,x]),!t)return e.jsx("div",{});const m=x.watch("isClient");return e.jsxs(G,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Configurations"}),e.jsx(K,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!m&&e.jsx(Xs,{businessId:t.id,onDone:n})]})}),e.jsx(Te,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(A),children:[e.jsxs(H,{className:"space-y-6",children:[e.jsx(Vt,{form:x}),e.jsx(Pe,{}),e.jsx(Ft,{form:x}),e.jsx(Pe,{}),e.jsx(_t,{form:x}),e.jsx(Pe,{}),e.jsx(Rt,{form:x})]}),e.jsx(Ke,{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(es,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(ot,{businessId:t.id,tagIds:h?.tagIds,description:h?.description,open:c,onOpenChange:d,onClose:n})]})}function Vt({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(g,{control:s.control,name:"isClient",render:({field:n,fieldState:t})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{children:"Is Client"}),e.jsx(Y,{children:"Mark this business as a client"})]}),e.jsx(v,{children:e.jsx(Q,{disabled:!0,checked:n.value,onCheckedChange:n.onChange,className:w(t)})})]})}),e.jsx(g,{control:s.control,name:"isActive",render:({field:n,fieldState:t})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{children:"Is Active"}),e.jsx(Y,{children:"Business is currently active"})]}),e.jsx(v,{children:e.jsx(Q,{checked:n.value,onCheckedChange:n.onChange,className:w(t)})})]})}),e.jsx(g,{control:s.control,name:"isReceiptEnough",render:({field:n,fieldState:t})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{children:"Is Receipt Enough"}),e.jsx(Y,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(v,{children:e.jsx(Q,{checked:n.value,onCheckedChange:n.onChange,className:w(t)})})]})}),e.jsx(g,{control:s.control,name:"isDocumentsOptional",render:({field:n,fieldState:t})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{children:"No Docs Required"}),e.jsx(Y,{children:"Skip document validation for common charges"})]}),e.jsx(v,{children:e.jsx(Q,{checked:n.value,onCheckedChange:n.onChange,className:w(t)})})]})}),e.jsx(g,{control:s.control,name:"isVatOptional",render:({field:n,fieldState:t})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{children:"Is VAT Optional"}),e.jsx(Y,{children:"Mute missing VAT indicator"})]}),e.jsx(v,{children:e.jsx(Q,{checked:n.value,onCheckedChange:n.onChange,className:w(t)})})]})}),e.jsx(g,{control:s.control,name:"isExemptDealer",render:({field:n,fieldState:t})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{children:"Is Exempt Dealer"}),e.jsx(Y,{children:"Business is exempt from VAT requirements"})]}),e.jsx(v,{children:e.jsx(Q,{checked:n.value,onCheckedChange:n.onChange,className:w(t)})})]})})]})]})}function Ft({form:s}){const{selectableTaxCategories:n,fetching:t}=Qs(),{selectableSortCodes:a,fetching:l,sortCodes:o}=Ys(),{selectableTags:i,fetching:r}=Zs(),c=N.useCallback(d=>{if(d){const h=o.find(u=>Number(u.key)===Number(d));h&&(h.defaultIrsCode?s.setValue("irsCode",h.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Default Settings"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:s.control,name:"sortCode",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Sort Code"}),e.jsx(v,{children:e.jsx(Fe,{onChange:u=>{c(u),d.onChange(u)},data:a,value:d.value,disabled:l,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:w(h)}})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"taxCategory",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Tax Category"}),e.jsx(v,{children:e.jsx(Fe,{data:n,disabled:t,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:w(h)}})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"PCN874 Record Type"}),e.jsxs(ue,{onValueChange:d.onChange,value:d.value,children:[e.jsx(v,{children:e.jsx(he,{className:w(h),children:e.jsx(xe,{})})}),e.jsx(pe,{children:Object.entries(en).map(([u,x])=>e.jsx(je,{value:u,children:`${x} (${u})`},u))})]}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"irsCode",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"IRS Code"}),e.jsx(v,{children:e.jsx(sn,{value:d.value??void 0,onValueChange:u=>d.onChange(u??null),hideControls:!0,decimalScale:0,className:w(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"description",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Charge Description"}),e.jsx(v,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:w(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"tags",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Tags"}),e.jsx(v,{children:e.jsx(nn,{options:Object.values(i).map(({value:u,label:x})=>({label:x,value:u})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:r,className:w(h)})}),e.jsx(b,{})]})})]})]})}function _t({form:s}){const[n,t]=N.useState(""),[a,l]=N.useState(""),o=()=>{if(n.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,n.trim()],{shouldDirty:!0}),t("")}},i=()=>{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((u,x)=>x!==d),{shouldDirty:!0})},c=d=>{const h=s.getValues("emails");s.setValue("emails",h.filter((u,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(g,{control:s.control,name:"phrases",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:n,onChange:u=>t(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),o())},className:w(h)}),e.jsx(E,{type:"button",size:"sm",onClick:o,children:e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,x)=>e.jsxs(ee,{variant:"secondary",className:"gap-1",children:[u,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>r(x),children:e.jsx(ye,{className:"size-3 cursor-pointer",onClick:()=>r(x)})})]},x))}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"emails",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(y,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"email",placeholder:"Add email...",value:a,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),i())},className:w(h)}),e.jsx(E,{type:"button",size:"sm",onClick:i,children:e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,x)=>e.jsxs(ee,{variant:"secondary",className:"gap-1",children:[u,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>c(x),children:e.jsx(ye,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(b,{})]})})]})}function Rt({form:s}){const[n,t]=N.useState(""),a=()=>{if(n.trim()){const i=s.getValues("internalLinks");s.setValue("internalLinks",[...i,n.trim()],{shouldDirty:!0}),t("")}},l=i=>{const r=s.getValues("attachmentTypes");s.setValue("attachmentTypes",r?.includes(i)?r.filter(c=>c!==i):[...r,i],{shouldDirty:!0})},o=i=>{const r=s.getValues("internalLinks");s.setValue("internalLinks",r.filter((c,d)=>d!==i),{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(g,{control:s.control,name:"attachmentTypes",render:({field:i,fieldState:r})=>e.jsxs(f,{children:[e.jsx(y,{children:"Attachment Types"}),e.jsx("div",{className:w(r)+" rounded-md flex flex-wrap gap-2",children:Bt.map(c=>e.jsx(ee,{variant:i.value?.includes(c)?"default":"outline",className:"cursor-pointer",onClick:()=>l(c),children:c},c))}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"internalLinks",render:({field:i,fieldState:r})=>e.jsxs(f,{children:[e.jsx(y,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"url",placeholder:"Add internal link...",value:n,onChange:c=>t(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())}}),e.jsx(E,{type:"button",size:"sm",onClick:a,children:e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsx("div",{className:w(r)+" flex flex-wrap gap-2 rounded-md",children:i.value?.map((c,d)=>e.jsxs(ee,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[c,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(ye,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"useMessageBody",render:({field:i,fieldState:r})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(y,{children:"Should Use Message Body"}),e.jsx(Y,{children:"Extract information from email message body"})]}),e.jsx(v,{children:e.jsx(Q,{checked:i.value,onCheckedChange:i.onChange,className:w(r)})})]})})]})}const Mt=He({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:ys("Invalid URL").optional().or(vs("")),generalContacts:ns(ts()).optional(),billingEmails:ns(ts()).optional()});function hs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(n=>n.trim()),billingEmails:s.clientInfo?.emails}}function $t(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 Ut({data:s,refetchBusiness:n}){const t=be(ln,s),[a,l]=N.useState(hs(t)),{userContext:o}=N.useContext(Je),{updateBusiness:i,fetching:r}=Ls(),c=ke({resolver:We(Mt),defaultValues:a}),{countries:d,fetching:h}=an(),[u,x]=N.useState(""),[A,m]=N.useState(""),p=c.watch("locality"),D=c.watch("address"),P=c.watch("localAddress");N.useEffect(()=>{D!==a.address&&c.setValue("address",D,{shouldDirty:!0})},[D,a.address,c]),N.useEffect(()=>{P!==a.localAddress&&c.setValue("localAddress",P,{shouldDirty:!0})},[P,a.localAddress,c]);const O=t&&"clientInfo"in t&&!!t.clientInfo,M=p===o?.context.locality,$=j=>{u.trim()&&(c.setValue("generalContacts",[...j,u.trim()],{shouldDirty:!0}),x(""))},F=(j,C)=>{c.setValue("generalContacts",j.filter((S,k)=>k!==C),{shouldDirty:!0})},X=j=>{A.trim()&&(c.setValue("billingEmails",[...j,A.trim()],{shouldDirty:!0}),m(""))},U=(j,C)=>{c.setValue("billingEmails",j.filter((S,k)=>k!==C),{shouldDirty:!0})},se=async j=>{if(!t||!o?.context.adminBusinessId)return;const C=Xe(j,c.formState.dirtyFields);if(!C)return;const S=$t(C);await i({businessId:t.id,ownerId:o.context.adminBusinessId,fields:S}),n?.()};return N.useEffect(()=>{if(t){const j=hs(t);l(j),c.reset(j)}},[t,c]),e.jsxs(G,{children:[e.jsxs(q,{children:[e.jsx(W,{children:"Contact Information"}),e.jsx(K,{children:"Business contact details and address information"})]}),e.jsx(Te,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(se),children:[e.jsx(H,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(g,{control:c.control,name:"businessName",render:({field:j,fieldState:C})=>e.jsxs(f,{children:[e.jsx(y,{children:"Business Name"}),e.jsx(v,{children:e.jsx(T,{...j,className:w(C)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"locality",render:({field:j,fieldState:C})=>e.jsxs(f,{children:[e.jsx(y,{children:"Locality / Country"}),e.jsx(Fe,{onChange:j.onChange,data:d.map(S=>({value:S.code,label:S.name})),value:j.value,disabled:h,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:w(C)}}),e.jsx(b,{})]})}),M&&e.jsx(g,{control:c.control,name:"localName",render:({field:j,fieldState:C})=>e.jsxs(f,{children:[e.jsx(y,{children:"Local Name"}),e.jsx(v,{children:e.jsx(T,{...j,placeholder:"Business name in local language",className:w(C)})}),e.jsx(b,{})]})}),M&&e.jsx(g,{control:c.control,name:"govId",render:({field:j,fieldState:C})=>e.jsxs(f,{children:[e.jsx(y,{children:"Government ID"}),e.jsx(v,{children:e.jsx(T,{...j,placeholder:"Enter Government ID",className:w(C)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"address",render:({field:j,fieldState:C})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Address"]}),e.jsx(v,{children:e.jsx(Re,{...j,rows:3,placeholder:"Enter business address",className:w(C)})}),e.jsx(b,{})]})}),M&&e.jsx(g,{control:c.control,name:"localAddress",render:({field:j,fieldState:C})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(v,{children:e.jsx(Re,{...j,rows:3,placeholder:"Enter address in local language",className:w(C)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"phone",render:({field:j,fieldState:C})=>e.jsxs(f,{children:[e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Phone"]}),e.jsx(v,{children:e.jsx(T,{...j,type:"tel",placeholder:"+1 (555) 123-4567",className:w(C)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"website",render:({field:j,fieldState:C})=>e.jsxs(f,{children:[e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(rn,{className:"h-4 w-4"}),"Website"]}),e.jsx(v,{children:e.jsx(T,{...j,type:"url",placeholder:"https://example.com",className:w(C)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"generalContacts",render:({field:j,fieldState:C})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:w(C)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((S,k)=>e.jsxs(ee,{variant:"secondary",className:"gap-1 pr-1",children:[S,e.jsx("button",{type:"button",onClick:()=>F(j.value??[],k),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ye,{className:"h-3 w-3"})})]},k))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:u,onChange:S=>x(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),$(j.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!u.trim(),onClick:()=>$(j.value??[]),children:e.jsx(Z,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})}),O&&e.jsx(g,{control:c.control,name:"billingEmails",render:({field:j,fieldState:C})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(v,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:w(C)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((S,k)=>e.jsxs(ee,{variant:"secondary",className:"gap-1 pr-1",children:[S,e.jsx("button",{type:"button",onClick:()=>U(j.value??[],k),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ye,{className:"h-3 w-3"})})]},k))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:A,onChange:S=>m(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),X(j.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!A.trim(),onClick:()=>X(j.value??[]),children:e.jsx(Z,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})})]})}),e.jsx(Ke,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:r||Object.keys(c.formState.dirtyFields).length===0,children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const zt="createContract",Gt=()=>{const[{fetching:s},n]=De(cn),t=N.useCallback(async a=>{const l=`Error creating new contract for client[${a.input.clientId}]`,o=`${zt}-${a.input.clientId}`;_.loading("Creating contract",{id:o});try{const i=await n(a);Se(i,l,o)&&_.success("Success",{id:o,description:`Contract for client ${a.input.clientId} was successfully created`})}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createContract:t}},qt="updateContract",Wt=()=>{const[{fetching:s},n]=De(on),t=N.useCallback(async a=>{const l=`Error updating contract ID [${a.contractId}]`,o=`${qt}-${a.contractId}`;_.loading("Updating contract",{id:o});try{const i=await n(a),r=Se(i,l,o,"updateContract");if(r)return _.success("Success",{id:o,description:"Contract updated"}),r.updateContract}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateContract:t}},Kt=He({id:mn().optional(),startDate:as("Start date is required"),endDate:as("End date is required"),po:V().optional(),paymentAmount:gs().min(0,"Payment amount must be non-negative"),paymentCurrency:ce(Object.values(Ye),"Currency is required"),productType:ce(Object.values(Ns)).optional(),msCloudLink:ys().optional().or(vs("")),billingCycle:ce(Object.values(fe)).optional(),subscriptionPlan:ce(Object.values(Ie)).optional(),isActive:dn(),defaultRemark:V().optional(),defaultDocumentType:ce(Object.values(Qe))}),xs={startDate:"",endDate:"",po:void 0,paymentAmount:0,paymentCurrency:Ye.Usd,productType:Ns.Hive,msCloudLink:void 0,billingCycle:fe.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:Qe.Proforma};function Ht({clientId:s,contract:n,onDone:t}){const[a,l]=N.useState(!1),[o,i]=N.useState(null),{updateContract:r,updating:c}=Wt(),{createContract:d,creating:h}=Gt(),u=ke({resolver:We(Kt),defaultValues:n||xs});N.useEffect(()=>{n&&(i(n),u.reset({startDate:n.startDate,endDate:n.endDate,po:n.po,paymentAmount:n.paymentAmount,paymentCurrency:n.paymentCurrency,productType:n.productType,msCloudLink:n.msCloudLink,billingCycle:n.billingCycle,subscriptionPlan:n.subscriptionPlan,isActive:n.isActive,defaultRemark:n.defaultRemark,defaultDocumentType:n.defaultDocumentType}),l(!0))},[n,u]);const x=()=>{i(null),u.reset(xs),l(!0)},A=N.useCallback(async m=>{if(o)await r({contractId:o.id,input:{amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:me(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrder:m.po,remarks:m.defaultRemark,startDate:me(new Date(m.startDate),"yyyy-MM-dd")}});else{if(!m.billingCycle){u.setError("billingCycle",{message:"Billing cycle is required"});return}await d({input:{clientId:s,amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:me(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrder:m.po,remarks:m.defaultRemark,startDate:me(new Date(m.startDate),"yyyy-MM-dd")}})}l(!1),i(null),t?.()},[o,t,d,r,s,u]);return e.jsxs(Ge,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(E,{size:"sm",onClick:x,children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(qe,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(ws,{children:o?"Edit Contract":"Create New Contract"}),e.jsx(Is,{children:o?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(Te,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(A),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:e.jsx(g,{control:u.control,name:"po",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"PO Number"}),e.jsx(v,{children:e.jsx(T,{placeholder:"PO-2024-001",...m})}),e.jsx(b,{})]})})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:u.control,name:"startDate",render:({field:{onChange:m,...p}})=>e.jsxs(f,{children:[e.jsx(y,{children:"Start Date"}),e.jsx(v,{children:e.jsx(T,{type:"date",...p,onInput:D=>m(D)})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"endDate",render:({field:{onChange:m,...p}})=>e.jsxs(f,{children:[e.jsx(y,{children:"End Date"}),e.jsx(v,{children:e.jsx(T,{type:"date",...p,onInput:D=>m(D)})}),e.jsx(b,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(g,{control:u.control,name:"paymentAmount",render:({field:m})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsx(y,{children:"Payment Amount"}),e.jsx(v,{children:e.jsx(T,{type:"number",placeholder:"24000",...m,onChange:p=>{m.onChange(p?.target.value?Number(p?.target.value):void 0)}})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"paymentCurrency",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"Currency"}),e.jsxs(ue,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(v,{children:e.jsx(he,{children:e.jsx(xe,{})})}),e.jsx(pe,{children:Object.values(Ye).map(p=>e.jsx(je,{value:p,children:p},p))})]}),e.jsx(b,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:u.control,name:"productType",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"Product Type"}),e.jsx(v,{children:e.jsx(T,{placeholder:"Cloud Services",...m})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"billingCycle",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"Billing Cycle"}),e.jsxs(ue,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(v,{children:e.jsx(he,{children:e.jsx(xe,{})})}),e.jsx(pe,{children:Object.values(fe).map(p=>e.jsx(je,{value:p,children:Es(p)},p))})]}),e.jsx(b,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:u.control,name:"subscriptionPlan",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"Subscription Plan"}),e.jsx(v,{children:e.jsxs(ue,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(v,{children:e.jsx(he,{children:e.jsx(xe,{})})}),e.jsx(pe,{children:Object.values(Ie).map(p=>e.jsx(je,{value:p,children:Ps(p)},p))})]})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"isActive",render:({field:m})=>e.jsxs(f,{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(y,{className:"text-base",children:"Active Status"})}),e.jsx(v,{children:e.jsx(Q,{checked:m.value,onCheckedChange:m.onChange})})]})})]}),e.jsx(g,{control:u.control,name:"msCloudLink",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"MS Cloud Link"}),e.jsx(v,{children:e.jsx(T,{type:"url",placeholder:"https://portal.azure.com/contract-id",...m})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"defaultDocumentType",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"Default Document Type"}),e.jsxs(ue,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(v,{children:e.jsx(he,{children:e.jsx(xe,{})})}),e.jsx(pe,{children:Object.values(Qe).map(p=>e.jsx(je,{value:p,children:As(p)},p))})]}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"defaultRemark",render:({field:m})=>e.jsxs(f,{children:[e.jsx(y,{children:"Default Remark"}),e.jsx(v,{children:e.jsx(Re,{placeholder:"Enter default remark for this contract...",rows:3,...m})}),e.jsx(b,{})]})})]}),e.jsxs(Ds,{children:[e.jsx(E,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{type:"submit",disabled:h||c,children:o?"Update Contract":"Create Contract"})]})]})})]})]})}function Xt(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 Jt({clientId:s}){const[n,t]=N.useState(null),[{data:a,fetching:l},o]=Ne({query:un,variables:{clientId:s}}),i=a?.contractsByClient??[];return l?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(G,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Contracts"}),e.jsx(K,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Ht,{clientId:s,contract:n,onDone:o})]})}),e.jsx(H,{className:"space-y-4",children:i.map(r=>{const c=!!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(ee,{variant:c?"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(Xt(r)),children:e.jsx(Yn,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(hn,{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:xn(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:Es(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?Ps(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:As(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(pn,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(jn,{className:"h-3 w-3 ml-1"})]})})})]},r.id)})})]})}function Qt({businessId:s}){return e.jsxs(G,{children:[e.jsx(q,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Documents"}),e.jsx(K,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(H,{children:e.jsx(gn,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const Yt=[{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 Zt({data:s}){const n=be(Nn,s),[{data:t,fetching:a},l]=Ne({query:fn,variables:{clientId:n?.id??""},pause:!n?.clientInfo?.greenInvoiceId||!n?.id}),{updateClient:o}=yn(),i=N.useCallback((c,d)=>{if(!n?.id)return;const h={};h[d]=c,o({businessId:n?.id,fields:h})},[n?.id,o]);N.useEffect(()=>{n?.clientInfo?.greenInvoiceId&&n?.id&&l()},[n?.clientInfo?.greenInvoiceId,n?.id,l]);const r=t?.greenInvoiceClient;return e.jsxs(G,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Integrations"}),e.jsx(K,{children:"Connected external services and providers"})]}),e.jsxs(E,{size:"sm",children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(H,{className:"space-y-6",children:e.jsxs(Zn,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[a?e.jsxs(Oe,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx(I,{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(I,{className:"h-6 w-32"}),e.jsx(I,{className:"h-5 w-5 rounded-full"})]}),e.jsx(I,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-8 w-24"}),e.jsx(I,{className:"h-8 w-8"})]})]})}),e.jsx(Le,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(I,{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(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(I,{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(I,{className:"h-3 w-32"}),e.jsx(I,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(I,{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(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-3 w-24"}),e.jsx(I,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Oe,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-600 flex items-center justify-center text-white font-bold",children:"GI"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Green Invoice"}),e.jsx(ls,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Israeli invoicing system integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ea,{id:n?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async c=>i(c,"greenInvoiceId")}),e.jsx(is,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Le,{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(Me,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.emails?.map((c,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:c},d))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(fs,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children: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(_e,{className:"h-3.5 w-3.5"}),"Address"]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Street Address"}),e.jsx("p",{className:"text-sm",children: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})]})]})]})]})})]}),Yt.map(c=>e.jsxs(Oe,{value:c.id,className:"rounded-lg border",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:c.name}),c.status==="connected"?e.jsx(ls,{className:"h-4 w-4 text-green-600"}):e.jsx(vn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(Ze,{className:"h-4 w-4"})}),e.jsx(is,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Le,{children:e.jsx("div",{className:"px-4 pb-4 pt-2 border-t",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last sync: "}),e.jsx("span",{className:"font-medium",children:c.lastSync})]})})})]},c.id))]})})]})}function ea({id:s,provider:n,updateClient:t}){const[a,l]=N.useState(!1),[o,i]=N.useState(s),r=N.useCallback(async()=>{await t(o),l(!1)},[o,t]);return e.jsxs(Ge,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",onClick:c=>c.stopPropagation(),children:[e.jsx(Ze,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(qe,{onClick:c=>c.stopPropagation(),children:[e.jsxs(Cs,{children:[e.jsxs(ws,{children:["Configure ",n]}),e.jsxs(Is,{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:o,onChange:c=>i(c.target.value),placeholder:`Enter ${n} ID`})]})}),e.jsxs(Ds,{children:[e.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{onClick:r,disabled:!o,children:"Save Changes"})]})]})]})}function sa({businessId:s}){return e.jsxs(G,{children:[e.jsx(q,{className:"flex w-full justify-between items-center",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Transactions"}),e.jsx(K,{children:"Complete transaction history for this business"})]})})}),e.jsx(H,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Cn,{businessID:s,filter:{}})})})]})}function na({data:s,refetchBusiness:n}){const t=be(kn,s),[a,l]=wn(),o=a.get("tab")||"contact",i=d=>{l({tab:d})};if(!t)return e.jsx("div",{children:"Business not found"});const r="clientInfo"in t&&!!t.clientInfo,c="adminInfo"in t&&!!t.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Bn,{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(In,{value:o,onValueChange:i,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(J,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(et,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(J,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(J,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(J,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Dn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(J,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Sn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(J,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(at,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(J,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(it,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),c&&e.jsxs(J,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(js,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx(z,{value:"contact",className:"mt-0",children:e.jsx(Ut,{data:t,refetchBusiness:n})}),e.jsx(z,{value:"config",className:"mt-0",children:e.jsx(Lt,{data:t,refetchBusiness:n})}),e.jsx(z,{value:"charges",className:"mt-0",children:e.jsx(pt,{businessId:t.id})}),e.jsx(z,{value:"transactions",className:"mt-0",children:e.jsx(sa,{businessId:t.id})}),e.jsx(z,{value:"documents",className:"mt-0",children:e.jsx(Qt,{businessId:t.id})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(z,{value:"contracts",className:"mt-0",children:e.jsx(Jt,{clientId:t.id})}),e.jsx(z,{value:"integrations",className:"mt-0",children:e.jsx(Zt,{data:t})}),e.jsx(z,{value:"charts",className:"mt-0",children:e.jsx(Et,{})})]}),c&&e.jsx(z,{value:"admin",className:"mt-0",children:e.jsx(xt,{data:t})})]})})]})}function ma(s){return`/businesses/${s}`}const ua=()=>{const{businessId:s}=Tn();let n;try{n=En()}catch{}const[{data:t,fetching:a},l]=Ne({query:Pn,pause:!s||!!n,variables:{businessId:s??""}}),o=n||t;return!n&&a&&!o?.business?e.jsx(ps,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(na,{data:o.business,refetchBusiness:async()=>l()})};export{ua as BusinessScreen,ma as getBusinessHref};
|