feat(api): add shop management clients
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user