Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .env
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
POSTGRES_URL="postgresql://postgres:PASSOWRD@localhost:5433/next-pizza?schema=public"
POSTGRES_URL="postgres://default:RKIHbVqs74ni@ep-round-violet-a2drsspn-pooler.eu-central-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_PRISMA_URL="postgres://default:RKIHbVqs74ni@ep-round-violet-a2drsspn-pooler.eu-central-1.aws.neon.tech:5432/verceldb?sslmode=require&pgbouncer=true&connect_timeout=15"
POSTGRES_URL_NO_SSL="postgres://default:RKIHbVqs74ni@ep-round-violet-a2drsspn-pooler.eu-central-1.aws.neon.tech:5432/verceldb"
POSTGRES_URL_NON_POOLING="postgres://default:RKIHbVqs74ni@ep-round-violet-a2drsspn.eu-central-1.aws.neon.tech:5432/verceldb?sslmode=require"
POSTGRES_USER="default"
POSTGRES_HOST="ep-round-violet-a2drsspn-pooler.eu-central-1.aws.neon.tech"
POSTGRES_PASSWORD="RKIHbVqs74ni"
POSTGRES_DATABASE="verceldb"


NEXT_PUBLIC_API_URL=/api

RESEND_API_KEY=
NEXTAUTH_SECRET=
RESEND_API_KEY=re_MaQpzHJj_4THr88nyQqhVxSmFsunBh5pF
NEXTAUTH_SECRET=5bNhbW+OgyVX7gMAZh3CalP7BJlYyXgtl7LPOveuHuQ=

YOOKASSA_STORE_ID=
YOOKASSA_API_KEY=
YOOKASSA_STORE_ID=464198
YOOKASSA_API_KEY=test_DCclawG3sFjXeCKmweaJ3xjVSpSCkqquxCjdYxVzcZE
YOOKASSA_CALLBACK_URL=http://localhost:3000/?paid

GITHUB_ID=
GITHUB_SECRET=
GITHUB_ID=Ov23liwDEw73WA1f6Y8L
GITHUB_SECRET=630df005edd445626f18427d61e639b18660d66a

# когда будем пушить продакшен, надо указать другой URL в developer settings

GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
2 changes: 1 addition & 1 deletion app/(checkout)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Metadata } from 'next';
import { Suspense } from 'react';

export const metadata: Metadata = {
title: 'Next Pizza | Корзина',
title: 'Ножи СПБ | Корзина',
description: 'Generated by create next app',
};

Expand Down
2 changes: 1 addition & 1 deletion app/(root)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Metadata } from 'next';
import { Suspense } from 'react';

export const metadata: Metadata = {
title: 'Next Pizza | Главная',
title: 'Ножи СПБ | Главная',
};

export default function HomeLayout({
Expand Down
2 changes: 1 addition & 1 deletion app/(root)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function Home({ searchParams }: { searchParams: GetSearchPa
return (
<>
<Container className="mt-10">
<Title text="Все пиццы" size="lg" className="font-extrabold" />
<Title text="Все товары" size="lg" className="font-extrabold" />
</Container>

<TopBar categories={categories.filter((category) => category.products.length > 0)} />
Expand Down
37 changes: 32 additions & 5 deletions app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use server';

import { prisma } from '@/prisma/prisma-client';
import { PayOrderTemplate } from '@/shared/components';
import { PayOrderTemplate } from '@/shared/components/shared/email-temapltes';

import { VerificationUserTemplate } from '@/shared/components/shared/email-temapltes/verification-user';
import { CheckoutFormValues } from '@/shared/constants';
import { createPayment, sendEmail } from '@/shared/lib';
Expand Down Expand Up @@ -103,7 +104,7 @@ export async function createOrder(data: CheckoutFormValues) {

await sendEmail(
data.email,
'Next Pizza / Оплатите заказ #' + order.id,
'Hoжы СПБ / Оплатите заказ #' + order.id,
PayOrderTemplate({
orderId: order.id,
totalAmount: order.totalAmount,
Expand Down Expand Up @@ -156,13 +157,39 @@ export async function registerUser(body: Prisma.UserCreateInput) {
});

if (user) {
// Проверяем, если пользователь существует и не верифицирован
if (!user.verified) {
throw new Error('Почта не подтверждена');
// Генерируем новый код подтверждения
const code = Math.floor(100000 + Math.random() * 900000).toString();

await prisma.verificationCode.upsert({
where: {
userId: user.id,
},
update: {
code,
},
create: {
code,
userId: user.id,
},
});

await sendEmail(
user.email,
'Ножи СПБ / 📝 Повторное подтверждение регистрации',
VerificationUserTemplate({
code,
}),
);

throw new Error('Почта не подтверждена. Новый код подтверждения отправлен.');
}

throw new Error('Пользователь уже существует');
throw new Error('Пользователь уже существует и верифицирован.');
}

// Если пользователь не найден, создаем нового
const createdUser = await prisma.user.create({
data: {
fullName: body.fullName,
Expand All @@ -182,7 +209,7 @@ export async function registerUser(body: Prisma.UserCreateInput) {

await sendEmail(
createdUser.email,
'Next Pizza / 📝 Подтверждение регистрации',
'Ножи СПБ / 📝 Подтверждение регистрации',
VerificationUserTemplate({
code,
}),
Expand Down
2 changes: 2 additions & 0 deletions app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import NextAuth from 'next-auth';
import { authOptions } from '@/shared/constants/auth-options';

//настройки выносим в отдельную переменнную

const handler = NextAuth(authOptions);

export { handler as GET, handler as POST };
11 changes: 8 additions & 3 deletions app/api/auth/verify/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { NextRequest, NextResponse } from 'next/server';

export async function GET(req: NextRequest) {
try {
// const code = req.nextUrl.searchParams.get('code');
const code = '';
// Получаем параметр 'code' из URL
const code = req.nextUrl.searchParams.get('code');

if (!code) {
return NextResponse.json({ error: 'Неверный код' }, { status: 400 });
}

// Ищем verificationCode в базе данных по коду
const verificationCode = await prisma.verificationCode.findFirst({
where: {
code,
Expand All @@ -20,24 +21,28 @@ export async function GET(req: NextRequest) {
return NextResponse.json({ error: 'Неверный код' }, { status: 400 });
}

// Обновляем статус пользователя как верифицированный
await prisma.user.update({
where: {
id: verificationCode.userId,
},
data: {
verified: new Date(),
verified: true, // Устанавливаем флаг верификации
},
});

// Удаляем использованный verificationCode
await prisma.verificationCode.delete({
where: {
id: verificationCode.id,
},
});

// Редиректим на главную с параметром ?verified
return NextResponse.redirect(new URL('/?verified', req.url));
} catch (error) {
console.error(error);
console.log('[VERIFY_GET] Server error', error);
return NextResponse.json({ error: 'Server error' }, { status: 500 });
}
}
2 changes: 1 addition & 1 deletion app/api/checkout/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function POST(req: NextRequest) {
if (isSucceeded) {
await sendEmail(
order.email,
'Next Pizza / Ваш заказ успешно оформлен 🎉',
'Ножи СПБ / Ваш заказ успешно оформлен 🎉',
OrderSuccessTemplate({ orderId: order.id, items }),
);
} else {
Expand Down
94 changes: 49 additions & 45 deletions app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,58 @@ html {

@layer base {
:root {
--foreground: 20 14.3% 4.1%;

--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 20 14.3% 4.1%;

--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 20 14.3% 4.1%;

--primary: 22 100% 50%;
--primary-foreground: 60 9.1% 97.8%;

--secondary: 32 100% 98%;
--secondary-foreground: 24 9.8% 10%;

--muted: 60 4.8% 95.9%;
--muted-foreground: 25 5.3% 44.7%;

--accent: 60 4.8% 95.9%;
--accent-foreground: 24 9.8% 10%;

--popover-foreground: 240 10% 3.9%;
--primary: 240 5.9% 10%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 60 9.1% 97.8%;
--destructive-foreground: 0 0% 98%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--ring: 240 5.9% 10%;
--radius: 0.5rem;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}

--border: 20 5.9% 90%;
--input: 0 0% 90%;
--ring: 24.6 95% 53.1%;
--radius: 18px;
.dark {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;
--card: 240 10% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 240 10% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 240 5.9% 10%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--muted: 240 3.7% 15.9%;
--muted-foreground: 240 5% 64.9%;
--accent: 240 3.7% 15.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 240 4.9% 83.9%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

Expand Down Expand Up @@ -70,25 +95,4 @@ html {
.text-balance {
text-wrap: balance;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}

#nprogress .bar {
@apply bg-primary !important;
}

#nprogress .peg {
@apply shadow-md shadow-primary !important;
}

#nprogress .spinner-icon {
@apply border-t-primary border-l-primary !important;
}
}
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function RootLayout({
return (
<html lang="en">
<head>
<link data-rh="true" rel="icon" href="/logo.png" />
<link data-rh="true" rel="icon" href="/logo1.png" />
</head>
<body className={nunito.className}>
<Providers>{children}</Providers>
Expand Down
1 change: 1 addition & 0 deletions next-pizza
Submodule next-pizza added at 03acc3
Loading