[dyad] Fixing schema display build error - wrote 1 file(s)
This commit is contained in:
@@ -15,16 +15,19 @@ interface SchemaDisplayProps {
|
||||
}
|
||||
|
||||
export function SchemaDisplay({ schemas }: SchemaDisplayProps) {
|
||||
const groupedSchemas = schemas.reduce((acc, schema) => {
|
||||
const type = Array.isArray(schema["@type"])
|
||||
? schema["@type"].join(", ")
|
||||
: schema["@type"] || "Untyped";
|
||||
if (!acc[type]) {
|
||||
acc[type] = [];
|
||||
}
|
||||
acc[type].push(schema);
|
||||
return acc;
|
||||
}, {} as Record<string, any[]>);
|
||||
const groupedSchemas = schemas.reduce(
|
||||
(acc: Record<string, any[]>, schema: any) => {
|
||||
const type = Array.isArray(schema["@type"])
|
||||
? schema["@type"].join(", ")
|
||||
: schema["@type"] || "Untyped";
|
||||
if (!acc[type]) {
|
||||
acc[type] = [];
|
||||
}
|
||||
acc[type].push(schema);
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
const SchemaContent = ({ schema }: { schema: any }) => {
|
||||
const schemaJson = JSON.stringify(schema, null, 2);
|
||||
@@ -55,7 +58,7 @@ export function SchemaDisplay({ schemas }: SchemaDisplayProps) {
|
||||
</div>
|
||||
<Accordion type="multiple" className="w-full space-y-4">
|
||||
{Object.entries(groupedSchemas).map(
|
||||
([type, schemaGroup], groupIndex) => (
|
||||
([type, schemaGroup]: [string, any[]], groupIndex: number) => (
|
||||
<AccordionItem
|
||||
value={`group-${type}-${groupIndex}`}
|
||||
key={groupIndex}
|
||||
@@ -74,7 +77,7 @@ export function SchemaDisplay({ schemas }: SchemaDisplayProps) {
|
||||
type="multiple"
|
||||
className="w-full space-y-2"
|
||||
>
|
||||
{schemaGroup.map((schema, schemaIndex) => (
|
||||
{schemaGroup.map((schema: any, schemaIndex: number) => (
|
||||
<AccordionItem
|
||||
value={`schema-${groupIndex}-${schemaIndex}`}
|
||||
key={schemaIndex}
|
||||
|
||||
Reference in New Issue
Block a user