feat(ui): dynamic logo customization, centralized contact links, hero slider, banner placements, reorganized admin sidebar & ui-texts save fix
Deploy Canina / deploy (push) Has been cancelled
Deploy Canina / deploy (push) Has been cancelled
This commit is contained in:
1 parent
2fca778930
commit
2d594c5d69
34 files changed
+126746
-9764
No files matched your search
@@ -5,12 +5,26 @@ export const DEFAULT_UI_TEXTS: Record<string, string> = {
|
||||
"maintenance_desc": "وبسایت رسمی کنینا ایران جهت ارتقای زیرساختها و بهبود عملکرد به صورت موقت در دست بهروزرسانی است. از شکیبایی شما سپاسگزاریم.",
|
||||
"maintenance_eta": "زمان تقریبی بازگشایی: کمتر از ۲ ساعت آینده",
|
||||
"maintenance_contact_phone": "۰۲۱-۸۸۸۸۸۸۸۸",
|
||||
"maintenance_contact_phone_link": "tel:02188888888",
|
||||
"maintenance_badge": "سامانه در حال ارتقا",
|
||||
"catalog_mode": "false",
|
||||
"catalog_hide_prices": "false",
|
||||
"catalog_disable_cart": "false",
|
||||
"catalog_disable_checkout": "false",
|
||||
|
||||
// === Brand & Logo ===
|
||||
"site_logo": "",
|
||||
"site_logo_text_en": "Canina",
|
||||
"site_logo_text_fa": "ایران",
|
||||
"site_logo_subtitle": "نماینده رسمی CANINA PHARMA GMBH GERMANY",
|
||||
"contact_phone": "۰۲۱-۸۸۸۸۴۴۴۴",
|
||||
"contact_phone_link": "tel:02188884444",
|
||||
"contact_email": "info@canina.ir",
|
||||
"contact_address": "تهران، جردن، خیابان سعیدی، ساختمان کنینا، طبقه ۵، واحد ۱۹",
|
||||
"contact_whatsapp": "09120000000",
|
||||
"contact_telegram": "https://t.me/canina_iran",
|
||||
"contact_instagram": "https://instagram.com/canina_iran",
|
||||
|
||||
// === Header / Navigation ===
|
||||
"shipping_notice": "ارسال رایگان برای سفارشهای بالای ۱۵۰ هزار تومان — گارانتی اصالت کنینا آلمان",
|
||||
"brand_name_fa": "کنینا ایران",
|
||||
|
||||
@@ -41,11 +41,40 @@ export class SettingsController {
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Patch('ui-texts/:key')
|
||||
@Put('ui-texts/:key')
|
||||
@ApiOperation({ summary: 'ویرایش یا ثبت متن یک کلید در رابط کاربری' })
|
||||
updateUiText(@Param('key') key: string, @Body('value') value: string) {
|
||||
return this.settingsService.updateUiText(key, value);
|
||||
@ApiOperation({ summary: 'ویرایش یا ثبت متن یک کلید در رابط کاربری با متد PUT' })
|
||||
putUiText(@Param('key') key: string, @Body() body: any) {
|
||||
const val =
|
||||
typeof body === 'object' && body !== null && 'value' in body
|
||||
? body.value
|
||||
: typeof body === 'string'
|
||||
? body
|
||||
: JSON.stringify(body);
|
||||
return this.settingsService.updateUiText(key, String(val ?? ''));
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Patch('ui-texts/:key')
|
||||
@ApiOperation({ summary: 'ویرایش یا ثبت متن یک کلید در رابط کاربری با متد PATCH' })
|
||||
patchUiText(@Param('key') key: string, @Body() body: any) {
|
||||
const val =
|
||||
typeof body === 'object' && body !== null && 'value' in body
|
||||
? body.value
|
||||
: typeof body === 'string'
|
||||
? body
|
||||
: JSON.stringify(body);
|
||||
return this.settingsService.updateUiText(key, String(val ?? ''));
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('Admin')
|
||||
@ApiBearerAuth()
|
||||
@Put('ui-texts')
|
||||
@ApiOperation({ summary: 'ویرایش گروهی متون رابط کاربری' })
|
||||
putBulkUiTexts(@Body() body: Record<string, string>) {
|
||||
return this.settingsService.updateBulkUiTexts(body);
|
||||
}
|
||||
|
||||
@Get('scientific-terms')
|
||||
|
||||
@@ -90,13 +90,33 @@ export class SettingsService implements OnModuleInit {
|
||||
}
|
||||
|
||||
async updateUiText(key: string, value: string) {
|
||||
const strVal = String(value ?? '');
|
||||
try {
|
||||
await this.prisma.setting.upsert({
|
||||
where: { key },
|
||||
update: { value: strVal },
|
||||
create: { key, value: strVal, category: 'general' },
|
||||
});
|
||||
} catch (e) {
|
||||
this.logger.warn(`Failed to sync setting key ${key}: ${e}`);
|
||||
}
|
||||
|
||||
return this.prisma.uiText.upsert({
|
||||
where: { key },
|
||||
update: { value },
|
||||
create: { key, value },
|
||||
update: { value: strVal },
|
||||
create: { key, value: strVal },
|
||||
});
|
||||
}
|
||||
|
||||
async updateBulkUiTexts(texts: Record<string, string>) {
|
||||
if (!texts || typeof texts !== 'object') return { success: true };
|
||||
const entries = Object.entries(texts);
|
||||
for (const [key, value] of entries) {
|
||||
await this.updateUiText(key, String(value ?? ''));
|
||||
}
|
||||
return { success: true, count: entries.length };
|
||||
}
|
||||
|
||||
async getScientificTerms() {
|
||||
return this.prisma.scientificTerm.findMany();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user