generated from pascalmartineau/wp-skeleton
wip: refactor sections
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user