mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-26 22:54:54 +00:00
Migration complete for: - 5 atoms: Accordion, CopyButton, FileUpload, FilterInput, Image, Input, PasswordInput, Popover (8 total) - 1 molecule: BindingEditor Changes: - Deleted 9 legacy TSX files that have complete JSON equivalents - Exported BindingEditor from json-components.ts with useBindingEditor hook - Registered useBindingEditor in hooks-registry.ts - Updated all imports across codebase to use JSON-based components - Fixed build errors: schema-loader dynamic import, DataSourceGroupSection - Cleaned up component index exports Build status: ✅ PASSING - 0 TypeScript errors - All 9,408 modules transformed successfully - No blocking build warnings Next steps: - 3 organisms still need conversion: DataSourceManager, NavigationMenu, TreeListPanel - 120+ additional components have TSX versions (need individual migration) - 22 JSON components now available for use throughout the app Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
31 lines
912 B
TypeScript
31 lines
912 B
TypeScript
import { useState, useEffect } from 'react'
|
|
import { PageSchema } from '@/types/json-ui'
|
|
|
|
export function useSchemaLoader(schemaPath: string) {
|
|
const [schema, setSchema] = useState<PageSchema | null>(null)
|
|
const [loading, setLoading] = useState(true)
|
|
const [error, setError] = useState<string | null>(null)
|
|
|
|
useEffect(() => {
|
|
async function loadSchema() {
|
|
try {
|
|
setLoading(true)
|
|
setError(null)
|
|
|
|
// Dynamically import the JSON schema
|
|
const schemaModule = await import(`../config/pages/${schemaPath}.json`)
|
|
setSchema(schemaModule.default || schemaModule)
|
|
} catch (err) {
|
|
console.error(`[Schema Loader] Failed to load schema: ${schemaPath}`, err)
|
|
setError(`Failed to load page schema: ${schemaPath}`)
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}
|
|
|
|
loadSchema()
|
|
}, [schemaPath])
|
|
|
|
return { schema, loading, error }
|
|
}
|