Compare commits
8 Commits
6f04e39bf3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71856799ac | ||
|
|
6169742476 | ||
|
|
4fbfd39736 | ||
|
|
9dcd441a13 | ||
|
|
77ba5702a6 | ||
|
|
bdf9dc5a78 | ||
|
|
ae0b856336 | ||
|
|
a1b74ec195 |
@@ -39,6 +39,7 @@ RUN chown nextjs:nodejs .next
|
|||||||
|
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||||
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules/.prisma ./node_modules/.prisma
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Link from 'next/use-pathname';
|
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import NextLink from 'next/link';
|
import NextLink from 'next/link';
|
||||||
|
|
||||||
|
|||||||
44
app/page.tsx
44
app/page.tsx
@@ -4,7 +4,9 @@ import MenuView from "./components/MenuView";
|
|||||||
export const dynamic = 'force-dynamic';
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
|
try {
|
||||||
const restaurant = await prisma.restaurant.findFirst({
|
const restaurant = await prisma.restaurant.findFirst({
|
||||||
|
orderBy: { createdAt: 'desc' },
|
||||||
include: {
|
include: {
|
||||||
categories: {
|
categories: {
|
||||||
include: {
|
include: {
|
||||||
@@ -18,7 +20,15 @@ export default async function Page() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!restaurant) {
|
if (!restaurant) {
|
||||||
return <div>Veritabanı yükleniyor...</div>;
|
return (
|
||||||
|
<div style={{ background: '#000', color: '#fff', height: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', textAlign: 'center', padding: '20px' }}>
|
||||||
|
<div>
|
||||||
|
<h1 style={{ color: 'var(--gold)' }}>LUNA</h1>
|
||||||
|
<p>Henüz menü verisi bulunamadı veya veritabanı bağlantısı kurulamadı.</p>
|
||||||
|
<p style={{ fontSize: '0.8rem', color: '#666' }}>Lütfen admin panelinden bir restoran ve kategori oluşturulduğundan emin olun.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map database structure to the structure expected by MenuView
|
// Map database structure to the structure expected by MenuView
|
||||||
@@ -29,15 +39,41 @@ export default async function Page() {
|
|||||||
id: cat.id,
|
id: cat.id,
|
||||||
title: cat.title,
|
title: cat.title,
|
||||||
externalId: cat.externalId,
|
externalId: cat.externalId,
|
||||||
items: cat.items.map(item => ({
|
items: (cat.items || []).map(item => ({
|
||||||
name: item.name,
|
name: item.name,
|
||||||
ingredients: item.ingredients,
|
ingredients: item.ingredients,
|
||||||
tasteProfile: item.tasteProfile,
|
tasteProfile: item.tasteProfile,
|
||||||
grapeVariety: item.grapeVariety,
|
grapeVariety: item.grapeVariety,
|
||||||
price: item.price,
|
price: item.price as any,
|
||||||
})),
|
})),
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
||||||
return <MenuView data={data} />;
|
if (data.categories.length === 0) {
|
||||||
|
return (
|
||||||
|
<div style={{ background: '#000', color: '#fff', height: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', textAlign: 'center', padding: '20px' }}>
|
||||||
|
<div>
|
||||||
|
<h1 style={{ color: 'var(--gold)' }}>LUNA</h1>
|
||||||
|
<p>Restoran bulundu ancak henüz hiç kategori eklenmemiş.</p>
|
||||||
|
<p style={{ fontSize: '0.8rem', color: '#666' }}>Lütfen admin panelinden kategori ve ürün ekleyin.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <MenuView data={data} />;
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error("Database error:", error);
|
||||||
|
return (
|
||||||
|
<div style={{ background: '#000', color: '#fff', height: '100vh', display: 'flex', alignItems: 'center', justifyContent: 'center', textAlign: 'center', padding: '20px' }}>
|
||||||
|
<div>
|
||||||
|
<h1 style={{ color: 'var(--gold)' }}>LUNA</h1>
|
||||||
|
<p>Veritabanı bağlantısı sırasında bir hata oluştu.</p>
|
||||||
|
<pre style={{ fontSize: '0.7rem', color: '#ff4d4d', marginTop: '10px', overflowX: 'auto', maxWidth: '80vw' }}>
|
||||||
|
{error.message || "Bilinmeyen hata"}
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
generator client {
|
generator client {
|
||||||
provider = "prisma-client-js"
|
provider = "prisma-client-js"
|
||||||
|
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
||||||
}
|
}
|
||||||
|
|
||||||
datasource db {
|
datasource db {
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ async function main() {
|
|||||||
const menuPath = path.join(__dirname, '../menu/menu.json');
|
const menuPath = path.join(__dirname, '../menu/menu.json');
|
||||||
const menuData = JSON.parse(fs.readFileSync(menuPath, 'utf-8'));
|
const menuData = JSON.parse(fs.readFileSync(menuPath, 'utf-8'));
|
||||||
|
|
||||||
// 1. Create Restaurant
|
console.log('Cleaning up existing data...');
|
||||||
const restaurant = await prisma.restaurant.create({
|
await (prisma as any).item.deleteMany();
|
||||||
|
await (prisma as any).category.deleteMany();
|
||||||
|
await (prisma as any).restaurant.deleteMany();
|
||||||
|
const restaurant = await (prisma as any).restaurant.create({
|
||||||
data: {
|
data: {
|
||||||
name: menuData.restaurant_name,
|
name: menuData.restaurant_name,
|
||||||
footerNote: menuData.footer_note,
|
footerNote: menuData.footer_note,
|
||||||
@@ -29,9 +32,9 @@ async function main() {
|
|||||||
const adminUsername = 'admin';
|
const adminUsername = 'admin';
|
||||||
const hashedPassword = await bcrypt.hash('admin', 10);
|
const hashedPassword = await bcrypt.hash('admin', 10);
|
||||||
|
|
||||||
const existingUser = await prisma.user.findUnique({ where: { username: adminUsername } });
|
const existingUser = await (prisma as any).user.findUnique({ where: { username: adminUsername } });
|
||||||
if (!existingUser) {
|
if (!existingUser) {
|
||||||
await prisma.user.create({
|
await (prisma as any).user.create({
|
||||||
data: {
|
data: {
|
||||||
username: adminUsername,
|
username: adminUsername,
|
||||||
password: hashedPassword,
|
password: hashedPassword,
|
||||||
@@ -40,7 +43,7 @@ async function main() {
|
|||||||
console.log(`Created admin user: ${adminUsername}`);
|
console.log(`Created admin user: ${adminUsername}`);
|
||||||
}
|
}
|
||||||
for (const cat of menuData.categories) {
|
for (const cat of menuData.categories) {
|
||||||
const category = await prisma.category.create({
|
const category = await (prisma as any).category.create({
|
||||||
data: {
|
data: {
|
||||||
title: cat.title,
|
title: cat.title,
|
||||||
externalId: cat.id,
|
externalId: cat.id,
|
||||||
@@ -51,7 +54,7 @@ async function main() {
|
|||||||
console.log(`Created category: ${category.title}`);
|
console.log(`Created category: ${category.title}`);
|
||||||
|
|
||||||
for (const item of cat.items) {
|
for (const item of cat.items) {
|
||||||
await prisma.item.create({
|
await (prisma as any).item.create({
|
||||||
data: {
|
data: {
|
||||||
name: item.name,
|
name: item.name,
|
||||||
ingredients: item.ingredients || null,
|
ingredients: item.ingredients || null,
|
||||||
|
|||||||
8
types/bcryptjs.d.ts
vendored
Normal file
8
types/bcryptjs.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
declare module 'bcryptjs' {
|
||||||
|
export function hash(s: string | Buffer, salt: string | number): Promise<string>;
|
||||||
|
export function hashSync(s: string | Buffer, salt: string | number): string;
|
||||||
|
export function compare(s: string | Buffer, hash: string): Promise<boolean>;
|
||||||
|
export function compareSync(s: string | Buffer, hash: string): boolean;
|
||||||
|
export function genSalt(rounds?: number): Promise<string>;
|
||||||
|
export function genSaltSync(rounds?: number): string;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user