Multi-tenant digital menu platform (Collina Systems): public QR menu with glassmorphism + 3D macro flip cards, mobile-first editor with draft/publish versioning (5-version history + restore), AI consultant & translation (Claude Haiku), realtime orders via SSE, configurable palette, QR generation, superadmin panel, and Docker/Coolify infra.
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import bcrypt from 'bcryptjs';
|
|
import crypto from 'crypto';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
// Seeds a demo restaurant so the app is browsable right after setup.
|
|
async function main() {
|
|
const slug = 'demo';
|
|
const existing = await prisma.restaurant.findUnique({ where: { slug } });
|
|
if (existing) {
|
|
console.log('Demo restaurant already exists:', `/${slug}`);
|
|
return;
|
|
}
|
|
|
|
const editorSecret = crypto.randomBytes(32).toString('base64url');
|
|
const hashedPassword = await bcrypt.hash('demo1234', 10);
|
|
|
|
const restaurant = await prisma.restaurant.create({
|
|
data: {
|
|
slug,
|
|
name: 'La Collina',
|
|
editorSecret,
|
|
username: 'admin',
|
|
hashedPassword,
|
|
defaultLocale: 'es',
|
|
ordersEnabled: true,
|
|
palette: {
|
|
background: '#f4f1ec',
|
|
surface: 'rgba(255,255,255,0.55)',
|
|
accent: '#b45309',
|
|
text: '#2a2520',
|
|
tab: 'rgba(255,255,255,0.45)',
|
|
},
|
|
},
|
|
});
|
|
|
|
const starters = await prisma.section.create({
|
|
data: { restaurantId: restaurant.id, name: { es: 'Entradas', en: 'Starters' }, order: 0 },
|
|
});
|
|
const mains = await prisma.section.create({
|
|
data: { restaurantId: restaurant.id, name: { es: 'Platos fuertes', en: 'Main dishes' }, order: 1 },
|
|
});
|
|
|
|
await prisma.product.create({
|
|
data: {
|
|
sectionId: starters.id,
|
|
restaurantId: restaurant.id,
|
|
name: { es: 'Ensalada de la casa', en: 'House salad' },
|
|
description: {
|
|
es: 'Verdes frescos, aderezo de la casa y nueces tostadas.',
|
|
en: 'Fresh greens, house dressing and toasted walnuts.',
|
|
},
|
|
price: 120,
|
|
order: 0,
|
|
dietTags: ['vegetariano'],
|
|
allergens: ['frutos secos'],
|
|
macros: { protein: 6, carbs: 12, sugar: 4, fat: 9, fiber: 5, kcal: 180 },
|
|
translationStatus: { en: 'reviewed' },
|
|
},
|
|
});
|
|
|
|
await prisma.product.create({
|
|
data: {
|
|
sectionId: mains.id,
|
|
restaurantId: restaurant.id,
|
|
name: { es: 'Salmón a la parrilla', en: 'Grilled salmon' },
|
|
description: {
|
|
es: 'Salmón con vegetales de temporada y puré de papa.',
|
|
en: 'Salmon with seasonal vegetables and mashed potato.',
|
|
},
|
|
price: 320,
|
|
order: 0,
|
|
allergens: ['pescado'],
|
|
macros: { protein: 38, carbs: 22, sugar: 3, fat: 18, fiber: 4, kcal: 420 },
|
|
translationStatus: { en: 'reviewed' },
|
|
},
|
|
});
|
|
|
|
console.log('Seeded demo restaurant.');
|
|
console.log('Public:', `/${slug}`);
|
|
console.log('Editor:', `/${slug}/editor?k=${editorSecret}`);
|
|
console.log('Login: admin / demo1234');
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(() => prisma.$disconnect());
|