refactor: sections-map
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m6s

This commit is contained in:
2025-09-24 14:05:47 -04:00
parent 0bffe2768d
commit 5ce55b5c33
5 changed files with 20 additions and 20 deletions

View File

@@ -0,0 +1,15 @@
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 };
}