5c1c998b97
Render front components in a widget. https://github.com/user-attachments/assets/1ae130a4-070d-498e-88f7-80cee847e2fa --------- Co-authored-by: Charles Bochet <charles@twenty.com>
21 lines
556 B
TypeScript
21 lines
556 B
TypeScript
import { type PropertySchema } from '../schemas';
|
|
import { schemaTypeToConstructor } from './schema-type-to-constructor';
|
|
|
|
export const generatePropertiesConfig = (
|
|
properties: Record<string, PropertySchema>,
|
|
): string => {
|
|
const entries = Object.entries(properties);
|
|
if (entries.length === 0) {
|
|
return '{}';
|
|
}
|
|
|
|
const props = entries
|
|
.map(([name, schema]) => {
|
|
const constructorType = schemaTypeToConstructor(schema.type);
|
|
return `'${name}': { type: ${constructorType} }`;
|
|
})
|
|
.join(', ');
|
|
|
|
return `{ ${props} }`;
|
|
};
|