mirror of
https://github.com/arthur-pbty/binouz.git
synced 2026-06-19 13:46:47 +02:00
feat: add authentication and user management features
- Implemented AuthButton component for Discord sign-in and sign-out functionality. - Created CopyButton component for copying server IP addresses. - Developed EventCard and GradeCard components for displaying events and grades. - Added Footer and Navbar components for site navigation and information. - Introduced PurchaseButton for handling grade purchases with Stripe integration. - Created SectionHeader component for consistent section titles. - Implemented session management with SessionProvider for NextAuth. - Set up PostgreSQL database with Docker and Prisma for data management. - Added admin guard functionality to restrict access to certain routes. - Configured NextAuth with Discord provider for user authentication. - Defined Prisma schema for user, admin, grade, event, and purchase models. - Seeded database with initial grades and events data. - Added SVG hero image for the landing page. - Extended NextAuth types to include additional user properties.
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
discordId String? @unique
|
||||
discordUsername String?
|
||||
discordAvatar String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
purchases Purchase[]
|
||||
admin Admin?
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String
|
||||
refresh_token String? @db.Text
|
||||
access_token String? @db.Text
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique
|
||||
userId String
|
||||
expires DateTime
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
}
|
||||
|
||||
model Admin {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
discordId String @unique
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model Grade {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
price Int
|
||||
description String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
purchases Purchase[]
|
||||
}
|
||||
|
||||
model Event {
|
||||
id String @id @default(cuid())
|
||||
title String
|
||||
description String
|
||||
eventDate DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
enum PurchaseStatus {
|
||||
PENDING
|
||||
PAID
|
||||
FAILED
|
||||
REFUNDED
|
||||
}
|
||||
|
||||
model Purchase {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
gradeId String
|
||||
amount Int
|
||||
status PurchaseStatus @default(PENDING)
|
||||
stripeSessionId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
grade Grade @relation(fields: [gradeId], references: [id], onDelete: Restrict)
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
const db = new PrismaClient();
|
||||
|
||||
const grades = [
|
||||
{
|
||||
name: "Eclaireur",
|
||||
price: 9,
|
||||
description:
|
||||
"Acces prioritaire, prefix colore, particules discretes et slots reserves.",
|
||||
},
|
||||
{
|
||||
name: "Gladiateur",
|
||||
price: 19,
|
||||
description:
|
||||
"Kit cosmetique PvP, tags exclusifs, bonus d'events et loot personnalise.",
|
||||
},
|
||||
{
|
||||
name: "Titan",
|
||||
price: 39,
|
||||
description:
|
||||
"Rang ultime, aura lumineuse, salons prives et avantages boutique VIP.",
|
||||
},
|
||||
];
|
||||
|
||||
const events = [
|
||||
{
|
||||
title: "UHC Arena - Duel Night",
|
||||
description:
|
||||
"Tournoi 1v1 avec bracket rapide. Score bonus pour les eliminations propres.",
|
||||
eventDate: new Date("2026-05-18T19:00:00Z"),
|
||||
},
|
||||
{
|
||||
title: "Rush 2v2 - Full PvP",
|
||||
description:
|
||||
"Arches, potions, clutchs. Inscription par equipe sur Discord.",
|
||||
eventDate: new Date("2026-05-25T19:00:00Z"),
|
||||
},
|
||||
{
|
||||
title: "UHC Royale",
|
||||
description:
|
||||
"Format 50 joueurs, shrink progressif, recompenses exclusives.",
|
||||
eventDate: new Date("2026-06-01T19:00:00Z"),
|
||||
},
|
||||
];
|
||||
|
||||
const main = async () => {
|
||||
for (const grade of grades) {
|
||||
const existing = await db.grade.findFirst({
|
||||
where: { name: grade.name },
|
||||
});
|
||||
if (!existing) {
|
||||
await db.grade.create({ data: grade });
|
||||
}
|
||||
}
|
||||
|
||||
for (const event of events) {
|
||||
const existing = await db.event.findFirst({
|
||||
where: { title: event.title },
|
||||
});
|
||||
if (!existing) {
|
||||
await db.event.create({ data: event });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
main()
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await db.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user