Initialize the API and add managed app banners.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-09 17:08:47 +03:30
co-authored by Cursor
commit b15fefe438
158 changed files with 25624 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
import type { PrismaService } from '../prisma/prisma.service'
export const USAGE_CATEGORIES = [
{ id: 'trousers', title: 'پارچه‌های شلواری', subtitle: 'مشاهده محصولات' },
{ id: 'suit', title: 'پارچه‌های کت‌شلواری', subtitle: 'مشاهده محصولات' },
{ id: 'shirt', title: 'پارچه‌های پیراهنی', subtitle: 'مشاهده محصولات' },
] as const
export const SEASON_CATEGORIES = [
{
id: 'summer',
title: 'تابستانه',
description: 'سبک، خنک و مناسب فصل گرم',
},
{
id: 'winter',
title: 'زمستانه',
description: 'گرم و مناسب فصل سرد',
},
{
id: 'all_season',
title: 'چهارفصل',
description: 'مناسب استفاده در بیشتر فصل‌های سال',
},
] as const
export const CATEGORY_IMAGE_KEYS = [
...USAGE_CATEGORIES.map((c) => c.id),
...SEASON_CATEGORIES.map((c) => c.id),
] as const
export type CategoryImageKey = (typeof CATEGORY_IMAGE_KEYS)[number]
export function asImageMap(value: unknown): Record<string, string> {
if (!value || typeof value !== 'object' || Array.isArray(value)) return {}
const out: Record<string, string> = {}
for (const [key, image] of Object.entries(value as Record<string, unknown>)) {
if (typeof image === 'string' && image.trim()) out[key] = image.trim()
}
return out
}
export async function loadCatalogCategories(prisma: PrismaService) {
const settings = await prisma.systemSettings.findUnique({
where: { id: 'default' },
})
const images = asImageMap(settings?.categoryImagesJson)
return {
usage: USAGE_CATEGORIES.map((item) => ({
...item,
imageUrl: images[item.id] || undefined,
})),
seasons: SEASON_CATEGORIES.map((item) => ({
...item,
imageUrl: images[item.id] || undefined,
})),
}
}