Files
cultureat-bak/wp-content/themes/ccat/shared/utils/sections-map.ts
Pascal Martineau 5ce55b5c33
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m6s
refactor: sections-map
2025-09-24 14:05:47 -04:00

16 lines
629 B
TypeScript

import SectionTextBlock from "~/components/sections/SectionTextBlock.vue";
import type { TheSectionFragment } from "#graphql-operations";
export const sectionsMap = {
GroupAbstractBuilderSectionsTextBlockLayout: SectionTextBlock,
} as const;
export type FieldGroupName = keyof typeof sectionsMap;
export function useSection(section: TheSectionFragment) {
const { fieldGroupName, ...attrs } = section;
const component = sectionsMap[fieldGroupName as FieldGroupName];
if (!component) throw createError({ statusCode: 500, statusMessage: "Erreur interne", message: "Section invalide." });
return { component, attrs };
}