canina/backend/prisma/seed-home.ts
parsa aghaei 8d1b786a24
All checks were successful
Deploy Canina / deploy (push) Successful in 1m50s
chore(brand): rename all Persian occurrences of کانینا to کنینا across the project
2026-08-16 16:40:08 +03:30

108 lines
3.8 KiB
TypeScript

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export async function main() {
console.log('Seeding Home Page Components...');
// 1. Seed Hero Banners
const banners = [
{
title: 'محصولات تخصصی مراقبت از مفاصل',
subtitle: 'برای سگ‌های مسن و پرتحرک، تضمین سلامت و شادابی با کلاژن فعال',
imageUrl: '/assets/images/hero-section-image.png',
buttonText: 'مشاهده محصولات مفاصل',
buttonLink: '/shop/joints',
order: 1,
isActive: true,
},
{
title: 'ویتامین‌های ضروری برای رشد توله سگ‌ها',
subtitle: 'رشد کامل استخوان‌ها و تقویت سیستم ایمنی از ماه اول',
imageUrl: '/assets/images/regenerated_image_1779109861747.png',
buttonText: 'خرید ویتامین توله',
buttonLink: '/shop/puppy',
order: 2,
isActive: true,
}
];
await prisma.heroBanner.deleteMany(); // Reset
for (const b of banners) {
await prisma.heroBanner.create({ data: b });
}
console.log('Seeded Hero Banners.');
// 2. Seed Vet Testimonials
const vets = [
{
vetName: 'دکتر علیرضا رضایی',
clinicName: 'کلینیک دامپزشکی پایتخت',
imageUrl: '/assets/images/regenerated_image_1779109861747.png',
quote: 'مکمل‌های مفصلی کنینا از نظر سرعت جذب و اثربخشی در سگ‌های نژاد بزرگ بی‌نظیر هستند. ما نتایج فوق‌العاده‌ای روی دیسپلازی هیپ مشاهده کردیم.',
rating: 5,
order: 1,
isActive: true,
},
{
vetName: 'دکتر سارا شمس',
clinicName: 'بیمارستان دامپزشکی تهران',
imageUrl: '/assets/images/regenerated_image_1779109861747.png',
quote: 'من همیشه برای ریزش مو و مشکلات پوستی گربه‌ها، قرص‌های مخمر و بیوتین کنینا را تجویز می‌کنم. نتایج معمولاً در کمتر از ۳ هفته قابل مشاهده است.',
rating: 5,
order: 2,
isActive: true,
}
];
await prisma.vetTestimonial.deleteMany();
for (const v of vets) {
await prisma.vetTestimonial.create({ data: v });
}
console.log('Seeded Vet Testimonials.');
// 3. Seed Smart Advisor Rules
// We need to fetch an actual product ID to link
const product = await prisma.product.findFirst();
if (product) {
const rules = [
{
condition: 'ریزش مو شدید',
targetPetType: 'سگ',
reason: 'حاوی بیوتین و روی بالا برای توقف ریزش مو و براق شدن پوشش',
recommendedProduct: product.id,
},
{
condition: 'لنگش یا ضعف مفاصل',
targetPetType: 'سگ',
reason: 'غنی از گلوکزامین، کندرویتین و پودر صدف سبز نیوزلندی برای ترمیم غضروف',
recommendedProduct: product.id,
},
{
condition: 'بی‌اشتهایی',
targetPetType: 'گربه',
reason: 'مخمر خالص و ویتامین‌های گروه B برای افزایش اشتها و شادابی',
recommendedProduct: product.id,
}
];
await prisma.smartAdvisorRule.deleteMany();
for (const r of rules) {
await prisma.smartAdvisorRule.create({ data: r });
}
console.log('Seeded Smart Advisor Rules.');
} else {
console.log('No products found in DB! Skipping Smart Advisor Rules seeding.');
}
}
main()
.catch(e => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});