Files
juwan-frontend/lib/domain/shop-template.ts
T
2026-04-25 14:49:25 +08:00

25 lines
633 B
TypeScript

import type { Shop, ShopSection } from "@/lib/types"
const defaultSectionTypes: ShopSection["type"][] = [
"banner",
"intro",
"services",
"players",
"announcements",
"reviews",
]
export function getDefaultShopSections(): ShopSection[] {
return defaultSectionTypes.map((type, order) => ({
type,
enabled: true,
order,
}))
}
export function getShopSections(shop: Pick<Shop, "templateConfig">): ShopSection[] {
const sections = shop.templateConfig.sections
if (!Array.isArray(sections) || sections.length === 0) return getDefaultShopSections()
return [...sections].sort((a, b) => a.order - b.order)
}