25 lines
633 B
TypeScript
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)
|
|
}
|