create-bluecopa-react-app 1.0.41 → 1.0.42

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 (102) hide show
  1. package/README.md +7 -5
  2. package/package.json +1 -1
  3. package/templates/latest/.claude/settings.local.json +56 -0
  4. package/templates/latest/.env.example +8 -0
  5. package/templates/latest/Agent.md +598 -775
  6. package/templates/latest/CLAUDE.md +759 -0
  7. package/templates/latest/README.md +11 -2
  8. package/templates/latest/app/app.css +292 -85
  9. package/templates/latest/app/app.tsx +48 -39
  10. package/templates/latest/app/components/bluecopa-logo.tsx +20 -0
  11. package/templates/latest/app/components/charts/bar-chart.tsx +132 -0
  12. package/templates/latest/app/components/charts/base-chart.tsx +149 -0
  13. package/templates/latest/app/components/charts/chart-provider.tsx +71 -0
  14. package/templates/latest/app/components/charts/chart-theme.ts +262 -0
  15. package/templates/latest/app/components/charts/chart-utils.ts +142 -0
  16. package/templates/latest/app/components/charts/donut-chart.tsx +110 -0
  17. package/templates/latest/app/components/charts/index.ts +5 -0
  18. package/templates/latest/app/components/layouts/app-layout.tsx +22 -0
  19. package/templates/latest/app/components/layouts/app-sidebar.tsx +88 -0
  20. package/templates/latest/app/components/layouts/nav-main.tsx +50 -0
  21. package/templates/latest/app/components/layouts/nav-user.tsx +38 -0
  22. package/templates/latest/app/components/layouts/site-header.tsx +93 -0
  23. package/templates/latest/app/components/loading-screen.tsx +41 -0
  24. package/templates/latest/app/components/ui/ag-grid-table.tsx +79 -0
  25. package/templates/latest/app/components/ui/button.tsx +23 -23
  26. package/templates/latest/app/components/ui/card.tsx +20 -20
  27. package/templates/latest/app/components/ui/dropdown-menu.tsx +54 -49
  28. package/templates/latest/app/components/ui/input.tsx +8 -8
  29. package/templates/latest/app/components/ui/label.tsx +8 -8
  30. package/templates/latest/app/components/ui/separator.tsx +7 -7
  31. package/templates/latest/app/components/ui/sheet.tsx +43 -32
  32. package/templates/latest/app/components/ui/sidebar.tsx +240 -235
  33. package/templates/latest/app/components/ui/skeleton.tsx +4 -4
  34. package/templates/latest/app/components/ui/sonner.tsx +6 -9
  35. package/templates/latest/app/components/ui/tabs.tsx +15 -15
  36. package/templates/latest/app/components/ui/tooltip.tsx +18 -12
  37. package/templates/latest/app/constants/index.ts +31 -0
  38. package/templates/latest/app/contexts/app-context.tsx +201 -0
  39. package/templates/latest/app/hooks/use-mobile.ts +13 -12
  40. package/templates/latest/app/main.tsx +1 -1
  41. package/templates/latest/app/pages/dashboard.tsx +246 -0
  42. package/templates/latest/app/pages/payments.tsx +182 -0
  43. package/templates/latest/app/pages/settings.tsx +128 -0
  44. package/templates/latest/app/routes/index.tsx +19 -0
  45. package/templates/latest/app/single-spa.tsx +69 -186
  46. package/templates/latest/app/types/index.ts +37 -0
  47. package/templates/latest/app/utils/ag-grid-datasource.ts +63 -0
  48. package/templates/latest/app/utils/ag-grid-license.ts +12 -0
  49. package/templates/latest/app/utils/ag-grid-theme.ts +9 -0
  50. package/templates/latest/app/utils/component-style.ts +7 -0
  51. package/templates/latest/app/utils/style-drivers.ts +24 -0
  52. package/templates/latest/app/utils/utils.ts +10 -0
  53. package/templates/latest/components.json +3 -3
  54. package/templates/latest/index.html +30 -2
  55. package/templates/latest/package-lock.json +15 -401
  56. package/templates/latest/package.json +8 -18
  57. package/templates/latest/preview/index.html +125 -285
  58. package/templates/latest/public/favicon.svg +1 -0
  59. package/templates/latest/vite.config.ts +2 -8
  60. package/templates/latest/app/components/app-sidebar.tsx +0 -182
  61. package/templates/latest/app/components/chart-area-interactive.tsx +0 -290
  62. package/templates/latest/app/components/data-table.tsx +0 -807
  63. package/templates/latest/app/components/nav-documents.tsx +0 -92
  64. package/templates/latest/app/components/nav-main.tsx +0 -40
  65. package/templates/latest/app/components/nav-secondary.tsx +0 -42
  66. package/templates/latest/app/components/nav-user.tsx +0 -111
  67. package/templates/latest/app/components/section-cards.tsx +0 -102
  68. package/templates/latest/app/components/site-header.tsx +0 -28
  69. package/templates/latest/app/components/ui/avatar.tsx +0 -53
  70. package/templates/latest/app/components/ui/badge.tsx +0 -46
  71. package/templates/latest/app/components/ui/breadcrumb.tsx +0 -109
  72. package/templates/latest/app/components/ui/chart.tsx +0 -352
  73. package/templates/latest/app/components/ui/checkbox.tsx +0 -30
  74. package/templates/latest/app/components/ui/drawer.tsx +0 -139
  75. package/templates/latest/app/components/ui/select.tsx +0 -183
  76. package/templates/latest/app/components/ui/table.tsx +0 -117
  77. package/templates/latest/app/components/ui/toggle-group.tsx +0 -73
  78. package/templates/latest/app/components/ui/toggle.tsx +0 -47
  79. package/templates/latest/app/data/data.json +0 -614
  80. package/templates/latest/app/data/mock-payments.json +0 -122
  81. package/templates/latest/app/data/mock-transactions.json +0 -128
  82. package/templates/latest/app/hooks/use-bluecopa-user.ts +0 -37
  83. package/templates/latest/app/lib/utils.ts +0 -6
  84. package/templates/latest/app/routes/apitest.tsx +0 -2118
  85. package/templates/latest/app/routes/comments.tsx +0 -588
  86. package/templates/latest/app/routes/dashboard.tsx +0 -36
  87. package/templates/latest/app/routes/payments.tsx +0 -342
  88. package/templates/latest/app/routes/statements.tsx +0 -493
  89. package/templates/latest/app/routes/websocket.tsx +0 -450
  90. package/templates/latest/app/routes.tsx +0 -22
  91. package/templates/latest/dist/assets/__federation_expose_App-D-lv9y21.js +0 -161
  92. package/templates/latest/dist/assets/__federation_fn_import-CzfA7kmP.js +0 -438
  93. package/templates/latest/dist/assets/__federation_shared_react-Bp6HVBS4.js +0 -16
  94. package/templates/latest/dist/assets/__federation_shared_react-dom-BCcRGiYp.js +0 -17
  95. package/templates/latest/dist/assets/client-Dms8K6Dw.js +0 -78879
  96. package/templates/latest/dist/assets/index-BrhXrqF7.js +0 -60
  97. package/templates/latest/dist/assets/index-BzNimew1.js +0 -69
  98. package/templates/latest/dist/assets/index-DMFtQdNS.js +0 -412
  99. package/templates/latest/dist/assets/remoteEntry.css +0 -3996
  100. package/templates/latest/dist/assets/remoteEntry.js +0 -88
  101. package/templates/latest/dist/favicon.ico +0 -0
  102. package/templates/latest/dist/index.html +0 -19
@@ -1,2118 +0,0 @@
1
- import React, { useState } from "react";
2
- import { AppSidebar } from "~/components/app-sidebar";
3
- import { SiteHeader } from "~/components/site-header";
4
- import { SidebarInset, SidebarProvider } from "~/components/ui/sidebar";
5
- import {
6
- Card,
7
- CardContent,
8
- CardDescription,
9
- CardHeader,
10
- CardTitle,
11
- } from "~/components/ui/card";
12
- import { Button } from "~/components/ui/button";
13
- import { Input } from "~/components/ui/input";
14
- import { Label } from "~/components/ui/label";
15
- import { toast } from "sonner";
16
- import {
17
- useGetWorkbookDetails,
18
- useSaveWorkbook,
19
- usePublishWorkbook,
20
- useGetTaskDetails,
21
- useRunRecon,
22
- useFileUpload,
23
- useFileDownload,
24
- useGetFormSchema,
25
- useGetFormData,
26
- useGetAuditLogs,
27
- useCreateAuditLog,
28
- useGetAllTemplatedPipelines,
29
- useGetAllRecon,
30
- useGetFormById,
31
- useCreateOrUpdateForm,
32
- useMarkTaskDone,
33
- useReassignTask,
34
- useGetAllUsers,
35
- useGetAllHttpTriggers,
36
- } from "@bluecopa/react";
37
-
38
- // Default values for examples
39
- const DEFAULT_WORKBOOK_ID = "MJ2T21GQ8O8DQXIOHZBF";
40
- const DEFAULT_TASK_ID = "0V4Kxc7LhIpUvwZeORaj";
41
- const DEFAULT_WORKFLOW_ID = "MJ02HD1HUJ4VCN66U0V0";
42
- const DEFAULT_FORM_INSTANCE_ID = "0V5W3KVAWdRnVOZczmSN";
43
- const DEFAULT_FORM_REVISION = 21949795;
44
- const DEFAULT_FORM_ID = "0V5W3KVAWdRnVOZczmSN";
45
- const DEFAULT_FILE_UPLOAD_PAYLOAD = {
46
- id: "0URYQ4DIHB1mVzPA87ZW",
47
- name: "octobereighteennnqq",
48
- description: "",
49
- sequence: [
50
- {
51
- step_id: "0URYQFlVMr1DuDagpmlS",
52
- name: "activity_1_",
53
- type: "UPDATE_AND_RUN_RECON",
54
- description: "",
55
- inputs: {
56
- recon_run_config_id: "${0URYQEEuxOPKIlGouLr2.form_data.recon_form}",
57
- },
58
- },
59
- ],
60
- };
61
-
62
- // Default values for audit log examples
63
- const DEFAULT_AUDIT_LOG_REQUEST = {
64
- entityId: "0TOlmUqx0TKseTn8W6gW",
65
- source: "UI",
66
- limit: 20,
67
- };
68
-
69
- const DEFAULT_AUDIT_RECORD = [
70
- {
71
- source: "UI",
72
- userId: "0TOlmUqx0TKseTn8W6gW",
73
- entityId: "0TOlmUqx0TKseTn8W6gW",
74
- entityType: "Dataset",
75
- action: "CREATE",
76
- eventType: "API",
77
- },
78
- ];
79
-
80
- const DEFAULT_NEW_ASSIGNEE = "0TOlmUqx0TKseTn8W6gW";
81
-
82
- // Workbook Test Component
83
- function WorkbookTestSection() {
84
- const [workbookId, setWorkbookId] = useState<string>("");
85
- const [workbookData, setWorkbookData] = useState<any>(null);
86
-
87
- // Save Workbook inputs
88
- const [saveWorkbookData, setSaveWorkbookData] = useState<string>("");
89
- const [sheetInputs, setSheetInputs] = useState<string>("[]");
90
-
91
- // Publish Workbook input
92
- const [publishWorkbookId, setPublishWorkbookId] = useState<string>("");
93
-
94
- // Get Workbook Details Hook - disabled by default, only runs on user action
95
- const workbookDetailsQuery = useGetWorkbookDetails(workbookId || null, {
96
- enabled: false, // No automatic fetching - all calls are user-initiated
97
- });
98
-
99
- // Save Workbook Hook
100
- const saveWorkbookMutation = useSaveWorkbook();
101
-
102
- // Publish Workbook Hook
103
- const publishWorkbookMutation = usePublishWorkbook();
104
-
105
- // Handle Load Example for Get Workbook
106
- const handleLoadExample = () => {
107
- setWorkbookId(DEFAULT_WORKBOOK_ID);
108
- toast.info(
109
- 'Example workbook ID loaded. Click "Get Workbook Details" to fetch.'
110
- );
111
- };
112
-
113
- // Handle Load Example for Save Workbook
114
- const handleLoadSaveExample = () => {
115
- // Create a minimal example workbook structure
116
- const exampleWorkbook = {
117
- name: "sap_test1",
118
- description: null,
119
- parentId: null,
120
- type: "PROCESS",
121
- addToHome: false,
122
- path: "prod/MJ2T21GQ8O8DQXIOHZBF",
123
- sheetIds: ["MJ2T1S6CAWSVEHR5136Z"],
124
- sheetRevisionById: {
125
- MJ2T1S6CAWSVEHR5136Z: 21944090,
126
- },
127
- published: false,
128
- sheets: [
129
- {
130
- name: "Process",
131
- sources: null,
132
- parentId: "MJ2T21GQ8O8DQXIOHZBF",
133
- parentVersion: null,
134
- parentType: "PROCESS",
135
- type: "PROCESS_SHEET",
136
- published: false,
137
- customFields: {},
138
- publishedVersion: null,
139
- externalUrl:
140
- "gs://stage-out_dev-local-363813_2/PROC_DEFINITION/MJ6WV5IW2FT808T2JWFK.json",
141
- modelUrl:
142
- "gs://stage-out_dev-local-363813_2/PROC_CUSTOM_MODEL/MJ6WV5IYWOZI9YY6M3UR.json",
143
- tags: null,
144
- createdBy: "0TOlmUqx0TKseTn8W6gW",
145
- createdDate: "2025-12-12T11:50:09.155+00:00",
146
- lastModifiedBy: "0TOlmUqx0TKseTn8W6gW",
147
- lastModifiedDate: "2025-12-15T08:47:53.402+00:00",
148
- id: "MJ2T1S6CAWSVEHR5136Z",
149
- workspaceId: "prod",
150
- entityVersion: 13,
151
- definitionFileId: "PROC_DEFINITION/MJ6WV5IW2FT808T2JWFK.json",
152
- modelFileId: "PROC_CUSTOM_MODEL/MJ6WV5IYWOZI9YY6M3UR.json",
153
- externalDataId: "PROC_DEFINITION/MJ6WV5IW2FT808T2JWFK.json",
154
- modelId: "PROC_CUSTOM_MODEL/MJ6WV5IYWOZI9YY6M3UR.json",
155
- },
156
- ],
157
- customFields: {
158
- formTriggered: {
159
- value: false,
160
- },
161
- httpTriggered: {
162
- value: false,
163
- },
164
- manualTriggered: {
165
- value: true,
166
- },
167
- scheduledTriggered: {
168
- value: false,
169
- },
170
- },
171
- indexedForAssistant: false,
172
- tags: null,
173
- builderSpaceType: null,
174
- latestVersionPublished: true,
175
- createdBy: "0TOlmUqx0TKseTn8W6gW",
176
- createdDate: "2025-12-12T11:50:09.183+00:00",
177
- lastModifiedBy: "0TOlmUqx0TKseTn8W6gW",
178
- lastModifiedDate: "2025-12-16T05:35:08.035+00:00",
179
- id: "MJ2T21GQ8O8DQXIOHZBF",
180
- workspaceId: "prod",
181
- entityVersion: 9,
182
- };
183
-
184
- setSaveWorkbookData(JSON.stringify(exampleWorkbook, null, 2));
185
- setSheetInputs("[]");
186
- toast.info('Example workbook data loaded. Click "Save Workbook" to save.');
187
- };
188
-
189
- // Handle Load Example for Publish Workbook
190
- const handleLoadPublishExample = () => {
191
- setPublishWorkbookId(DEFAULT_WORKBOOK_ID);
192
- toast.info(
193
- 'Example workbook ID loaded. Click "Publish Workbook" to publish.'
194
- );
195
- };
196
-
197
- // Handle Get Workbook Details
198
- const handleGetWorkbookDetails = async () => {
199
- if (!workbookId) {
200
- toast.error("Please enter a workbook ID");
201
- return;
202
- }
203
- try {
204
- const result = await workbookDetailsQuery.refetch();
205
- if (result.data) {
206
- setWorkbookData(result.data);
207
- console.log("Workbook details:", result.data);
208
- toast.success("Workbook details loaded! Check console for data.");
209
- }
210
- } catch (error: any) {
211
- toast.error(`Error: ${error.message}`);
212
- }
213
- };
214
-
215
- // Handle Save Workbook
216
- const handleSaveWorkbook = async () => {
217
- if (!saveWorkbookData) {
218
- toast.error("Please enter workbook data (JSON)");
219
- return;
220
- }
221
- try {
222
- let parsedWorkbook;
223
- let parsedSheetInputs;
224
-
225
- try {
226
- parsedWorkbook = JSON.parse(saveWorkbookData);
227
- } catch (e) {
228
- toast.error("Invalid JSON format for workbook data");
229
- return;
230
- }
231
-
232
- try {
233
- parsedSheetInputs = JSON.parse(sheetInputs);
234
- } catch (e) {
235
- toast.error("Invalid JSON format for sheet inputs");
236
- return;
237
- }
238
-
239
- const result = await saveWorkbookMutation.mutateAsync({
240
- workbook: parsedWorkbook,
241
- sheetInputs: parsedSheetInputs,
242
- });
243
- console.log("Workbook saved:", result);
244
- toast.success("Workbook saved successfully! Check console for data.");
245
- } catch (error: any) {
246
- console.error("Save error:", error);
247
- toast.error(`Save failed: ${error.message}`);
248
- }
249
- };
250
-
251
- // Handle Publish Workbook
252
- const handlePublishWorkbook = async () => {
253
- if (!publishWorkbookId) {
254
- toast.error("Please enter a workbook ID");
255
- return;
256
- }
257
- try {
258
- const result = await publishWorkbookMutation.mutateAsync({
259
- workbookId: publishWorkbookId,
260
- });
261
- console.log("Workbook published:", result);
262
- toast.success("Workbook published successfully! Check console for data.");
263
- } catch (error: any) {
264
- console.error("Publish error:", error);
265
- toast.error(`Publish failed: ${error.message}`);
266
- }
267
- };
268
-
269
- return (
270
- <Card className="mb-6">
271
- <CardHeader>
272
- <CardTitle>Workbook Operations Test</CardTitle>
273
- <CardDescription>
274
- Get, save, and publish workbook details
275
- </CardDescription>
276
- </CardHeader>
277
- <CardContent className="space-y-4">
278
- <div className="space-y-2">
279
- <Label htmlFor="workbookId">Workbook ID</Label>
280
- <div className="flex gap-2">
281
- <Input
282
- id="workbookId"
283
- value={workbookId}
284
- onChange={(e) => setWorkbookId(e.target.value)}
285
- placeholder="Enter workbook ID"
286
- />
287
- <Button onClick={handleLoadExample} variant="outline" type="button">
288
- Load Example
289
- </Button>
290
- </div>
291
- <p className="text-xs text-muted-foreground">
292
- Example:{" "}
293
- <button
294
- type="button"
295
- onClick={handleLoadExample}
296
- className="underline text-blue-600 hover:text-blue-800"
297
- >
298
- {DEFAULT_WORKBOOK_ID}
299
- </button>
300
- </p>
301
- </div>
302
-
303
- <div className="flex gap-4">
304
- <Button
305
- onClick={handleGetWorkbookDetails}
306
- disabled={workbookDetailsQuery.isLoading || !workbookId}
307
- variant="default"
308
- >
309
- {workbookDetailsQuery.isLoading
310
- ? "Loading..."
311
- : "1. Get Workbook Details"}
312
- </Button>
313
- </div>
314
-
315
- {/* Status Messages for Get Workbook */}
316
- {workbookDetailsQuery.isError && (
317
- <p className="text-red-500">
318
- Get Error: {workbookDetailsQuery.error?.message}
319
- </p>
320
- )}
321
- {workbookDetailsQuery.isSuccess && workbookData && (
322
- <p className="text-green-500">
323
- ✓ Workbook details loaded (ID: {workbookData.id})
324
- </p>
325
- )}
326
-
327
- {/* Workbook Data Preview */}
328
- {workbookData && (
329
- <div className="mt-4 p-4 bg-muted rounded-lg">
330
- <p className="text-sm font-semibold mb-2">Workbook Data:</p>
331
- <pre className="text-xs overflow-auto max-h-60">
332
- {JSON.stringify(workbookData, null, 2)}
333
- </pre>
334
- </div>
335
- )}
336
-
337
- {/* Save Workbook Section */}
338
- <div className="border-t pt-4 mt-4 space-y-4">
339
- <h3 className="text-lg font-semibold">Save Workbook</h3>
340
- <div className="space-y-2">
341
- <Label htmlFor="saveWorkbookData">Workbook Data (JSON)</Label>
342
- <div className="flex gap-2 mb-2">
343
- <Button
344
- onClick={handleLoadSaveExample}
345
- variant="outline"
346
- type="button"
347
- >
348
- Load Example
349
- </Button>
350
- </div>
351
- <textarea
352
- id="saveWorkbookData"
353
- value={saveWorkbookData}
354
- onChange={(e) => setSaveWorkbookData(e.target.value)}
355
- placeholder="Enter workbook JSON data"
356
- className="w-full min-h-[150px] p-2 border rounded-md font-mono text-xs"
357
- />
358
- <p className="text-xs text-muted-foreground">
359
- Example: Click "Load Example" button above to load sample workbook
360
- data
361
- </p>
362
- </div>
363
-
364
- <div className="space-y-2">
365
- <Label htmlFor="sheetInputs">Sheet Inputs (JSON Array)</Label>
366
- <Input
367
- id="sheetInputs"
368
- value={sheetInputs}
369
- onChange={(e) => setSheetInputs(e.target.value)}
370
- placeholder="Enter sheet inputs as JSON array, e.g., []"
371
- className="font-mono text-xs"
372
- />
373
- <p className="text-xs text-muted-foreground">
374
- Example: <code className="bg-muted px-1 rounded">[]</code> (empty
375
- array)
376
- </p>
377
- </div>
378
-
379
- <div className="space-y-2">
380
- <Button
381
- onClick={handleSaveWorkbook}
382
- disabled={saveWorkbookMutation.isPending || !saveWorkbookData}
383
- variant="default"
384
- >
385
- {saveWorkbookMutation.isPending
386
- ? "Saving..."
387
- : "2. Save Workbook"}
388
- </Button>
389
-
390
- {/* Status Messages for Save Workbook */}
391
- {saveWorkbookMutation.isError && (
392
- <p className="text-red-500">
393
- Save Error: {saveWorkbookMutation.error?.message}
394
- </p>
395
- )}
396
- {saveWorkbookMutation.isSuccess && (
397
- <p className="text-green-500">✓ Workbook saved successfully</p>
398
- )}
399
- </div>
400
- </div>
401
-
402
- {/* Publish Workbook Section */}
403
- <div className="border-t pt-4 mt-4 space-y-4">
404
- <h3 className="text-lg font-semibold">Publish Workbook</h3>
405
- <div className="space-y-2">
406
- <Label htmlFor="publishWorkbookId">Workbook ID</Label>
407
- <div className="flex gap-2">
408
- <Input
409
- id="publishWorkbookId"
410
- value={publishWorkbookId}
411
- onChange={(e) => setPublishWorkbookId(e.target.value)}
412
- placeholder="Enter workbook ID"
413
- />
414
- <Button
415
- onClick={handleLoadPublishExample}
416
- variant="outline"
417
- type="button"
418
- >
419
- Load Example
420
- </Button>
421
- </div>
422
- <p className="text-xs text-muted-foreground">
423
- Example:{" "}
424
- <button
425
- type="button"
426
- onClick={handleLoadPublishExample}
427
- className="underline text-blue-600 hover:text-blue-800"
428
- >
429
- {DEFAULT_WORKBOOK_ID}
430
- </button>
431
- </p>
432
- </div>
433
-
434
- <Button
435
- onClick={handlePublishWorkbook}
436
- disabled={publishWorkbookMutation.isPending || !publishWorkbookId}
437
- variant="default"
438
- >
439
- {publishWorkbookMutation.isPending
440
- ? "Publishing..."
441
- : "3. Publish Workbook"}
442
- </Button>
443
-
444
- {/* Status Messages for Publish Workbook */}
445
- {publishWorkbookMutation.isError && (
446
- <p className="text-red-500">
447
- Publish Error: {publishWorkbookMutation.error?.message}
448
- </p>
449
- )}
450
- {publishWorkbookMutation.isSuccess && (
451
- <p className="text-green-500">✓ Workbook published successfully</p>
452
- )}
453
- </div>
454
- </CardContent>
455
- </Card>
456
- );
457
- }
458
-
459
- // Task Test Component
460
- function TaskTestSection() {
461
- const [taskId, setTaskId] = useState<string>("");
462
-
463
- // Get Task Details Hook - disabled by default
464
- const taskDetailsQuery = useGetTaskDetails(taskId || null, {
465
- enabled: false, // No automatic fetching - all calls are user-initiated
466
- });
467
-
468
- // Handle Load Example
469
- const handleLoadExample = () => {
470
- setTaskId(DEFAULT_TASK_ID);
471
- toast.info('Example task ID loaded. Click "Get Task Details" to fetch.');
472
- };
473
-
474
- // Handle Get Task Details
475
- const handleGetTaskDetails = async () => {
476
- if (!taskId) {
477
- toast.error("Please enter a task ID");
478
- return;
479
- }
480
- try {
481
- const result = await taskDetailsQuery.refetch();
482
- if (result.data) {
483
- console.log("Task details:", result.data);
484
- toast.success("Task details loaded! Check console for data.");
485
- }
486
- } catch (error: any) {
487
- toast.error(`Error: ${error.message}`);
488
- }
489
- };
490
-
491
- return (
492
- <Card className="mb-6">
493
- <CardHeader>
494
- <CardTitle>Task Operations Test</CardTitle>
495
- <CardDescription>Get task details by task ID</CardDescription>
496
- </CardHeader>
497
- <CardContent className="space-y-4">
498
- <div className="space-y-2">
499
- <Label htmlFor="taskId">Task ID</Label>
500
- <div className="flex gap-2">
501
- <Input
502
- id="taskId"
503
- value={taskId}
504
- onChange={(e) => setTaskId(e.target.value)}
505
- placeholder="Enter task ID"
506
- />
507
- <Button onClick={handleLoadExample} variant="outline" type="button">
508
- Load Example
509
- </Button>
510
- </div>
511
- <p className="text-xs text-muted-foreground">
512
- Example:{" "}
513
- <button
514
- type="button"
515
- onClick={handleLoadExample}
516
- className="underline text-blue-600 hover:text-blue-800"
517
- >
518
- {DEFAULT_TASK_ID}
519
- </button>
520
- </p>
521
- </div>
522
-
523
- <div className="flex gap-4">
524
- <Button
525
- onClick={handleGetTaskDetails}
526
- disabled={taskDetailsQuery.isLoading || !taskId}
527
- variant="default"
528
- >
529
- {taskDetailsQuery.isLoading ? "Loading..." : "Get Task Details"}
530
- </Button>
531
- </div>
532
-
533
- {/* Status Messages */}
534
- {taskDetailsQuery.isError && (
535
- <p className="text-red-500">
536
- Get Error: {taskDetailsQuery.error?.message}
537
- </p>
538
- )}
539
- {taskDetailsQuery.isSuccess && taskDetailsQuery.data && (
540
- <p className="text-green-500">
541
- ✓ Task details loaded (ID: {taskDetailsQuery.data.id || taskId})
542
- </p>
543
- )}
544
-
545
- {/* Task Data Preview */}
546
- {taskDetailsQuery.data && (
547
- <div className="mt-4 p-4 bg-muted rounded-lg">
548
- <p className="text-sm font-semibold mb-2">Task Data:</p>
549
- <pre className="text-xs overflow-auto max-h-60">
550
- {JSON.stringify(taskDetailsQuery.data, null, 2)}
551
- </pre>
552
- </div>
553
- )}
554
- </CardContent>
555
- </Card>
556
- );
557
- }
558
-
559
- // Run Recon Test Component
560
- function RunReconTestSection() {
561
- const [workflowId, setWorkflowId] = useState<string>("");
562
- const [fullRefresh, setFullRefresh] = useState<boolean>(true);
563
- const [reconResult, setReconResult] = useState<any>(null);
564
-
565
- // Run Recon Hook
566
- const runReconMutation = useRunRecon();
567
-
568
- // Handle Load Example
569
- const handleLoadExample = () => {
570
- setWorkflowId(DEFAULT_WORKFLOW_ID);
571
- setFullRefresh(true);
572
- toast.info('Example workflow ID loaded. Click "Run Recon" to execute.');
573
- };
574
-
575
- // Handle Run Recon
576
- const handleRunRecon = async () => {
577
- if (!workflowId) {
578
- toast.error("Please enter a workflow ID");
579
- return;
580
- }
581
- try {
582
- const result = await runReconMutation.mutateAsync({
583
- workflowId: workflowId,
584
- fullRefresh: fullRefresh,
585
- });
586
- console.log("Run Recon result:", result);
587
- setReconResult(result);
588
- toast.success("Recon workflow started! Check console for data.");
589
- } catch (error: any) {
590
- console.error("Run Recon error:", error);
591
- toast.error(`Run Recon failed: ${error.message}`);
592
- }
593
- };
594
-
595
- return (
596
- <Card className="mb-6">
597
- <CardHeader>
598
- <CardTitle>Run Recon Operations Test</CardTitle>
599
- <CardDescription>Run a reconciliation workflow</CardDescription>
600
- </CardHeader>
601
- <CardContent className="space-y-4">
602
- <div className="space-y-2">
603
- <Label htmlFor="workflowId">Workflow ID</Label>
604
- <div className="flex gap-2">
605
- <Input
606
- id="workflowId"
607
- value={workflowId}
608
- onChange={(e) => setWorkflowId(e.target.value)}
609
- placeholder="Enter workflow ID"
610
- />
611
- <Button onClick={handleLoadExample} variant="outline" type="button">
612
- Load Example
613
- </Button>
614
- </div>
615
- <p className="text-xs text-muted-foreground">
616
- Example:{" "}
617
- <button
618
- type="button"
619
- onClick={handleLoadExample}
620
- className="underline text-blue-600 hover:text-blue-800"
621
- >
622
- {DEFAULT_WORKFLOW_ID}
623
- </button>
624
- </p>
625
- </div>
626
-
627
- <div className="flex items-center gap-2">
628
- <input
629
- type="checkbox"
630
- id="fullRefresh"
631
- checked={fullRefresh}
632
- onChange={(e) => setFullRefresh(e.target.checked)}
633
- className="h-4 w-4"
634
- />
635
- <Label htmlFor="fullRefresh" className="cursor-pointer">
636
- Full Refresh
637
- </Label>
638
- </div>
639
-
640
- <div className="flex gap-4">
641
- <Button
642
- onClick={handleRunRecon}
643
- disabled={runReconMutation.isPending || !workflowId}
644
- variant="default"
645
- >
646
- {runReconMutation.isPending ? "Running..." : "Run Recon"}
647
- </Button>
648
- </div>
649
-
650
- {/* Status Messages */}
651
- {runReconMutation.isError && (
652
- <p className="text-red-500">
653
- Run Recon Error: {runReconMutation.error?.message}
654
- </p>
655
- )}
656
- {runReconMutation.isSuccess && reconResult && (
657
- <p className="text-green-500">
658
- ✓ Recon workflow started successfully
659
- </p>
660
- )}
661
-
662
- {/* Recon Result Preview */}
663
- {reconResult && (
664
- <div className="mt-4 p-4 bg-muted rounded-lg">
665
- <p className="text-sm font-semibold mb-2">Recon Result:</p>
666
- <pre className="text-xs overflow-auto max-h-60">
667
- {JSON.stringify(reconResult, null, 2)}
668
- </pre>
669
- </div>
670
- )}
671
- </CardContent>
672
- </Card>
673
- );
674
- }
675
-
676
- // File Upload Test Component
677
- function FileUploadTestSection() {
678
- const [fileUploadData, setFileUploadData] = useState<string>("");
679
- const [fileId, setFileId] = useState<string>("");
680
- const [downloadedData, setDownloadedData] = useState<any>(null);
681
-
682
- // File Upload Hook
683
- const fileUploadMutation = useFileUpload();
684
-
685
- // File Download Hook - disabled by default
686
- const fileDownloadQuery = useFileDownload({
687
- fileId: fileId || "",
688
- contentType: "application/json",
689
- method: "GET",
690
- }, {
691
- enabled: false, // No automatic fetching - all calls are user-initiated
692
- });
693
-
694
- // Handle Load Example
695
- const handleLoadExample = () => {
696
- setFileUploadData(JSON.stringify(DEFAULT_FILE_UPLOAD_PAYLOAD, null, 2));
697
- toast.info('Example payload loaded. Click "Upload File" to upload.');
698
- };
699
-
700
- // Handle File Upload
701
- const handleFileUpload = async () => {
702
- if (!fileUploadData) {
703
- toast.error("Please enter file data (JSON)");
704
- return;
705
- }
706
- try {
707
- let parsedData;
708
- try {
709
- parsedData = JSON.parse(fileUploadData);
710
- } catch (e) {
711
- toast.error("Invalid JSON format");
712
- return;
713
- }
714
-
715
- const result = await fileUploadMutation.mutateAsync({
716
- data: parsedData,
717
- path: "test/test.json",
718
- contentType: "application/json",
719
- method: "PUT",
720
- });
721
- console.log("File uploaded, fileId:", result.fileId);
722
- setFileId(result.fileId);
723
- toast.success(`File uploaded successfully! File ID: ${result.fileId}`);
724
- } catch (error: any) {
725
- console.error("File upload error:", error);
726
- toast.error(`File upload failed: ${error.message || error.response?.data?.message}`);
727
- }
728
- };
729
-
730
- // Handle File Download
731
- const handleFileDownload = async () => {
732
- if (!fileId) {
733
- toast.error("Please upload a file first to get fileId");
734
- return;
735
- }
736
- try {
737
- const result = await fileDownloadQuery.refetch();
738
- if (result.data) {
739
- setDownloadedData(result.data);
740
- console.log("File downloaded:", result.data);
741
- toast.success("File downloaded! Check console for data.");
742
- }
743
- } catch (error: any) {
744
- toast.error(`Download Error: ${error.message}`);
745
- }
746
- };
747
-
748
- return (
749
- <Card className="mb-6">
750
- <CardHeader>
751
- <CardTitle>File Upload/Download Operations Test</CardTitle>
752
- <CardDescription>
753
- Upload a file, get fileId, then download and display the file
754
- </CardDescription>
755
- </CardHeader>
756
- <CardContent className="space-y-4">
757
- <div className="space-y-2">
758
- <Label htmlFor="fileUploadData">File Data (JSON)</Label>
759
- <div className="flex gap-2 mb-2">
760
- <Button onClick={handleLoadExample} variant="outline" type="button">
761
- Load Example
762
- </Button>
763
- </div>
764
- <textarea
765
- id="fileUploadData"
766
- value={fileUploadData}
767
- onChange={(e) => setFileUploadData(e.target.value)}
768
- placeholder="Enter JSON data to upload"
769
- className="w-full min-h-[150px] p-2 border rounded-md font-mono text-xs"
770
- />
771
- <p className="text-xs text-muted-foreground">
772
- Example: Click "Load Example" button above to load sample JSON
773
- payload
774
- </p>
775
- </div>
776
-
777
- <div className="space-y-2">
778
- <Label htmlFor="fileId">File ID (from upload response)</Label>
779
- <Input
780
- id="fileId"
781
- value={fileId}
782
- onChange={(e) => setFileId(e.target.value)}
783
- placeholder="File ID will appear here after upload"
784
- />
785
- </div>
786
-
787
- <div className="flex gap-4">
788
- <Button
789
- onClick={handleFileUpload}
790
- disabled={fileUploadMutation.isPending || !fileUploadData}
791
- variant="default"
792
- >
793
- {fileUploadMutation.isPending ? "Uploading..." : "1. Upload File"}
794
- </Button>
795
-
796
- <Button
797
- onClick={handleFileDownload}
798
- disabled={fileDownloadQuery.isLoading || !fileId}
799
- variant="default"
800
- >
801
- {fileDownloadQuery.isLoading
802
- ? "Downloading..."
803
- : "2. Download File"}
804
- </Button>
805
- </div>
806
-
807
- {/* Status Messages */}
808
- {fileUploadMutation.isError && (
809
- <p className="text-red-500">
810
- Upload Error: {fileUploadMutation.error?.message}
811
- </p>
812
- )}
813
- {fileUploadMutation.isSuccess && fileId && (
814
- <p className="text-green-500">
815
- ✓ File uploaded successfully (File ID: {fileId})
816
- </p>
817
- )}
818
-
819
- {fileDownloadQuery.isError && (
820
- <p className="text-red-500">
821
- Download Error: {fileDownloadQuery.error?.message}
822
- </p>
823
- )}
824
- {fileDownloadQuery.isSuccess && downloadedData && (
825
- <p className="text-green-500">✓ File downloaded successfully</p>
826
- )}
827
-
828
- {/* Uploaded Payload Preview */}
829
- {fileUploadMutation.isSuccess && fileUploadData && (
830
- <div className="mt-4 p-4 bg-muted rounded-lg">
831
- <p className="text-sm font-semibold mb-2">Uploaded Payload:</p>
832
- <pre className="text-xs overflow-auto max-h-40">
833
- {fileUploadData}
834
- </pre>
835
- </div>
836
- )}
837
-
838
- {/* Downloaded File Data Preview */}
839
- {downloadedData && (
840
- <div className="mt-4 p-4 bg-muted rounded-lg">
841
- <p className="text-sm font-semibold mb-2">Downloaded File Data:</p>
842
- <pre className="text-xs overflow-auto max-h-60">
843
- {JSON.stringify(downloadedData, null, 2)}
844
- </pre>
845
- </div>
846
- )}
847
- </CardContent>
848
- </Card>
849
- );
850
- }
851
-
852
- // Form Schema Test Component
853
- function FormSchemaTestSection() {
854
- const [formInstanceId, setFormInstanceId] = useState<string>("");
855
- const [formRevision, setFormRevision] = useState<number>(1);
856
-
857
- // Get Form Schema Hook - disabled by default
858
- const formSchemaQuery = useGetFormSchema(
859
- formInstanceId || null,
860
- formRevision ? Number(formRevision) : null
861
- );
862
-
863
- // Handle Load Example
864
- const handleLoadExample = () => {
865
- setFormInstanceId(DEFAULT_FORM_INSTANCE_ID);
866
- setFormRevision(DEFAULT_FORM_REVISION);
867
- toast.info(
868
- 'Example form instance ID and revision loaded. Click "Get Form Schema" to fetch.'
869
- );
870
- };
871
-
872
- // Handle Get Form Schema
873
- const handleGetFormSchema = async () => {
874
- if (!formInstanceId || !formRevision) {
875
- toast.error("Please enter form instance ID and revision");
876
- return;
877
- }
878
- try {
879
- const result = await formSchemaQuery.refetch();
880
- if (result.data) {
881
- console.log("Form schema:", result.data);
882
- toast.success("Form schema loaded! Check console for data.");
883
- }
884
- } catch (error: any) {
885
- toast.error(`Error: ${error.message}`);
886
- }
887
- };
888
-
889
- return (
890
- <Card className="mb-6">
891
- <CardHeader>
892
- <CardTitle>Form Schema Operations Test</CardTitle>
893
- <CardDescription>
894
- Get form schema by form instance ID and revision
895
- </CardDescription>
896
- </CardHeader>
897
- <CardContent className="space-y-4">
898
- <div className="space-y-2">
899
- <Label htmlFor="formInstanceId">Form Instance ID</Label>
900
- <div className="flex gap-2">
901
- <Input
902
- id="formInstanceId"
903
- value={formInstanceId}
904
- onChange={(e) => setFormInstanceId(e.target.value)}
905
- placeholder="Enter form instance ID"
906
- />
907
- <Button onClick={handleLoadExample} variant="outline" type="button">
908
- Load Example
909
- </Button>
910
- </div>
911
- <p className="text-xs text-muted-foreground">
912
- Example:{" "}
913
- <button
914
- type="button"
915
- onClick={handleLoadExample}
916
- className="underline text-blue-600 hover:text-blue-800"
917
- >
918
- {DEFAULT_FORM_INSTANCE_ID || "Enter form instance ID"}
919
- </button>
920
- </p>
921
- </div>
922
-
923
- <div className="space-y-2">
924
- <Label htmlFor="formRevision">Form Revision</Label>
925
- <Input
926
- id="formRevision"
927
- value={formRevision}
928
- onChange={(e) => setFormRevision(Number(e.target.value) || 1)}
929
- placeholder="Enter form revision (e.g., 1)"
930
- />
931
- <p className="text-xs text-muted-foreground">
932
- Example:{" "}
933
- <code className="bg-muted px-1 rounded">
934
- {DEFAULT_FORM_REVISION}
935
- </code>
936
- </p>
937
- </div>
938
-
939
- <div className="flex gap-4">
940
- <Button
941
- onClick={handleGetFormSchema}
942
- disabled={
943
- formSchemaQuery.isLoading || !formInstanceId || !formRevision
944
- }
945
- variant="default"
946
- >
947
- {formSchemaQuery.isLoading ? "Loading..." : "Get Form Schema"}
948
- </Button>
949
- </div>
950
-
951
- {/* Status Messages */}
952
- {formSchemaQuery.isError && (
953
- <p className="text-red-500">
954
- Get Error: {formSchemaQuery.error?.message}
955
- </p>
956
- )}
957
- {formSchemaQuery.isSuccess && formSchemaQuery.data && (
958
- <p className="text-green-500">✓ Form schema loaded successfully</p>
959
- )}
960
-
961
- {/* Form Schema Data Preview */}
962
- {formSchemaQuery.data && (
963
- <div className="mt-4 p-4 bg-muted rounded-lg">
964
- <p className="text-sm font-semibold mb-2">Form Schema Data:</p>
965
- <pre className="text-xs overflow-auto max-h-60">
966
- {JSON.stringify(formSchemaQuery.data, null, 2)}
967
- </pre>
968
- </div>
969
- )}
970
- </CardContent>
971
- </Card>
972
- );
973
- }
974
-
975
- // Get Audit Logs Test Component
976
- function GetAuditLogsTestSection() {
977
- const [auditLogRequest, setAuditLogRequest] = useState<string>("");
978
- const [auditLogsResult, setAuditLogsResult] = useState<any>(null);
979
-
980
- // Get Audit Logs Hook
981
- const getAuditLogsMutation = useGetAuditLogs();
982
-
983
- // Handle Load Example
984
- const handleLoadExample = () => {
985
- setAuditLogRequest(JSON.stringify(DEFAULT_AUDIT_LOG_REQUEST, null, 2));
986
- toast.info(
987
- 'Example audit log request loaded. Click "Get Audit Logs" to fetch.'
988
- );
989
- };
990
-
991
- // Handle Get Audit Logs
992
- const handleGetAuditLogs = async () => {
993
- if (!auditLogRequest) {
994
- toast.error("Please enter audit log request (JSON)");
995
- return;
996
- }
997
- try {
998
- let parsedRequest;
999
- try {
1000
- parsedRequest = JSON.parse(auditLogRequest);
1001
- } catch (e) {
1002
- toast.error("Invalid JSON format");
1003
- return;
1004
- }
1005
-
1006
- const result = await getAuditLogsMutation.mutateAsync(parsedRequest);
1007
- setAuditLogsResult(result);
1008
- toast.success("Audit logs loaded! Check console for data.");
1009
- } catch (error: any) {
1010
- console.error("Get audit logs error:", error);
1011
- toast.error(`Get audit logs failed: ${error.message}`);
1012
- }
1013
- };
1014
-
1015
- return (
1016
- <Card className="mb-6">
1017
- <CardHeader>
1018
- <CardTitle>Get Audit Logs Operations Test</CardTitle>
1019
- <CardDescription>Get audit logs with filter criteria</CardDescription>
1020
- </CardHeader>
1021
- <CardContent className="space-y-4">
1022
- <div className="space-y-2">
1023
- <Label htmlFor="auditLogRequest">Audit Log Request (JSON)</Label>
1024
- <div className="flex gap-2 mb-2">
1025
- <Button onClick={handleLoadExample} variant="outline" type="button">
1026
- Load Example
1027
- </Button>
1028
- </div>
1029
- <textarea
1030
- id="auditLogRequest"
1031
- value={auditLogRequest}
1032
- onChange={(e) => setAuditLogRequest(e.target.value)}
1033
- placeholder="Enter audit log request JSON"
1034
- className="w-full min-h-[150px] p-2 border rounded-md font-mono text-xs"
1035
- />
1036
- <p className="text-xs text-muted-foreground">
1037
- Example: Click "Load Example" button above to load sample request
1038
- </p>
1039
- </div>
1040
-
1041
- <div className="flex gap-4">
1042
- <Button
1043
- onClick={handleGetAuditLogs}
1044
- disabled={getAuditLogsMutation.isPending || !auditLogRequest}
1045
- variant="default"
1046
- >
1047
- {getAuditLogsMutation.isPending ? "Loading..." : "Get Audit Logs"}
1048
- </Button>
1049
- </div>
1050
-
1051
- {/* Status Messages */}
1052
- {getAuditLogsMutation.isError && (
1053
- <p className="text-red-500">
1054
- Get Error: {getAuditLogsMutation.error?.message}
1055
- </p>
1056
- )}
1057
- {getAuditLogsMutation.isSuccess && auditLogsResult && (
1058
- <p className="text-green-500">
1059
- ✓ Audit logs loaded successfully (Count:{" "}
1060
- {auditLogsResult.count || 0})
1061
- </p>
1062
- )}
1063
-
1064
- {/* Audit Logs Result Preview */}
1065
- {auditLogsResult && (
1066
- <div className="mt-4 p-4 bg-muted rounded-lg">
1067
- <p className="text-sm font-semibold mb-2">Audit Logs Result:</p>
1068
- <pre className="text-xs overflow-auto max-h-60">
1069
- {JSON.stringify(auditLogsResult, null, 2)}
1070
- </pre>
1071
- </div>
1072
- )}
1073
- </CardContent>
1074
- </Card>
1075
- );
1076
- }
1077
-
1078
- // Create Audit Log Test Component
1079
- function CreateAuditLogTestSection() {
1080
- const [auditRecords, setAuditRecords] = useState<string>("");
1081
- const [createResult, setCreateResult] = useState<any>(null);
1082
-
1083
- // Create Audit Log Hook
1084
- const createAuditLogMutation = useCreateAuditLog();
1085
-
1086
- // Handle Load Example
1087
- const handleLoadExample = () => {
1088
- const exampleRecords = DEFAULT_AUDIT_RECORD;
1089
- setAuditRecords(JSON.stringify(exampleRecords, null, 2));
1090
- toast.info(
1091
- 'Example audit record loaded. Click "Create Audit Log" to create.'
1092
- );
1093
- };
1094
-
1095
- // Handle Create Audit Log
1096
- const handleCreateAuditLog = async () => {
1097
- if (!auditRecords) {
1098
- toast.error("Please enter audit records (JSON array)");
1099
- return;
1100
- }
1101
- try {
1102
- let parsedRecords;
1103
- try {
1104
- parsedRecords = JSON.parse(auditRecords);
1105
- } catch (e) {
1106
- toast.error("Invalid JSON format");
1107
- return;
1108
- }
1109
-
1110
- if (!Array.isArray(parsedRecords)) {
1111
- toast.error("Audit records must be an array");
1112
- return;
1113
- }
1114
-
1115
- const result = await createAuditLogMutation.mutateAsync({
1116
- auditRecords: parsedRecords,
1117
- });
1118
- console.log("Audit log created:", result);
1119
- setCreateResult(result);
1120
- toast.success("Audit log created successfully! Check console for data.");
1121
- } catch (error: any) {
1122
- console.error("Create audit log error:", error);
1123
- toast.error(`Create audit log failed: ${error.message}`);
1124
- }
1125
- };
1126
-
1127
- return (
1128
- <Card className="mb-6">
1129
- <CardHeader>
1130
- <CardTitle>Create Audit Log Operations Test</CardTitle>
1131
- <CardDescription>Create audit log records</CardDescription>
1132
- </CardHeader>
1133
- <CardContent className="space-y-4">
1134
- <div className="space-y-2">
1135
- <Label htmlFor="auditRecords">Audit Records (JSON Array)</Label>
1136
- <div className="flex gap-2 mb-2">
1137
- <Button onClick={handleLoadExample} variant="outline" type="button">
1138
- Load Example
1139
- </Button>
1140
- </div>
1141
- <textarea
1142
- id="auditRecords"
1143
- value={auditRecords}
1144
- onChange={(e) => setAuditRecords(e.target.value)}
1145
- placeholder="Enter audit records as JSON array"
1146
- className="w-full min-h-[200px] p-2 border rounded-md font-mono text-xs"
1147
- />
1148
- <p className="text-xs text-muted-foreground">
1149
- Example: Click "Load Example" button above to load sample audit
1150
- record
1151
- </p>
1152
- </div>
1153
-
1154
- <div className="flex gap-4">
1155
- <Button
1156
- onClick={handleCreateAuditLog}
1157
- disabled={createAuditLogMutation.isPending || !auditRecords}
1158
- variant="default"
1159
- >
1160
- {createAuditLogMutation.isPending
1161
- ? "Creating..."
1162
- : "Create Audit Log"}
1163
- </Button>
1164
- </div>
1165
-
1166
- {/* Status Messages */}
1167
- {createAuditLogMutation.isError && (
1168
- <p className="text-red-500">
1169
- Create Error: {createAuditLogMutation.error?.message}
1170
- </p>
1171
- )}
1172
- {createAuditLogMutation.isSuccess && createResult && (
1173
- <p className="text-green-500">✓ Audit log created successfully</p>
1174
- )}
1175
-
1176
- {/* Create Result Preview */}
1177
- {createResult && (
1178
- <div className="mt-4 p-4 bg-muted rounded-lg">
1179
- <p className="text-sm font-semibold mb-2">Create Result:</p>
1180
- <pre className="text-xs overflow-auto max-h-60">
1181
- {JSON.stringify(createResult, null, 2)}
1182
- </pre>
1183
- </div>
1184
- )}
1185
- </CardContent>
1186
- </Card>
1187
- );
1188
- }
1189
-
1190
- // Get All Templated Pipelines Test Component
1191
- function GetAllTemplatedPipelinesTestSection() {
1192
- const [templatedPipelinesResult, setTemplatedPipelinesResult] =
1193
- useState<any>(null);
1194
-
1195
- // Get All Templated Pipelines Hook - disabled by default
1196
- const templatedPipelinesQuery = useGetAllTemplatedPipelines({
1197
- enabled: false,
1198
- });
1199
-
1200
- // Handle Get All Templated Pipelines
1201
- const handleGetAllTemplatedPipelines = async () => {
1202
- try {
1203
- const result = await templatedPipelinesQuery.refetch();
1204
- if (result.data) {
1205
- setTemplatedPipelinesResult(result.data);
1206
- console.log("Templated pipelines:", result.data);
1207
- toast.success("Templated pipelines loaded! Check console for data.");
1208
- }
1209
- } catch (error: any) {
1210
- toast.error(`Error: ${error.message}`);
1211
- }
1212
- };
1213
-
1214
- return (
1215
- <Card className="mb-6">
1216
- <CardHeader>
1217
- <CardTitle>Get All Templated Pipelines Test</CardTitle>
1218
- <CardDescription>Get all templated pipeline workflows</CardDescription>
1219
- </CardHeader>
1220
- <CardContent className="space-y-4">
1221
- <div className="flex gap-4">
1222
- <Button
1223
- onClick={handleGetAllTemplatedPipelines}
1224
- disabled={templatedPipelinesQuery.isLoading}
1225
- variant="default"
1226
- >
1227
- {templatedPipelinesQuery.isLoading
1228
- ? "Loading..."
1229
- : "Get All Templated Pipelines"}
1230
- </Button>
1231
- </div>
1232
-
1233
- {/* Status Messages */}
1234
- {templatedPipelinesQuery.isError && (
1235
- <p className="text-red-500">
1236
- Get Error: {templatedPipelinesQuery.error?.message}
1237
- </p>
1238
- )}
1239
- {templatedPipelinesQuery.isSuccess && templatedPipelinesResult && (
1240
- <p className="text-green-500">
1241
- ✓ Templated pipelines loaded successfully (Count:{" "}
1242
- {templatedPipelinesResult.length || 0})
1243
- </p>
1244
- )}
1245
-
1246
- {/* Templated Pipelines Result Preview */}
1247
- {templatedPipelinesResult && (
1248
- <div className="mt-4 p-4 bg-muted rounded-lg">
1249
- <p className="text-sm font-semibold mb-2">
1250
- Templated Pipelines Result:
1251
- </p>
1252
- <pre className="text-xs overflow-auto max-h-60">
1253
- {JSON.stringify(templatedPipelinesResult, null, 2)}
1254
- </pre>
1255
- </div>
1256
- )}
1257
- </CardContent>
1258
- </Card>
1259
- );
1260
- }
1261
-
1262
- // Get All Recon Test Component
1263
- function GetAllReconTestSection() {
1264
- const [reconResult, setReconResult] = useState<any>(null);
1265
-
1266
- // Get All Recon Hook - disabled by default
1267
- const reconQuery = useGetAllRecon({
1268
- enabled: false,
1269
- });
1270
-
1271
- // Handle Get All Recon
1272
- const handleGetAllRecon = async () => {
1273
- try {
1274
- const result = await reconQuery.refetch();
1275
- if (result.data) {
1276
- setReconResult(result.data);
1277
- console.log("Recon workflows:", result.data);
1278
- toast.success("Recon workflows loaded! Check console for data.");
1279
- }
1280
- } catch (error: any) {
1281
- toast.error(`Error: ${error.message}`);
1282
- }
1283
- };
1284
-
1285
- return (
1286
- <Card className="mb-6">
1287
- <CardHeader>
1288
- <CardTitle>Get All Recon Workflows Test</CardTitle>
1289
- <CardDescription>Get all reconciliation workflows</CardDescription>
1290
- </CardHeader>
1291
- <CardContent className="space-y-4">
1292
- <div className="flex gap-4">
1293
- <Button
1294
- onClick={handleGetAllRecon}
1295
- disabled={reconQuery.isLoading}
1296
- variant="default"
1297
- >
1298
- {reconQuery.isLoading ? "Loading..." : "Get All Recon Workflows"}
1299
- </Button>
1300
- </div>
1301
-
1302
- {/* Status Messages */}
1303
- {reconQuery.isError && (
1304
- <p className="text-red-500">Get Error: {reconQuery.error?.message}</p>
1305
- )}
1306
- {reconQuery.isSuccess && reconResult && (
1307
- <p className="text-green-500">
1308
- ✓ Recon workflows loaded successfully (Count:{" "}
1309
- {reconResult.length || 0})
1310
- </p>
1311
- )}
1312
-
1313
- {/* Recon Result Preview */}
1314
- {reconResult && (
1315
- <div className="mt-4 p-4 bg-muted rounded-lg">
1316
- <p className="text-sm font-semibold mb-2">
1317
- Recon Workflows Result:
1318
- </p>
1319
- <pre className="text-xs overflow-auto max-h-60">
1320
- {JSON.stringify(reconResult, null, 2)}
1321
- </pre>
1322
- </div>
1323
- )}
1324
- </CardContent>
1325
- </Card>
1326
- );
1327
- }
1328
-
1329
- // Get Form By ID Test Component
1330
- function GetFormByIdTestSection() {
1331
- const [formId, setFormId] = useState<string>("");
1332
- const [formResult, setFormResult] = useState<any>(null);
1333
-
1334
- // Get Form By ID Hook - disabled by default
1335
- const formQuery = useGetFormById(formId || null, {
1336
- enabled: false,
1337
- });
1338
-
1339
- // Handle Load Example
1340
- const handleLoadExample = () => {
1341
- setFormId(DEFAULT_FORM_ID);
1342
- toast.info('Example form ID loaded. Click "Get Form By ID" to fetch.');
1343
- };
1344
-
1345
- // Handle Get Form By ID
1346
- const handleGetFormById = async () => {
1347
- if (!formId) {
1348
- toast.error("Please enter a form ID");
1349
- return;
1350
- }
1351
- try {
1352
- const result = await formQuery.refetch();
1353
- if (result.data) {
1354
- setFormResult(result.data);
1355
- console.log("Form:", result.data);
1356
- toast.success("Form loaded! Check console for data.");
1357
- }
1358
- } catch (error: any) {
1359
- toast.error(`Error: ${error.message}`);
1360
- }
1361
- };
1362
-
1363
- return (
1364
- <Card className="mb-6">
1365
- <CardHeader>
1366
- <CardTitle>Get Form By ID Test</CardTitle>
1367
- <CardDescription>Get form details by form ID</CardDescription>
1368
- </CardHeader>
1369
- <CardContent className="space-y-4">
1370
- <div className="space-y-2">
1371
- <Label htmlFor="formId">Form ID</Label>
1372
- <div className="flex gap-2">
1373
- <Input
1374
- id="formId"
1375
- value={formId}
1376
- onChange={(e) => setFormId(e.target.value)}
1377
- placeholder="Enter form ID"
1378
- />
1379
- <Button onClick={handleLoadExample} variant="outline" type="button">
1380
- Load Example
1381
- </Button>
1382
- </div>
1383
- <p className="text-xs text-muted-foreground">
1384
- Example:{" "}
1385
- <button
1386
- type="button"
1387
- onClick={handleLoadExample}
1388
- className="underline text-blue-600 hover:text-blue-800"
1389
- >
1390
- {DEFAULT_FORM_ID || "Enter form ID"}
1391
- </button>
1392
- </p>
1393
- </div>
1394
-
1395
- <div className="flex gap-4">
1396
- <Button
1397
- onClick={handleGetFormById}
1398
- disabled={formQuery.isLoading || !formId}
1399
- variant="default"
1400
- >
1401
- {formQuery.isLoading ? "Loading..." : "Get Form By ID"}
1402
- </Button>
1403
- </div>
1404
-
1405
- {/* Status Messages */}
1406
- {formQuery.isError && (
1407
- <p className="text-red-500">Get Error: {formQuery.error?.message}</p>
1408
- )}
1409
- {formQuery.isSuccess && formResult && (
1410
- <p className="text-green-500">
1411
- ✓ Form loaded successfully (ID: {formResult.id || formId})
1412
- </p>
1413
- )}
1414
-
1415
- {/* Form Result Preview */}
1416
- {formResult && (
1417
- <div className="mt-4 p-4 bg-muted rounded-lg">
1418
- <p className="text-sm font-semibold mb-2">Form Result:</p>
1419
- <pre className="text-xs overflow-auto max-h-60">
1420
- {JSON.stringify(formResult, null, 2)}
1421
- </pre>
1422
- </div>
1423
- )}
1424
- </CardContent>
1425
- </Card>
1426
- );
1427
- }
1428
-
1429
- // Create Or Update Form Test Component
1430
- function CreateOrUpdateFormTestSection() {
1431
- const [formData, setFormData] = useState<string>("");
1432
- const [createResult, setCreateResult] = useState<any>(null);
1433
-
1434
- // Create Or Update Form Hook
1435
- const createOrUpdateFormMutation = useCreateOrUpdateForm();
1436
-
1437
- // Handle Create Or Update Form
1438
- const handleCreateOrUpdateForm = async () => {
1439
- if (!formData) {
1440
- toast.error("Please enter form data (JSON)");
1441
- return;
1442
- }
1443
- try {
1444
- let parsedForm;
1445
- try {
1446
- parsedForm = JSON.parse(formData);
1447
- } catch (e) {
1448
- toast.error("Invalid JSON format");
1449
- return;
1450
- }
1451
-
1452
- const result = await createOrUpdateFormMutation.mutateAsync({
1453
- data: parsedForm,
1454
- processSheetId: "123",
1455
- formInstanceId: "123",
1456
- isDummy: false,
1457
- status: "DRAFTED",
1458
- });
1459
- console.log("Form created/updated:", result);
1460
- setCreateResult(result);
1461
- toast.success(
1462
- "Form created/updated successfully! Check console for data."
1463
- );
1464
- } catch (error: any) {
1465
- console.error("Create/Update form error:", error);
1466
- toast.error(`Create/Update form failed: ${error.message}`);
1467
- }
1468
- };
1469
-
1470
- return (
1471
- <Card className="mb-6">
1472
- <CardHeader>
1473
- <CardTitle>Create Or Update Form Test</CardTitle>
1474
- <CardDescription>Create or update a form</CardDescription>
1475
- </CardHeader>
1476
- <CardContent className="space-y-4">
1477
- <div className="space-y-2">
1478
- <Label htmlFor="formData">Form Data (JSON)</Label>
1479
- <div className="flex gap-2 mb-2">
1480
- </div>
1481
- <textarea
1482
- id="formData"
1483
- value={formData}
1484
- onChange={(e) => setFormData(e.target.value)}
1485
- placeholder="Enter form data as JSON"
1486
- className="w-full min-h-[200px] p-2 border rounded-md font-mono text-xs"
1487
- />
1488
- <p className="text-xs text-muted-foreground">
1489
- Example: Click "Load Example" button above to load sample form data
1490
- </p>
1491
- </div>
1492
-
1493
- <div className="flex gap-4">
1494
- <Button
1495
- onClick={handleCreateOrUpdateForm}
1496
- disabled={createOrUpdateFormMutation.isPending || !formData}
1497
- variant="default"
1498
- >
1499
- {createOrUpdateFormMutation.isPending
1500
- ? "Saving..."
1501
- : "Create Or Update Form"}
1502
- </Button>
1503
- </div>
1504
-
1505
- {/* Status Messages */}
1506
- {createOrUpdateFormMutation.isError && (
1507
- <p className="text-red-500">
1508
- Create/Update Error: {createOrUpdateFormMutation.error?.message}
1509
- </p>
1510
- )}
1511
- {createOrUpdateFormMutation.isSuccess && createResult && (
1512
- <p className="text-green-500">✓ Form created/updated successfully</p>
1513
- )}
1514
-
1515
- {/* Create Result Preview */}
1516
- {createResult && (
1517
- <div className="mt-4 p-4 bg-muted rounded-lg">
1518
- <p className="text-sm font-semibold mb-2">Form Result:</p>
1519
- <pre className="text-xs overflow-auto max-h-60">
1520
- {JSON.stringify(createResult, null, 2)}
1521
- </pre>
1522
- </div>
1523
- )}
1524
- </CardContent>
1525
- </Card>
1526
- );
1527
- }
1528
-
1529
- // Mark Task Done Test Component
1530
- function MarkTaskDoneTestSection() {
1531
- const [taskId, setTaskId] = useState<string>("");
1532
- const [taskData, setTaskData] = useState<string>("");
1533
- const [markResult, setMarkResult] = useState<any>(null);
1534
-
1535
- // Mark Task Done Hook
1536
- const markTaskDoneMutation = useMarkTaskDone();
1537
-
1538
- // Handle Load Example
1539
- const handleLoadExample = () => {
1540
- setTaskId(DEFAULT_TASK_ID);
1541
- const exampleTaskData = {
1542
- notes: "Task completed successfully",
1543
- completedAt: new Date().toISOString(),
1544
- };
1545
- setTaskData(JSON.stringify(exampleTaskData, null, 2));
1546
- toast.info(
1547
- 'Example task ID and data loaded. Click "Mark Task Done" to complete.'
1548
- );
1549
- };
1550
-
1551
- // Handle Mark Task Done
1552
- const handleMarkTaskDone = async () => {
1553
- if (!taskId) {
1554
- toast.error("Please enter a task ID");
1555
- return;
1556
- }
1557
- if (!taskData) {
1558
- toast.error("Please enter task completion data (JSON)");
1559
- return;
1560
- }
1561
- try {
1562
- let parsedData;
1563
- try {
1564
- parsedData = JSON.parse(taskData);
1565
- } catch (e) {
1566
- toast.error("Invalid JSON format");
1567
- return;
1568
- }
1569
-
1570
- const result = await markTaskDoneMutation.mutateAsync({
1571
- taskId,
1572
- data: parsedData,
1573
- });
1574
- console.log("Task marked as done:", result);
1575
- setMarkResult(result);
1576
- toast.success(
1577
- "Task marked as done successfully! Check console for data."
1578
- );
1579
- } catch (error: any) {
1580
- console.error("Mark task done error:", error);
1581
- toast.error(`Mark task done failed: ${error.message}`);
1582
- }
1583
- };
1584
-
1585
- return (
1586
- <Card className="mb-6">
1587
- <CardHeader>
1588
- <CardTitle>Mark Task Done Test</CardTitle>
1589
- <CardDescription>Mark a task as completed</CardDescription>
1590
- </CardHeader>
1591
- <CardContent className="space-y-4">
1592
- <div className="space-y-2">
1593
- <Label htmlFor="taskId">Task ID</Label>
1594
- <div className="flex gap-2">
1595
- <Input
1596
- id="taskId"
1597
- value={taskId}
1598
- onChange={(e) => setTaskId(e.target.value)}
1599
- placeholder="Enter task ID"
1600
- />
1601
- <Button onClick={handleLoadExample} variant="outline" type="button">
1602
- Load Example
1603
- </Button>
1604
- </div>
1605
- <p className="text-xs text-muted-foreground">
1606
- Example:{" "}
1607
- <button
1608
- type="button"
1609
- onClick={handleLoadExample}
1610
- className="underline text-blue-600 hover:text-blue-800"
1611
- >
1612
- {DEFAULT_TASK_ID}
1613
- </button>
1614
- </p>
1615
- </div>
1616
-
1617
- <div className="space-y-2">
1618
- <Label htmlFor="taskData">Task Completion Data (JSON)</Label>
1619
- <textarea
1620
- id="taskData"
1621
- value={taskData}
1622
- onChange={(e) => setTaskData(e.target.value)}
1623
- placeholder="Enter task completion data as JSON"
1624
- className="w-full min-h-[150px] p-2 border rounded-md font-mono text-xs"
1625
- />
1626
- <p className="text-xs text-muted-foreground">
1627
- Example: Click "Load Example" button above to load sample data
1628
- </p>
1629
- </div>
1630
-
1631
- <div className="flex gap-4">
1632
- <Button
1633
- onClick={handleMarkTaskDone}
1634
- disabled={markTaskDoneMutation.isPending || !taskId || !taskData}
1635
- variant="default"
1636
- >
1637
- {markTaskDoneMutation.isPending ? "Marking..." : "Mark Task Done"}
1638
- </Button>
1639
- </div>
1640
-
1641
- {/* Status Messages */}
1642
- {markTaskDoneMutation.isError && (
1643
- <p className="text-red-500">
1644
- Mark Error: {markTaskDoneMutation.error?.message}
1645
- </p>
1646
- )}
1647
- {markTaskDoneMutation.isSuccess && markResult && (
1648
- <p className="text-green-500">✓ Task marked as done successfully</p>
1649
- )}
1650
-
1651
- {/* Mark Result Preview */}
1652
- {markResult && (
1653
- <div className="mt-4 p-4 bg-muted rounded-lg">
1654
- <p className="text-sm font-semibold mb-2">Task Result:</p>
1655
- <pre className="text-xs overflow-auto max-h-60">
1656
- {JSON.stringify(markResult, null, 2)}
1657
- </pre>
1658
- </div>
1659
- )}
1660
- </CardContent>
1661
- </Card>
1662
- );
1663
- }
1664
-
1665
- // Reassign Task Test Component
1666
- function ReassignTaskTestSection() {
1667
- const [taskId, setTaskId] = useState<string>("");
1668
- const [newAssignee, setNewAssignee] = useState<string>("");
1669
- const [assigneeType, setAssigneeType] = useState<"USER" | "TEAM">("USER");
1670
- const [reassignResult, setReassignResult] = useState<any>(null);
1671
-
1672
- // Reassign Task Hook
1673
- const reassignTaskMutation = useReassignTask();
1674
-
1675
- // Handle Load Example
1676
- const handleLoadExample = () => {
1677
- setTaskId(DEFAULT_TASK_ID);
1678
- setNewAssignee(DEFAULT_NEW_ASSIGNEE);
1679
- setAssigneeType("USER");
1680
- toast.info(
1681
- 'Example task ID and assignee loaded. Click "Reassign Task" to reassign.'
1682
- );
1683
- };
1684
-
1685
- // Handle Reassign Task
1686
- const handleReassignTask = async () => {
1687
- if (!taskId) {
1688
- toast.error("Please enter a task ID");
1689
- return;
1690
- }
1691
- if (!newAssignee) {
1692
- toast.error("Please enter a new assignee");
1693
- return;
1694
- }
1695
- try {
1696
- const result = await reassignTaskMutation.mutateAsync({
1697
- taskId,
1698
- newAssignee,
1699
- assigneeType,
1700
- });
1701
- console.log("Task reassigned:", result);
1702
- setReassignResult(result);
1703
- toast.success("Task reassigned successfully! Check console for data.");
1704
- } catch (error: any) {
1705
- console.error("Reassign task error:", error);
1706
- toast.error(`Reassign task failed: ${error.message}`);
1707
- }
1708
- };
1709
-
1710
- return (
1711
- <Card className="mb-6">
1712
- <CardHeader>
1713
- <CardTitle>Reassign Task Test</CardTitle>
1714
- <CardDescription>Reassign a task to a new assignee</CardDescription>
1715
- </CardHeader>
1716
- <CardContent className="space-y-4">
1717
- <div className="space-y-2">
1718
- <Label htmlFor="taskId">Task ID</Label>
1719
- <div className="flex gap-2">
1720
- <Input
1721
- id="taskId"
1722
- value={taskId}
1723
- onChange={(e) => setTaskId(e.target.value)}
1724
- placeholder="Enter task ID"
1725
- />
1726
- <Button onClick={handleLoadExample} variant="outline" type="button">
1727
- Load Example
1728
- </Button>
1729
- </div>
1730
- <p className="text-xs text-muted-foreground">
1731
- Example:{" "}
1732
- <button
1733
- type="button"
1734
- onClick={handleLoadExample}
1735
- className="underline text-blue-600 hover:text-blue-800"
1736
- >
1737
- {DEFAULT_TASK_ID}
1738
- </button>
1739
- </p>
1740
- </div>
1741
-
1742
- <div className="space-y-2">
1743
- <Label htmlFor="newAssignee">New Assignee</Label>
1744
- <Input
1745
- id="newAssignee"
1746
- value={newAssignee}
1747
- onChange={(e) => setNewAssignee(e.target.value)}
1748
- placeholder="Enter new assignee ID"
1749
- />
1750
- <p className="text-xs text-muted-foreground">
1751
- Example: {DEFAULT_NEW_ASSIGNEE}
1752
- </p>
1753
- </div>
1754
-
1755
- <div className="space-y-2">
1756
- <Label htmlFor="assigneeType">Assignee Type</Label>
1757
- <select
1758
- id="assigneeType"
1759
- value={assigneeType}
1760
- onChange={(e) => setAssigneeType(e.target.value as "USER" | "TEAM")}
1761
- className="w-full p-2 border rounded-md"
1762
- >
1763
- <option value="USER">USER</option>
1764
- <option value="TEAM">TEAM</option>
1765
- </select>
1766
- </div>
1767
-
1768
- <div className="flex gap-4">
1769
- <Button
1770
- onClick={handleReassignTask}
1771
- disabled={reassignTaskMutation.isPending || !taskId || !newAssignee}
1772
- variant="default"
1773
- >
1774
- {reassignTaskMutation.isPending
1775
- ? "Reassigning..."
1776
- : "Reassign Task"}
1777
- </Button>
1778
- </div>
1779
-
1780
- {/* Status Messages */}
1781
- {reassignTaskMutation.isError && (
1782
- <p className="text-red-500">
1783
- Reassign Error: {reassignTaskMutation.error?.message}
1784
- </p>
1785
- )}
1786
- {reassignTaskMutation.isSuccess && reassignResult && (
1787
- <p className="text-green-500">✓ Task reassigned successfully</p>
1788
- )}
1789
-
1790
- {/* Reassign Result Preview */}
1791
- {reassignResult && (
1792
- <div className="mt-4 p-4 bg-muted rounded-lg">
1793
- <p className="text-sm font-semibold mb-2">Task Result:</p>
1794
- <pre className="text-xs overflow-auto max-h-60">
1795
- {JSON.stringify(reassignResult, null, 2)}
1796
- </pre>
1797
- </div>
1798
- )}
1799
- </CardContent>
1800
- </Card>
1801
- );
1802
- }
1803
-
1804
- // Form Data Test Component
1805
- function FormDataTestSection() {
1806
- const [formId, setFormId] = useState<string>("");
1807
-
1808
- // Get Form Data Hook - disabled by default
1809
- const formDataQuery = useGetFormData(formId || null);
1810
-
1811
- // Handle Load Example
1812
- const handleLoadExample = () => {
1813
- setFormId(DEFAULT_FORM_ID);
1814
- toast.info('Example form ID loaded. Click "Get Form Data" to fetch.');
1815
- };
1816
-
1817
- // Handle Get Form Data
1818
- const handleGetFormData = async () => {
1819
- if (!formId) {
1820
- toast.error("Please enter a form ID");
1821
- return;
1822
- }
1823
- try {
1824
- const result = await formDataQuery.refetch();
1825
- if (result.data) {
1826
- console.log("Form data:", result.data);
1827
- toast.success("Form data loaded! Check console for data.");
1828
- }
1829
- } catch (error: any) {
1830
- toast.error(`Error: ${error.message}`);
1831
- }
1832
- };
1833
-
1834
- return (
1835
- <Card className="mb-6">
1836
- <CardHeader>
1837
- <CardTitle>Form Data Operations Test</CardTitle>
1838
- <CardDescription>Get form data by form ID</CardDescription>
1839
- </CardHeader>
1840
- <CardContent className="space-y-4">
1841
- <div className="space-y-2">
1842
- <Label htmlFor="formId">Form ID</Label>
1843
- <div className="flex gap-2">
1844
- <Input
1845
- id="formId"
1846
- value={formId}
1847
- onChange={(e) => setFormId(e.target.value)}
1848
- placeholder="Enter form ID"
1849
- />
1850
- <Button onClick={handleLoadExample} variant="outline" type="button">
1851
- Load Example
1852
- </Button>
1853
- </div>
1854
- <p className="text-xs text-muted-foreground">
1855
- Example:{" "}
1856
- <button
1857
- type="button"
1858
- onClick={handleLoadExample}
1859
- className="underline text-blue-600 hover:text-blue-800"
1860
- >
1861
- {DEFAULT_FORM_ID || "Enter form ID"}
1862
- </button>
1863
- </p>
1864
- </div>
1865
-
1866
- <div className="flex gap-4">
1867
- <Button
1868
- onClick={handleGetFormData}
1869
- disabled={formDataQuery.isLoading || !formId}
1870
- variant="default"
1871
- >
1872
- {formDataQuery.isLoading ? "Loading..." : "Get Form Data"}
1873
- </Button>
1874
- </div>
1875
-
1876
- {/* Status Messages */}
1877
- {formDataQuery.isError && (
1878
- <p className="text-red-500">
1879
- Get Error: {formDataQuery.error?.message}
1880
- </p>
1881
- )}
1882
- {formDataQuery.isSuccess && formDataQuery.data && (
1883
- <p className="text-green-500">✓ Form data loaded successfully</p>
1884
- )}
1885
-
1886
- {/* Form Data Preview */}
1887
- {formDataQuery.data && (
1888
- <div className="mt-4 p-4 bg-muted rounded-lg">
1889
- <p className="text-sm font-semibold mb-2">Form Data:</p>
1890
- <pre className="text-xs overflow-auto max-h-60">
1891
- {JSON.stringify(formDataQuery.data, null, 2)}
1892
- </pre>
1893
- </div>
1894
- )}
1895
- </CardContent>
1896
- </Card>
1897
- );
1898
- }
1899
-
1900
- // Get All Users Test Component
1901
- function GetAllUsersTestSection() {
1902
- const [usersResult, setUsersResult] = useState<any>(null);
1903
-
1904
- // Get All Users Hook - disabled by default
1905
- const usersQuery = useGetAllUsers({
1906
- enabled: false,
1907
- });
1908
-
1909
- // Handle Get All Users
1910
- const handleGetAllUsers = async () => {
1911
- try {
1912
- const result = await usersQuery.refetch();
1913
- if (result.data) {
1914
- setUsersResult(result.data);
1915
- console.log("Users:", result.data);
1916
- toast.success("Users loaded! Check console for data.");
1917
- }
1918
- } catch (error: any) {
1919
- toast.error(`Error: ${error.message}`);
1920
- }
1921
- };
1922
-
1923
- return (
1924
- <Card className="mb-6">
1925
- <CardHeader>
1926
- <CardTitle>Get All Users Test</CardTitle>
1927
- <CardDescription>Get all users in the current workspace</CardDescription>
1928
- </CardHeader>
1929
- <CardContent className="space-y-4">
1930
- <div className="flex gap-4">
1931
- <Button
1932
- onClick={handleGetAllUsers}
1933
- disabled={usersQuery.isLoading}
1934
- variant="default"
1935
- >
1936
- {usersQuery.isLoading ? "Loading..." : "Get All Users"}
1937
- </Button>
1938
- </div>
1939
-
1940
- {/* Status Messages */}
1941
- {usersQuery.isError && (
1942
- <p className="text-red-500">Get Error: {usersQuery.error?.message}</p>
1943
- )}
1944
- {usersQuery.isSuccess && usersResult && (
1945
- <p className="text-green-500">
1946
- ✓ Users loaded successfully (Count: {usersResult.length || 0})
1947
- </p>
1948
- )}
1949
-
1950
- {/* Users Result Preview */}
1951
- {usersResult && (
1952
- <div className="mt-4 p-4 bg-muted rounded-lg">
1953
- <p className="text-sm font-semibold mb-2">Users Result:</p>
1954
- <pre className="text-xs overflow-auto max-h-60">
1955
- {JSON.stringify(usersResult, null, 2)}
1956
- </pre>
1957
- </div>
1958
- )}
1959
- </CardContent>
1960
- </Card>
1961
- );
1962
- }
1963
-
1964
- // Get All HTTP Triggers Test Component
1965
- function GetAllHttpTriggersTestSection() {
1966
- const [triggersResult, setTriggersResult] = useState<any>(null);
1967
-
1968
- // Get All HTTP Triggers Hook - disabled by default
1969
- const triggersQuery = useGetAllHttpTriggers({
1970
- enabled: false,
1971
- });
1972
-
1973
- // Handle Get All HTTP Triggers
1974
- const handleGetAllHttpTriggers = async () => {
1975
- try {
1976
- const result = await triggersQuery.refetch();
1977
- if (result.data) {
1978
- setTriggersResult(result.data);
1979
- console.log("HTTP Triggers:", result.data);
1980
- toast.success("HTTP Triggers loaded! Check console for data.");
1981
- }
1982
- } catch (error: any) {
1983
- toast.error(`Error: ${error.message}`);
1984
- }
1985
- };
1986
-
1987
- return (
1988
- <Card className="mb-6">
1989
- <CardHeader>
1990
- <CardTitle>Get All HTTP Triggers Test</CardTitle>
1991
- <CardDescription>
1992
- Get all HTTP triggers (webhooks) in the current workspace
1993
- </CardDescription>
1994
- </CardHeader>
1995
- <CardContent className="space-y-4">
1996
- <div className="flex gap-4">
1997
- <Button
1998
- onClick={handleGetAllHttpTriggers}
1999
- disabled={triggersQuery.isLoading}
2000
- variant="default"
2001
- >
2002
- {triggersQuery.isLoading
2003
- ? "Loading..."
2004
- : "Get All HTTP Triggers"}
2005
- </Button>
2006
- </div>
2007
-
2008
- {/* Status Messages */}
2009
- {triggersQuery.isError && (
2010
- <p className="text-red-500">
2011
- Get Error: {triggersQuery.error?.message}
2012
- </p>
2013
- )}
2014
- {triggersQuery.isSuccess && triggersResult && (
2015
- <p className="text-green-500">
2016
- ✓ HTTP Triggers loaded successfully (Count:{" "}
2017
- {triggersResult.length || 0})
2018
- </p>
2019
- )}
2020
-
2021
- {/* HTTP Triggers Result Preview */}
2022
- {triggersResult && (
2023
- <div className="mt-4 p-4 bg-muted rounded-lg">
2024
- <p className="text-sm font-semibold mb-2">
2025
- HTTP Triggers Result:
2026
- </p>
2027
- <pre className="text-xs overflow-auto max-h-60">
2028
- {JSON.stringify(triggersResult, null, 2)}
2029
- </pre>
2030
- </div>
2031
- )}
2032
- </CardContent>
2033
- </Card>
2034
- );
2035
- }
2036
-
2037
- // Main API Test Page Component
2038
- export default function ApiTestPage() {
2039
- return (
2040
- <SidebarProvider
2041
- style={
2042
- {
2043
- "--sidebar-width": "calc(var(--spacing) * 72)",
2044
- "--header-height": "calc(var(--spacing) * 12)",
2045
- } as React.CSSProperties
2046
- }
2047
- >
2048
- <AppSidebar variant="inset" />
2049
- <SidebarInset>
2050
- <SiteHeader />
2051
- <div className="flex flex-1 flex-col">
2052
- <div className="@container/main flex flex-1 flex-col gap-6 p-6">
2053
- {/* Page Header */}
2054
- <div className="flex items-center justify-between">
2055
- <div>
2056
- <h1 className="text-3xl font-bold tracking-tight">
2057
- API Test Page
2058
- </h1>
2059
- <p className="text-muted-foreground">
2060
- Test various API endpoints and hooks. All calls are
2061
- user-initiated.
2062
- </p>
2063
- </div>
2064
- </div>
2065
-
2066
- {/* Workbook Test Section */}
2067
- <WorkbookTestSection />
2068
-
2069
- {/* Task Test Section */}
2070
- <TaskTestSection />
2071
-
2072
- {/* Run Recon Test Section */}
2073
- <RunReconTestSection />
2074
-
2075
- {/* File Upload/Download Test Section */}
2076
- <FileUploadTestSection />
2077
-
2078
- {/* Form Schema Test Section */}
2079
- <FormSchemaTestSection />
2080
-
2081
- {/* Form Data Test Section */}
2082
- <FormDataTestSection />
2083
-
2084
- {/* Get Audit Logs Test Section */}
2085
- <GetAuditLogsTestSection />
2086
-
2087
- {/* Create Audit Log Test Section */}
2088
- <CreateAuditLogTestSection />
2089
-
2090
- {/* Get All Templated Pipelines Test Section */}
2091
- <GetAllTemplatedPipelinesTestSection />
2092
-
2093
- {/* Get All Recon Test Section */}
2094
- <GetAllReconTestSection />
2095
-
2096
- {/* Get Form By ID Test Section */}
2097
- <GetFormByIdTestSection />
2098
-
2099
- {/* Create Or Update Form Test Section */}
2100
- <CreateOrUpdateFormTestSection />
2101
-
2102
- {/* Mark Task Done Test Section */}
2103
- <MarkTaskDoneTestSection />
2104
-
2105
- {/* Reassign Task Test Section */}
2106
- <ReassignTaskTestSection />
2107
-
2108
- {/* Get All Users Test Section */}
2109
- <GetAllUsersTestSection />
2110
-
2111
- {/* Get All HTTP Triggers Test Section */}
2112
- <GetAllHttpTriggersTestSection />
2113
- </div>
2114
- </div>
2115
- </SidebarInset>
2116
- </SidebarProvider>
2117
- );
2118
- }