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