@friggframework/devtools 2.0.0-next.61 → 2.0.0-next.62
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/package.json +14 -7
- package/.eslintrc.json +0 -3
- package/CHANGELOG.md +0 -132
- package/infrastructure/ARCHITECTURE.md +0 -487
- package/infrastructure/CLAUDE.md +0 -481
- package/infrastructure/HEALTH.md +0 -468
- package/infrastructure/README.md +0 -522
- package/infrastructure/__tests__/fixtures/mock-aws-resources.js +0 -391
- package/infrastructure/__tests__/helpers/test-utils.js +0 -277
- package/infrastructure/__tests__/postgres-config.test.js +0 -914
- package/infrastructure/__tests__/template-generation.test.js +0 -687
- package/infrastructure/create-frigg-infrastructure.js +0 -147
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +0 -630
- package/infrastructure/docs/PRE-DEPLOYMENT-HEALTH-CHECK-SPEC.md +0 -1317
- package/infrastructure/docs/WEBSOCKET-CONFIGURATION.md +0 -105
- package/infrastructure/docs/deployment-instructions.md +0 -268
- package/infrastructure/docs/generate-iam-command.md +0 -278
- package/infrastructure/docs/iam-policy-templates.md +0 -193
- package/infrastructure/domains/database/aurora-builder.js +0 -809
- package/infrastructure/domains/database/aurora-builder.test.js +0 -950
- package/infrastructure/domains/database/aurora-discovery.js +0 -87
- package/infrastructure/domains/database/aurora-discovery.test.js +0 -188
- package/infrastructure/domains/database/aurora-resolver.js +0 -210
- package/infrastructure/domains/database/aurora-resolver.test.js +0 -347
- package/infrastructure/domains/database/migration-builder.js +0 -701
- package/infrastructure/domains/database/migration-builder.test.js +0 -321
- package/infrastructure/domains/database/migration-resolver.js +0 -163
- package/infrastructure/domains/database/migration-resolver.test.js +0 -337
- package/infrastructure/domains/health/application/ports/IPropertyReconciler.js +0 -164
- package/infrastructure/domains/health/application/ports/IResourceDetector.js +0 -129
- package/infrastructure/domains/health/application/ports/IResourceImporter.js +0 -142
- package/infrastructure/domains/health/application/ports/IStackRepository.js +0 -131
- package/infrastructure/domains/health/application/ports/index.js +0 -26
- package/infrastructure/domains/health/application/use-cases/__tests__/execute-resource-import-use-case.test.js +0 -679
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +0 -167
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +0 -1130
- package/infrastructure/domains/health/application/use-cases/execute-resource-import-use-case.js +0 -221
- package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.js +0 -152
- package/infrastructure/domains/health/application/use-cases/reconcile-properties-use-case.test.js +0 -343
- package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.js +0 -535
- package/infrastructure/domains/health/application/use-cases/repair-via-import-use-case.test.js +0 -376
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.js +0 -213
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +0 -441
- package/infrastructure/domains/health/docs/ACME-DEV-DRIFT-ANALYSIS.md +0 -267
- package/infrastructure/domains/health/docs/BUILD-VS-DEPLOYED-TEMPLATE-ANALYSIS.md +0 -324
- package/infrastructure/domains/health/docs/ORPHAN-DETECTION-ANALYSIS.md +0 -386
- package/infrastructure/domains/health/docs/SPEC-CLEANUP-COMMAND.md +0 -1419
- package/infrastructure/domains/health/docs/TDD-IMPLEMENTATION-SUMMARY.md +0 -391
- package/infrastructure/domains/health/docs/TEMPLATE-COMPARISON-IMPLEMENTATION.md +0 -551
- package/infrastructure/domains/health/domain/entities/issue.js +0 -299
- package/infrastructure/domains/health/domain/entities/issue.test.js +0 -528
- package/infrastructure/domains/health/domain/entities/property-mismatch.js +0 -108
- package/infrastructure/domains/health/domain/entities/property-mismatch.test.js +0 -275
- package/infrastructure/domains/health/domain/entities/resource.js +0 -159
- package/infrastructure/domains/health/domain/entities/resource.test.js +0 -432
- package/infrastructure/domains/health/domain/entities/stack-health-report.js +0 -306
- package/infrastructure/domains/health/domain/entities/stack-health-report.test.js +0 -601
- package/infrastructure/domains/health/domain/services/__tests__/health-score-percentage-based.test.js +0 -380
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +0 -971
- package/infrastructure/domains/health/domain/services/__tests__/import-template-generator.test.js +0 -1150
- package/infrastructure/domains/health/domain/services/__tests__/logical-id-mapper.test.js +0 -672
- package/infrastructure/domains/health/domain/services/__tests__/template-parser.test.js +0 -496
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +0 -419
- package/infrastructure/domains/health/domain/services/health-score-calculator.js +0 -248
- package/infrastructure/domains/health/domain/services/health-score-calculator.test.js +0 -504
- package/infrastructure/domains/health/domain/services/import-progress-monitor.js +0 -195
- package/infrastructure/domains/health/domain/services/import-template-generator.js +0 -435
- package/infrastructure/domains/health/domain/services/logical-id-mapper.js +0 -345
- package/infrastructure/domains/health/domain/services/mismatch-analyzer.js +0 -234
- package/infrastructure/domains/health/domain/services/mismatch-analyzer.test.js +0 -431
- package/infrastructure/domains/health/domain/services/property-mutability-config.js +0 -382
- package/infrastructure/domains/health/domain/services/template-parser.js +0 -245
- package/infrastructure/domains/health/domain/services/update-progress-monitor.js +0 -192
- package/infrastructure/domains/health/domain/value-objects/health-score.js +0 -138
- package/infrastructure/domains/health/domain/value-objects/health-score.test.js +0 -267
- package/infrastructure/domains/health/domain/value-objects/property-mutability.js +0 -161
- package/infrastructure/domains/health/domain/value-objects/property-mutability.test.js +0 -198
- package/infrastructure/domains/health/domain/value-objects/resource-state.js +0 -167
- package/infrastructure/domains/health/domain/value-objects/resource-state.test.js +0 -196
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.js +0 -192
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.test.js +0 -262
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-cfn-tagged.test.js +0 -312
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-multi-stack.test.js +0 -367
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +0 -432
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.js +0 -784
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +0 -1133
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.js +0 -565
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -554
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.js +0 -318
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-importer.test.js +0 -398
- package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.js +0 -777
- package/infrastructure/domains/health/infrastructure/adapters/aws-stack-repository.test.js +0 -580
- package/infrastructure/domains/integration/integration-builder.js +0 -404
- package/infrastructure/domains/integration/integration-builder.test.js +0 -690
- package/infrastructure/domains/integration/integration-resolver.js +0 -170
- package/infrastructure/domains/integration/integration-resolver.test.js +0 -369
- package/infrastructure/domains/integration/websocket-builder.js +0 -69
- package/infrastructure/domains/integration/websocket-builder.test.js +0 -195
- package/infrastructure/domains/networking/vpc-builder.js +0 -2051
- package/infrastructure/domains/networking/vpc-builder.test.js +0 -1960
- package/infrastructure/domains/networking/vpc-discovery.js +0 -177
- package/infrastructure/domains/networking/vpc-discovery.test.js +0 -350
- package/infrastructure/domains/networking/vpc-resolver.js +0 -505
- package/infrastructure/domains/networking/vpc-resolver.test.js +0 -801
- package/infrastructure/domains/parameters/ssm-builder.js +0 -79
- package/infrastructure/domains/parameters/ssm-builder.test.js +0 -189
- package/infrastructure/domains/parameters/ssm-discovery.js +0 -84
- package/infrastructure/domains/parameters/ssm-discovery.test.js +0 -210
- package/infrastructure/domains/security/iam-generator.js +0 -816
- package/infrastructure/domains/security/iam-generator.test.js +0 -204
- package/infrastructure/domains/security/kms-builder.js +0 -415
- package/infrastructure/domains/security/kms-builder.test.js +0 -392
- package/infrastructure/domains/security/kms-discovery.js +0 -80
- package/infrastructure/domains/security/kms-discovery.test.js +0 -177
- package/infrastructure/domains/security/kms-resolver.js +0 -96
- package/infrastructure/domains/security/kms-resolver.test.js +0 -216
- package/infrastructure/domains/security/templates/frigg-deployment-iam-stack.yaml +0 -401
- package/infrastructure/domains/security/templates/iam-policy-basic.json +0 -218
- package/infrastructure/domains/security/templates/iam-policy-full.json +0 -288
- package/infrastructure/domains/shared/base-builder.js +0 -112
- package/infrastructure/domains/shared/base-resolver.js +0 -186
- package/infrastructure/domains/shared/base-resolver.test.js +0 -305
- package/infrastructure/domains/shared/builder-orchestrator.js +0 -212
- package/infrastructure/domains/shared/builder-orchestrator.test.js +0 -213
- package/infrastructure/domains/shared/cloudformation-discovery-v2.js +0 -334
- package/infrastructure/domains/shared/cloudformation-discovery.js +0 -672
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +0 -985
- package/infrastructure/domains/shared/environment-builder.js +0 -119
- package/infrastructure/domains/shared/environment-builder.test.js +0 -247
- package/infrastructure/domains/shared/providers/aws-provider-adapter.js +0 -579
- package/infrastructure/domains/shared/providers/aws-provider-adapter.test.js +0 -416
- package/infrastructure/domains/shared/providers/azure-provider-adapter.stub.js +0 -93
- package/infrastructure/domains/shared/providers/cloud-provider-adapter.js +0 -136
- package/infrastructure/domains/shared/providers/gcp-provider-adapter.stub.js +0 -82
- package/infrastructure/domains/shared/providers/provider-factory.js +0 -108
- package/infrastructure/domains/shared/providers/provider-factory.test.js +0 -170
- package/infrastructure/domains/shared/resource-discovery.enhanced.test.js +0 -306
- package/infrastructure/domains/shared/resource-discovery.js +0 -233
- package/infrastructure/domains/shared/resource-discovery.test.js +0 -588
- package/infrastructure/domains/shared/types/app-definition.js +0 -205
- package/infrastructure/domains/shared/types/discovery-result.js +0 -106
- package/infrastructure/domains/shared/types/discovery-result.test.js +0 -258
- package/infrastructure/domains/shared/types/index.js +0 -46
- package/infrastructure/domains/shared/types/resource-ownership.js +0 -108
- package/infrastructure/domains/shared/types/resource-ownership.test.js +0 -101
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +0 -394
- package/infrastructure/domains/shared/utilities/base-definition-factory.js.bak +0 -338
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +0 -291
- package/infrastructure/domains/shared/utilities/handler-path-resolver.js +0 -134
- package/infrastructure/domains/shared/utilities/handler-path-resolver.test.js +0 -268
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +0 -159
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +0 -444
- package/infrastructure/domains/shared/validation/env-validator.js +0 -78
- package/infrastructure/domains/shared/validation/env-validator.test.js +0 -173
- package/infrastructure/domains/shared/validation/plugin-validator.js +0 -187
- package/infrastructure/domains/shared/validation/plugin-validator.test.js +0 -323
- package/infrastructure/esbuild.config.js +0 -53
- package/infrastructure/index.js +0 -4
- package/infrastructure/infrastructure-composer.js +0 -117
- package/infrastructure/infrastructure-composer.test.js +0 -1895
- package/infrastructure/integration.test.js +0 -383
- package/infrastructure/scripts/build-prisma-layer.js +0 -701
- package/infrastructure/scripts/build-prisma-layer.test.js +0 -170
- package/infrastructure/scripts/build-time-discovery.js +0 -238
- package/infrastructure/scripts/build-time-discovery.test.js +0 -379
- package/infrastructure/scripts/run-discovery.js +0 -110
- package/infrastructure/scripts/verify-prisma-layer.js +0 -72
- package/layers/prisma/.build-complete +0 -3
- package/layers/prisma/nodejs/package.json +0 -8
- package/management-ui/.eslintrc.js +0 -22
- package/management-ui/components.json +0 -21
- package/management-ui/docs/phase2-integration-guide.md +0 -320
- package/management-ui/index.html +0 -13
- package/management-ui/package.json +0 -76
- package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +0 -302
- package/management-ui/postcss.config.js +0 -6
- package/management-ui/server/api/backend.js +0 -256
- package/management-ui/server/api/cli.js +0 -315
- package/management-ui/server/api/codegen.js +0 -663
- package/management-ui/server/api/connections.js +0 -857
- package/management-ui/server/api/discovery.js +0 -185
- package/management-ui/server/api/environment/index.js +0 -1
- package/management-ui/server/api/environment/router.js +0 -378
- package/management-ui/server/api/environment.js +0 -328
- package/management-ui/server/api/integrations.js +0 -876
- package/management-ui/server/api/logs.js +0 -248
- package/management-ui/server/api/monitoring.js +0 -282
- package/management-ui/server/api/open-ide.js +0 -31
- package/management-ui/server/api/project.js +0 -1029
- package/management-ui/server/api/users/sessions.js +0 -371
- package/management-ui/server/api/users/simulation.js +0 -254
- package/management-ui/server/api/users.js +0 -362
- package/management-ui/server/api-contract.md +0 -275
- package/management-ui/server/index.js +0 -873
- package/management-ui/server/middleware/errorHandler.js +0 -93
- package/management-ui/server/middleware/security.js +0 -32
- package/management-ui/server/processManager.js +0 -296
- package/management-ui/server/server.js +0 -346
- package/management-ui/server/services/aws-monitor.js +0 -413
- package/management-ui/server/services/npm-registry.js +0 -347
- package/management-ui/server/services/template-engine.js +0 -538
- package/management-ui/server/utils/cliIntegration.js +0 -220
- package/management-ui/server/utils/environment/auditLogger.js +0 -471
- package/management-ui/server/utils/environment/awsParameterStore.js +0 -275
- package/management-ui/server/utils/environment/encryption.js +0 -278
- package/management-ui/server/utils/environment/envFileManager.js +0 -286
- package/management-ui/server/utils/import-commonjs.js +0 -28
- package/management-ui/server/utils/response.js +0 -83
- package/management-ui/server/websocket/handler.js +0 -325
- package/management-ui/src/App.jsx +0 -25
- package/management-ui/src/assets/FriggLogo.svg +0 -1
- package/management-ui/src/components/AppRouter.jsx +0 -65
- package/management-ui/src/components/Button.jsx +0 -70
- package/management-ui/src/components/Card.jsx +0 -97
- package/management-ui/src/components/EnvironmentCompare.jsx +0 -400
- package/management-ui/src/components/EnvironmentEditor.jsx +0 -372
- package/management-ui/src/components/EnvironmentImportExport.jsx +0 -469
- package/management-ui/src/components/EnvironmentSchema.jsx +0 -491
- package/management-ui/src/components/EnvironmentSecurity.jsx +0 -463
- package/management-ui/src/components/ErrorBoundary.jsx +0 -73
- package/management-ui/src/components/IntegrationCard.jsx +0 -481
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +0 -770
- package/management-ui/src/components/IntegrationExplorer.jsx +0 -379
- package/management-ui/src/components/IntegrationStatus.jsx +0 -336
- package/management-ui/src/components/Layout.jsx +0 -716
- package/management-ui/src/components/LoadingSpinner.jsx +0 -113
- package/management-ui/src/components/RepositoryPicker.jsx +0 -248
- package/management-ui/src/components/SessionMonitor.jsx +0 -350
- package/management-ui/src/components/StatusBadge.jsx +0 -208
- package/management-ui/src/components/UserContextSwitcher.jsx +0 -212
- package/management-ui/src/components/UserSimulation.jsx +0 -327
- package/management-ui/src/components/Welcome.jsx +0 -434
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +0 -637
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +0 -227
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +0 -247
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +0 -316
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +0 -271
- package/management-ui/src/components/codegen/FormBuilder.jsx +0 -737
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +0 -855
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +0 -797
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +0 -303
- package/management-ui/src/components/codegen/TemplateSelector.jsx +0 -586
- package/management-ui/src/components/codegen/index.js +0 -10
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +0 -362
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +0 -182
- package/management-ui/src/components/connections/ConnectionTester.jsx +0 -200
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +0 -292
- package/management-ui/src/components/connections/OAuthFlow.jsx +0 -204
- package/management-ui/src/components/connections/index.js +0 -5
- package/management-ui/src/components/index.js +0 -21
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +0 -222
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +0 -169
- package/management-ui/src/components/monitoring/MetricsChart.jsx +0 -197
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +0 -393
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +0 -246
- package/management-ui/src/components/monitoring/index.js +0 -6
- package/management-ui/src/components/monitoring/monitoring.css +0 -218
- package/management-ui/src/components/theme-provider.jsx +0 -52
- package/management-ui/src/components/theme-toggle.jsx +0 -39
- package/management-ui/src/components/ui/badge.tsx +0 -36
- package/management-ui/src/components/ui/button.test.jsx +0 -56
- package/management-ui/src/components/ui/button.tsx +0 -57
- package/management-ui/src/components/ui/card.tsx +0 -76
- package/management-ui/src/components/ui/dropdown-menu.tsx +0 -199
- package/management-ui/src/components/ui/select.tsx +0 -157
- package/management-ui/src/components/ui/skeleton.jsx +0 -15
- package/management-ui/src/hooks/useFrigg.jsx +0 -387
- package/management-ui/src/hooks/useSocket.jsx +0 -58
- package/management-ui/src/index.css +0 -193
- package/management-ui/src/lib/utils.ts +0 -6
- package/management-ui/src/main.jsx +0 -10
- package/management-ui/src/pages/CodeGeneration.jsx +0 -14
- package/management-ui/src/pages/Connections.jsx +0 -252
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +0 -633
- package/management-ui/src/pages/Dashboard.jsx +0 -311
- package/management-ui/src/pages/Environment.jsx +0 -314
- package/management-ui/src/pages/IntegrationConfigure.jsx +0 -669
- package/management-ui/src/pages/IntegrationDiscovery.jsx +0 -567
- package/management-ui/src/pages/IntegrationTest.jsx +0 -742
- package/management-ui/src/pages/Integrations.jsx +0 -253
- package/management-ui/src/pages/Monitoring.jsx +0 -17
- package/management-ui/src/pages/Simulation.jsx +0 -155
- package/management-ui/src/pages/Users.jsx +0 -492
- package/management-ui/src/services/api.js +0 -41
- package/management-ui/src/services/apiModuleService.js +0 -193
- package/management-ui/src/services/websocket-handlers.js +0 -120
- package/management-ui/src/test/api/project.test.js +0 -273
- package/management-ui/src/test/components/Welcome.test.jsx +0 -378
- package/management-ui/src/test/mocks/server.js +0 -178
- package/management-ui/src/test/setup.js +0 -61
- package/management-ui/src/test/utils/test-utils.jsx +0 -134
- package/management-ui/src/utils/repository.js +0 -98
- package/management-ui/src/utils/repository.test.js +0 -118
- package/management-ui/src/workflows/phase2-integration-workflows.js +0 -884
- package/management-ui/tailwind.config.js +0 -63
- package/management-ui/tsconfig.json +0 -37
- package/management-ui/tsconfig.node.json +0 -10
- package/management-ui/vite.config.js +0 -26
- package/management-ui/vitest.config.js +0 -38
- package/test/auther-definition-method-tester.js +0 -45
- package/test/index.js +0 -9
- package/test/integration-validator.js +0 -2
- package/test/mock-api-readme.md +0 -102
- package/test/mock-api.js +0 -284
- package/test/mock-integration.js +0 -78
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
-
import { Card } from '../Card';
|
|
3
|
-
import { Button } from '../Button';
|
|
4
|
-
|
|
5
|
-
const CodePreviewEditor = ({ code, metadata, onChange }) => {
|
|
6
|
-
const [selectedFile, setSelectedFile] = useState(null);
|
|
7
|
-
const [editableCode, setEditableCode] = useState({});
|
|
8
|
-
const [showPreview, setShowPreview] = useState(true);
|
|
9
|
-
|
|
10
|
-
// Extract files from metadata or code
|
|
11
|
-
const files = useMemo(() => {
|
|
12
|
-
if (metadata?.files) {
|
|
13
|
-
return metadata.files;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// If no files in metadata, create a single file from code
|
|
17
|
-
if (typeof code === 'string') {
|
|
18
|
-
return [{ name: 'index.js', content: code }];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// If code is an object with multiple files
|
|
22
|
-
if (typeof code === 'object' && code !== null) {
|
|
23
|
-
return Object.entries(code).map(([name, content]) => ({
|
|
24
|
-
name: name.endsWith('.js') ? name : `${name}.js`,
|
|
25
|
-
content: typeof content === 'string' ? content : JSON.stringify(content, null, 2)
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return [];
|
|
30
|
-
}, [code, metadata]);
|
|
31
|
-
|
|
32
|
-
// Initialize selected file
|
|
33
|
-
React.useEffect(() => {
|
|
34
|
-
if (files.length > 0 && !selectedFile) {
|
|
35
|
-
setSelectedFile(files[0].name);
|
|
36
|
-
}
|
|
37
|
-
}, [files, selectedFile]);
|
|
38
|
-
|
|
39
|
-
const handleCodeChange = useCallback((fileName, newContent) => {
|
|
40
|
-
setEditableCode(prev => ({
|
|
41
|
-
...prev,
|
|
42
|
-
[fileName]: newContent
|
|
43
|
-
}));
|
|
44
|
-
|
|
45
|
-
// Notify parent component of changes
|
|
46
|
-
if (onChange) {
|
|
47
|
-
const updatedFiles = files.map(file =>
|
|
48
|
-
file.name === fileName
|
|
49
|
-
? { ...file, content: newContent }
|
|
50
|
-
: file
|
|
51
|
-
);
|
|
52
|
-
onChange(updatedFiles);
|
|
53
|
-
}
|
|
54
|
-
}, [files, onChange]);
|
|
55
|
-
|
|
56
|
-
const getCurrentContent = useCallback((fileName) => {
|
|
57
|
-
return editableCode[fileName] ?? files.find(f => f.name === fileName)?.content ?? '';
|
|
58
|
-
}, [editableCode, files]);
|
|
59
|
-
|
|
60
|
-
const getFileIcon = (fileName) => {
|
|
61
|
-
const ext = fileName.split('.').pop()?.toLowerCase();
|
|
62
|
-
switch (ext) {
|
|
63
|
-
case 'js':
|
|
64
|
-
return '📄';
|
|
65
|
-
case 'json':
|
|
66
|
-
return '📋';
|
|
67
|
-
case 'md':
|
|
68
|
-
return '📝';
|
|
69
|
-
case 'yml':
|
|
70
|
-
case 'yaml':
|
|
71
|
-
return '⚙️';
|
|
72
|
-
case 'env':
|
|
73
|
-
return '🔐';
|
|
74
|
-
default:
|
|
75
|
-
return '📄';
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const getLanguage = (fileName) => {
|
|
80
|
-
const ext = fileName.split('.').pop()?.toLowerCase();
|
|
81
|
-
switch (ext) {
|
|
82
|
-
case 'js':
|
|
83
|
-
return 'javascript';
|
|
84
|
-
case 'json':
|
|
85
|
-
return 'json';
|
|
86
|
-
case 'md':
|
|
87
|
-
return 'markdown';
|
|
88
|
-
case 'yml':
|
|
89
|
-
case 'yaml':
|
|
90
|
-
return 'yaml';
|
|
91
|
-
case 'env':
|
|
92
|
-
return 'bash';
|
|
93
|
-
default:
|
|
94
|
-
return 'text';
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const formatCode = (content, language) => {
|
|
99
|
-
// Simple syntax highlighting for demonstration
|
|
100
|
-
// In a real implementation, you'd use a proper syntax highlighter like Prism.js
|
|
101
|
-
if (language === 'javascript') {
|
|
102
|
-
return content
|
|
103
|
-
.replace(/(\/\/.*$)/gm, '<span style="color: #008000;">$1</span>')
|
|
104
|
-
.replace(/(\/\*[\s\S]*?\*\/)/g, '<span style="color: #008000;">$1</span>')
|
|
105
|
-
.replace(/\b(const|let|var|function|class|if|else|for|while|return|import|export|require|module)\b/g, '<span style="color: #0000FF;">$1</span>')
|
|
106
|
-
.replace(/(['"`])((?:(?!\1)[^\\]|\\.)*)(\1)/g, '<span style="color: #A31515;">$1$2$3</span>');
|
|
107
|
-
}
|
|
108
|
-
return content;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const downloadFile = (fileName) => {
|
|
112
|
-
const content = getCurrentContent(fileName);
|
|
113
|
-
const blob = new Blob([content], { type: 'text/plain' });
|
|
114
|
-
const url = URL.createObjectURL(blob);
|
|
115
|
-
const a = document.createElement('a');
|
|
116
|
-
a.href = url;
|
|
117
|
-
a.download = fileName;
|
|
118
|
-
document.body.appendChild(a);
|
|
119
|
-
a.click();
|
|
120
|
-
document.body.removeChild(a);
|
|
121
|
-
URL.revokeObjectURL(url);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const downloadAll = () => {
|
|
125
|
-
const zip = files.map(file => ({
|
|
126
|
-
name: file.name,
|
|
127
|
-
content: getCurrentContent(file.name)
|
|
128
|
-
}));
|
|
129
|
-
|
|
130
|
-
// In a real implementation, you'd use a library like JSZip
|
|
131
|
-
const contents = zip.map(file => `// File: ${file.name}\n${file.content}`).join('\n\n' + '='.repeat(50) + '\n\n');
|
|
132
|
-
const blob = new Blob([contents], { type: 'text/plain' });
|
|
133
|
-
const url = URL.createObjectURL(blob);
|
|
134
|
-
const a = document.createElement('a');
|
|
135
|
-
a.href = url;
|
|
136
|
-
a.download = `${metadata?.name || 'generated-code'}.txt`;
|
|
137
|
-
document.body.appendChild(a);
|
|
138
|
-
a.click();
|
|
139
|
-
document.body.removeChild(a);
|
|
140
|
-
URL.revokeObjectURL(url);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
if (files.length === 0) {
|
|
144
|
-
return (
|
|
145
|
-
<Card className="p-8">
|
|
146
|
-
<div className="text-center text-gray-500">
|
|
147
|
-
<svg className="w-12 h-12 mx-auto mb-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
148
|
-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
|
149
|
-
</svg>
|
|
150
|
-
<p>No code generated yet</p>
|
|
151
|
-
<p className="text-sm mt-1">Configure your settings and generate code to see a preview</p>
|
|
152
|
-
</div>
|
|
153
|
-
</Card>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<div className="space-y-4">
|
|
159
|
-
{/* Header */}
|
|
160
|
-
<div className="flex justify-between items-center">
|
|
161
|
-
<h3 className="text-lg font-medium">Code Preview & Editor</h3>
|
|
162
|
-
<div className="flex space-x-2">
|
|
163
|
-
<div className="flex border rounded-md">
|
|
164
|
-
<button
|
|
165
|
-
onClick={() => setShowPreview(true)}
|
|
166
|
-
className={`px-3 py-1 text-sm ${showPreview ? 'bg-blue-600 text-white' : 'text-gray-600'}`}
|
|
167
|
-
>
|
|
168
|
-
Preview
|
|
169
|
-
</button>
|
|
170
|
-
<button
|
|
171
|
-
onClick={() => setShowPreview(false)}
|
|
172
|
-
className={`px-3 py-1 text-sm ${!showPreview ? 'bg-blue-600 text-white' : 'text-gray-600'}`}
|
|
173
|
-
>
|
|
174
|
-
Edit
|
|
175
|
-
</button>
|
|
176
|
-
</div>
|
|
177
|
-
<Button onClick={downloadAll} size="sm">
|
|
178
|
-
Download All
|
|
179
|
-
</Button>
|
|
180
|
-
</div>
|
|
181
|
-
</div>
|
|
182
|
-
|
|
183
|
-
<div className="grid grid-cols-1 lg:grid-cols-4 gap-4">
|
|
184
|
-
{/* File Explorer */}
|
|
185
|
-
<div className="lg:col-span-1">
|
|
186
|
-
<Card className="p-4">
|
|
187
|
-
<h4 className="font-medium mb-3">Files ({files.length})</h4>
|
|
188
|
-
<div className="space-y-1">
|
|
189
|
-
{files.map((file) => (
|
|
190
|
-
<div
|
|
191
|
-
key={file.name}
|
|
192
|
-
onClick={() => setSelectedFile(file.name)}
|
|
193
|
-
className={`flex items-center justify-between p-2 rounded cursor-pointer transition-colors ${
|
|
194
|
-
selectedFile === file.name
|
|
195
|
-
? 'bg-blue-100 text-blue-800'
|
|
196
|
-
: 'hover:bg-gray-100'
|
|
197
|
-
}`}
|
|
198
|
-
>
|
|
199
|
-
<div className="flex items-center">
|
|
200
|
-
<span className="mr-2">{getFileIcon(file.name)}</span>
|
|
201
|
-
<span className="text-sm truncate">{file.name}</span>
|
|
202
|
-
</div>
|
|
203
|
-
<button
|
|
204
|
-
onClick={(e) => {
|
|
205
|
-
e.stopPropagation();
|
|
206
|
-
downloadFile(file.name);
|
|
207
|
-
}}
|
|
208
|
-
className="text-gray-400 hover:text-gray-600"
|
|
209
|
-
title="Download file"
|
|
210
|
-
>
|
|
211
|
-
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
212
|
-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 10v6m0 0l-3-3m3 3l3-3M3 17V7a2 2 0 012-2h6l2 2h6a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2z" />
|
|
213
|
-
</svg>
|
|
214
|
-
</button>
|
|
215
|
-
</div>
|
|
216
|
-
))}
|
|
217
|
-
</div>
|
|
218
|
-
</Card>
|
|
219
|
-
</div>
|
|
220
|
-
|
|
221
|
-
{/* Code Display */}
|
|
222
|
-
<div className="lg:col-span-3">
|
|
223
|
-
{selectedFile && (
|
|
224
|
-
<Card className="p-0 overflow-hidden">
|
|
225
|
-
<div className="bg-gray-50 px-4 py-2 border-b flex justify-between items-center">
|
|
226
|
-
<div className="flex items-center">
|
|
227
|
-
<span className="mr-2">{getFileIcon(selectedFile)}</span>
|
|
228
|
-
<span className="font-medium">{selectedFile}</span>
|
|
229
|
-
<span className="ml-2 text-sm text-gray-500">
|
|
230
|
-
({getLanguage(selectedFile)})
|
|
231
|
-
</span>
|
|
232
|
-
</div>
|
|
233
|
-
<div className="text-sm text-gray-500">
|
|
234
|
-
{getCurrentContent(selectedFile).split('\n').length} lines
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
|
|
238
|
-
<div className="p-0">
|
|
239
|
-
{showPreview ? (
|
|
240
|
-
<pre className="p-4 bg-gray-900 text-gray-100 overflow-x-auto text-sm">
|
|
241
|
-
<code
|
|
242
|
-
dangerouslySetInnerHTML={{
|
|
243
|
-
__html: formatCode(getCurrentContent(selectedFile), getLanguage(selectedFile))
|
|
244
|
-
}}
|
|
245
|
-
/>
|
|
246
|
-
</pre>
|
|
247
|
-
) : (
|
|
248
|
-
<textarea
|
|
249
|
-
value={getCurrentContent(selectedFile)}
|
|
250
|
-
onChange={(e) => handleCodeChange(selectedFile, e.target.value)}
|
|
251
|
-
className="w-full h-96 p-4 font-mono text-sm border-0 resize-none focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
252
|
-
style={{ tabSize: 2 }}
|
|
253
|
-
/>
|
|
254
|
-
)}
|
|
255
|
-
</div>
|
|
256
|
-
</Card>
|
|
257
|
-
)}
|
|
258
|
-
</div>
|
|
259
|
-
</div>
|
|
260
|
-
|
|
261
|
-
{/* File Stats */}
|
|
262
|
-
<Card className="p-4">
|
|
263
|
-
<h4 className="font-medium mb-2">Generation Summary</h4>
|
|
264
|
-
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 text-center">
|
|
265
|
-
<div>
|
|
266
|
-
<div className="text-2xl font-bold text-blue-600">{files.length}</div>
|
|
267
|
-
<div className="text-sm text-gray-500">Files</div>
|
|
268
|
-
</div>
|
|
269
|
-
<div>
|
|
270
|
-
<div className="text-2xl font-bold text-green-600">
|
|
271
|
-
{files.reduce((total, file) => total + getCurrentContent(file.name).split('\n').length, 0)}
|
|
272
|
-
</div>
|
|
273
|
-
<div className="text-sm text-gray-500">Lines</div>
|
|
274
|
-
</div>
|
|
275
|
-
<div>
|
|
276
|
-
<div className="text-2xl font-bold text-purple-600">
|
|
277
|
-
{Math.round(files.reduce((total, file) => total + getCurrentContent(file.name).length, 0) / 1024)}K
|
|
278
|
-
</div>
|
|
279
|
-
<div className="text-sm text-gray-500">Characters</div>
|
|
280
|
-
</div>
|
|
281
|
-
<div>
|
|
282
|
-
<div className="text-2xl font-bold text-orange-600">
|
|
283
|
-
{metadata?.type || 'Generated'}
|
|
284
|
-
</div>
|
|
285
|
-
<div className="text-sm text-gray-500">Type</div>
|
|
286
|
-
</div>
|
|
287
|
-
</div>
|
|
288
|
-
</Card>
|
|
289
|
-
|
|
290
|
-
{/* Validation Messages */}
|
|
291
|
-
{metadata?.validationErrors && metadata.validationErrors.length > 0 && (
|
|
292
|
-
<Card className="p-4 border-red-200 bg-red-50">
|
|
293
|
-
<h4 className="font-medium text-red-800 mb-2">Validation Errors</h4>
|
|
294
|
-
<ul className="list-disc list-inside text-sm text-red-700 space-y-1">
|
|
295
|
-
{metadata.validationErrors.map((error, index) => (
|
|
296
|
-
<li key={index}>{error}</li>
|
|
297
|
-
))}
|
|
298
|
-
</ul>
|
|
299
|
-
</Card>
|
|
300
|
-
)}
|
|
301
|
-
|
|
302
|
-
{/* Tips */}
|
|
303
|
-
<Card className="p-4 bg-blue-50 border-blue-200">
|
|
304
|
-
<h4 className="font-medium text-blue-800 mb-2">💡 Tips</h4>
|
|
305
|
-
<ul className="text-sm text-blue-700 space-y-1">
|
|
306
|
-
<li>• Switch between Preview and Edit modes to review or modify generated code</li>
|
|
307
|
-
<li>• Download individual files or all files as a bundle</li>
|
|
308
|
-
<li>• Changes made in edit mode will be included in the final generation</li>
|
|
309
|
-
<li>• Use the file explorer to navigate between generated files</li>
|
|
310
|
-
</ul>
|
|
311
|
-
</Card>
|
|
312
|
-
</div>
|
|
313
|
-
);
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
export default CodePreviewEditor;
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from 'react';
|
|
2
|
-
import { Card } from '../Card';
|
|
3
|
-
import { Button } from '../Button';
|
|
4
|
-
|
|
5
|
-
const DynamicModuleForm = ({ moduleDetails, onSubmit, initialValues = {} }) => {
|
|
6
|
-
const [formValues, setFormValues] = useState(initialValues);
|
|
7
|
-
const [errors, setErrors] = useState({});
|
|
8
|
-
|
|
9
|
-
// Initialize form values when module details change
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (moduleDetails?.requiredFields) {
|
|
12
|
-
const defaultValues = {};
|
|
13
|
-
moduleDetails.requiredFields.forEach(field => {
|
|
14
|
-
defaultValues[field.name] = initialValues[field.name] || field.default || '';
|
|
15
|
-
});
|
|
16
|
-
setFormValues(prev => ({ ...defaultValues, ...prev }));
|
|
17
|
-
}
|
|
18
|
-
}, [moduleDetails, initialValues]);
|
|
19
|
-
|
|
20
|
-
const handleInputChange = (fieldName, value) => {
|
|
21
|
-
setFormValues(prev => ({
|
|
22
|
-
...prev,
|
|
23
|
-
[fieldName]: value
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
// Clear error for this field
|
|
27
|
-
if (errors[fieldName]) {
|
|
28
|
-
setErrors(prev => {
|
|
29
|
-
const newErrors = { ...prev };
|
|
30
|
-
delete newErrors[fieldName];
|
|
31
|
-
return newErrors;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const validateForm = () => {
|
|
37
|
-
const newErrors = {};
|
|
38
|
-
|
|
39
|
-
if (!moduleDetails?.requiredFields) return true;
|
|
40
|
-
|
|
41
|
-
moduleDetails.requiredFields.forEach(field => {
|
|
42
|
-
if (field.required && !formValues[field.name]) {
|
|
43
|
-
newErrors[field.name] = `${field.label} is required`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Additional validation based on field type
|
|
47
|
-
if (formValues[field.name]) {
|
|
48
|
-
switch (field.type) {
|
|
49
|
-
case 'url':
|
|
50
|
-
if (!isValidUrl(formValues[field.name])) {
|
|
51
|
-
newErrors[field.name] = `${field.label} must be a valid URL`;
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
case 'email':
|
|
55
|
-
if (!isValidEmail(formValues[field.name])) {
|
|
56
|
-
newErrors[field.name] = `${field.label} must be a valid email`;
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case 'number':
|
|
60
|
-
if (isNaN(formValues[field.name])) {
|
|
61
|
-
newErrors[field.name] = `${field.label} must be a number`;
|
|
62
|
-
}
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
setErrors(newErrors);
|
|
69
|
-
return Object.keys(newErrors).length === 0;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const handleSubmit = (e) => {
|
|
73
|
-
e.preventDefault();
|
|
74
|
-
if (validateForm()) {
|
|
75
|
-
onSubmit(formValues);
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const isValidUrl = (string) => {
|
|
80
|
-
try {
|
|
81
|
-
new URL(string);
|
|
82
|
-
return true;
|
|
83
|
-
} catch (_) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const isValidEmail = (email) => {
|
|
89
|
-
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const renderField = (field) => {
|
|
93
|
-
const fieldId = `field-${field.name}`;
|
|
94
|
-
const hasError = !!errors[field.name];
|
|
95
|
-
|
|
96
|
-
switch (field.type) {
|
|
97
|
-
case 'password':
|
|
98
|
-
return (
|
|
99
|
-
<div key={field.name} className="space-y-2">
|
|
100
|
-
<label htmlFor={fieldId} className="block text-sm font-medium text-gray-700">
|
|
101
|
-
{field.label}
|
|
102
|
-
{field.required && <span className="text-red-500 ml-1">*</span>}
|
|
103
|
-
</label>
|
|
104
|
-
<input
|
|
105
|
-
id={fieldId}
|
|
106
|
-
type="password"
|
|
107
|
-
value={formValues[field.name] || ''}
|
|
108
|
-
onChange={(e) => handleInputChange(field.name, e.target.value)}
|
|
109
|
-
placeholder={field.placeholder || `Enter ${field.label.toLowerCase()}`}
|
|
110
|
-
className={`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 ${
|
|
111
|
-
hasError
|
|
112
|
-
? 'border-red-300 focus:ring-red-500'
|
|
113
|
-
: 'border-gray-300 focus:ring-blue-500'
|
|
114
|
-
}`}
|
|
115
|
-
/>
|
|
116
|
-
{hasError && (
|
|
117
|
-
<p className="text-sm text-red-600">{errors[field.name]}</p>
|
|
118
|
-
)}
|
|
119
|
-
{field.hint && (
|
|
120
|
-
<p className="text-sm text-gray-500">{field.hint}</p>
|
|
121
|
-
)}
|
|
122
|
-
</div>
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
case 'select':
|
|
126
|
-
return (
|
|
127
|
-
<div key={field.name} className="space-y-2">
|
|
128
|
-
<label htmlFor={fieldId} className="block text-sm font-medium text-gray-700">
|
|
129
|
-
{field.label}
|
|
130
|
-
{field.required && <span className="text-red-500 ml-1">*</span>}
|
|
131
|
-
</label>
|
|
132
|
-
<select
|
|
133
|
-
id={fieldId}
|
|
134
|
-
value={formValues[field.name] || ''}
|
|
135
|
-
onChange={(e) => handleInputChange(field.name, e.target.value)}
|
|
136
|
-
className={`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 ${
|
|
137
|
-
hasError
|
|
138
|
-
? 'border-red-300 focus:ring-red-500'
|
|
139
|
-
: 'border-gray-300 focus:ring-blue-500'
|
|
140
|
-
}`}
|
|
141
|
-
>
|
|
142
|
-
<option value="">Select {field.label}</option>
|
|
143
|
-
{field.options?.map(option => (
|
|
144
|
-
<option key={option.value} value={option.value}>
|
|
145
|
-
{option.label}
|
|
146
|
-
</option>
|
|
147
|
-
))}
|
|
148
|
-
</select>
|
|
149
|
-
{hasError && (
|
|
150
|
-
<p className="text-sm text-red-600">{errors[field.name]}</p>
|
|
151
|
-
)}
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
case 'boolean':
|
|
156
|
-
return (
|
|
157
|
-
<div key={field.name} className="space-y-2">
|
|
158
|
-
<label className="flex items-center space-x-3">
|
|
159
|
-
<input
|
|
160
|
-
type="checkbox"
|
|
161
|
-
checked={formValues[field.name] || false}
|
|
162
|
-
onChange={(e) => handleInputChange(field.name, e.target.checked)}
|
|
163
|
-
className="h-4 w-4 text-blue-600 rounded focus:ring-blue-500"
|
|
164
|
-
/>
|
|
165
|
-
<span className="text-sm font-medium text-gray-700">
|
|
166
|
-
{field.label}
|
|
167
|
-
{field.required && <span className="text-red-500 ml-1">*</span>}
|
|
168
|
-
</span>
|
|
169
|
-
</label>
|
|
170
|
-
{field.hint && (
|
|
171
|
-
<p className="text-sm text-gray-500 ml-7">{field.hint}</p>
|
|
172
|
-
)}
|
|
173
|
-
</div>
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
case 'textarea':
|
|
177
|
-
return (
|
|
178
|
-
<div key={field.name} className="space-y-2">
|
|
179
|
-
<label htmlFor={fieldId} className="block text-sm font-medium text-gray-700">
|
|
180
|
-
{field.label}
|
|
181
|
-
{field.required && <span className="text-red-500 ml-1">*</span>}
|
|
182
|
-
</label>
|
|
183
|
-
<textarea
|
|
184
|
-
id={fieldId}
|
|
185
|
-
value={formValues[field.name] || ''}
|
|
186
|
-
onChange={(e) => handleInputChange(field.name, e.target.value)}
|
|
187
|
-
placeholder={field.placeholder || `Enter ${field.label.toLowerCase()}`}
|
|
188
|
-
rows={field.rows || 3}
|
|
189
|
-
className={`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 ${
|
|
190
|
-
hasError
|
|
191
|
-
? 'border-red-300 focus:ring-red-500'
|
|
192
|
-
: 'border-gray-300 focus:ring-blue-500'
|
|
193
|
-
}`}
|
|
194
|
-
/>
|
|
195
|
-
{hasError && (
|
|
196
|
-
<p className="text-sm text-red-600">{errors[field.name]}</p>
|
|
197
|
-
)}
|
|
198
|
-
</div>
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
default:
|
|
202
|
-
return (
|
|
203
|
-
<div key={field.name} className="space-y-2">
|
|
204
|
-
<label htmlFor={fieldId} className="block text-sm font-medium text-gray-700">
|
|
205
|
-
{field.label}
|
|
206
|
-
{field.required && <span className="text-red-500 ml-1">*</span>}
|
|
207
|
-
</label>
|
|
208
|
-
<input
|
|
209
|
-
id={fieldId}
|
|
210
|
-
type={field.type || 'text'}
|
|
211
|
-
value={formValues[field.name] || ''}
|
|
212
|
-
onChange={(e) => handleInputChange(field.name, e.target.value)}
|
|
213
|
-
placeholder={field.placeholder || `Enter ${field.label.toLowerCase()}`}
|
|
214
|
-
className={`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 ${
|
|
215
|
-
hasError
|
|
216
|
-
? 'border-red-300 focus:ring-red-500'
|
|
217
|
-
: 'border-gray-300 focus:ring-blue-500'
|
|
218
|
-
}`}
|
|
219
|
-
/>
|
|
220
|
-
{hasError && (
|
|
221
|
-
<p className="text-sm text-red-600">{errors[field.name]}</p>
|
|
222
|
-
)}
|
|
223
|
-
{field.hint && (
|
|
224
|
-
<p className="text-sm text-gray-500">{field.hint}</p>
|
|
225
|
-
)}
|
|
226
|
-
</div>
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
if (!moduleDetails) {
|
|
232
|
-
return (
|
|
233
|
-
<Card className="p-6">
|
|
234
|
-
<p className="text-gray-500 text-center">No module selected</p>
|
|
235
|
-
</Card>
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
const requiredFields = moduleDetails.requiredFields || [];
|
|
240
|
-
const optionalFields = moduleDetails.optionalFields || [];
|
|
241
|
-
|
|
242
|
-
return (
|
|
243
|
-
<form onSubmit={handleSubmit} className="space-y-6">
|
|
244
|
-
{requiredFields.length > 0 && (
|
|
245
|
-
<div>
|
|
246
|
-
<h4 className="text-lg font-medium text-gray-900 mb-4">Required Configuration</h4>
|
|
247
|
-
<div className="space-y-4">
|
|
248
|
-
{requiredFields.map(field => renderField(field))}
|
|
249
|
-
</div>
|
|
250
|
-
</div>
|
|
251
|
-
)}
|
|
252
|
-
|
|
253
|
-
{optionalFields.length > 0 && (
|
|
254
|
-
<div>
|
|
255
|
-
<h4 className="text-lg font-medium text-gray-900 mb-4">Optional Configuration</h4>
|
|
256
|
-
<div className="space-y-4">
|
|
257
|
-
{optionalFields.map(field => renderField(field))}
|
|
258
|
-
</div>
|
|
259
|
-
</div>
|
|
260
|
-
)}
|
|
261
|
-
|
|
262
|
-
<div className="flex justify-end space-x-3">
|
|
263
|
-
<Button type="submit" className="bg-blue-600 hover:bg-blue-700">
|
|
264
|
-
Generate Configuration
|
|
265
|
-
</Button>
|
|
266
|
-
</div>
|
|
267
|
-
</form>
|
|
268
|
-
);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
export default DynamicModuleForm;
|