@accounter/client 0.0.7-alpha-20251021062721-ab43b5f013b9852ff5216bc141852da9dcfe0df7 → 0.0.8-alpha-20251021150501-2328478f6fd03d3eb9b501fe1840430e6983940d

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +109 -105
  2. package/dist/assets/index-CqaS5jWM.css +1 -0
  3. package/dist/assets/index-IlfO2QvT.js +1188 -0
  4. package/dist/assets/{index.es-NOVMdy_X.js → index.es-BaJmdn-u.js} +1 -1
  5. package/dist/index.html +2 -2
  6. package/package.json +5 -6
  7. package/src/app.tsx +4 -8
  8. package/src/components/business-transactions/business-extended-info.tsx +13 -9
  9. package/src/components/charges/charge-extended-info-menu.tsx +21 -27
  10. package/src/components/charges/charges-row.tsx +10 -12
  11. package/src/components/charges/charges-table.tsx +9 -15
  12. package/src/components/common/documents/issue-document/index.tsx +3 -3
  13. package/src/components/common/documents/issue-document/{recent-business-docs.tsx → recent-client-docs.tsx} +13 -19
  14. package/src/components/common/forms/business-card.tsx +0 -1
  15. package/src/components/common/forms/modify-business-fields.tsx +19 -2
  16. package/src/components/common/inputs/combo-box.tsx +1 -1
  17. package/src/components/reports/trial-balance-report/trial-balance-report-group.tsx +6 -4
  18. package/src/components/reports/trial-balance-report/trial-balance-report-sort-code.tsx +11 -8
  19. package/src/components/screens/documents/issue-documents/edit-issue-document-modal.tsx +4 -4
  20. package/src/gql/gql.ts +9 -93
  21. package/src/gql/graphql.ts +9 -285
  22. package/src/helpers/currency.ts +0 -5
  23. package/src/helpers/index.ts +0 -2
  24. package/src/hooks/use-get-all-contracts.ts +1 -0
  25. package/dist/assets/index-CJB5mMpd.js +0 -1224
  26. package/dist/assets/index-CzRRUK04.css +0 -1
  27. package/src/components/business/business-header.tsx +0 -65
  28. package/src/components/business/charges-section.tsx +0 -82
  29. package/src/components/business/charts-section.tsx +0 -115
  30. package/src/components/business/configurations-section.tsx +0 -835
  31. package/src/components/business/contact-info-section.tsx +0 -544
  32. package/src/components/business/contracts-section.tsx +0 -195
  33. package/src/components/business/documents-section.tsx +0 -26
  34. package/src/components/business/index.tsx +0 -171
  35. package/src/components/business/integrations-section.tsx +0 -479
  36. package/src/components/business/transactions-section.tsx +0 -26
  37. package/src/components/clients/contracts/modify-contract-dialog.tsx +0 -466
  38. package/src/components/clients/modify-client-dialog.tsx +0 -276
  39. package/src/components/screens/businesses/business.tsx +0 -50
  40. package/src/components/ui/progress.tsx +0 -25
  41. package/src/components/ui/skeleton.tsx +0 -12
  42. package/src/helpers/contracts.ts +0 -22
  43. package/src/helpers/pcn874.ts +0 -17
  44. package/src/hooks/use-create-contract.ts +0 -62
  45. package/src/hooks/use-delete-contract.ts +0 -64
  46. package/src/hooks/use-insert-client.ts +0 -80
  47. package/src/hooks/use-update-client.ts +0 -75
  48. package/src/hooks/use-update-contract.ts +0 -69
@@ -1,466 +0,0 @@
1
- import { useCallback, useEffect, useState } from 'react';
2
- import { format } from 'date-fns';
3
- import { Plus } from 'lucide-react';
4
- import { useForm } from 'react-hook-form';
5
- import { z } from 'zod';
6
- import { Button } from '@/components/ui/button.js';
7
- import {
8
- Dialog,
9
- DialogContent,
10
- DialogDescription,
11
- DialogFooter,
12
- DialogHeader,
13
- DialogTitle,
14
- DialogTrigger,
15
- } from '@/components/ui/dialog.js';
16
- import {
17
- Form,
18
- FormControl,
19
- FormField,
20
- FormItem,
21
- FormLabel,
22
- FormMessage,
23
- } from '@/components/ui/form.js';
24
- import { Input } from '@/components/ui/input.js';
25
- import {
26
- Select,
27
- SelectContent,
28
- SelectItem,
29
- SelectTrigger,
30
- SelectValue,
31
- } from '@/components/ui/select.js';
32
- import { Switch } from '@/components/ui/switch.js';
33
- import { Textarea } from '@/components/ui/textarea.js';
34
- import { BillingCycle, Currency, DocumentType, Product, SubscriptionPlan } from '@/gql/graphql.js';
35
- import {
36
- getDocumentNameFromType,
37
- standardBillingCycle,
38
- standardPlan,
39
- type TimelessDateString,
40
- } from '@/helpers/index.js';
41
- import { useCreateContract } from '@/hooks/use-create-contract.js';
42
- import { useUpdateContract } from '@/hooks/use-update-contract.js';
43
- import { zodResolver } from '@hookform/resolvers/zod';
44
-
45
- const contractFormSchema = z.object({
46
- id: z.uuid().optional(),
47
- // operationsLimit: z.number().optional(),
48
- startDate: z.iso.date('Start date is required'),
49
- endDate: z.iso.date('End date is required'),
50
- po: z.string().optional(),
51
- paymentAmount: z.number().min(0, 'Payment amount must be non-negative'),
52
- paymentCurrency: z.enum(Object.values(Currency), 'Currency is required'),
53
- productType: z.enum(Object.values(Product)).optional(),
54
- msCloudLink: z.url().optional().or(z.literal('')),
55
- billingCycle: z.enum(Object.values(BillingCycle)).optional(),
56
- subscriptionPlan: z.enum(Object.values(SubscriptionPlan)).optional(),
57
- isActive: z.boolean(),
58
- defaultRemark: z.string().optional(),
59
- defaultDocumentType: z.enum(Object.values(DocumentType)),
60
- });
61
-
62
- export type ContractFormValues = z.infer<typeof contractFormSchema>;
63
-
64
- const newContractDefaultValues: ContractFormValues = {
65
- // operationsLimit: 0,
66
- startDate: '',
67
- endDate: '',
68
- po: undefined,
69
- paymentAmount: 0,
70
- paymentCurrency: Currency.Usd,
71
- productType: Product.Hive,
72
- msCloudLink: undefined,
73
- billingCycle: BillingCycle.Monthly,
74
- subscriptionPlan: undefined,
75
- isActive: true,
76
- defaultRemark: undefined,
77
- defaultDocumentType: DocumentType.Proforma,
78
- };
79
-
80
- interface Props {
81
- clientId: string;
82
- contract?: ContractFormValues | null;
83
- onDone?: () => void;
84
- }
85
-
86
- export function ModifyContractDialog({ clientId, contract, onDone }: Props) {
87
- const [isDialogOpen, setIsDialogOpen] = useState(false);
88
- const [editingContract, setEditingContract] = useState<ContractFormValues | null>(null);
89
-
90
- const { updateContract, updating } = useUpdateContract();
91
- const { createContract, creating } = useCreateContract();
92
-
93
- const form = useForm<ContractFormValues>({
94
- resolver: zodResolver(contractFormSchema),
95
- defaultValues: contract || newContractDefaultValues,
96
- });
97
-
98
- useEffect(() => {
99
- if (contract) {
100
- setEditingContract(contract);
101
- form.reset({
102
- // operationsLimit: contract.operationsLimit,
103
- startDate: contract.startDate,
104
- endDate: contract.endDate,
105
- po: contract.po,
106
- paymentAmount: contract.paymentAmount,
107
- paymentCurrency: contract.paymentCurrency,
108
- productType: contract.productType,
109
- msCloudLink: contract.msCloudLink,
110
- billingCycle: contract.billingCycle,
111
- subscriptionPlan: contract.subscriptionPlan,
112
- isActive: contract.isActive,
113
- defaultRemark: contract.defaultRemark,
114
- defaultDocumentType: contract.defaultDocumentType,
115
- });
116
- setIsDialogOpen(true);
117
- }
118
- }, [contract, form]);
119
-
120
- const handleNew = () => {
121
- setEditingContract(null);
122
- form.reset(newContractDefaultValues);
123
- setIsDialogOpen(true);
124
- };
125
-
126
- const onSubmit = useCallback(
127
- async (values: ContractFormValues) => {
128
- if (editingContract) {
129
- // Handle contract update
130
- console.log('[v0] Updating contract:', editingContract.id, values);
131
- await updateContract({
132
- contractId: editingContract.id!,
133
- input: {
134
- amount: { raw: values.paymentAmount, currency: values.paymentCurrency },
135
- billingCycle: values.billingCycle,
136
- documentType: values.defaultDocumentType,
137
- endDate: format(new Date(values.endDate), 'yyyy-MM-dd') as TimelessDateString,
138
- isActive: values.isActive,
139
- msCloud: values.msCloudLink,
140
- plan: values.subscriptionPlan,
141
- product: values.productType,
142
- purchaseOrder: values.po,
143
- remarks: values.defaultRemark,
144
- startDate: format(new Date(values.startDate), 'yyyy-MM-dd') as TimelessDateString,
145
- },
146
- });
147
- } else {
148
- // Handle new contract creation
149
- if (!values.billingCycle) {
150
- form.setError('billingCycle', { message: 'Billing cycle is required' });
151
- return;
152
- }
153
- console.log('[v0] Creating new contract:', values);
154
- await createContract({
155
- input: {
156
- clientId,
157
- amount: { raw: values.paymentAmount, currency: values.paymentCurrency },
158
- billingCycle: values.billingCycle,
159
- documentType: values.defaultDocumentType,
160
- endDate: format(new Date(values.endDate), 'yyyy-MM-dd') as TimelessDateString,
161
- isActive: values.isActive,
162
- msCloud: values.msCloudLink,
163
- plan: values.subscriptionPlan,
164
- product: values.productType,
165
- purchaseOrder: values.po,
166
- remarks: values.defaultRemark,
167
- startDate: format(new Date(values.startDate), 'yyyy-MM-dd') as TimelessDateString,
168
- },
169
- });
170
- }
171
- setIsDialogOpen(false);
172
- setEditingContract(null);
173
- onDone?.();
174
- },
175
- [editingContract, onDone, createContract, updateContract, clientId, form],
176
- );
177
-
178
- const endDate = form.watch('endDate');
179
- console.log('Watched endDate:', endDate);
180
-
181
- return (
182
- <Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
183
- <DialogTrigger asChild>
184
- <Button size="sm" onClick={handleNew}>
185
- <Plus className="h-4 w-4 mr-2" />
186
- New Contract
187
- </Button>
188
- </DialogTrigger>
189
- <DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
190
- <DialogHeader>
191
- <DialogTitle>{editingContract ? 'Edit Contract' : 'Create New Contract'}</DialogTitle>
192
- <DialogDescription>
193
- {editingContract
194
- ? 'Update contract details'
195
- : 'Add a new contract with all required details'}
196
- </DialogDescription>
197
- </DialogHeader>
198
- <Form {...form}>
199
- <form onSubmit={form.handleSubmit(onSubmit)}>
200
- <div className="grid gap-4 py-4">
201
- <div className="grid gap-4 md:grid-cols-2">
202
- {/* <FormField
203
- control={form.control}
204
- name="operationsLimit"
205
- render={({ field }) => (
206
- <FormItem>
207
- <FormLabel>Operations Limit</FormLabel>
208
- <FormControl>
209
- <Input type="number" placeholder="500" {...field} />
210
- </FormControl>
211
- <FormMessage />
212
- </FormItem>
213
- )}
214
- /> */}
215
- <FormField
216
- control={form.control}
217
- name="po"
218
- render={({ field }) => (
219
- <FormItem>
220
- <FormLabel>PO Number</FormLabel>
221
- <FormControl>
222
- <Input placeholder="PO-2024-001" {...field} />
223
- </FormControl>
224
- <FormMessage />
225
- </FormItem>
226
- )}
227
- />
228
- </div>
229
-
230
- <div className="grid gap-4 md:grid-cols-2">
231
- <FormField
232
- control={form.control}
233
- name="startDate"
234
- render={({ field: { onChange, ...field } }) => (
235
- <FormItem>
236
- <FormLabel>Start Date</FormLabel>
237
- <FormControl>
238
- <Input type="date" {...field} onInput={date => onChange(date)} />
239
- </FormControl>
240
- <FormMessage />
241
- </FormItem>
242
- )}
243
- />
244
- <FormField
245
- control={form.control}
246
- name="endDate"
247
- render={({ field: { onChange, ...field } }) => (
248
- <FormItem>
249
- <FormLabel>End Date</FormLabel>
250
- <FormControl>
251
- <Input type="date" {...field} onInput={date => onChange(date)} />
252
- </FormControl>
253
- <FormMessage />
254
- </FormItem>
255
- )}
256
- />
257
- </div>
258
-
259
- <div className="grid gap-4 md:grid-cols-3">
260
- <FormField
261
- control={form.control}
262
- name="paymentAmount"
263
- render={({ field }) => (
264
- <FormItem className="md:col-span-2">
265
- <FormLabel>Payment Amount</FormLabel>
266
- <FormControl>
267
- <Input
268
- type="number"
269
- placeholder="24000"
270
- {...field}
271
- onChange={event => {
272
- console.log('Payment amount changed to:', event?.target.value);
273
- field.onChange(
274
- event?.target.value ? Number(event?.target.value) : undefined,
275
- );
276
- }}
277
- />
278
- </FormControl>
279
- <FormMessage />
280
- </FormItem>
281
- )}
282
- />
283
- <FormField
284
- control={form.control}
285
- name="paymentCurrency"
286
- render={({ field }) => (
287
- <FormItem>
288
- <FormLabel>Currency</FormLabel>
289
- <Select onValueChange={field.onChange} defaultValue={field.value}>
290
- <FormControl>
291
- <SelectTrigger>
292
- <SelectValue />
293
- </SelectTrigger>
294
- </FormControl>
295
- <SelectContent>
296
- {Object.values(Currency).map(currency => (
297
- <SelectItem key={currency} value={currency}>
298
- {currency}
299
- </SelectItem>
300
- ))}
301
- </SelectContent>
302
- </Select>
303
- <FormMessage />
304
- </FormItem>
305
- )}
306
- />
307
- </div>
308
-
309
- <div className="grid gap-4 md:grid-cols-2">
310
- <FormField
311
- control={form.control}
312
- name="productType"
313
- render={({ field }) => (
314
- <FormItem>
315
- <FormLabel>Product Type</FormLabel>
316
- <FormControl>
317
- <Input placeholder="Cloud Services" {...field} />
318
- </FormControl>
319
- <FormMessage />
320
- </FormItem>
321
- )}
322
- />
323
- <FormField
324
- control={form.control}
325
- name="billingCycle"
326
- render={({ field }) => (
327
- <FormItem>
328
- <FormLabel>Billing Cycle</FormLabel>
329
- <Select onValueChange={field.onChange} defaultValue={field.value}>
330
- <FormControl>
331
- <SelectTrigger>
332
- <SelectValue />
333
- </SelectTrigger>
334
- </FormControl>
335
- <SelectContent>
336
- {Object.values(BillingCycle).map(cycle => (
337
- <SelectItem key={cycle} value={cycle}>
338
- {standardBillingCycle(cycle)}
339
- </SelectItem>
340
- ))}
341
- </SelectContent>
342
- </Select>
343
- <FormMessage />
344
- </FormItem>
345
- )}
346
- />
347
- </div>
348
-
349
- <div className="grid gap-4 md:grid-cols-2">
350
- <FormField
351
- control={form.control}
352
- name="subscriptionPlan"
353
- render={({ field }) => (
354
- <FormItem>
355
- <FormLabel>Subscription Plan</FormLabel>
356
- <FormControl>
357
- <Select onValueChange={field.onChange} defaultValue={field.value}>
358
- <FormControl>
359
- <SelectTrigger>
360
- <SelectValue />
361
- </SelectTrigger>
362
- </FormControl>
363
- <SelectContent>
364
- {Object.values(SubscriptionPlan).map(plan => (
365
- <SelectItem key={plan} value={plan}>
366
- {standardPlan(plan)}
367
- </SelectItem>
368
- ))}
369
- </SelectContent>
370
- </Select>
371
- </FormControl>
372
- <FormMessage />
373
- </FormItem>
374
- )}
375
- />
376
- <FormField
377
- control={form.control}
378
- name="isActive"
379
- render={({ field }) => (
380
- <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4">
381
- <div className="space-y-0.5">
382
- <FormLabel className="text-base">Active Status</FormLabel>
383
- </div>
384
- <FormControl>
385
- <Switch checked={field.value} onCheckedChange={field.onChange} />
386
- </FormControl>
387
- </FormItem>
388
- )}
389
- />
390
- </div>
391
-
392
- <FormField
393
- control={form.control}
394
- name="msCloudLink"
395
- render={({ field }) => (
396
- <FormItem>
397
- <FormLabel>MS Cloud Link</FormLabel>
398
- <FormControl>
399
- <Input
400
- type="url"
401
- placeholder="https://portal.azure.com/contract-id"
402
- {...field}
403
- />
404
- </FormControl>
405
- <FormMessage />
406
- </FormItem>
407
- )}
408
- />
409
-
410
- <FormField
411
- control={form.control}
412
- name="defaultDocumentType"
413
- render={({ field }) => (
414
- <FormItem>
415
- <FormLabel>Default Document Type</FormLabel>
416
- <Select onValueChange={field.onChange} defaultValue={field.value}>
417
- <FormControl>
418
- <SelectTrigger>
419
- <SelectValue />
420
- </SelectTrigger>
421
- </FormControl>
422
- <SelectContent>
423
- {Object.values(DocumentType).map(type => (
424
- <SelectItem key={type} value={type}>
425
- {getDocumentNameFromType(type)}
426
- </SelectItem>
427
- ))}
428
- </SelectContent>
429
- </Select>
430
- <FormMessage />
431
- </FormItem>
432
- )}
433
- />
434
-
435
- <FormField
436
- control={form.control}
437
- name="defaultRemark"
438
- render={({ field }) => (
439
- <FormItem>
440
- <FormLabel>Default Remark</FormLabel>
441
- <FormControl>
442
- <Textarea
443
- placeholder="Enter default remark for this contract..."
444
- rows={3}
445
- {...field}
446
- />
447
- </FormControl>
448
- <FormMessage />
449
- </FormItem>
450
- )}
451
- />
452
- </div>
453
- <DialogFooter>
454
- <Button type="button" variant="outline" onClick={() => setIsDialogOpen(false)}>
455
- Cancel
456
- </Button>
457
- <Button type="submit" disabled={creating || updating}>
458
- {editingContract ? 'Update Contract' : 'Create Contract'}
459
- </Button>
460
- </DialogFooter>
461
- </form>
462
- </Form>
463
- </DialogContent>
464
- </Dialog>
465
- );
466
- }