fix: hero image configurable via uiText + seed no longer overwrites admin values
- Hero.tsx reads hero_image_url from uiText store first, falls back to banners then default - Seed script now only creates keys that don't exist (no overwrite) - Added hero_image_url key to seed + admin panel UI texts groups - Reverted DEFAULT_TEXTS initialization (caused hydration mismatch) - settingsStore back to empty init, fetchSettings populates from API
This commit is contained in:
1 parent
53301705da
commit
40d750ad4b
3 files changed
+7
-6
No files matched your search
@@ -30,6 +30,7 @@ const UI_TEXTS: Record<string, string> = {
|
||||
"hero_image_badge": "سرآمد علمی در پزشکی پتها",
|
||||
"hero_image_title": "مکملهای تایید شده دامپزشکی",
|
||||
"hero_quality_standard": "استاندارد کیفی آلمان",
|
||||
"hero_image_url": "/assets/images/hero-section-image.png",
|
||||
"hero_stat_founded": "سال تأسیس ۱۹۸۴",
|
||||
"hero_stat_agencies": "نمایندگی فعال",
|
||||
"hero_stat_german_formula": "فرمول آلمانی",
|
||||
@@ -130,11 +131,10 @@ async function main() {
|
||||
const entries = Object.entries(UI_TEXTS);
|
||||
|
||||
for (const [key, value] of entries) {
|
||||
await prisma.uiText.upsert({
|
||||
where: { key },
|
||||
update: { value },
|
||||
create: { key, value },
|
||||
});
|
||||
const existing = await prisma.uiText.findUnique({ where: { key } });
|
||||
if (!existing) {
|
||||
await prisma.uiText.create({ data: { key, value } });
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Seeded ${entries.length} UI texts.`);
|
||||
|
||||
@@ -14,6 +14,7 @@ const GROUPS: Record<string, string[]> = {
|
||||
"hero_badge", "hero_title", "hero_desc",
|
||||
"hero_btn_advisor", "hero_btn_products",
|
||||
"hero_image_badge", "hero_image_title", "hero_quality_standard",
|
||||
"hero_image_url",
|
||||
"hero_stat_founded", "hero_stat_agencies", "hero_stat_german_formula",
|
||||
],
|
||||
"دستیار سلامت": [
|
||||
|
||||
@@ -138,7 +138,7 @@ export default function Hero({ banners = [] }: { banners?: any[] }) {
|
||||
>
|
||||
<div className="aspect-square bg-gradient-to-br from-slate-200 to-slate-300 rounded-[2rem] overflow-hidden border-4 border-white shadow-2xl relative">
|
||||
<img
|
||||
src={banners.length > 0 && banners[0].imageUrl ? banners[0].imageUrl : "/assets/images/hero-section-image.png"}
|
||||
src={getText('hero_image_url', '') || (banners.length > 0 && banners[0].imageUrl ? banners[0].imageUrl : "/assets/images/hero-section-image.png")}
|
||||
alt={banners.length > 0 ? banners[0].title : "Canina Pharma Germany"}
|
||||
className="w-full h-full object-cover"
|
||||
loading="eager"
|
||||
|
||||
Reference in new issue
Block a user