feat(api): add shop management clients

This commit is contained in:
zetaloop
2026-04-25 14:49:25 +08:00
parent e559204347
commit 358bfc7ac9
3 changed files with 193 additions and 7 deletions
+24
View File
@@ -0,0 +1,24 @@
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)
}