Spaces:
Sleeping
Sleeping
Upload 74 files
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +3 -0
- Dockerfile +70 -11
- components.json +23 -0
- eslint.config.mjs +18 -0
- next-env.d.ts +6 -0
- next.config.ts +23 -0
- package-lock.json +0 -0
- package.json +42 -11
- postcss.config.mjs +6 -0
- prisma/schema.prisma +74 -0
- public/.DS_Store +0 -0
- public/dark.png +3 -0
- public/file.svg +1 -0
- public/fonts/Bitcount.ttf +3 -0
- public/globe.svg +1 -0
- public/light.png +3 -0
- public/next.svg +1 -0
- public/vercel.svg +1 -0
- public/window.svg +1 -0
- scripts/fix-visibility.js +60 -0
- scripts/seed-aspect-ratios.js +183 -0
- scripts/seed-data.js +240 -0
- scripts/seed-more.js +203 -0
- scripts/update-credits.ts +24 -0
- src/app/(auth)/login/page.tsx +201 -0
- src/app/(auth)/signup/page.tsx +239 -0
- src/app/(dashboard)/create/page.tsx +292 -0
- src/app/(dashboard)/history/page.tsx +61 -0
- src/app/(dashboard)/profile/page.tsx +82 -0
- src/app/about/page.tsx +244 -0
- src/app/actions/auth.ts +51 -0
- src/app/api/auth/[...nextauth]/route.ts +2 -0
- src/app/api/gallery/route.ts +44 -0
- src/app/api/generate/route.ts +118 -0
- src/app/api/generation/[id]/route.ts +39 -0
- src/app/api/image/[id]/[filename]/route.ts +42 -0
- src/app/api/user/route.ts +63 -0
- src/app/artwork/[id]/page.tsx +181 -0
- src/app/favicon.ico +0 -0
- src/app/gallery/page.tsx +46 -0
- src/app/globals.css +126 -0
- src/app/layout.tsx +46 -0
- src/app/page.tsx +243 -0
- src/auth.config.ts +41 -0
- src/auth.ts +88 -0
- src/components/edit-profile-dialog.tsx +163 -0
- src/components/gallery-grid.tsx +69 -0
- src/components/gallery-masonry.tsx +151 -0
- src/components/gallery-modal.tsx +132 -0
- src/components/history-card.tsx +80 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
public/dark.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
public/fonts/Bitcount.ttf filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
public/light.png filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
CHANGED
|
@@ -1,21 +1,80 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
# Create app directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
COPY package.json
|
| 8 |
-
|
| 9 |
|
| 10 |
-
#
|
|
|
|
|
|
|
|
|
|
| 11 |
COPY . .
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
|
|
|
| 20 |
|
|
|
|
|
|
|
| 21 |
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# STAGE 1: Builder
|
| 3 |
+
# ==========================================
|
| 4 |
+
FROM ubuntu:22.04 AS builder
|
| 5 |
+
|
| 6 |
+
# Prevent interactive prompts
|
| 7 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 8 |
+
|
| 9 |
+
# Update system and install build dependencies
|
| 10 |
+
# curl, ca-certificates, gnupg: for Node.js
|
| 11 |
+
# openssl: for Prisma
|
| 12 |
+
RUN apt-get update && apt-get install -y \
|
| 13 |
+
curl \
|
| 14 |
+
ca-certificates \
|
| 15 |
+
openssl \
|
| 16 |
+
gnupg \
|
| 17 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 18 |
+
|
| 19 |
+
# Install Node.js 20 (LTS)
|
| 20 |
+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
| 21 |
+
&& apt-get install -y nodejs \
|
| 22 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 23 |
|
|
|
|
| 24 |
WORKDIR /app
|
| 25 |
|
| 26 |
+
# Copy package files first for caching
|
| 27 |
+
COPY package*.json ./
|
| 28 |
+
COPY prisma ./prisma/
|
| 29 |
|
| 30 |
+
# Install dependencies (including devDependencies for build)
|
| 31 |
+
RUN npm install
|
| 32 |
+
|
| 33 |
+
# Copy source code
|
| 34 |
COPY . .
|
| 35 |
|
| 36 |
+
# Generate Prisma Client and Build
|
| 37 |
+
# Prisma client will be generated for "native" and "debian-openssl-*" targets per schema
|
| 38 |
+
RUN npx prisma generate
|
| 39 |
+
RUN npm run build
|
| 40 |
+
|
| 41 |
+
# ==========================================
|
| 42 |
+
# STAGE 2: Runner
|
| 43 |
+
# ==========================================
|
| 44 |
+
FROM ubuntu:22.04 AS runner
|
| 45 |
+
|
| 46 |
+
# Prevent interactive prompts
|
| 47 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 48 |
+
|
| 49 |
+
# Update system and install runtime dependencies
|
| 50 |
+
# We need openssl for Prisma runtime
|
| 51 |
+
RUN apt-get update && apt-get install -y \
|
| 52 |
+
curl \
|
| 53 |
+
ca-certificates \
|
| 54 |
+
openssl \
|
| 55 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 56 |
+
|
| 57 |
+
# Install Node.js 20 (LTS) - Optimized for runtime
|
| 58 |
+
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
| 59 |
+
&& apt-get install -y nodejs \
|
| 60 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 61 |
+
|
| 62 |
+
WORKDIR /app
|
| 63 |
+
|
| 64 |
+
# Set environment to production
|
| 65 |
+
ENV NODE_ENV=production
|
| 66 |
|
| 67 |
+
# Copy built artifacts from builder stage
|
| 68 |
+
# We use the specific path from the builder's output
|
| 69 |
+
COPY --from=builder /app/public ./public
|
| 70 |
+
COPY --from=builder /app/.next/static ./.next/static
|
| 71 |
+
COPY --from=builder /app/.next/standalone ./
|
| 72 |
|
| 73 |
+
# Expose port
|
| 74 |
+
EXPOSE 3000
|
| 75 |
|
| 76 |
+
ENV HOSTNAME="0.0.0.0"
|
| 77 |
+
ENV PORT=3000
|
| 78 |
|
| 79 |
+
# Start server
|
| 80 |
+
CMD ["node", "server.js"]
|
components.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://ui.shadcn.com/schema.json",
|
| 3 |
+
"style": "new-york",
|
| 4 |
+
"rsc": true,
|
| 5 |
+
"tsx": true,
|
| 6 |
+
"tailwind": {
|
| 7 |
+
"config": "",
|
| 8 |
+
"css": "src/app/globals.css",
|
| 9 |
+
"baseColor": "neutral",
|
| 10 |
+
"cssVariables": true,
|
| 11 |
+
"prefix": ""
|
| 12 |
+
},
|
| 13 |
+
"iconLibrary": "lucide",
|
| 14 |
+
"rtl": false,
|
| 15 |
+
"aliases": {
|
| 16 |
+
"components": "@/components",
|
| 17 |
+
"utils": "@/lib/utils",
|
| 18 |
+
"ui": "@/components/ui",
|
| 19 |
+
"lib": "@/lib",
|
| 20 |
+
"hooks": "@/hooks"
|
| 21 |
+
},
|
| 22 |
+
"registries": {}
|
| 23 |
+
}
|
eslint.config.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { defineConfig, globalIgnores } from "eslint/config";
|
| 2 |
+
import nextVitals from "eslint-config-next/core-web-vitals";
|
| 3 |
+
import nextTs from "eslint-config-next/typescript";
|
| 4 |
+
|
| 5 |
+
const eslintConfig = defineConfig([
|
| 6 |
+
...nextVitals,
|
| 7 |
+
...nextTs,
|
| 8 |
+
// Override default ignores of eslint-config-next.
|
| 9 |
+
globalIgnores([
|
| 10 |
+
// Default ignores of eslint-config-next:
|
| 11 |
+
".next/**",
|
| 12 |
+
"out/**",
|
| 13 |
+
"build/**",
|
| 14 |
+
"next-env.d.ts",
|
| 15 |
+
]),
|
| 16 |
+
]);
|
| 17 |
+
|
| 18 |
+
export default eslintConfig;
|
next-env.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/// <reference types="next" />
|
| 2 |
+
/// <reference types="next/image-types/global" />
|
| 3 |
+
import "./.next/types/routes.d.ts";
|
| 4 |
+
|
| 5 |
+
// NOTE: This file should not be edited
|
| 6 |
+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
|
next.config.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { NextConfig } from "next";
|
| 2 |
+
|
| 3 |
+
const nextConfig: NextConfig = {
|
| 4 |
+
output: "standalone",
|
| 5 |
+
images: {
|
| 6 |
+
remotePatterns: [
|
| 7 |
+
{
|
| 8 |
+
protocol: "https",
|
| 9 |
+
hostname: "i.ibb.co",
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
protocol: "https",
|
| 13 |
+
hostname: "replicate.delivery",
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
protocol: "https",
|
| 17 |
+
hostname: "*.workers.dev",
|
| 18 |
+
}
|
| 19 |
+
],
|
| 20 |
+
},
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
export default nextConfig;
|
package-lock.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
package.json
CHANGED
|
@@ -1,18 +1,49 @@
|
|
| 1 |
{
|
| 2 |
-
"name": "
|
| 3 |
-
"version": "1.0
|
| 4 |
"private": true,
|
| 5 |
-
"description": "Simple Express + Socket.IO app for LED control",
|
| 6 |
-
"main": "server.js",
|
| 7 |
-
"type": "commonjs",
|
| 8 |
"scripts": {
|
| 9 |
-
"
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
"
|
| 13 |
},
|
| 14 |
"dependencies": {
|
| 15 |
-
"
|
| 16 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"name": "wild-ar-ai",
|
| 3 |
+
"version": "0.1.0",
|
| 4 |
"private": true,
|
|
|
|
|
|
|
|
|
|
| 5 |
"scripts": {
|
| 6 |
+
"dev": "next dev",
|
| 7 |
+
"build": "npx prisma generate && next build",
|
| 8 |
+
"start": "next start",
|
| 9 |
+
"lint": "eslint"
|
| 10 |
},
|
| 11 |
"dependencies": {
|
| 12 |
+
"@auth/prisma-adapter": "^2.11.1",
|
| 13 |
+
"@hookform/resolvers": "^5.2.2",
|
| 14 |
+
"@prisma/client": "6.0.0",
|
| 15 |
+
"@radix-ui/react-dialog": "^1.1.15",
|
| 16 |
+
"@radix-ui/react-visually-hidden": "^1.2.4",
|
| 17 |
+
"@types/bcryptjs": "^2.4.6",
|
| 18 |
+
"@types/next-auth": "^3.13.0",
|
| 19 |
+
"bcryptjs": "^3.0.3",
|
| 20 |
+
"class-variance-authority": "^0.7.1",
|
| 21 |
+
"clsx": "^2.1.1",
|
| 22 |
+
"lucide-react": "^0.563.0",
|
| 23 |
+
"next": "16.1.6",
|
| 24 |
+
"next-auth": "^5.0.0-beta.30",
|
| 25 |
+
"next-themes": "^0.4.6",
|
| 26 |
+
"radix-ui": "^1.4.3",
|
| 27 |
+
"react": "19.2.3",
|
| 28 |
+
"react-dom": "19.2.3",
|
| 29 |
+
"react-hook-form": "^7.71.1",
|
| 30 |
+
"tailwind-merge": "^3.4.0",
|
| 31 |
+
"tailwindcss-animate": "^1.0.7",
|
| 32 |
+
"zod": "^4.3.6"
|
| 33 |
+
},
|
| 34 |
+
"devDependencies": {
|
| 35 |
+
"@tailwindcss/postcss": "^4",
|
| 36 |
+
"@types/node": "^20",
|
| 37 |
+
"@types/react": "^19",
|
| 38 |
+
"@types/react-dom": "^19",
|
| 39 |
+
"autoprefixer": "^10.4.24",
|
| 40 |
+
"eslint": "^9",
|
| 41 |
+
"eslint-config-next": "16.1.6",
|
| 42 |
+
"postcss": "^8.5.6",
|
| 43 |
+
"prisma": "6.0.0",
|
| 44 |
+
"tailwind-scrollbar": "^3.1.0",
|
| 45 |
+
"tailwindcss": "^3.4.17",
|
| 46 |
+
"tw-animate-css": "^1.4.0",
|
| 47 |
+
"typescript": "^5"
|
| 48 |
}
|
| 49 |
}
|
postcss.config.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export default {
|
| 2 |
+
plugins: {
|
| 3 |
+
tailwindcss: {},
|
| 4 |
+
autoprefixer: {},
|
| 5 |
+
},
|
| 6 |
+
}
|
prisma/schema.prisma
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
generator client {
|
| 2 |
+
provider = "prisma-client-js"
|
| 3 |
+
binaryTargets = ["native", "debian-openssl-1.1.x", "debian-openssl-3.0.x"]
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
datasource db {
|
| 7 |
+
provider = "postgresql"
|
| 8 |
+
url = env("DATABASE_URL")
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
model User {
|
| 12 |
+
id String @id @default(cuid())
|
| 13 |
+
name String?
|
| 14 |
+
username String? @unique
|
| 15 |
+
email String @unique
|
| 16 |
+
emailVerified DateTime?
|
| 17 |
+
password String?
|
| 18 |
+
image String?
|
| 19 |
+
credits Int @default(100)
|
| 20 |
+
lastDailyCredit DateTime @default(now())
|
| 21 |
+
accounts Account[]
|
| 22 |
+
sessions Session[]
|
| 23 |
+
generations Generation[]
|
| 24 |
+
createdAt DateTime @default(now())
|
| 25 |
+
updatedAt DateTime @updatedAt
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
model Account {
|
| 29 |
+
id String @id @default(cuid())
|
| 30 |
+
userId String
|
| 31 |
+
type String
|
| 32 |
+
provider String
|
| 33 |
+
providerAccountId String
|
| 34 |
+
refresh_token String? @db.Text
|
| 35 |
+
access_token String? @db.Text
|
| 36 |
+
expires_at Int?
|
| 37 |
+
token_type String?
|
| 38 |
+
scope String?
|
| 39 |
+
id_token String? @db.Text
|
| 40 |
+
session_state String?
|
| 41 |
+
|
| 42 |
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
| 43 |
+
|
| 44 |
+
@@unique([provider, providerAccountId])
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
model Session {
|
| 48 |
+
id String @id @default(cuid())
|
| 49 |
+
sessionToken String @unique
|
| 50 |
+
userId String
|
| 51 |
+
expires DateTime
|
| 52 |
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
model VerificationToken {
|
| 56 |
+
identifier String
|
| 57 |
+
token String @unique
|
| 58 |
+
expires DateTime
|
| 59 |
+
|
| 60 |
+
@@unique([identifier, token])
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
model Generation {
|
| 64 |
+
id String @id @default(cuid())
|
| 65 |
+
prompt String
|
| 66 |
+
model String
|
| 67 |
+
imageUrl String
|
| 68 |
+
width Int
|
| 69 |
+
height Int
|
| 70 |
+
userId String
|
| 71 |
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
| 72 |
+
isPublic Boolean @default(true)
|
| 73 |
+
createdAt DateTime @default(now())
|
| 74 |
+
}
|
public/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
public/dark.png
ADDED
|
Git LFS Details
|
public/file.svg
ADDED
|
|
public/fonts/Bitcount.ttf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c4d16dfd9bbfbae68cd523a0a34cae8fd01f3324f305affec8908508111614b0
|
| 3 |
+
size 342692
|
public/globe.svg
ADDED
|
|
public/light.png
ADDED
|
Git LFS Details
|
public/next.svg
ADDED
|
|
public/vercel.svg
ADDED
|
|
public/window.svg
ADDED
|
|
scripts/fix-visibility.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
const fs = require('fs');
|
| 3 |
+
const path = require('path');
|
| 4 |
+
|
| 5 |
+
// Load .env manually
|
| 6 |
+
try {
|
| 7 |
+
const envPath = path.resolve(__dirname, '../.env');
|
| 8 |
+
if (fs.existsSync(envPath)) {
|
| 9 |
+
const envConfig = fs.readFileSync(envPath, 'utf8');
|
| 10 |
+
envConfig.split('\n').forEach(line => {
|
| 11 |
+
line = line.trim();
|
| 12 |
+
if (!line || line.startsWith('#')) return;
|
| 13 |
+
|
| 14 |
+
const [key, ...valueParts] = line.split('=');
|
| 15 |
+
if (key && valueParts.length > 0) {
|
| 16 |
+
let value = valueParts.join('=').trim();
|
| 17 |
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
| 18 |
+
value = value.slice(1, -1);
|
| 19 |
+
}
|
| 20 |
+
if (!process.env[key.trim()]) {
|
| 21 |
+
process.env[key.trim()] = value;
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
console.log("Loaded .env file");
|
| 26 |
+
}
|
| 27 |
+
} catch (e) {
|
| 28 |
+
console.warn("Could not load .env file:", e.message);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const { PrismaClient } = require('@prisma/client');
|
| 32 |
+
const prisma = new PrismaClient();
|
| 33 |
+
|
| 34 |
+
async function main() {
|
| 35 |
+
console.log("🔍 Starting Visibility Fix...");
|
| 36 |
+
|
| 37 |
+
try {
|
| 38 |
+
const result = await prisma.generation.updateMany({
|
| 39 |
+
where: {
|
| 40 |
+
isPublic: false
|
| 41 |
+
},
|
| 42 |
+
data: {
|
| 43 |
+
isPublic: true
|
| 44 |
+
}
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
console.log(`✅ Updated ${result.count} generations to be public.`);
|
| 48 |
+
} catch (error) {
|
| 49 |
+
console.error("❌ Error updating visibility:", error);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
main()
|
| 54 |
+
.catch(e => {
|
| 55 |
+
console.error(e);
|
| 56 |
+
process.exit(1);
|
| 57 |
+
})
|
| 58 |
+
.finally(async () => {
|
| 59 |
+
await prisma.$disconnect();
|
| 60 |
+
});
|
scripts/seed-aspect-ratios.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
const fs = require('fs');
|
| 3 |
+
const path = require('path');
|
| 4 |
+
|
| 5 |
+
// Load .env manually
|
| 6 |
+
try {
|
| 7 |
+
const envPath = path.resolve(__dirname, '../.env');
|
| 8 |
+
if (fs.existsSync(envPath)) {
|
| 9 |
+
const envConfig = fs.readFileSync(envPath, 'utf8');
|
| 10 |
+
envConfig.split('\n').forEach(line => {
|
| 11 |
+
line = line.trim();
|
| 12 |
+
if (!line || line.startsWith('#')) return;
|
| 13 |
+
|
| 14 |
+
const [key, ...valueParts] = line.split('=');
|
| 15 |
+
if (key && valueParts.length > 0) {
|
| 16 |
+
let value = valueParts.join('=').trim();
|
| 17 |
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
| 18 |
+
value = value.slice(1, -1);
|
| 19 |
+
}
|
| 20 |
+
if (!process.env[key.trim()]) {
|
| 21 |
+
process.env[key.trim()] = value;
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
console.log("Loaded .env file");
|
| 26 |
+
}
|
| 27 |
+
} catch (e) {
|
| 28 |
+
console.warn("Could not load .env file:", e.message);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const { PrismaClient } = require('@prisma/client');
|
| 32 |
+
const prisma = new PrismaClient();
|
| 33 |
+
|
| 34 |
+
// Configuration
|
| 35 |
+
const WORKER_URL = process.env.CLOUDFLARE_WORKER_URL || "https://wild-art-dca7.veltrix620.workers.dev";
|
| 36 |
+
const MODELS = ["flux-klein", "flux-klein-4b", "flux-dev"];
|
| 37 |
+
|
| 38 |
+
// Target First 5 Users
|
| 39 |
+
const USERS = [
|
| 40 |
+
{ email: "aarav.patel@gmail.com" },
|
| 41 |
+
{ email: "diya.sharma88@outlook.com" },
|
| 42 |
+
{ email: "vihaan.singh@yahoo.com" },
|
| 43 |
+
{ email: "ananya.g@hotmail.com" },
|
| 44 |
+
{ email: "arjun.reddy@gmail.com" }
|
| 45 |
+
];
|
| 46 |
+
|
| 47 |
+
// Aspect Ratios
|
| 48 |
+
const RATIOS = [
|
| 49 |
+
{ label: "16:9", width: 1024, height: 576 },
|
| 50 |
+
{ label: "9:16", width: 576, height: 1024 },
|
| 51 |
+
{ label: "4:3", width: 1024, height: 768 },
|
| 52 |
+
{ label: "3:4", width: 768, height: 1024 },
|
| 53 |
+
{ label: "1:1", width: 1024, height: 1024 }
|
| 54 |
+
];
|
| 55 |
+
|
| 56 |
+
// 15 FRESH Unique Prompts (Batch 2)
|
| 57 |
+
const PROMPTS = [
|
| 58 |
+
// Aarav (Futuristic)
|
| 59 |
+
"A transparent smartphone with holographic display, floating user interface, tech realism",
|
| 60 |
+
"A sleek bullet train speeding through a snowy mountain pass, motion blur, 8k",
|
| 61 |
+
"A cyberpunk street cat with neon collar, rainy alleyway reflection, cinematic",
|
| 62 |
+
|
| 63 |
+
// Diya (Artistic)
|
| 64 |
+
"A portrait of a girl where her hair turns into a flock of birds, surrealism, double exposure",
|
| 65 |
+
"A miniature world inside a lightbulb, tiny house and forest, magical lighting",
|
| 66 |
+
"A giant whale flying in the sky above the clouds, dreamlike fantasy art",
|
| 67 |
+
|
| 68 |
+
// Vihaan (Action/Bold)
|
| 69 |
+
"A knight facing a giant lava monster in a volcano, epic scale, dynamic lighting",
|
| 70 |
+
"A futuristic formula 1 car, wide angle shot, sparks flying, aggressive stance",
|
| 71 |
+
"A detailed skull made of melting gold and black liquid, high contrast 3d render",
|
| 72 |
+
|
| 73 |
+
// Ananya (Abstract/Texture)
|
| 74 |
+
"Close up of colorful ink dropping into water, swirling smoke effect, macro photography",
|
| 75 |
+
"A geometric origami animal series, lion made of paper folds, studio lighting",
|
| 76 |
+
"Liquid mercury flowing over black rocks, realistic texture render",
|
| 77 |
+
|
| 78 |
+
// Arjun (Landscape/Epic)
|
| 79 |
+
"A lost city underwater, sunlight filtering through the ocean surface, ancient ruins",
|
| 80 |
+
"A cabin in the woods during aurora borealis, cozy warm light, winter night",
|
| 81 |
+
"A post-apocalyptic overgrown city, nature taking back skyscrapers, last of us vibe"
|
| 82 |
+
];
|
| 83 |
+
|
| 84 |
+
async function generateImage(prompt, model, width, height) {
|
| 85 |
+
const workerUrl = WORKER_URL.endsWith("/") ? WORKER_URL.slice(0, -1) : WORKER_URL;
|
| 86 |
+
const endpoint = model;
|
| 87 |
+
const url = `${workerUrl}/${endpoint}`;
|
| 88 |
+
|
| 89 |
+
try {
|
| 90 |
+
console.log(`Generating: "${prompt.slice(0, 20)}..." [${width}x${height}] with ${model}`);
|
| 91 |
+
|
| 92 |
+
const response = await fetch(url, {
|
| 93 |
+
method: "POST",
|
| 94 |
+
headers: { "Content-Type": "application/json" },
|
| 95 |
+
body: JSON.stringify({
|
| 96 |
+
prompt,
|
| 97 |
+
negative_prompt: "blurry, low quality, bad anatomy, text, watermark",
|
| 98 |
+
width,
|
| 99 |
+
height,
|
| 100 |
+
steps: 30
|
| 101 |
+
}),
|
| 102 |
+
});
|
| 103 |
+
|
| 104 |
+
if (!response.ok) {
|
| 105 |
+
console.error(`Failed to generate: ${response.status} ${response.statusText}`);
|
| 106 |
+
return null;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
const result = await response.json();
|
| 110 |
+
|
| 111 |
+
if (result.success && result.url) {
|
| 112 |
+
return result.url;
|
| 113 |
+
} else {
|
| 114 |
+
console.error("API returned success:false or no URL");
|
| 115 |
+
return null;
|
| 116 |
+
}
|
| 117 |
+
} catch (error) {
|
| 118 |
+
console.error("Generation error:", error.message);
|
| 119 |
+
return null;
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
async function main() {
|
| 124 |
+
console.log("🌱 Starting Aspect Ratio Seeding (Batch 2)...");
|
| 125 |
+
|
| 126 |
+
let promptIndex = 0;
|
| 127 |
+
|
| 128 |
+
for (const userData of USERS) {
|
| 129 |
+
// 1. Find User
|
| 130 |
+
const user = await prisma.user.findUnique({ where: { email: userData.email } });
|
| 131 |
+
|
| 132 |
+
if (!user) {
|
| 133 |
+
console.log(`User ${userData.email} not found. Skipping.`);
|
| 134 |
+
promptIndex += 3;
|
| 135 |
+
continue;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
console.log(`\nProcessing ${user.name}...`);
|
| 139 |
+
|
| 140 |
+
// 2. Generate 3 Images
|
| 141 |
+
const userPrompts = PROMPTS.slice(promptIndex, promptIndex + 3);
|
| 142 |
+
promptIndex += 3;
|
| 143 |
+
|
| 144 |
+
for (const prompt of userPrompts) {
|
| 145 |
+
const model = MODELS[Math.floor(Math.random() * MODELS.length)];
|
| 146 |
+
const ratio = RATIOS[Math.floor(Math.random() * RATIOS.length)];
|
| 147 |
+
|
| 148 |
+
const imageUrl = await generateImage(prompt, model, ratio.width, ratio.height);
|
| 149 |
+
|
| 150 |
+
if (imageUrl) {
|
| 151 |
+
await prisma.generation.create({
|
| 152 |
+
data: {
|
| 153 |
+
prompt: prompt,
|
| 154 |
+
model: model,
|
| 155 |
+
width: ratio.width,
|
| 156 |
+
height: ratio.height,
|
| 157 |
+
imageUrl: imageUrl,
|
| 158 |
+
userId: user.id,
|
| 159 |
+
isPublic: true,
|
| 160 |
+
createdAt: new Date()
|
| 161 |
+
}
|
| 162 |
+
});
|
| 163 |
+
console.log(`Saved generation (${ratio.label})`);
|
| 164 |
+
} else {
|
| 165 |
+
console.log(`Failed generation`);
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// Small delay
|
| 169 |
+
await new Promise(r => setTimeout(r, 1000));
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
console.log("\n✅ Seeding Complete!");
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
main()
|
| 177 |
+
.catch(e => {
|
| 178 |
+
console.error(e);
|
| 179 |
+
process.exit(1);
|
| 180 |
+
})
|
| 181 |
+
.finally(async () => {
|
| 182 |
+
await prisma.$disconnect();
|
| 183 |
+
});
|
scripts/seed-data.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
const fs = require('fs');
|
| 3 |
+
const path = require('path');
|
| 4 |
+
|
| 5 |
+
// Load .env manually since dotenv might not be installed
|
| 6 |
+
try {
|
| 7 |
+
const envPath = path.resolve(__dirname, '../.env');
|
| 8 |
+
if (fs.existsSync(envPath)) {
|
| 9 |
+
const envConfig = fs.readFileSync(envPath, 'utf8');
|
| 10 |
+
envConfig.split('\n').forEach(line => {
|
| 11 |
+
line = line.trim();
|
| 12 |
+
if (!line || line.startsWith('#')) return;
|
| 13 |
+
|
| 14 |
+
const [key, ...valueParts] = line.split('=');
|
| 15 |
+
if (key && valueParts.length > 0) {
|
| 16 |
+
let value = valueParts.join('=').trim();
|
| 17 |
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
| 18 |
+
value = value.slice(1, -1);
|
| 19 |
+
}
|
| 20 |
+
if (!process.env[key.trim()]) {
|
| 21 |
+
process.env[key.trim()] = value;
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
console.log("Loaded .env file");
|
| 26 |
+
}
|
| 27 |
+
} catch (e) {
|
| 28 |
+
console.warn("Could not load .env file:", e.message);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const { PrismaClient } = require('@prisma/client');
|
| 32 |
+
const prisma = new PrismaClient();
|
| 33 |
+
|
| 34 |
+
// Configuration
|
| 35 |
+
const WORKER_URL = process.env.CLOUDFLARE_WORKER_URL || "https://wild-art-dca7.veltrix620.workers.dev"; // Fallback if env not set
|
| 36 |
+
const MODELS = ["flux-klein", "flux-klein-4b"];
|
| 37 |
+
|
| 38 |
+
// 10 Realistic Indian Users
|
| 39 |
+
const USERS = [
|
| 40 |
+
{ name: "Aarav Patel", email: "aarav.patel@gmail.com", username: "aarav_art" },
|
| 41 |
+
{ name: "Diya Sharma", email: "diya.sharma88@outlook.com", username: "diya_creates" },
|
| 42 |
+
{ name: "Vihaan Singh", email: "vihaan.singh@yahoo.com", username: "vihaan_visuals" },
|
| 43 |
+
{ name: "Ananya Gupta", email: "ananya.g@hotmail.com", username: "art_by_ananya" },
|
| 44 |
+
{ name: "Arjun Reddy", email: "arjun.reddy@gmail.com", username: "arjun_pixels" },
|
| 45 |
+
{ name: "Zara Khan", email: "zara.khan.design@gmail.com", username: "zara_designs" },
|
| 46 |
+
{ name: "Ishaan Kumar", email: "ishaan.k99@outlook.com", username: "ishaan_imagines" },
|
| 47 |
+
{ name: "Priya Malhotra", email: "priya.malhotra@yahoo.com", username: "priya_paints" },
|
| 48 |
+
{ name: "Rohan Verma", email: "rohan.verma@gmail.com", username: "rohan_renders" },
|
| 49 |
+
{ name: "Sanya Kapoor", email: "sanya.kapoor@hotmail.com", username: "sanya_studio" }
|
| 50 |
+
];
|
| 51 |
+
|
| 52 |
+
// 50 Unique Prompts (5 per user)
|
| 53 |
+
const PROMPTS = [
|
| 54 |
+
// Aarav
|
| 55 |
+
"A futuristic cyberpunk city street in Mumbai at night, neon lights reflecting on wet pavement, 8k resolution",
|
| 56 |
+
"Portrait of an old Indian wise man with a turban, hyperrealistic, detailed wrinkles, warm lighting",
|
| 57 |
+
"A minimalist logo design of a lotus flower, vector art, flat style, orange and white",
|
| 58 |
+
"Concept art of a flying car in a retro-futuristic style, chrome finish, sunset background",
|
| 59 |
+
"Macro photography of a dew drop on a green leaf, bokeh background, natural lighting",
|
| 60 |
+
|
| 61 |
+
// Diya
|
| 62 |
+
"A watercolor painting of the Taj Mahal at sunrise, soft pastel colors, dreamy atmosphere",
|
| 63 |
+
"Digital illustration of a chaotic workspace with multiple screens and coffee cups, lo-fi aesthetic",
|
| 64 |
+
"A fantasy landscape with floating islands and waterfalls, vibrant colors, cinematic lighting",
|
| 65 |
+
"Character design of a female warrior in ancient armor, holding a glowing sword, dynamic pose",
|
| 66 |
+
"Abstract expressionist painting with bold brushstrokes of red and gold, chaotic texture",
|
| 67 |
+
|
| 68 |
+
// Vihaan
|
| 69 |
+
"A close-up of a tiger's eye, intense gaze, highly detailed fur, wildlife photography style",
|
| 70 |
+
"A delicious plate of butter chicken with naan, steam rising, food photography, top-down view",
|
| 71 |
+
"Architectural render of a modern eco-friendly house in the forest, glass walls, green roof",
|
| 72 |
+
"A steampunk robot playing a violin, detailed gears and brass, moody lighting",
|
| 73 |
+
"A stylized 3D character of a cute astronaut floating in space, low poly style",
|
| 74 |
+
|
| 75 |
+
// Ananya
|
| 76 |
+
"Pattern design of traditional Indian block print, indigo and white, seamless texture",
|
| 77 |
+
"A tranquil zen garden with raked sand and stones, morning mist, peaceful atmosphere",
|
| 78 |
+
"Cybernetic implant concept art, detailed metal and skin integration, blue glowing lights",
|
| 79 |
+
"A vintage travel poster for Goa, palm trees and beach, retro typography and colors",
|
| 80 |
+
"Oil painting of a rainy window looking out at a city skyline, melancholy mood",
|
| 81 |
+
|
| 82 |
+
// Arjun
|
| 83 |
+
"Isometric view of a cozy gaming room, neon accents, detailed props, 3D render",
|
| 84 |
+
"A majestic dragon perched on a mountain peak, breathing fire, epic fantasy art",
|
| 85 |
+
"Portrait of a woman made entirely of flowers and vines, surrealism style",
|
| 86 |
+
"A bustling market in Delhi, colorful spices and fabrics, vibrant energy, street photography",
|
| 87 |
+
"A sleek sports car drifting on a race track, motion blur, smoke effects, photorealistic",
|
| 88 |
+
|
| 89 |
+
// Zara
|
| 90 |
+
"Fashion illustration of a modern saree with geometric patterns, high fashion style",
|
| 91 |
+
"A glowing magical forest with bioluminescent plants, purple and blue color palette",
|
| 92 |
+
"Double exposure portrait of a man and a wolf, black and white photography",
|
| 93 |
+
"A tasty burger with melting cheese and fries, advertising photography style",
|
| 94 |
+
"Concept art of a space station orbiting a red planet, sci-fi realism",
|
| 95 |
+
|
| 96 |
+
// Ishaan
|
| 97 |
+
"A pixel art scene of a retro arcade, neon signs, 8-bit style",
|
| 98 |
+
"A detailed map of a fantasy world, parchment texture, hand-drawn style",
|
| 99 |
+
"A spooky haunted house on a hill, thunderstorm background, horror atmosphere",
|
| 100 |
+
"Product photography of a luxury perfume bottle, gold accents, elegant lighting",
|
| 101 |
+
"A cute anime girl with cat ears holding a bubble tea, pastel colors",
|
| 102 |
+
|
| 103 |
+
// Priya
|
| 104 |
+
"Mandala art with intricate patterns, black ink on white paper, meditative style",
|
| 105 |
+
"A majestic lion with a galaxy mane, cosmic colors, digital art",
|
| 106 |
+
"A snowy mountain landscape at twilight, cold blue tones, serene mood",
|
| 107 |
+
"Character concept of a cyberpunk hacker, neon hair, futuristic clothing",
|
| 108 |
+
"A vibrant fruit bowl painting, still life, impressionist style",
|
| 109 |
+
|
| 110 |
+
// Rohan
|
| 111 |
+
"3D text render saying 'WILD ART', metallic texture, glossy finish",
|
| 112 |
+
"A surreal landscape with melting clocks, inspired by Dali, dreamlike",
|
| 113 |
+
"A detailed sketch of a human skull, anatomical accuracy, charcoal style",
|
| 114 |
+
"A cozy library with wall-to-wall books, warm fireplace light, inviting atmosphere",
|
| 115 |
+
"A futuristic drone delivering a package, city skyline background, realistic",
|
| 116 |
+
|
| 117 |
+
// Sanya
|
| 118 |
+
"A fashion photoshoot of a model in a desert, flowing red dress, dramatic lighting",
|
| 119 |
+
"A cute vector illustration of a corgi dog wearing sunglasses, flat design",
|
| 120 |
+
"A post-apocalyptic city overflown with nature, ruins and vines, concept art",
|
| 121 |
+
"A close-up of a human eye with a universe reflection, macro photography",
|
| 122 |
+
"A traditional Indian wedding procession, colorful attire, festive atmosphere"
|
| 123 |
+
];
|
| 124 |
+
|
| 125 |
+
async function generateImage(prompt, model) {
|
| 126 |
+
const workerUrl = WORKER_URL.endsWith("/") ? WORKER_URL.slice(0, -1) : WORKER_URL;
|
| 127 |
+
const endpoint = model;
|
| 128 |
+
const url = `${workerUrl}/${endpoint}`;
|
| 129 |
+
|
| 130 |
+
try {
|
| 131 |
+
console.log(`Generating: "${prompt.slice(0, 30)}..." with ${model}`);
|
| 132 |
+
|
| 133 |
+
// Using fetch (requires Node 18+)
|
| 134 |
+
const response = await fetch(url, {
|
| 135 |
+
method: "POST",
|
| 136 |
+
headers: { "Content-Type": "application/json" },
|
| 137 |
+
body: JSON.stringify({ prompt, width: 1024, height: 1024, steps: 30 }),
|
| 138 |
+
});
|
| 139 |
+
|
| 140 |
+
if (!response.ok) {
|
| 141 |
+
console.error(`Failed to generate: ${response.status} ${response.statusText}`);
|
| 142 |
+
return null;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
const result = await response.json();
|
| 146 |
+
|
| 147 |
+
if (result.success && result.url) {
|
| 148 |
+
return result.url;
|
| 149 |
+
} else {
|
| 150 |
+
console.error("API returned success:false or no URL");
|
| 151 |
+
return null;
|
| 152 |
+
}
|
| 153 |
+
} catch (error) {
|
| 154 |
+
console.error("Generation error:", error.message);
|
| 155 |
+
return null;
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
async function main() {
|
| 160 |
+
console.log("🌱 Starting Data Seeding...");
|
| 161 |
+
|
| 162 |
+
// 1. Create Users
|
| 163 |
+
const createdUsers = [];
|
| 164 |
+
for (const userData of USERS) {
|
| 165 |
+
try {
|
| 166 |
+
// Check if exists
|
| 167 |
+
const existing = await prisma.user.findUnique({ where: { email: userData.email } });
|
| 168 |
+
if (existing) {
|
| 169 |
+
console.log(`User ${userData.name} already exists.`);
|
| 170 |
+
createdUsers.push(existing);
|
| 171 |
+
} else {
|
| 172 |
+
const user = await prisma.user.create({
|
| 173 |
+
data: {
|
| 174 |
+
name: userData.name,
|
| 175 |
+
email: userData.email,
|
| 176 |
+
username: userData.username,
|
| 177 |
+
credits: 1000, // Give them plenty of credits
|
| 178 |
+
image: `https://api.dicebear.com/7.x/avataaars/svg?seed=${userData.username}` // Random avatar
|
| 179 |
+
}
|
| 180 |
+
});
|
| 181 |
+
console.log(`Created user: ${user.name}`);
|
| 182 |
+
createdUsers.push(user);
|
| 183 |
+
}
|
| 184 |
+
} catch (e) {
|
| 185 |
+
console.error(`Error creating user ${userData.name}:`, e.message);
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
// 2. Generate Images
|
| 190 |
+
console.log("\n🎨 Generating 50 Images...");
|
| 191 |
+
let promptIndex = 0;
|
| 192 |
+
|
| 193 |
+
// Distribute 5 images per user
|
| 194 |
+
for (const user of createdUsers) {
|
| 195 |
+
if (promptIndex >= PROMPTS.length) break;
|
| 196 |
+
|
| 197 |
+
const userPrompts = PROMPTS.slice(promptIndex, promptIndex + 5);
|
| 198 |
+
promptIndex += 5;
|
| 199 |
+
|
| 200 |
+
console.log(`\nProcessing ${user.name}...`);
|
| 201 |
+
|
| 202 |
+
for (const prompt of userPrompts) {
|
| 203 |
+
const model = MODELS[Math.floor(Math.random() * MODELS.length)]; // Randomly pick model
|
| 204 |
+
|
| 205 |
+
const imageUrl = await generateImage(prompt, model);
|
| 206 |
+
|
| 207 |
+
if (imageUrl) {
|
| 208 |
+
await prisma.generation.create({
|
| 209 |
+
data: {
|
| 210 |
+
prompt: prompt,
|
| 211 |
+
model: model,
|
| 212 |
+
width: 1024,
|
| 213 |
+
height: 1024,
|
| 214 |
+
imageUrl: imageUrl,
|
| 215 |
+
userId: user.id,
|
| 216 |
+
isPublic: true,
|
| 217 |
+
createdAt: new Date() // Current time
|
| 218 |
+
}
|
| 219 |
+
});
|
| 220 |
+
console.log(`Saved generation for prompt: "${prompt.slice(0, 20)}..."`);
|
| 221 |
+
} else {
|
| 222 |
+
console.log(`Skipping DB save due to generation failure for: "${prompt.slice(0, 20)}..."`);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
// Small delay to be nice to the API
|
| 226 |
+
await new Promise(r => setTimeout(r, 1000));
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
console.log("\n✅ Seeding Complete!");
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
main()
|
| 234 |
+
.catch(e => {
|
| 235 |
+
console.error(e);
|
| 236 |
+
process.exit(1);
|
| 237 |
+
})
|
| 238 |
+
.finally(async () => {
|
| 239 |
+
await prisma.$disconnect();
|
| 240 |
+
});
|
scripts/seed-more.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
const fs = require('fs');
|
| 3 |
+
const path = require('path');
|
| 4 |
+
|
| 5 |
+
// Load .env manually since dotenv might not be installed
|
| 6 |
+
try {
|
| 7 |
+
const envPath = path.resolve(__dirname, '../.env');
|
| 8 |
+
if (fs.existsSync(envPath)) {
|
| 9 |
+
const envConfig = fs.readFileSync(envPath, 'utf8');
|
| 10 |
+
envConfig.split('\n').forEach(line => {
|
| 11 |
+
line = line.trim();
|
| 12 |
+
if (!line || line.startsWith('#')) return;
|
| 13 |
+
|
| 14 |
+
const [key, ...valueParts] = line.split('=');
|
| 15 |
+
if (key && valueParts.length > 0) {
|
| 16 |
+
let value = valueParts.join('=').trim();
|
| 17 |
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
| 18 |
+
value = value.slice(1, -1);
|
| 19 |
+
}
|
| 20 |
+
if (!process.env[key.trim()]) {
|
| 21 |
+
process.env[key.trim()] = value;
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
console.log("Loaded .env file");
|
| 26 |
+
}
|
| 27 |
+
} catch (e) {
|
| 28 |
+
console.warn("Could not load .env file:", e.message);
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const { PrismaClient } = require('@prisma/client');
|
| 32 |
+
const prisma = new PrismaClient();
|
| 33 |
+
|
| 34 |
+
// Configuration
|
| 35 |
+
const WORKER_URL = process.env.CLOUDFLARE_WORKER_URL || "https://wild-art-dca7.veltrix620.workers.dev";
|
| 36 |
+
const MODELS = ["flux-klein", "flux-klein-4b", "flux-dev"];
|
| 37 |
+
|
| 38 |
+
// 10 Realistic Indian Users (Same as seed-data.js)
|
| 39 |
+
const USERS = [
|
| 40 |
+
{ email: "aarav.patel@gmail.com" },
|
| 41 |
+
{ email: "diya.sharma88@outlook.com" },
|
| 42 |
+
{ email: "vihaan.singh@yahoo.com" },
|
| 43 |
+
{ email: "ananya.g@hotmail.com" },
|
| 44 |
+
{ email: "arjun.reddy@gmail.com" },
|
| 45 |
+
{ email: "zara.khan.design@gmail.com" },
|
| 46 |
+
{ email: "ishaan.k99@outlook.com" },
|
| 47 |
+
{ email: "priya.malhotra@yahoo.com" },
|
| 48 |
+
{ email: "rohan.verma@gmail.com" },
|
| 49 |
+
{ email: "sanya.kapoor@hotmail.com" }
|
| 50 |
+
];
|
| 51 |
+
|
| 52 |
+
// 30 Fresh Unique Prompts (3 per user)
|
| 53 |
+
const PROMPTS = [
|
| 54 |
+
// Aarav (Mix of Tech & Nature)
|
| 55 |
+
"A solar-powered eco-city floating on the ocean, green technology, utopia, aerial view",
|
| 56 |
+
"Close-up of a mechanical beetle with gemstone eyes, intricate clockwork details",
|
| 57 |
+
"A lone astronaut standing on a purple sand dune, gazing at double moons",
|
| 58 |
+
|
| 59 |
+
// Diya (Artistic & Soft)
|
| 60 |
+
"A glasshouse filled with bioluminescent giant mushrooms, night time, magical atmosphere",
|
| 61 |
+
"Portrait of a woman wearing a dress made of flowing water, surreal fashion",
|
| 62 |
+
"A cozy reading nook inside a hollowed-out ancient tree, warm lantern light",
|
| 63 |
+
|
| 64 |
+
// Vihaan (Bold & dynamic)
|
| 65 |
+
"A cyberpunk samurai riding a neon motorcycle, rainy tokyo street background",
|
| 66 |
+
"A massive stone golem sleeping in a mountain range, covered in moss and trees",
|
| 67 |
+
"Abstract visualization of sound waves, vibrant neon colors against black",
|
| 68 |
+
|
| 69 |
+
// Ananya (Pattern & Texture)
|
| 70 |
+
"Intricate mosaic floor design with gold and turquoise tiles, geometric patterns",
|
| 71 |
+
"A macro shot of a peacock feather, iridescent colors, high detail",
|
| 72 |
+
"A vintage library with floating books, magical realism style",
|
| 73 |
+
|
| 74 |
+
// Arjun (Fantasy & Epic)
|
| 75 |
+
"A phoenix rising from ashes, dramatic fire effects, cinematic lighting",
|
| 76 |
+
"A hidden temple in the jungle, overgrown with vines, waterfalls cascading down",
|
| 77 |
+
"A fleet of steampunk airships in the clouds, brass and copper textures",
|
| 78 |
+
|
| 79 |
+
// Zara (Fashion & Modern)
|
| 80 |
+
"Futuristic runway fashion, holographic fabric, avant-garde style",
|
| 81 |
+
"A modern architectural glass building reflecting a sunset, sleek lines",
|
| 82 |
+
"A stylized portrait of a cat wearing diamond jewelry, luxury art",
|
| 83 |
+
|
| 84 |
+
// Ishaan (Playful & Retro)
|
| 85 |
+
"A 90s vaporwave aesthetic landscape, grid floor, palm trees, pink sun",
|
| 86 |
+
"A cute robot watering plants in a greenhouse, pixar style render",
|
| 87 |
+
"A delicious tower of colorful macarons, food photography",
|
| 88 |
+
|
| 89 |
+
// Priya (Traditional & Cosmic)
|
| 90 |
+
"A mandala made of stars and galaxies, cosmic spiritual art",
|
| 91 |
+
"A traditional Indian dancer silhouette against a giant moon",
|
| 92 |
+
"A serene lake reflecting the aurora borealis, winter landscape",
|
| 93 |
+
|
| 94 |
+
// Rohan (Render & 3D)
|
| 95 |
+
"Low poly 3D island with a volcano and palm trees, isometric view",
|
| 96 |
+
"A futuristic helmet design, glossy white and orange, sci-fi concept",
|
| 97 |
+
"A liquid chrome sphere reflecting a distorted city, abstract 3D art",
|
| 98 |
+
|
| 99 |
+
// Sanya (Nature & Portrait)
|
| 100 |
+
"Double exposure of a tiger and a dense jungle, black and white",
|
| 101 |
+
"A field of sunflowers at golden hour, warm and sunny vibe",
|
| 102 |
+
"A portrait of a girl with butterfly wings, fantasy concept art"
|
| 103 |
+
];
|
| 104 |
+
|
| 105 |
+
async function generateImage(prompt, model) {
|
| 106 |
+
const workerUrl = WORKER_URL.endsWith("/") ? WORKER_URL.slice(0, -1) : WORKER_URL;
|
| 107 |
+
const endpoint = model;
|
| 108 |
+
const url = `${workerUrl}/${endpoint}`;
|
| 109 |
+
|
| 110 |
+
try {
|
| 111 |
+
console.log(`Generating: "${prompt.slice(0, 30)}..." with ${model}`);
|
| 112 |
+
|
| 113 |
+
const response = await fetch(url, {
|
| 114 |
+
method: "POST",
|
| 115 |
+
headers: { "Content-Type": "application/json" },
|
| 116 |
+
body: JSON.stringify({
|
| 117 |
+
prompt,
|
| 118 |
+
negative_prompt: "blurry, low quality, bad anatomy, text, watermark",
|
| 119 |
+
width: 1024,
|
| 120 |
+
height: 1024,
|
| 121 |
+
steps: 30
|
| 122 |
+
}),
|
| 123 |
+
});
|
| 124 |
+
|
| 125 |
+
if (!response.ok) {
|
| 126 |
+
console.error(`Failed to generate: ${response.status} ${response.statusText}`);
|
| 127 |
+
return null;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
const result = await response.json();
|
| 131 |
+
|
| 132 |
+
if (result.success && result.url) {
|
| 133 |
+
return result.url;
|
| 134 |
+
} else {
|
| 135 |
+
console.error("API returned success:false or no URL");
|
| 136 |
+
return null;
|
| 137 |
+
}
|
| 138 |
+
} catch (error) {
|
| 139 |
+
console.error("Generation error:", error.message);
|
| 140 |
+
return null;
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
async function main() {
|
| 145 |
+
console.log("🌱 Starting Additional Seeding (3 images/user)...");
|
| 146 |
+
|
| 147 |
+
let promptIndex = 0;
|
| 148 |
+
|
| 149 |
+
for (const userData of USERS) {
|
| 150 |
+
// 1. Find User
|
| 151 |
+
const user = await prisma.user.findUnique({ where: { email: userData.email } });
|
| 152 |
+
|
| 153 |
+
if (!user) {
|
| 154 |
+
console.log(`User ${userData.email} not found. Skipping.`);
|
| 155 |
+
promptIndex += 3; // Skip 3 prompts to keep alignment
|
| 156 |
+
continue;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
console.log(`\nProcessing ${user.name}...`);
|
| 160 |
+
|
| 161 |
+
// 2. Generate 3 Images
|
| 162 |
+
const userPrompts = PROMPTS.slice(promptIndex, promptIndex + 3);
|
| 163 |
+
promptIndex += 3;
|
| 164 |
+
|
| 165 |
+
for (const prompt of userPrompts) {
|
| 166 |
+
const model = MODELS[Math.floor(Math.random() * MODELS.length)];
|
| 167 |
+
|
| 168 |
+
const imageUrl = await generateImage(prompt, model);
|
| 169 |
+
|
| 170 |
+
if (imageUrl) {
|
| 171 |
+
await prisma.generation.create({
|
| 172 |
+
data: {
|
| 173 |
+
prompt: prompt,
|
| 174 |
+
model: model,
|
| 175 |
+
width: 1024,
|
| 176 |
+
height: 1024,
|
| 177 |
+
imageUrl: imageUrl,
|
| 178 |
+
userId: user.id,
|
| 179 |
+
isPublic: true,
|
| 180 |
+
createdAt: new Date()
|
| 181 |
+
}
|
| 182 |
+
});
|
| 183 |
+
console.log(`Saved generation: "${prompt.slice(0, 20)}..."`);
|
| 184 |
+
} else {
|
| 185 |
+
console.log(`Failed generation: "${prompt.slice(0, 20)}..."`);
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
// Small delay
|
| 189 |
+
await new Promise(r => setTimeout(r, 1000));
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
console.log("\n✅ Seeding Complete!");
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
main()
|
| 197 |
+
.catch(e => {
|
| 198 |
+
console.error(e);
|
| 199 |
+
process.exit(1);
|
| 200 |
+
})
|
| 201 |
+
.finally(async () => {
|
| 202 |
+
await prisma.$disconnect();
|
| 203 |
+
});
|
scripts/update-credits.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { PrismaClient } from "@prisma/client"
|
| 2 |
+
|
| 3 |
+
const prisma = new PrismaClient()
|
| 4 |
+
|
| 5 |
+
async function main() {
|
| 6 |
+
console.log("Starting credit migration...")
|
| 7 |
+
|
| 8 |
+
try {
|
| 9 |
+
const result = await prisma.user.updateMany({
|
| 10 |
+
data: {
|
| 11 |
+
credits: 100
|
| 12 |
+
}
|
| 13 |
+
})
|
| 14 |
+
|
| 15 |
+
console.log(`Successfully updated credits for ${result.count} users.`)
|
| 16 |
+
} catch (error) {
|
| 17 |
+
console.error("Error updating credits:", error)
|
| 18 |
+
process.exit(1)
|
| 19 |
+
} finally {
|
| 20 |
+
await prisma.$disconnect()
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
main()
|
src/app/(auth)/login/page.tsx
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState } from "react"
|
| 4 |
+
import Link from "next/link"
|
| 5 |
+
import { useRouter } from "next/navigation"
|
| 6 |
+
import { signIn } from "next-auth/react"
|
| 7 |
+
import { Button } from "@/components/ui/button"
|
| 8 |
+
import { Input } from "@/components/ui/input"
|
| 9 |
+
import { Label } from "@/components/ui/label"
|
| 10 |
+
import { Loader2, Sparkles, Eye, EyeOff } from "lucide-react"
|
| 11 |
+
|
| 12 |
+
export default function LoginPage() {
|
| 13 |
+
const router = useRouter()
|
| 14 |
+
const [isLoading, setIsLoading] = useState(false)
|
| 15 |
+
const [showPassword, setShowPassword] = useState(false)
|
| 16 |
+
const [error, setError] = useState("")
|
| 17 |
+
|
| 18 |
+
async function onSubmit(e: React.FormEvent<HTMLFormElement>) {
|
| 19 |
+
e.preventDefault()
|
| 20 |
+
setIsLoading(true)
|
| 21 |
+
setError("")
|
| 22 |
+
|
| 23 |
+
const formData = new FormData(e.currentTarget)
|
| 24 |
+
|
| 25 |
+
try {
|
| 26 |
+
const result = await signIn("credentials", {
|
| 27 |
+
email: formData.get("email"),
|
| 28 |
+
password: formData.get("password"),
|
| 29 |
+
redirect: false,
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
+
if (result?.error) {
|
| 33 |
+
setError("Invalid email or password")
|
| 34 |
+
} else {
|
| 35 |
+
router.push("/create")
|
| 36 |
+
router.refresh()
|
| 37 |
+
}
|
| 38 |
+
} catch (error) {
|
| 39 |
+
setError("Something went wrong")
|
| 40 |
+
} finally {
|
| 41 |
+
setIsLoading(false)
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
return (
|
| 46 |
+
<div className="min-h-screen flex font-sans">
|
| 47 |
+
{/* Left Panel - Branding */}
|
| 48 |
+
<div className="hidden lg:flex lg:w-1/2 relative overflow-hidden bg-primary/5 border-r-2 border-border">
|
| 49 |
+
{/* Background Pattern */}
|
| 50 |
+
<div className="absolute inset-0 bg-[linear-gradient(rgba(0,0,0,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,0,0,0.02)_1px,transparent_1px)] dark:bg-[linear-gradient(rgba(255,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.02)_1px,transparent_1px)] bg-[size:64px_64px]" />
|
| 51 |
+
|
| 52 |
+
{/* Content */}
|
| 53 |
+
<div className="relative z-10 flex flex-col justify-center items-center p-8 text-center w-full">
|
| 54 |
+
<div className="space-y-8 max-w-lg">
|
| 55 |
+
<div className="inline-flex items-center gap-2 px-3 py-1.5 border-2 border-primary bg-primary/10 shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)]">
|
| 56 |
+
<Sparkles className="h-4 w-4 text-primary" />
|
| 57 |
+
<span className="text-xs font-black uppercase tracking-widest text-primary">AI Powered</span>
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
<h1 className="text-4xl xl:text-5xl font-black tracking-tighter leading-none uppercase">
|
| 61 |
+
Create Art That<br />
|
| 62 |
+
<span className="text-primary text-stroke-primary">
|
| 63 |
+
Breaks Limits
|
| 64 |
+
</span>
|
| 65 |
+
</h1>
|
| 66 |
+
|
| 67 |
+
<p className="text-xl text-muted-foreground font-medium uppercase tracking-wide">
|
| 68 |
+
Join thousands of artists using Imyra to transform imagination into stunning visuals.
|
| 69 |
+
</p>
|
| 70 |
+
|
| 71 |
+
{/* Stats */}
|
| 72 |
+
<div className="flex gap-8 justify-center pt-8">
|
| 73 |
+
<div className="text-center p-4 border-2 border-border bg-card shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 74 |
+
<p className="text-3xl font-black text-primary">50K+</p>
|
| 75 |
+
<p className="text-xs font-bold uppercase tracking-wider text-muted-foreground mt-1">Artworks</p>
|
| 76 |
+
</div>
|
| 77 |
+
<div className="text-center p-4 border-2 border-border bg-card shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 78 |
+
<p className="text-3xl font-black text-primary">10K+</p>
|
| 79 |
+
<p className="text-xs font-bold uppercase tracking-wider text-muted-foreground mt-1">Artists</p>
|
| 80 |
+
</div>
|
| 81 |
+
<div className="text-center p-4 border-2 border-border bg-card shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 82 |
+
<p className="text-3xl font-black text-primary">Free</p>
|
| 83 |
+
<p className="text-xs font-bold uppercase tracking-wider text-muted-foreground mt-1">To Start</p>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
|
| 90 |
+
{/* Right Panel - Form */}
|
| 91 |
+
<div className="w-full lg:w-1/2 flex flex-col justify-center p-8 lg:p-12 bg-background relative">
|
| 92 |
+
<div className="relative z-10 max-w-sm mx-auto w-full space-y-6">
|
| 93 |
+
{/* Logo */}
|
| 94 |
+
<Link href="/" className="inline-flex items-center gap-3 mb-6 group">
|
| 95 |
+
<div className="h-10 w-10 border-2 border-border bg-primary text-white flex items-center justify-center shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)] group-hover:translate-x-[2px] group-hover:translate-y-[2px] group-hover:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] dark:group-hover:shadow-[1px_1px_0px_0px_rgba(255,255,255,1)] transition-all">
|
| 96 |
+
<Sparkles className="h-5 w-5" />
|
| 97 |
+
</div>
|
| 98 |
+
<span className="text-xl font-black tracking-tighter uppercase group-hover:text-primary transition-colors">Imyra</span>
|
| 99 |
+
</Link>
|
| 100 |
+
|
| 101 |
+
<div className="space-y-2 border-l-4 border-primary pl-4">
|
| 102 |
+
<h2 className="text-3xl font-black tracking-tighter uppercase">Welcome back</h2>
|
| 103 |
+
<p className="text-muted-foreground font-medium uppercase tracking-wide text-xs">
|
| 104 |
+
Enter your credentials to access your creative studio
|
| 105 |
+
</p>
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<form onSubmit={onSubmit} className="space-y-6">
|
| 109 |
+
{error && (
|
| 110 |
+
<div className="p-4 border-2 border-destructive bg-destructive/5 text-destructive font-bold uppercase tracking-wide text-sm shadow-[4px_4px_0px_0px_rgba(239,68,68,1)]">
|
| 111 |
+
{error}
|
| 112 |
+
</div>
|
| 113 |
+
)}
|
| 114 |
+
|
| 115 |
+
<div className="space-y-6">
|
| 116 |
+
<div className="space-y-2">
|
| 117 |
+
<Label htmlFor="email" className="text-sm font-black uppercase tracking-wider">Email</Label>
|
| 118 |
+
<Input
|
| 119 |
+
id="email"
|
| 120 |
+
name="email"
|
| 121 |
+
type="email"
|
| 122 |
+
placeholder="artist@example.com"
|
| 123 |
+
required
|
| 124 |
+
className="h-12 rounded-none border-2 border-border bg-card px-3 text-sm font-medium shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)] focus:translate-x-[1px] focus:translate-y-[1px] focus:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] dark:focus:shadow-[1px_1px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 125 |
+
/>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<div className="space-y-2">
|
| 129 |
+
<div className="flex items-center justify-between">
|
| 130 |
+
<Label htmlFor="password" className="text-xs font-black uppercase tracking-wider">Password</Label>
|
| 131 |
+
<Link href="#" className="text-[10px] font-bold uppercase tracking-wider text-muted-foreground hover:text-primary hover:underline decoration-2 underline-offset-4">
|
| 132 |
+
Forgot password?
|
| 133 |
+
</Link>
|
| 134 |
+
</div>
|
| 135 |
+
<div className="relative">
|
| 136 |
+
<Input
|
| 137 |
+
id="password"
|
| 138 |
+
name="password"
|
| 139 |
+
type={showPassword ? "text" : "password"}
|
| 140 |
+
placeholder="••••••••"
|
| 141 |
+
required
|
| 142 |
+
className="h-12 rounded-none border-2 border-border bg-card px-3 text-sm font-medium pr-10 shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)] focus:translate-x-[1px] focus:translate-y-[1px] focus:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] dark:focus:shadow-[1px_1px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 143 |
+
/>
|
| 144 |
+
<Button
|
| 145 |
+
type="button"
|
| 146 |
+
variant="ghost"
|
| 147 |
+
size="icon"
|
| 148 |
+
className="absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8 hover:bg-transparent text-muted-foreground hover:text-foreground"
|
| 149 |
+
onClick={() => setShowPassword(!showPassword)}
|
| 150 |
+
>
|
| 151 |
+
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
| 152 |
+
</Button>
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
|
| 157 |
+
<Button
|
| 158 |
+
type="submit"
|
| 159 |
+
disabled={isLoading}
|
| 160 |
+
className="w-full h-12 rounded-none border-2 border-primary bg-primary text-white text-base font-black uppercase tracking-widest shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)] hover:translate-x-[1px] hover:translate-y-[1px] hover:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[1px_1px_0px_0px_rgba(255,255,255,1)] active:translate-x-[2px] active:translate-y-[2px] active:shadow-none transition-all"
|
| 161 |
+
>
|
| 162 |
+
{isLoading && <Loader2 className="mr-2 h-5 w-5 animate-spin" />}
|
| 163 |
+
Sign In
|
| 164 |
+
</Button>
|
| 165 |
+
</form>
|
| 166 |
+
|
| 167 |
+
<div className="relative py-4">
|
| 168 |
+
<div className="absolute inset-0 flex items-center">
|
| 169 |
+
<div className="w-full border-t-2 border-border" />
|
| 170 |
+
</div>
|
| 171 |
+
<div className="relative flex justify-center">
|
| 172 |
+
<span className="bg-background px-4 text-xs font-black uppercase tracking-widest text-muted-foreground">Or</span>
|
| 173 |
+
</div>
|
| 174 |
+
</div>
|
| 175 |
+
|
| 176 |
+
<Button
|
| 177 |
+
type="button"
|
| 178 |
+
variant="outline"
|
| 179 |
+
onClick={() => signIn("google", { callbackUrl: "/create" })}
|
| 180 |
+
className="w-full h-14 rounded-none border-2 border-border bg-card text-foreground text-base font-bold uppercase tracking-wider shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] active:translate-x-[4px] active:translate-y-[4px] active:shadow-none transition-all"
|
| 181 |
+
>
|
| 182 |
+
<svg className="mr-3 h-5 w-5" viewBox="0 0 24 24">
|
| 183 |
+
<path fill="currentColor" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" />
|
| 184 |
+
<path fill="currentColor" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" />
|
| 185 |
+
<path fill="currentColor" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" />
|
| 186 |
+
<path fill="currentColor" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" />
|
| 187 |
+
</svg>
|
| 188 |
+
Continue with Google
|
| 189 |
+
</Button>
|
| 190 |
+
|
| 191 |
+
<p className="text-center text-sm font-medium text-muted-foreground">
|
| 192 |
+
Don't have an account?{" "}
|
| 193 |
+
<Link href="/signup" className="text-primary font-black uppercase tracking-wide hover:underline decoration-2 underline-offset-4 ml-1">
|
| 194 |
+
Create one free
|
| 195 |
+
</Link>
|
| 196 |
+
</p>
|
| 197 |
+
</div>
|
| 198 |
+
</div>
|
| 199 |
+
</div>
|
| 200 |
+
)
|
| 201 |
+
}
|
src/app/(auth)/signup/page.tsx
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState } from "react"
|
| 4 |
+
import Link from "next/link"
|
| 5 |
+
import { useRouter } from "next/navigation"
|
| 6 |
+
import { signIn } from "next-auth/react"
|
| 7 |
+
import { Button } from "@/components/ui/button"
|
| 8 |
+
import { Input } from "@/components/ui/input"
|
| 9 |
+
import { Label } from "@/components/ui/label"
|
| 10 |
+
import { Loader2, Sparkles, Eye, EyeOff, Check } from "lucide-react"
|
| 11 |
+
|
| 12 |
+
export default function SignupPage() {
|
| 13 |
+
const router = useRouter()
|
| 14 |
+
const [isLoading, setIsLoading] = useState(false)
|
| 15 |
+
const [showPassword, setShowPassword] = useState(false)
|
| 16 |
+
const [error, setError] = useState("")
|
| 17 |
+
|
| 18 |
+
async function onSubmit(e: React.FormEvent<HTMLFormElement>) {
|
| 19 |
+
e.preventDefault()
|
| 20 |
+
setIsLoading(true)
|
| 21 |
+
setError("")
|
| 22 |
+
|
| 23 |
+
const formData = new FormData(e.currentTarget)
|
| 24 |
+
|
| 25 |
+
try {
|
| 26 |
+
const res = await fetch("/api/auth/register", {
|
| 27 |
+
method: "POST",
|
| 28 |
+
headers: { "Content-Type": "application/json" },
|
| 29 |
+
body: JSON.stringify({
|
| 30 |
+
name: formData.get("name"),
|
| 31 |
+
email: formData.get("email"),
|
| 32 |
+
password: formData.get("password"),
|
| 33 |
+
}),
|
| 34 |
+
})
|
| 35 |
+
|
| 36 |
+
if (!res.ok) {
|
| 37 |
+
const data = await res.json()
|
| 38 |
+
setError(data.error || "Something went wrong")
|
| 39 |
+
return
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// Auto sign in after registration
|
| 43 |
+
const result = await signIn("credentials", {
|
| 44 |
+
email: formData.get("email"),
|
| 45 |
+
password: formData.get("password"),
|
| 46 |
+
redirect: false,
|
| 47 |
+
})
|
| 48 |
+
|
| 49 |
+
if (result?.ok) {
|
| 50 |
+
router.push("/create")
|
| 51 |
+
router.refresh()
|
| 52 |
+
}
|
| 53 |
+
} catch (error) {
|
| 54 |
+
setError("Something went wrong")
|
| 55 |
+
} finally {
|
| 56 |
+
setIsLoading(false)
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
const features = [
|
| 61 |
+
"100 free credits daily",
|
| 62 |
+
"Access to all AI models",
|
| 63 |
+
"High-resolution exports",
|
| 64 |
+
"Public gallery showcase",
|
| 65 |
+
"No credit card required"
|
| 66 |
+
]
|
| 67 |
+
|
| 68 |
+
return (
|
| 69 |
+
<div className="min-h-screen flex font-sans">
|
| 70 |
+
{/* Left Panel - Form */}
|
| 71 |
+
<div className="w-full lg:w-1/2 flex flex-col justify-center p-8 lg:p-12 bg-background relative">
|
| 72 |
+
<div className="relative z-10 max-w-sm mx-auto w-full space-y-6">
|
| 73 |
+
{/* Logo */}
|
| 74 |
+
<Link href="/" className="inline-flex items-center gap-3 mb-6 group">
|
| 75 |
+
<div className="h-10 w-10 border-2 border-border bg-primary text-white flex items-center justify-center shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)] group-hover:translate-x-[2px] group-hover:translate-y-[2px] group-hover:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] dark:group-hover:shadow-[1px_1px_0px_0px_rgba(255,255,255,1)] transition-all">
|
| 76 |
+
<Sparkles className="h-5 w-5" />
|
| 77 |
+
</div>
|
| 78 |
+
<span className="text-xl font-black tracking-tighter uppercase group-hover:text-primary transition-colors">Imyra</span>
|
| 79 |
+
</Link>
|
| 80 |
+
|
| 81 |
+
<div className="space-y-2 border-l-4 border-primary pl-4">
|
| 82 |
+
<h2 className="text-3xl font-black tracking-tighter uppercase">Start creating</h2>
|
| 83 |
+
<p className="text-muted-foreground font-medium uppercase tracking-wide text-xs">
|
| 84 |
+
Create your account and get 100 free credits instantly
|
| 85 |
+
</p>
|
| 86 |
+
</div>
|
| 87 |
+
|
| 88 |
+
<form onSubmit={onSubmit} className="space-y-6">
|
| 89 |
+
{error && (
|
| 90 |
+
<div className="p-4 border-2 border-destructive bg-destructive/5 text-destructive font-bold uppercase tracking-wide text-sm shadow-[4px_4px_0px_0px_rgba(239,68,68,1)]">
|
| 91 |
+
{error}
|
| 92 |
+
</div>
|
| 93 |
+
)}
|
| 94 |
+
|
| 95 |
+
<div className="space-y-4">
|
| 96 |
+
<div className="space-y-2">
|
| 97 |
+
<Label htmlFor="name" className="text-sm font-black uppercase tracking-wider">Name</Label>
|
| 98 |
+
<Input
|
| 99 |
+
id="name"
|
| 100 |
+
name="name"
|
| 101 |
+
type="text"
|
| 102 |
+
placeholder="Your name"
|
| 103 |
+
required
|
| 104 |
+
className="h-14 rounded-none border-2 border-border bg-card px-4 text-base font-medium shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] focus:translate-x-[2px] focus:translate-y-[2px] focus:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:focus:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 105 |
+
/>
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<div className="space-y-2">
|
| 109 |
+
<Label htmlFor="email" className="text-sm font-black uppercase tracking-wider">Email</Label>
|
| 110 |
+
<Input
|
| 111 |
+
id="email"
|
| 112 |
+
name="email"
|
| 113 |
+
type="email"
|
| 114 |
+
placeholder="artist@example.com"
|
| 115 |
+
required
|
| 116 |
+
className="h-14 rounded-none border-2 border-border bg-card px-4 text-base font-medium shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] focus:translate-x-[2px] focus:translate-y-[2px] focus:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:focus:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 117 |
+
/>
|
| 118 |
+
</div>
|
| 119 |
+
|
| 120 |
+
<div className="space-y-2">
|
| 121 |
+
<Label htmlFor="password" className="text-sm font-black uppercase tracking-wider">Password</Label>
|
| 122 |
+
<div className="relative">
|
| 123 |
+
<Input
|
| 124 |
+
id="password"
|
| 125 |
+
name="password"
|
| 126 |
+
type={showPassword ? "text" : "password"}
|
| 127 |
+
placeholder="Min. 8 characters"
|
| 128 |
+
required
|
| 129 |
+
minLength={8}
|
| 130 |
+
className="h-12 rounded-none border-2 border-border bg-card px-3 text-sm font-medium pr-10 shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)] focus:translate-x-[1px] focus:translate-y-[1px] focus:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] dark:focus:shadow-[1px_1px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 131 |
+
/>
|
| 132 |
+
<Button
|
| 133 |
+
type="button"
|
| 134 |
+
variant="ghost"
|
| 135 |
+
size="icon"
|
| 136 |
+
className="absolute right-1 top-1/2 -translate-y-1/2 h-8 w-8 hover:bg-transparent text-muted-foreground hover:text-foreground"
|
| 137 |
+
onClick={() => setShowPassword(!showPassword)}
|
| 138 |
+
>
|
| 139 |
+
{showPassword ? <EyeOff className="h-4 w-4" /> : <Eye className="h-4 w-4" />}
|
| 140 |
+
</Button>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
</div>
|
| 144 |
+
|
| 145 |
+
<Button
|
| 146 |
+
type="submit"
|
| 147 |
+
disabled={isLoading}
|
| 148 |
+
className="w-full h-12 rounded-none border-2 border-primary bg-primary text-white text-base font-black uppercase tracking-widest shadow-[3px_3px_0px_0px_rgba(0,0,0,1)] dark:shadow-[3px_3px_0px_0px_rgba(255,255,255,1)] hover:translate-x-[1px] hover:translate-y-[1px] hover:shadow-[1px_1px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[1px_1px_0px_0px_rgba(255,255,255,1)] active:translate-x-[2px] active:translate-y-[2px] active:shadow-none transition-all"
|
| 149 |
+
>
|
| 150 |
+
{isLoading && <Loader2 className="mr-2 h-5 w-5 animate-spin" />}
|
| 151 |
+
Create Account
|
| 152 |
+
</Button>
|
| 153 |
+
</form>
|
| 154 |
+
|
| 155 |
+
<div className="relative py-4">
|
| 156 |
+
<div className="absolute inset-0 flex items-center">
|
| 157 |
+
<div className="w-full border-t-2 border-border" />
|
| 158 |
+
</div>
|
| 159 |
+
<div className="relative flex justify-center">
|
| 160 |
+
<span className="bg-background px-4 text-xs font-black uppercase tracking-widest text-muted-foreground">Or</span>
|
| 161 |
+
</div>
|
| 162 |
+
</div>
|
| 163 |
+
|
| 164 |
+
<Button
|
| 165 |
+
type="button"
|
| 166 |
+
variant="outline"
|
| 167 |
+
onClick={() => signIn("google", { callbackUrl: "/create" })}
|
| 168 |
+
className="w-full h-14 rounded-none border-2 border-border bg-card text-foreground text-base font-bold uppercase tracking-wider shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] active:translate-x-[4px] active:translate-y-[4px] active:shadow-none transition-all"
|
| 169 |
+
>
|
| 170 |
+
<svg className="mr-3 h-5 w-5" viewBox="0 0 24 24">
|
| 171 |
+
<path fill="currentColor" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" />
|
| 172 |
+
<path fill="currentColor" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" />
|
| 173 |
+
<path fill="currentColor" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" />
|
| 174 |
+
<path fill="currentColor" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" />
|
| 175 |
+
</svg>
|
| 176 |
+
Continue with Google
|
| 177 |
+
</Button>
|
| 178 |
+
|
| 179 |
+
<p className="text-center text-sm font-medium text-muted-foreground">
|
| 180 |
+
Already have an account?{" "}
|
| 181 |
+
<Link href="/login" className="text-primary font-black uppercase tracking-wide hover:underline decoration-2 underline-offset-4 ml-1">
|
| 182 |
+
Sign in
|
| 183 |
+
</Link>
|
| 184 |
+
</p>
|
| 185 |
+
</div>
|
| 186 |
+
</div>
|
| 187 |
+
|
| 188 |
+
{/* Right Panel - Features */}
|
| 189 |
+
<div className="hidden lg:flex lg:w-1/2 relative overflow-hidden bg-primary/5 border-l-2 border-border">
|
| 190 |
+
{/* Background Pattern */}
|
| 191 |
+
<div className="absolute inset-0 bg-[linear-gradient(rgba(0,0,0,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,0,0,0.02)_1px,transparent_1px)] dark:bg-[linear-gradient(rgba(255,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.02)_1px,transparent_1px)] bg-[size:64px_64px]" />
|
| 192 |
+
|
| 193 |
+
{/* Content */}
|
| 194 |
+
<div className="relative z-10 flex flex-col justify-center items-center p-12 w-full">
|
| 195 |
+
<div className="max-w-lg space-y-12">
|
| 196 |
+
<div className="inline-flex items-center gap-2 px-4 py-2 border-2 border-secondary bg-secondary/10 shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 197 |
+
<Sparkles className="h-5 w-5 text-secondary" />
|
| 198 |
+
<span className="text-sm font-black uppercase tracking-widest text-secondary">Free Forever</span>
|
| 199 |
+
</div>
|
| 200 |
+
|
| 201 |
+
<h1 className="text-4xl xl:text-6xl font-black tracking-tighter leading-none uppercase">
|
| 202 |
+
Everything you need to create
|
| 203 |
+
<span className="text-primary block text-stroke-primary">
|
| 204 |
+
Stunning Art
|
| 205 |
+
</span>
|
| 206 |
+
</h1>
|
| 207 |
+
|
| 208 |
+
<ul className="space-y-6">
|
| 209 |
+
{features.map((feature, index) => (
|
| 210 |
+
<li key={index} className="flex items-center gap-4 group">
|
| 211 |
+
<div className="h-8 w-8 rounded-none border-2 border-primary bg-primary text-white flex items-center justify-center shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] group-hover:translate-x-[1px] group-hover:translate-y-[1px] group-hover:shadow-none transition-all">
|
| 212 |
+
<Check className="h-5 w-5" />
|
| 213 |
+
</div>
|
| 214 |
+
<span className="text-lg font-bold uppercase tracking-wide">{feature}</span>
|
| 215 |
+
</li>
|
| 216 |
+
))}
|
| 217 |
+
</ul>
|
| 218 |
+
|
| 219 |
+
{/* Testimonial */}
|
| 220 |
+
<div className="pt-8 border-t-2 border-border">
|
| 221 |
+
<p className="text-xl italic font-serif text-muted-foreground mb-6">
|
| 222 |
+
"Imyra has completely transformed how I create visual content. The quality is incredible!"
|
| 223 |
+
</p>
|
| 224 |
+
<div className="flex items-center gap-4">
|
| 225 |
+
<div className="h-12 w-12 border-2 border-border bg-gradient-to-br from-primary to-secondary flex items-center justify-center text-white font-black text-xl shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 226 |
+
S
|
| 227 |
+
</div>
|
| 228 |
+
<div>
|
| 229 |
+
<p className="font-black uppercase tracking-wide">Sarah Chen</p>
|
| 230 |
+
<p className="text-sm font-bold text-muted-foreground uppercase tracking-wider">Digital Artist</p>
|
| 231 |
+
</div>
|
| 232 |
+
</div>
|
| 233 |
+
</div>
|
| 234 |
+
</div>
|
| 235 |
+
</div>
|
| 236 |
+
</div>
|
| 237 |
+
</div>
|
| 238 |
+
)
|
| 239 |
+
}
|
src/app/(dashboard)/create/page.tsx
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState, useTransition } from "react"
|
| 4 |
+
import { useRouter } from "next/navigation"
|
| 5 |
+
import Image from "next/image"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
import { Label } from "@/components/ui/label"
|
| 8 |
+
import { Textarea } from "@/components/ui/textarea"
|
| 9 |
+
import {
|
| 10 |
+
Select,
|
| 11 |
+
SelectContent,
|
| 12 |
+
SelectItem,
|
| 13 |
+
SelectTrigger,
|
| 14 |
+
SelectValue,
|
| 15 |
+
} from "@/components/ui/select"
|
| 16 |
+
import {
|
| 17 |
+
Card,
|
| 18 |
+
CardContent,
|
| 19 |
+
CardDescription,
|
| 20 |
+
CardFooter,
|
| 21 |
+
CardHeader,
|
| 22 |
+
CardTitle,
|
| 23 |
+
} from "@/components/ui/card"
|
| 24 |
+
import { Loader2, Download, Sparkles, AlertCircle, Wand2 } from "lucide-react"
|
| 25 |
+
|
| 26 |
+
export default function CreatePage() {
|
| 27 |
+
const router = useRouter()
|
| 28 |
+
const [isPending, startTransition] = useTransition()
|
| 29 |
+
const [prompt, setPrompt] = useState("")
|
| 30 |
+
const [model, setModel] = useState("flux-dev")
|
| 31 |
+
const [width, setWidth] = useState("1024")
|
| 32 |
+
const [height, setHeight] = useState("1024")
|
| 33 |
+
const [isCustomWidth, setIsCustomWidth] = useState(false)
|
| 34 |
+
const [isCustomHeight, setIsCustomHeight] = useState(false)
|
| 35 |
+
const [resultUrl, setResultUrl] = useState<string | null>(null)
|
| 36 |
+
const [error, setError] = useState<string | null>(null)
|
| 37 |
+
|
| 38 |
+
async function handleGenerate() {
|
| 39 |
+
if (!prompt) return
|
| 40 |
+
setError(null)
|
| 41 |
+
setResultUrl(null)
|
| 42 |
+
|
| 43 |
+
startTransition(async () => {
|
| 44 |
+
try {
|
| 45 |
+
const res = await fetch("/api/generate", {
|
| 46 |
+
method: "POST",
|
| 47 |
+
headers: { "Content-Type": "application/json" },
|
| 48 |
+
body: JSON.stringify({
|
| 49 |
+
prompt,
|
| 50 |
+
model,
|
| 51 |
+
width: parseInt(width),
|
| 52 |
+
height: parseInt(height),
|
| 53 |
+
}),
|
| 54 |
+
})
|
| 55 |
+
|
| 56 |
+
const data = await res.json()
|
| 57 |
+
if (!res.ok) {
|
| 58 |
+
setError(data.error || "Generation failed")
|
| 59 |
+
} else if (data.url) {
|
| 60 |
+
setResultUrl(data.url)
|
| 61 |
+
router.refresh() // Update credits in navbar
|
| 62 |
+
} else {
|
| 63 |
+
setError("No image URL returned")
|
| 64 |
+
}
|
| 65 |
+
} catch (err) {
|
| 66 |
+
setError("Something went wrong")
|
| 67 |
+
}
|
| 68 |
+
})
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
return (
|
| 72 |
+
<div className="container py-8 md:py-16 max-w-7xl min-h-[calc(100vh-4rem)]">
|
| 73 |
+
{/* Background elements */}
|
| 74 |
+
<div className="fixed inset-0 -z-20 mesh-gradient opacity-30 dark:opacity-20" />
|
| 75 |
+
|
| 76 |
+
<div className="grid grid-cols-1 lg:grid-cols-5 gap-8 items-start">
|
| 77 |
+
|
| 78 |
+
{/* Left Column: Control Panel */}
|
| 79 |
+
<div className="lg:col-span-2 space-y-6">
|
| 80 |
+
<div className="space-y-1 pl-1">
|
| 81 |
+
<h1 className="text-4xl font-black tracking-tighter uppercase text-stroke text-transparent bg-clip-text bg-gradient-to-br from-foreground to-muted-foreground">Studio</h1>
|
| 82 |
+
<p className="text-sm font-bold text-muted-foreground uppercase tracking-widest">
|
| 83 |
+
Cost: 5 Credits / Gen
|
| 84 |
+
</p>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<div className="glass-panel p-6 rounded-none space-y-6 relative overflow-hidden group">
|
| 88 |
+
<div className="absolute top-0 right-0 w-24 h-24 bg-primary/10 rounded-full blur-2xl group-hover:bg-primary/20 transition-all duration-500" />
|
| 89 |
+
|
| 90 |
+
<div className="space-y-4">
|
| 91 |
+
<div className="space-y-2">
|
| 92 |
+
<Label htmlFor="model" className="uppercase text-xs font-bold tracking-wider">Model Architecture</Label>
|
| 93 |
+
<Select value={model} onValueChange={setModel}>
|
| 94 |
+
<SelectTrigger id="model" className="h-12 border-2 border-border rounded-none font-bold focus:ring-offset-0 focus:ring-0 focus:border-primary bg-background/50">
|
| 95 |
+
<SelectValue placeholder="Select model" />
|
| 96 |
+
</SelectTrigger>
|
| 97 |
+
<SelectContent className="rounded-none border-2 border-border neo-brutalist">
|
| 98 |
+
<SelectItem value="flux-dev" className="font-medium focus:bg-primary/20">Flux 2 Dev</SelectItem>
|
| 99 |
+
<SelectItem value="flux-klein-9b" className="font-medium focus:bg-primary/20">Flux Klein 9B</SelectItem>
|
| 100 |
+
<SelectItem value="flux-klein-4b" className="font-medium focus:bg-primary/20">Flux Klein 4B</SelectItem>
|
| 101 |
+
<SelectItem value="lucid-origin" className="font-medium focus:bg-primary/20">Lucid Origin</SelectItem>
|
| 102 |
+
<SelectItem value="dreamshaper" className="font-medium focus:bg-primary/20">DreamShaper 8</SelectItem>
|
| 103 |
+
<SelectItem value="stable-diffusion-xl-lightning" className="font-medium focus:bg-primary/20">SDXL Lightning (Fast)</SelectItem>
|
| 104 |
+
</SelectContent>
|
| 105 |
+
</Select>
|
| 106 |
+
</div>
|
| 107 |
+
|
| 108 |
+
<div className="grid grid-cols-2 gap-4">
|
| 109 |
+
<div className="space-y-2">
|
| 110 |
+
<Label htmlFor="width" className="uppercase text-xs font-bold tracking-wider">Width</Label>
|
| 111 |
+
<Select
|
| 112 |
+
value={isCustomWidth ? "custom" : width}
|
| 113 |
+
onValueChange={(val) => {
|
| 114 |
+
if (val === "custom") setIsCustomWidth(true)
|
| 115 |
+
else {
|
| 116 |
+
setIsCustomWidth(false)
|
| 117 |
+
setWidth(val)
|
| 118 |
+
}
|
| 119 |
+
}}
|
| 120 |
+
>
|
| 121 |
+
<SelectTrigger id="width" className="h-12 border-2 border-border rounded-none font-bold bg-background/50">
|
| 122 |
+
<SelectValue placeholder="Width" />
|
| 123 |
+
</SelectTrigger>
|
| 124 |
+
<SelectContent className="rounded-none border-2 border-border neo-brutalist">
|
| 125 |
+
<SelectItem value="512">512px</SelectItem>
|
| 126 |
+
<SelectItem value="768">768px</SelectItem>
|
| 127 |
+
<SelectItem value="1024">1024px</SelectItem>
|
| 128 |
+
<SelectItem value="custom" className="text-primary font-bold">Custom...</SelectItem>
|
| 129 |
+
</SelectContent>
|
| 130 |
+
</Select>
|
| 131 |
+
{/* Custom Input */}
|
| 132 |
+
{isCustomWidth && (
|
| 133 |
+
<input
|
| 134 |
+
type="number"
|
| 135 |
+
value={width}
|
| 136 |
+
onChange={(e) => setWidth(e.target.value)}
|
| 137 |
+
className="w-full h-10 border-2 border-primary/50 rounded-none px-3 font-medium text-sm bg-background mt-2 focus:outline-none focus:border-primary transition-colors"
|
| 138 |
+
placeholder="Width (256-1440)"
|
| 139 |
+
min="256"
|
| 140 |
+
max="1440"
|
| 141 |
+
step="32"
|
| 142 |
+
/>
|
| 143 |
+
)}
|
| 144 |
+
</div>
|
| 145 |
+
<div className="space-y-2">
|
| 146 |
+
<Label htmlFor="height" className="uppercase text-xs font-bold tracking-wider">Height</Label>
|
| 147 |
+
<Select
|
| 148 |
+
value={isCustomHeight ? "custom" : height}
|
| 149 |
+
onValueChange={(val) => {
|
| 150 |
+
if (val === "custom") setIsCustomHeight(true)
|
| 151 |
+
else {
|
| 152 |
+
setIsCustomHeight(false)
|
| 153 |
+
setHeight(val)
|
| 154 |
+
}
|
| 155 |
+
}}
|
| 156 |
+
>
|
| 157 |
+
<SelectTrigger id="height" className="h-12 border-2 border-border rounded-none font-bold bg-background/50">
|
| 158 |
+
<SelectValue placeholder="Height" />
|
| 159 |
+
</SelectTrigger>
|
| 160 |
+
<SelectContent className="rounded-none border-2 border-border neo-brutalist">
|
| 161 |
+
<SelectItem value="512">512px</SelectItem>
|
| 162 |
+
<SelectItem value="768">768px</SelectItem>
|
| 163 |
+
<SelectItem value="1024">1024px</SelectItem>
|
| 164 |
+
<SelectItem value="custom" className="text-primary font-bold">Custom...</SelectItem>
|
| 165 |
+
</SelectContent>
|
| 166 |
+
</Select>
|
| 167 |
+
{/* Custom Input */}
|
| 168 |
+
{isCustomHeight && (
|
| 169 |
+
<input
|
| 170 |
+
type="number"
|
| 171 |
+
value={height}
|
| 172 |
+
onChange={(e) => setHeight(e.target.value)}
|
| 173 |
+
className="w-full h-10 border-2 border-primary/50 rounded-none px-3 font-medium text-sm bg-background mt-2 focus:outline-none focus:border-primary transition-colors"
|
| 174 |
+
placeholder="Height (256-1440)"
|
| 175 |
+
min="256"
|
| 176 |
+
max="1440"
|
| 177 |
+
step="32"
|
| 178 |
+
/>
|
| 179 |
+
)}
|
| 180 |
+
</div>
|
| 181 |
+
</div>
|
| 182 |
+
|
| 183 |
+
<div className="space-y-2 pt-2">
|
| 184 |
+
<Label htmlFor="prompt" className="uppercase text-xs font-bold tracking-wider flex justify-between">
|
| 185 |
+
Prompt
|
| 186 |
+
<span className="text-muted-foreground text-[10px] font-normal tracking-normal normal-case">Be descriptive for best results</span>
|
| 187 |
+
</Label>
|
| 188 |
+
<Textarea
|
| 189 |
+
id="prompt"
|
| 190 |
+
placeholder="Describe your imagination in detail... (e.g. A futuristic neon city with flying cars, cyberpunk style, cinematic lighting)"
|
| 191 |
+
className="min-h-[140px] resize-none border-2 border-border rounded-none font-medium bg-background/50 focus-visible:ring-0 focus-visible:border-primary p-4 leading-relaxed"
|
| 192 |
+
value={prompt}
|
| 193 |
+
onChange={(e) => setPrompt(e.target.value)}
|
| 194 |
+
/>
|
| 195 |
+
</div>
|
| 196 |
+
|
| 197 |
+
{error && (
|
| 198 |
+
<div className="p-4 text-sm font-bold text-destructive bg-destructive/10 border-2 border-destructive/20 flex items-center gap-2 animate-in slide-in-from-left-2">
|
| 199 |
+
<AlertCircle className="h-4 w-4" />
|
| 200 |
+
{error}
|
| 201 |
+
</div>
|
| 202 |
+
)}
|
| 203 |
+
</div>
|
| 204 |
+
|
| 205 |
+
<div className="pt-2">
|
| 206 |
+
<Button
|
| 207 |
+
onClick={handleGenerate}
|
| 208 |
+
className="w-full h-14 text-lg bg-primary hover:bg-primary/90 text-primary-foreground font-black uppercase tracking-widest rounded-none md:neo-brutalist"
|
| 209 |
+
disabled={isPending || !prompt}
|
| 210 |
+
>
|
| 211 |
+
{isPending ? (
|
| 212 |
+
<>
|
| 213 |
+
<Loader2 className="mr-3 h-5 w-5 animate-spin" />
|
| 214 |
+
Dreaming...
|
| 215 |
+
</>
|
| 216 |
+
) : (
|
| 217 |
+
<>
|
| 218 |
+
<Wand2 className="mr-3 h-5 w-5" />
|
| 219 |
+
Generate Art
|
| 220 |
+
</>
|
| 221 |
+
)}
|
| 222 |
+
</Button>
|
| 223 |
+
</div>
|
| 224 |
+
</div>
|
| 225 |
+
</div>
|
| 226 |
+
|
| 227 |
+
{/* Right Column: Canvas */}
|
| 228 |
+
<div className="lg:col-span-3 h-full">
|
| 229 |
+
<div className="h-full min-h-[500px] glass-panel rounded-none p-2 md:p-4 flex flex-col relative group">
|
| 230 |
+
<div className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-primary via-secondary to-accent opacity-50" />
|
| 231 |
+
|
| 232 |
+
<div className="flex-1 flex items-center justify-center bg-secondary/5 border-2 border-dashed border-border/30 relative overflow-hidden min-h-[400px]">
|
| 233 |
+
{/* Grid Pattern Background */}
|
| 234 |
+
<div className="absolute inset-0 bg-[linear-gradient(to_right,#80808012_1px,transparent_1px),linear-gradient(to_bottom,#80808012_1px,transparent_1px)] bg-[size:24px_24px] pointer-events-none" />
|
| 235 |
+
|
| 236 |
+
{resultUrl ? (
|
| 237 |
+
<div className="relative w-full h-full min-h-[inherit] flex items-center justify-center p-4">
|
| 238 |
+
<Image
|
| 239 |
+
src={resultUrl}
|
| 240 |
+
alt={prompt}
|
| 241 |
+
width={1024}
|
| 242 |
+
height={1024}
|
| 243 |
+
className="object-contain max-h-[70vh] w-auto h-auto shadow-2xl border-4 border-black dark:border-white"
|
| 244 |
+
unoptimized
|
| 245 |
+
/>
|
| 246 |
+
<div className="absolute bottom-4 right-4 flex gap-3 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
|
| 247 |
+
<Button variant="secondary" className="neo-brutalist h-10 w-10 p-0 rounded-full" asChild>
|
| 248 |
+
<a href={resultUrl} target="_blank" rel="noopener noreferrer">
|
| 249 |
+
<Sparkles className="h-4 w-4" />
|
| 250 |
+
</a>
|
| 251 |
+
</Button>
|
| 252 |
+
<Button className="neo-brutalist h-10 w-10 p-0 rounded-full bg-primary text-white" asChild>
|
| 253 |
+
<a href={resultUrl} download="wild-art-generated.png">
|
| 254 |
+
<Download className="h-4 w-4" />
|
| 255 |
+
</a>
|
| 256 |
+
</Button>
|
| 257 |
+
</div>
|
| 258 |
+
</div>
|
| 259 |
+
) : (
|
| 260 |
+
<div className="text-center text-muted-foreground p-8 max-w-sm relative z-10">
|
| 261 |
+
{isPending ? (
|
| 262 |
+
<div className="flex flex-col items-center gap-6">
|
| 263 |
+
<div className="relative">
|
| 264 |
+
<div className="absolute inset-0 bg-primary/20 blur-xl animate-pulse rounded-full" />
|
| 265 |
+
<Loader2 className="h-16 w-16 animate-spin text-primary relative z-10" />
|
| 266 |
+
</div>
|
| 267 |
+
<div className="space-y-2">
|
| 268 |
+
<p className="font-bold text-xl animate-pulse text-foreground">Materializing...</p>
|
| 269 |
+
<p className="text-xs uppercase tracking-widest opacity-70">Computing Tensors • Denoising • Upscaling</p>
|
| 270 |
+
</div>
|
| 271 |
+
</div>
|
| 272 |
+
) : (
|
| 273 |
+
<div className="flex flex-col items-center gap-4 group/placeholder cursor-default">
|
| 274 |
+
<div className="h-24 w-24 rounded-full bg-secondary/20 flex items-center justify-center mb-4 group-hover/placeholder:scale-110 transition-transform duration-500 border-2 border-dashed border-muted-foreground/30">
|
| 275 |
+
<Sparkles className="h-10 w-10 text-muted-foreground/50" />
|
| 276 |
+
</div>
|
| 277 |
+
<h3 className="font-bold text-xl text-foreground">Canvas Empty</h3>
|
| 278 |
+
<p className="text-sm leading-relaxed opacity-70">
|
| 279 |
+
Your imagination is the only limit.<br />
|
| 280 |
+
Configure the settings on the left and hit <span className="text-primary font-bold">GENERATE</span>.
|
| 281 |
+
</p>
|
| 282 |
+
</div>
|
| 283 |
+
)}
|
| 284 |
+
</div>
|
| 285 |
+
)}
|
| 286 |
+
</div>
|
| 287 |
+
</div>
|
| 288 |
+
</div>
|
| 289 |
+
</div>
|
| 290 |
+
</div>
|
| 291 |
+
)
|
| 292 |
+
}
|
src/app/(dashboard)/history/page.tsx
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { auth } from "@/auth"
|
| 2 |
+
import { redirect } from "next/navigation"
|
| 3 |
+
import { prisma } from "@/lib/prisma"
|
| 4 |
+
import Image from "next/image"
|
| 5 |
+
import { Button } from "@/components/ui/button"
|
| 6 |
+
import Link from "next/link"
|
| 7 |
+
import { Download, LayoutGrid } from "lucide-react"
|
| 8 |
+
|
| 9 |
+
import { HistoryCard } from "@/components/history-card"
|
| 10 |
+
|
| 11 |
+
export const dynamic = "force-dynamic"
|
| 12 |
+
|
| 13 |
+
export default async function HistoryPage() {
|
| 14 |
+
const session = await auth()
|
| 15 |
+
if (!session?.user?.id) redirect("/login")
|
| 16 |
+
|
| 17 |
+
const generations = await prisma.generation.findMany({
|
| 18 |
+
where: { userId: session.user.id },
|
| 19 |
+
orderBy: { createdAt: "desc" },
|
| 20 |
+
})
|
| 21 |
+
|
| 22 |
+
return (
|
| 23 |
+
<div className="container py-8 md:py-16 max-w-7xl min-h-[calc(100vh-4rem)]">
|
| 24 |
+
<div className="fixed inset-0 -z-20 mesh-gradient opacity-20" />
|
| 25 |
+
|
| 26 |
+
<div className="space-y-8">
|
| 27 |
+
<div className="flex flex-col md:flex-row gap-4 items-start md:items-center justify-between">
|
| 28 |
+
<div className="space-y-1 pl-1 border-l-4 border-primary pl-4">
|
| 29 |
+
<h1 className="text-4xl font-black tracking-tighter uppercase">Archives</h1>
|
| 30 |
+
<p className="text-sm font-bold text-muted-foreground uppercase tracking-widest">
|
| 31 |
+
{generations.length} {generations.length === 1 ? 'Creation' : 'Creations'} Stored
|
| 32 |
+
</p>
|
| 33 |
+
</div>
|
| 34 |
+
<Button variant="outline" className="neo-brutalist bg-background" asChild>
|
| 35 |
+
<Link href="/create">
|
| 36 |
+
<LayoutGrid className="mr-2 h-4 w-4" />
|
| 37 |
+
New Generation
|
| 38 |
+
</Link>
|
| 39 |
+
</Button>
|
| 40 |
+
</div>
|
| 41 |
+
|
| 42 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
|
| 43 |
+
{generations.map((gen: any) => (
|
| 44 |
+
<HistoryCard key={gen.id} generation={gen} />
|
| 45 |
+
))}
|
| 46 |
+
|
| 47 |
+
{generations.length === 0 && (
|
| 48 |
+
<div className="col-span-full py-32 text-center glass-panel border-2 border-dashed border-border rounded-none">
|
| 49 |
+
<div className="max-w-md mx-auto space-y-6">
|
| 50 |
+
<p className="text-xl font-bold uppercase tracking-widest text-muted-foreground">The archives are empty</p>
|
| 51 |
+
<Button className="neo-brutalist w-full" size="lg" asChild>
|
| 52 |
+
<Link href="/create">Start Creating History</Link>
|
| 53 |
+
</Button>
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
)}
|
| 57 |
+
</div>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
)
|
| 61 |
+
}
|
src/app/(dashboard)/profile/page.tsx
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { auth } from "@/auth"
|
| 2 |
+
import { redirect } from "next/navigation"
|
| 3 |
+
import { checkAndResetDailyCredits } from "@/lib/credits"
|
| 4 |
+
import { Button } from "@/components/ui/button"
|
| 5 |
+
import {
|
| 6 |
+
Card,
|
| 7 |
+
CardContent,
|
| 8 |
+
CardDescription,
|
| 9 |
+
CardHeader,
|
| 10 |
+
CardTitle,
|
| 11 |
+
CardFooter,
|
| 12 |
+
} from "@/components/ui/card"
|
| 13 |
+
import { Input } from "@/components/ui/input"
|
| 14 |
+
import { Label } from "@/components/ui/label"
|
| 15 |
+
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
| 16 |
+
|
| 17 |
+
import { EditProfileDialog } from "@/components/edit-profile-dialog"
|
| 18 |
+
|
| 19 |
+
export default async function ProfilePage() {
|
| 20 |
+
const session = await auth()
|
| 21 |
+
if (!session?.user?.id) redirect("/login")
|
| 22 |
+
|
| 23 |
+
const credits = await checkAndResetDailyCredits(session.user.id)
|
| 24 |
+
|
| 25 |
+
return (
|
| 26 |
+
<div className="container py-8 max-w-2xl">
|
| 27 |
+
<h1 className="text-3xl font-black tracking-tight mb-8 uppercase">Profile</h1>
|
| 28 |
+
|
| 29 |
+
<Card>
|
| 30 |
+
<CardHeader>
|
| 31 |
+
<CardTitle>Your Account</CardTitle>
|
| 32 |
+
<CardDescription>
|
| 33 |
+
Manage your account settings and view your credits.
|
| 34 |
+
</CardDescription>
|
| 35 |
+
</CardHeader>
|
| 36 |
+
<CardContent className="space-y-6">
|
| 37 |
+
<div className="flex items-center gap-4">
|
| 38 |
+
<Avatar className="h-20 w-20 border-2 border-border shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] rounded-none">
|
| 39 |
+
<AvatarImage src={session.user.image || ""} />
|
| 40 |
+
<AvatarFallback className="text-2xl bg-primary text-white font-black">
|
| 41 |
+
{session.user.name?.[0]?.toUpperCase()}
|
| 42 |
+
</AvatarFallback>
|
| 43 |
+
</Avatar>
|
| 44 |
+
<div>
|
| 45 |
+
<h3 className="font-semibold text-xl">{session.user.name}</h3>
|
| 46 |
+
<p className="text-muted-foreground">{session.user.email}</p>
|
| 47 |
+
</div>
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
+
<div className="grid gap-2">
|
| 51 |
+
<Label>Email</Label>
|
| 52 |
+
<Input value={session.user.email || ""} disabled readOnly />
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<div className="rounded-none border-2 border-border bg-primary/10 p-4 flex justify-between items-center shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 56 |
+
<div>
|
| 57 |
+
<p className="font-bold">Available Credits</p>
|
| 58 |
+
<p className="text-sm text-muted-foreground">
|
| 59 |
+
Resets to 100 every 24 hours.
|
| 60 |
+
</p>
|
| 61 |
+
</div>
|
| 62 |
+
<div className="text-3xl font-black text-primary">{credits} ⚡</div>
|
| 63 |
+
</div>
|
| 64 |
+
</CardContent>
|
| 65 |
+
<CardFooter className="flex justify-between">
|
| 66 |
+
<EditProfileDialog user={session.user} />
|
| 67 |
+
<form
|
| 68 |
+
action={async () => {
|
| 69 |
+
"use server"
|
| 70 |
+
const { signOut } = await import("@/auth")
|
| 71 |
+
await signOut()
|
| 72 |
+
}}
|
| 73 |
+
>
|
| 74 |
+
<Button variant="destructive" type="submit">
|
| 75 |
+
Sign Out
|
| 76 |
+
</Button>
|
| 77 |
+
</form>
|
| 78 |
+
</CardFooter>
|
| 79 |
+
</Card>
|
| 80 |
+
</div>
|
| 81 |
+
)
|
| 82 |
+
}
|
src/app/about/page.tsx
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Link from "next/link"
|
| 2 |
+
import { Button } from "@/components/ui/button"
|
| 3 |
+
import {
|
| 4 |
+
Sparkles,
|
| 5 |
+
Zap,
|
| 6 |
+
Globe,
|
| 7 |
+
Shield,
|
| 8 |
+
Users,
|
| 9 |
+
Heart,
|
| 10 |
+
ArrowRight,
|
| 11 |
+
Github,
|
| 12 |
+
Twitter,
|
| 13 |
+
Mail
|
| 14 |
+
} from "lucide-react"
|
| 15 |
+
import { getPlatformStats } from "@/lib/data"
|
| 16 |
+
|
| 17 |
+
export default async function AboutPage() {
|
| 18 |
+
const platformStats = await getPlatformStats()
|
| 19 |
+
|
| 20 |
+
const stats = [
|
| 21 |
+
{ value: `${platformStats.totalImages}+`, label: "Images Generated" },
|
| 22 |
+
{ value: `${platformStats.totalArtists}+`, label: "Active Artists" },
|
| 23 |
+
{ value: "100", label: "Free Daily Credits" },
|
| 24 |
+
{ value: "5", label: "Credits per Image" },
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
const features = [
|
| 28 |
+
{
|
| 29 |
+
icon: Zap,
|
| 30 |
+
title: "Lightning Fast Generation",
|
| 31 |
+
description: "Powered by our AI edge network for instant image generation anywhere in the world."
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
icon: Globe,
|
| 35 |
+
title: "Global Edge Network",
|
| 36 |
+
description: "Our infrastructure spans 200+ cities worldwide, ensuring low latency no matter where you are."
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
icon: Shield,
|
| 40 |
+
title: "Privacy First",
|
| 41 |
+
description: "Your prompts and images are yours. We don't sell your data or use it for training without consent."
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
icon: Users,
|
| 45 |
+
title: "Community Driven",
|
| 46 |
+
description: "Share your creations with a vibrant community of digital artists and AI enthusiasts."
|
| 47 |
+
}
|
| 48 |
+
]
|
| 49 |
+
|
| 50 |
+
return (
|
| 51 |
+
<div className="min-h-screen font-sans">
|
| 52 |
+
{/* Clean Background */}
|
| 53 |
+
<div className="fixed inset-0 -z-10 bg-background">
|
| 54 |
+
<div className="absolute inset-0 bg-[linear-gradient(rgba(0,0,0,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,0,0,0.02)_1px,transparent_1px)] dark:bg-[linear-gradient(rgba(255,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.02)_1px,transparent_1px)] bg-[size:64px_64px]" />
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
{/* Hero Section */}
|
| 58 |
+
<section className="pt-24 pb-16 lg:pt-32 lg:pb-24">
|
| 59 |
+
<div className="container px-4 md:px-6">
|
| 60 |
+
<div className="max-w-4xl mx-auto text-center space-y-8">
|
| 61 |
+
<div className="inline-flex items-center gap-2 px-4 py-2 border-2 border-primary bg-primary/5 shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 62 |
+
<Heart className="h-4 w-4 text-primary" />
|
| 63 |
+
<span className="text-sm font-black uppercase tracking-widest text-primary">Our Story</span>
|
| 64 |
+
</div>
|
| 65 |
+
|
| 66 |
+
<h1 className="text-3xl md:text-5xl lg:text-6xl font-black tracking-tighter uppercase">
|
| 67 |
+
Democratizing AI Art
|
| 68 |
+
<br />
|
| 69 |
+
<span className="text-primary text-stroke-primary">
|
| 70 |
+
For Everyone
|
| 71 |
+
</span>
|
| 72 |
+
</h1>
|
| 73 |
+
|
| 74 |
+
<p className="text-lg md:text-xl text-muted-foreground max-w-2xl mx-auto font-medium">
|
| 75 |
+
Imyra was built with a simple mission: make AI-powered image generation accessible,
|
| 76 |
+
fast, and free for creators worldwide. No subscriptions, no hidden fees—just pure creativity.
|
| 77 |
+
</p>
|
| 78 |
+
</div>
|
| 79 |
+
</div>
|
| 80 |
+
</section>
|
| 81 |
+
|
| 82 |
+
{/* Stats Section */}
|
| 83 |
+
<section className="py-16 border-y-2 border-border bg-muted/20">
|
| 84 |
+
<div className="container px-4 md:px-6">
|
| 85 |
+
<div className="grid grid-cols-2 md:grid-cols-4 gap-8">
|
| 86 |
+
{stats.map((stat, index) => (
|
| 87 |
+
<div key={index} className="text-center space-y-2 p-6 border-2 border-border bg-card shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all">
|
| 88 |
+
<p className="text-4xl md:text-5xl font-black text-primary">
|
| 89 |
+
{stat.value}
|
| 90 |
+
</p>
|
| 91 |
+
<p className="text-sm font-bold text-muted-foreground uppercase tracking-wider">
|
| 92 |
+
{stat.label}
|
| 93 |
+
</p>
|
| 94 |
+
</div>
|
| 95 |
+
))}
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
</section>
|
| 99 |
+
|
| 100 |
+
{/* Mission Section */}
|
| 101 |
+
<section className="py-16 lg:py-24">
|
| 102 |
+
<div className="container px-4 md:px-6">
|
| 103 |
+
<div className="grid lg:grid-cols-2 gap-12 items-center">
|
| 104 |
+
<div className="space-y-6">
|
| 105 |
+
<div className="inline-flex items-center gap-2 px-3 py-1 border-2 border-border bg-secondary/10 shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 106 |
+
<Sparkles className="h-3 w-3 text-foreground" />
|
| 107 |
+
<span className="text-xs font-black uppercase tracking-widest text-foreground">Our Mission</span>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<h2 className="text-3xl md:text-4xl font-black tracking-tighter uppercase">
|
| 111 |
+
Art Should Be <span className="text-primary underline decoration-4 decoration-primary underline-offset-4">Accessible</span>
|
| 112 |
+
</h2>
|
| 113 |
+
|
| 114 |
+
<div className="space-y-4 text-muted-foreground font-medium">
|
| 115 |
+
<p>
|
| 116 |
+
We believe everyone should have the power to create stunning visuals,
|
| 117 |
+
regardless of their artistic background or budget. That's why we offer
|
| 118 |
+
100 free credits every single day.
|
| 119 |
+
</p>
|
| 120 |
+
<p>
|
| 121 |
+
Our platform leverages the best open-source AI models including Flux, Stable Diffusion,
|
| 122 |
+
and more—running on distributed GPU infrastructure for blazing-fast
|
| 123 |
+
generation times.
|
| 124 |
+
</p>
|
| 125 |
+
<p>
|
| 126 |
+
At just <strong className="text-foreground">5 credits per image</strong>,
|
| 127 |
+
you can generate up to <strong className="text-foreground">20 images daily</strong>
|
| 128 |
+
completely free. No strings attached.
|
| 129 |
+
</p>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
{/* Feature Grid */}
|
| 134 |
+
<div className="grid sm:grid-cols-2 gap-6">
|
| 135 |
+
{features.map((feature, index) => (
|
| 136 |
+
<div
|
| 137 |
+
key={index}
|
| 138 |
+
className="p-6 rounded-none border-2 border-border bg-card shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 139 |
+
>
|
| 140 |
+
<div className="h-12 w-12 flex items-center justify-center mb-4 border-2 border-border bg-primary/10">
|
| 141 |
+
<feature.icon className="h-6 w-6 text-primary" />
|
| 142 |
+
</div>
|
| 143 |
+
<h3 className="font-black mb-2 uppercase tracking-tight">{feature.title}</h3>
|
| 144 |
+
<p className="text-sm text-muted-foreground font-medium">{feature.description}</p>
|
| 145 |
+
</div>
|
| 146 |
+
))}
|
| 147 |
+
</div>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
</section>
|
| 151 |
+
|
| 152 |
+
{/* Technology Section */}
|
| 153 |
+
<section className="py-16 lg:py-24 border-t-2 border-border bg-muted/20">
|
| 154 |
+
<div className="container px-4 md:px-6">
|
| 155 |
+
<div className="max-w-3xl mx-auto text-center space-y-12">
|
| 156 |
+
<h2 className="text-3xl md:text-4xl font-black tracking-tighter uppercase">
|
| 157 |
+
Powered by <span className="text-primary">Cutting-Edge</span> Tech
|
| 158 |
+
</h2>
|
| 159 |
+
|
| 160 |
+
<div className="grid md:grid-cols-3 gap-8">
|
| 161 |
+
<div className="p-8 rounded-none border-2 border-border bg-card shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all">
|
| 162 |
+
<div className="text-4xl mb-4">🌐</div>
|
| 163 |
+
<h3 className="font-black mb-2 uppercase">Open Source</h3>
|
| 164 |
+
<p className="text-sm text-muted-foreground font-medium">Built on community-driven OSS models</p>
|
| 165 |
+
</div>
|
| 166 |
+
<div className="p-8 rounded-none border-2 border-border bg-card shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all">
|
| 167 |
+
<div className="text-4xl mb-4">🎨</div>
|
| 168 |
+
<h3 className="font-black mb-2 uppercase">Flux & SD Models</h3>
|
| 169 |
+
<p className="text-sm text-muted-foreground font-medium">State-of-the-art AI image generation</p>
|
| 170 |
+
</div>
|
| 171 |
+
<div className="p-8 rounded-none border-2 border-border bg-card shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all">
|
| 172 |
+
<div className="text-4xl mb-4">🚀</div>
|
| 173 |
+
<h3 className="font-black mb-2 uppercase">Next.js 15</h3>
|
| 174 |
+
<p className="text-sm text-muted-foreground font-medium">Modern React framework for speed</p>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
</div>
|
| 179 |
+
</section>
|
| 180 |
+
|
| 181 |
+
{/* CTA Section */}
|
| 182 |
+
<section className="py-16 lg:py-24 border-t-2 border-border">
|
| 183 |
+
<div className="container px-4 md:px-6">
|
| 184 |
+
<div className="relative overflow-hidden border-2 border-border bg-primary/5 p-8 md:p-10 lg:p-12 shadow-[8px_8px_0px_0px_rgba(0,0,0,1)] dark:shadow-[8px_8px_0px_0px_rgba(255,255,255,1)]">
|
| 185 |
+
|
| 186 |
+
<div className="relative z-10 text-center max-w-2xl mx-auto space-y-8">
|
| 187 |
+
<h2 className="text-3xl md:text-5xl font-black tracking-tighter uppercase">
|
| 188 |
+
Ready to Start Creating?
|
| 189 |
+
</h2>
|
| 190 |
+
<p className="text-xl text-muted-foreground font-medium">
|
| 191 |
+
Join our community of artists and start generating stunning AI art today.
|
| 192 |
+
It's completely free to get started.
|
| 193 |
+
</p>
|
| 194 |
+
<div className="flex flex-col sm:flex-row gap-4 justify-center">
|
| 195 |
+
<Button
|
| 196 |
+
size="lg"
|
| 197 |
+
className="h-16 px-12 text-xl bg-primary hover:bg-primary/90 text-white font-black uppercase tracking-wider rounded-none border-2 border-primary shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 198 |
+
asChild
|
| 199 |
+
>
|
| 200 |
+
<Link href="/create" className="flex items-center gap-2">
|
| 201 |
+
Start Creating
|
| 202 |
+
<ArrowRight className="h-5 w-5" />
|
| 203 |
+
</Link>
|
| 204 |
+
</Button>
|
| 205 |
+
<Button
|
| 206 |
+
size="lg"
|
| 207 |
+
variant="outline"
|
| 208 |
+
className="h-16 px-12 text-xl bg-background hover:bg-accent font-black uppercase tracking-wider rounded-none border-2 border-border shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 209 |
+
asChild
|
| 210 |
+
>
|
| 211 |
+
<Link href="/gallery">View Gallery</Link>
|
| 212 |
+
</Button>
|
| 213 |
+
</div>
|
| 214 |
+
</div>
|
| 215 |
+
</div>
|
| 216 |
+
</div>
|
| 217 |
+
</section>
|
| 218 |
+
|
| 219 |
+
{/* Footer */}
|
| 220 |
+
<footer className="border-t-2 border-border py-12 bg-muted/20">
|
| 221 |
+
<div className="container px-4 md:px-6">
|
| 222 |
+
<div className="flex flex-col md:flex-row justify-between items-center gap-6">
|
| 223 |
+
<div className="flex items-center gap-2">
|
| 224 |
+
<div className="p-2 border-2 border-border bg-primary text-white shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)]">
|
| 225 |
+
<Sparkles className="h-6 w-6" />
|
| 226 |
+
</div>
|
| 227 |
+
<span className="font-black text-xl uppercase tracking-tight">Imyra</span>
|
| 228 |
+
</div>
|
| 229 |
+
|
| 230 |
+
<nav className="flex gap-8 text-sm font-bold uppercase tracking-wider">
|
| 231 |
+
<Link href="/" className="hover:text-primary transition-colors hover:underline decoration-2 underline-offset-4">Home</Link>
|
| 232 |
+
<Link href="/create" className="hover:text-primary transition-colors hover:underline decoration-2 underline-offset-4">Create</Link>
|
| 233 |
+
<Link href="/about" className="hover:text-primary transition-colors hover:underline decoration-2 underline-offset-4">About</Link>
|
| 234 |
+
</nav>
|
| 235 |
+
|
| 236 |
+
<p className="text-sm font-bold text-muted-foreground">
|
| 237 |
+
© {new Date().getFullYear()} Imyra.
|
| 238 |
+
</p>
|
| 239 |
+
</div>
|
| 240 |
+
</div>
|
| 241 |
+
</footer>
|
| 242 |
+
</div>
|
| 243 |
+
)
|
| 244 |
+
}
|
src/app/actions/auth.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use server"
|
| 2 |
+
|
| 3 |
+
import { prisma } from "@/lib/prisma"
|
| 4 |
+
import bcrypt from "bcryptjs"
|
| 5 |
+
import { z } from "zod"
|
| 6 |
+
|
| 7 |
+
const signupSchema = z.object({
|
| 8 |
+
name: z.string().min(2, "Name must be at least 2 characters"),
|
| 9 |
+
username: z.string().min(3, "Username must be at least 3 characters"),
|
| 10 |
+
email: z.string().email("Invalid email address"),
|
| 11 |
+
password: z.string().min(6, "Password must be at least 6 characters"),
|
| 12 |
+
})
|
| 13 |
+
|
| 14 |
+
export async function signup(data: z.infer<typeof signupSchema>) {
|
| 15 |
+
const result = signupSchema.safeParse(data)
|
| 16 |
+
|
| 17 |
+
if (!result.success) {
|
| 18 |
+
return { error: "Invalid input" }
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
const { name, username, email, password } = result.data
|
| 22 |
+
|
| 23 |
+
try {
|
| 24 |
+
const existingUser = await prisma.user.findFirst({
|
| 25 |
+
where: {
|
| 26 |
+
OR: [{ email }, { username }],
|
| 27 |
+
},
|
| 28 |
+
})
|
| 29 |
+
|
| 30 |
+
if (existingUser) {
|
| 31 |
+
return { error: "User with this email or username already exists" }
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
const hashedPassword = await bcrypt.hash(password, 10)
|
| 35 |
+
|
| 36 |
+
await prisma.user.create({
|
| 37 |
+
data: {
|
| 38 |
+
name,
|
| 39 |
+
username,
|
| 40 |
+
email,
|
| 41 |
+
password: hashedPassword,
|
| 42 |
+
credits: 50,
|
| 43 |
+
},
|
| 44 |
+
})
|
| 45 |
+
|
| 46 |
+
return { success: true }
|
| 47 |
+
} catch (error) {
|
| 48 |
+
console.error("Signup error:", error)
|
| 49 |
+
return { error: "Something went wrong. Please try again." }
|
| 50 |
+
}
|
| 51 |
+
}
|
src/app/api/auth/[...nextauth]/route.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { handlers } from "@/auth"
|
| 2 |
+
export const { GET, POST } = handlers
|
src/app/api/gallery/route.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { prisma } from "@/lib/prisma"
|
| 2 |
+
import { NextResponse } from "next/server"
|
| 3 |
+
|
| 4 |
+
export async function GET(request: Request) {
|
| 5 |
+
try {
|
| 6 |
+
const { searchParams } = new URL(request.url)
|
| 7 |
+
const cursor = searchParams.get("cursor")
|
| 8 |
+
const limit = parseInt(searchParams.get("limit") || "20")
|
| 9 |
+
|
| 10 |
+
const generations = await prisma.generation.findMany({
|
| 11 |
+
where: { isPublic: true },
|
| 12 |
+
orderBy: [{ createdAt: "desc" }, { id: "desc" }],
|
| 13 |
+
take: limit + 1, // Fetch one extra to check for next page
|
| 14 |
+
cursor: cursor ? { id: cursor } : undefined,
|
| 15 |
+
skip: cursor ? 1 : 0, // Skip the cursor itself if present
|
| 16 |
+
include: {
|
| 17 |
+
user: {
|
| 18 |
+
select: {
|
| 19 |
+
name: true,
|
| 20 |
+
username: true,
|
| 21 |
+
image: true,
|
| 22 |
+
},
|
| 23 |
+
},
|
| 24 |
+
},
|
| 25 |
+
})
|
| 26 |
+
|
| 27 |
+
let nextCursor: string | null = null
|
| 28 |
+
if (generations.length > limit) {
|
| 29 |
+
const nextItem = generations.pop() // Remove the extra item
|
| 30 |
+
nextCursor = nextItem?.id || null
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
return NextResponse.json({
|
| 34 |
+
data: generations,
|
| 35 |
+
nextCursor,
|
| 36 |
+
})
|
| 37 |
+
} catch (error) {
|
| 38 |
+
console.error("Gallery fetch error:", error)
|
| 39 |
+
return NextResponse.json(
|
| 40 |
+
{ error: "Failed to fetch gallery images" },
|
| 41 |
+
{ status: 500 }
|
| 42 |
+
)
|
| 43 |
+
}
|
| 44 |
+
}
|
src/app/api/generate/route.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { auth } from "@/auth"
|
| 2 |
+
import { checkAndResetDailyCredits, deductCredits } from "@/lib/credits"
|
| 3 |
+
import { prisma } from "@/lib/prisma"
|
| 4 |
+
import { NextRequest, NextResponse } from "next/server"
|
| 5 |
+
|
| 6 |
+
export const DEFAULT_NEGATIVE_PROMPT = "blurry, low quality, bad anatomy, bad hands, distorted, ugly, pixelated, watermark, text, signature, grains, haze"
|
| 7 |
+
|
| 8 |
+
export async function POST(req: NextRequest) {
|
| 9 |
+
try {
|
| 10 |
+
const session = await auth()
|
| 11 |
+
if (!session || !session.user || !session.user.id) {
|
| 12 |
+
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
const { prompt, model = "flux-dev", width = 1024, height = 1024 } = await req.json()
|
| 16 |
+
|
| 17 |
+
if (!prompt) {
|
| 18 |
+
return NextResponse.json({ error: "Prompt is required" }, { status: 400 })
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// 1. Check Credits
|
| 22 |
+
const credits = await checkAndResetDailyCredits(session.user.id)
|
| 23 |
+
// 2. Load Balancing Configuration
|
| 24 |
+
// Parse workers from Environment Variable (comma separated) or default to known instances
|
| 25 |
+
const envWorkers = process.env.CLOUDFLARE_WORKER_URL
|
| 26 |
+
? process.env.CLOUDFLARE_WORKER_URL.split(",").map(url => url.trim())
|
| 27 |
+
: []
|
| 28 |
+
|
| 29 |
+
// Add hardcoded fallbacks/extras if they aren't in the env
|
| 30 |
+
// The user might put the primary in env and want to add others here or in env
|
| 31 |
+
const extraWorkers = [
|
| 32 |
+
"https://bitter-forest-7e87.bob17040246.workers.dev/"
|
| 33 |
+
]
|
| 34 |
+
|
| 35 |
+
// Combine and Deduplicate
|
| 36 |
+
const ALL_WORKERS = Array.from(new Set([...envWorkers, ...extraWorkers])).filter(url => url.length > 0)
|
| 37 |
+
|
| 38 |
+
if (ALL_WORKERS.length === 0) {
|
| 39 |
+
return NextResponse.json({ error: "Server configuration error: No worker URLs found" }, { status: 500 })
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// Round-robin selection
|
| 43 |
+
if (typeof (global as any).requestCounter === 'undefined') {
|
| 44 |
+
(global as any).requestCounter = 0
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
const counter = (global as any).requestCounter++
|
| 48 |
+
const selectedWorkerUrl = ALL_WORKERS[counter % ALL_WORKERS.length]
|
| 49 |
+
|
| 50 |
+
console.log(`[LoadBalancer] Request #${counter} -> Using Worker ${counter % ALL_WORKERS.length + 1}/${ALL_WORKERS.length}: ${selectedWorkerUrl}`)
|
| 51 |
+
|
| 52 |
+
// Clean up URL construction
|
| 53 |
+
const baseUrl = selectedWorkerUrl.endsWith("/") ? selectedWorkerUrl.slice(0, -1) : selectedWorkerUrl
|
| 54 |
+
// If model includes a slash, remove it for consistency
|
| 55 |
+
const cleanModel = model.startsWith("/") ? model.slice(1) : model
|
| 56 |
+
const url = `${baseUrl}/${cleanModel}`
|
| 57 |
+
|
| 58 |
+
// Prepare payload with Negative Prompt
|
| 59 |
+
const payload = {
|
| 60 |
+
prompt,
|
| 61 |
+
negative_prompt: DEFAULT_NEGATIVE_PROMPT, // Pass explicit negative prompt
|
| 62 |
+
width,
|
| 63 |
+
height,
|
| 64 |
+
steps: 30
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
// For Flux models that might ignore negative_prompt, we can optionally append it to the prompt
|
| 68 |
+
// IF the model is known to not support it. But standard practice is to send it separately first.
|
| 69 |
+
|
| 70 |
+
const response = await fetch(url, {
|
| 71 |
+
method: "POST",
|
| 72 |
+
headers: { "Content-Type": "application/json" },
|
| 73 |
+
body: JSON.stringify(payload),
|
| 74 |
+
})
|
| 75 |
+
// }
|
| 76 |
+
|
| 77 |
+
if (!response.ok) {
|
| 78 |
+
const errorText = await response.text()
|
| 79 |
+
console.error("AI Generation failed:", errorText)
|
| 80 |
+
return NextResponse.json({ error: "Image generation failed upstream" }, { status: 500 })
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
const result = await response.json()
|
| 84 |
+
|
| 85 |
+
if (!result.success || !result.url) {
|
| 86 |
+
return NextResponse.json({ error: "Image generation returned no URL" }, { status: 500 })
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
// 3. Deduct Credits (Success confirmed) - 5 credits per generation
|
| 90 |
+
await deductCredits(session.user.id, 5)
|
| 91 |
+
|
| 92 |
+
// 4. Save to Database
|
| 93 |
+
const generation = await prisma.generation.create({
|
| 94 |
+
data: {
|
| 95 |
+
prompt,
|
| 96 |
+
model,
|
| 97 |
+
width,
|
| 98 |
+
height,
|
| 99 |
+
imageUrl: result.url,
|
| 100 |
+
userId: session.user.id,
|
| 101 |
+
isPublic: true, // Default to public as per requirement "gallery... new non auth users will be able to see"
|
| 102 |
+
}
|
| 103 |
+
})
|
| 104 |
+
|
| 105 |
+
return NextResponse.json({
|
| 106 |
+
success: true,
|
| 107 |
+
url: generation.imageUrl,
|
| 108 |
+
width: generation.width,
|
| 109 |
+
height: generation.height,
|
| 110 |
+
prompt: generation.prompt,
|
| 111 |
+
model: generation.model
|
| 112 |
+
})
|
| 113 |
+
|
| 114 |
+
} catch (error) {
|
| 115 |
+
console.error("Generate API error:", error)
|
| 116 |
+
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
|
| 117 |
+
}
|
| 118 |
+
}
|
src/app/api/generation/[id]/route.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { auth } from "@/auth"
|
| 2 |
+
import { prisma } from "@/lib/prisma"
|
| 3 |
+
import { NextResponse } from "next/server"
|
| 4 |
+
|
| 5 |
+
export async function DELETE(
|
| 6 |
+
req: Request,
|
| 7 |
+
{ params }: { params: Promise<{ id: string }> }
|
| 8 |
+
) {
|
| 9 |
+
try {
|
| 10 |
+
const session = await auth()
|
| 11 |
+
if (!session?.user?.id) {
|
| 12 |
+
return new NextResponse("Unauthorized", { status: 401 })
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
const { id } = await params
|
| 16 |
+
|
| 17 |
+
// Verify ownership
|
| 18 |
+
const generation = await prisma.generation.findUnique({
|
| 19 |
+
where: { id },
|
| 20 |
+
})
|
| 21 |
+
|
| 22 |
+
if (!generation) {
|
| 23 |
+
return new NextResponse("Not Found", { status: 404 })
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
if (generation.userId !== session.user.id) {
|
| 27 |
+
return new NextResponse("Forbidden", { status: 403 })
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
await prisma.generation.delete({
|
| 31 |
+
where: { id },
|
| 32 |
+
})
|
| 33 |
+
|
| 34 |
+
return new NextResponse(null, { status: 204 })
|
| 35 |
+
} catch (error) {
|
| 36 |
+
console.error("[GENERATION_DELETE]", error)
|
| 37 |
+
return new NextResponse("Internal Error", { status: 500 })
|
| 38 |
+
}
|
| 39 |
+
}
|
src/app/api/image/[id]/[filename]/route.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { NextRequest, NextResponse } from "next/server"
|
| 2 |
+
import { prisma } from "@/lib/prisma"
|
| 3 |
+
|
| 4 |
+
export async function GET(
|
| 5 |
+
req: NextRequest,
|
| 6 |
+
{ params }: { params: Promise<{ id: string }> }
|
| 7 |
+
) {
|
| 8 |
+
const { id } = await params
|
| 9 |
+
|
| 10 |
+
if (!id) {
|
| 11 |
+
return NextResponse.json({ error: "Image ID is required" }, { status: 400 })
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
try {
|
| 15 |
+
const generation = await prisma.generation.findUnique({
|
| 16 |
+
where: { id },
|
| 17 |
+
select: { imageUrl: true }
|
| 18 |
+
})
|
| 19 |
+
|
| 20 |
+
if (!generation || !generation.imageUrl) {
|
| 21 |
+
return NextResponse.json({ error: "Image not found" }, { status: 404 })
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
const response = await fetch(generation.imageUrl)
|
| 25 |
+
if (!response.ok) {
|
| 26 |
+
return NextResponse.json({ error: "Failed to fetch image" }, { status: response.status })
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
const contentType = response.headers.get("Content-Type") || "image/jpeg"
|
| 30 |
+
const buffer = await response.arrayBuffer()
|
| 31 |
+
|
| 32 |
+
return new NextResponse(buffer, {
|
| 33 |
+
headers: {
|
| 34 |
+
"Content-Type": contentType,
|
| 35 |
+
"Cache-Control": "public, max-age=31536000, immutable",
|
| 36 |
+
},
|
| 37 |
+
})
|
| 38 |
+
} catch (error) {
|
| 39 |
+
console.error("Image proxy error:", error)
|
| 40 |
+
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
|
| 41 |
+
}
|
| 42 |
+
}
|
src/app/api/user/route.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { auth } from "@/auth"
|
| 2 |
+
import { prisma } from "@/lib/prisma"
|
| 3 |
+
import { NextResponse } from "next/server"
|
| 4 |
+
import { z } from "zod"
|
| 5 |
+
|
| 6 |
+
export async function PUT(req: Request) {
|
| 7 |
+
try {
|
| 8 |
+
const session = await auth()
|
| 9 |
+
if (!session?.user?.id) {
|
| 10 |
+
return new NextResponse("Unauthorized", { status: 401 })
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
const body = await req.json()
|
| 14 |
+
const { name, username } = z
|
| 15 |
+
.object({
|
| 16 |
+
name: z.string().min(2).max(50),
|
| 17 |
+
username: z.string().min(3).max(20).regex(/^[a-zA-Z0-9_]+$/, "Username must be alphanumeric"),
|
| 18 |
+
})
|
| 19 |
+
.parse(body)
|
| 20 |
+
|
| 21 |
+
// Check if username is taken (if changed)
|
| 22 |
+
if (username !== session.user.username) {
|
| 23 |
+
const existingUser = await prisma.user.findUnique({
|
| 24 |
+
where: { username },
|
| 25 |
+
})
|
| 26 |
+
if (existingUser) {
|
| 27 |
+
return new NextResponse("Username already taken", { status: 409 })
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
const updatedUser = await prisma.user.update({
|
| 32 |
+
where: { id: session.user.id },
|
| 33 |
+
data: { name, username },
|
| 34 |
+
})
|
| 35 |
+
|
| 36 |
+
return NextResponse.json(updatedUser)
|
| 37 |
+
} catch (error) {
|
| 38 |
+
if (error instanceof z.ZodError) {
|
| 39 |
+
return new NextResponse("Invalid data", { status: 422 })
|
| 40 |
+
}
|
| 41 |
+
console.error("[USER_UPDATE]", error)
|
| 42 |
+
return new NextResponse("Internal Error", { status: 500 })
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
export async function DELETE(req: Request) {
|
| 47 |
+
try {
|
| 48 |
+
const session = await auth()
|
| 49 |
+
if (!session?.user?.id) {
|
| 50 |
+
return new NextResponse("Unauthorized", { status: 401 })
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
// Delete user (Cascade will handle Generations, Accounts, Sessions)
|
| 54 |
+
await prisma.user.delete({
|
| 55 |
+
where: { id: session.user.id },
|
| 56 |
+
})
|
| 57 |
+
|
| 58 |
+
return new NextResponse(null, { status: 204 })
|
| 59 |
+
} catch (error) {
|
| 60 |
+
console.error("[USER_DELETE]", error)
|
| 61 |
+
return new NextResponse("Internal Error", { status: 500 })
|
| 62 |
+
}
|
| 63 |
+
}
|
src/app/artwork/[id]/page.tsx
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { prisma } from "@/lib/prisma"
|
| 2 |
+
import { notFound } from "next/navigation"
|
| 3 |
+
import Image from "next/image"
|
| 4 |
+
import { Button } from "@/components/ui/button"
|
| 5 |
+
import { ShareMenu } from "@/components/share-menu"
|
| 6 |
+
import { Download, Info, ArrowLeft, Paintbrush, Calendar, User } from "lucide-react"
|
| 7 |
+
import Link from "next/link"
|
| 8 |
+
import { Metadata } from "next"
|
| 9 |
+
|
| 10 |
+
// Force dynamic rendering to ensure fresh data and valid auth checks if needed
|
| 11 |
+
// though this page is public
|
| 12 |
+
export const dynamic = "force-dynamic"
|
| 13 |
+
|
| 14 |
+
interface ArtworkPageProps {
|
| 15 |
+
params: Promise<{ id: string }>
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
export async function generateMetadata({ params }: ArtworkPageProps): Promise<Metadata> {
|
| 19 |
+
const resolvedParams = await params
|
| 20 |
+
const generation = await prisma.generation.findUnique({
|
| 21 |
+
where: { id: resolvedParams.id },
|
| 22 |
+
select: { prompt: true, id: true, imageUrl: true, user: { select: { name: true } } }
|
| 23 |
+
})
|
| 24 |
+
|
| 25 |
+
if (!generation) {
|
| 26 |
+
return {
|
| 27 |
+
title: "Artwork Not Found | Imyra",
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
return {
|
| 32 |
+
title: `${generation.prompt} by ${generation.user.name || "Anonymous"} | Imyra`,
|
| 33 |
+
description: `View this AI-generated artwork: "${generation.prompt}" created using Imyra.`,
|
| 34 |
+
openGraph: {
|
| 35 |
+
title: `Imyra: ${generation.prompt}`,
|
| 36 |
+
description: "Check out this amazing AI artwork generated on Imyra.",
|
| 37 |
+
images: [generation.imageUrl], // Use the direct URL for social preview
|
| 38 |
+
},
|
| 39 |
+
twitter: {
|
| 40 |
+
card: "summary_large_image",
|
| 41 |
+
title: `Imyra: ${generation.prompt}`,
|
| 42 |
+
description: "Check out this amazing AI artwork generated on Imyra.",
|
| 43 |
+
images: [generation.imageUrl],
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
export default async function ArtworkPage({ params }: ArtworkPageProps) {
|
| 49 |
+
const resolvedParams = await params
|
| 50 |
+
const generation = await prisma.generation.findUnique({
|
| 51 |
+
where: { id: resolvedParams.id },
|
| 52 |
+
include: {
|
| 53 |
+
user: {
|
| 54 |
+
select: {
|
| 55 |
+
name: true,
|
| 56 |
+
username: true,
|
| 57 |
+
image: true,
|
| 58 |
+
},
|
| 59 |
+
},
|
| 60 |
+
},
|
| 61 |
+
})
|
| 62 |
+
|
| 63 |
+
if (!generation) {
|
| 64 |
+
notFound()
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
const imageUrl = generation.imageUrl
|
| 68 |
+
|
| 69 |
+
return (
|
| 70 |
+
<div className="min-h-screen bg-background flex flex-col">
|
| 71 |
+
{/* Header */}
|
| 72 |
+
<header className="border-b border-border bg-background/50 backdrop-blur-md sticky top-0 z-50">
|
| 73 |
+
<div className="container mx-auto px-4 h-16 flex items-center justify-between">
|
| 74 |
+
<Link href="/" className="flex items-center gap-2 group">
|
| 75 |
+
<div className="h-8 w-8 bg-primary rounded-lg flex items-center justify-center text-primary-foreground font-bold group-hover:scale-105 transition-transform">
|
| 76 |
+
W
|
| 77 |
+
</div>
|
| 78 |
+
<span className="font-bold text-lg tracking-tight">Imyra</span>
|
| 79 |
+
</Link>
|
| 80 |
+
<Link href="/create">
|
| 81 |
+
<Button variant="ghost" size="sm">
|
| 82 |
+
<ArrowLeft className="mr-2 h-4 w-4" /> Go to Studio
|
| 83 |
+
</Button>
|
| 84 |
+
</Link>
|
| 85 |
+
</div>
|
| 86 |
+
</header>
|
| 87 |
+
|
| 88 |
+
<main className="flex-1 container mx-auto px-4 py-8 md:py-12">
|
| 89 |
+
<div className="max-w-6xl mx-auto neo-brutalist bg-card border-2 border-border overflow-hidden rounded-xl">
|
| 90 |
+
<div className="grid grid-cols-1 lg:grid-cols-3 min-h-[600px]">
|
| 91 |
+
{/* Image Section - Takes up 2 columns */}
|
| 92 |
+
<div className="lg:col-span-2 bg-secondary/5 relative border-b lg:border-b-0 lg:border-r border-border min-h-[400px] flex items-center justify-center p-6 md:p-12">
|
| 93 |
+
<div className="absolute inset-0 bg-[linear-gradient(45deg,#0000_25%,#fff2_25%,#fff2_50%,#0000_50%,#0000_75%,#fff2_75%,#fff2_100%)] bg-[size:20px_20px] opacity-[0.05]" />
|
| 94 |
+
<div className="relative w-full h-full min-h-[400px]">
|
| 95 |
+
<Image
|
| 96 |
+
src={imageUrl}
|
| 97 |
+
alt={generation.prompt}
|
| 98 |
+
fill
|
| 99 |
+
className="object-contain" // keeps aspect ratio, shows full image
|
| 100 |
+
unoptimized
|
| 101 |
+
priority
|
| 102 |
+
/>
|
| 103 |
+
</div>
|
| 104 |
+
</div>
|
| 105 |
+
|
| 106 |
+
{/* Details Sidebar */}
|
| 107 |
+
<div className="lg:col-span-1 flex flex-col h-full bg-background/50">
|
| 108 |
+
<div className="p-6 md:p-8 space-y-8 flex-1">
|
| 109 |
+
{/* Creator Info */}
|
| 110 |
+
<div>
|
| 111 |
+
<h1 className="text-2xl md:text-3xl font-black mb-4 leading-tight">
|
| 112 |
+
Generation Details
|
| 113 |
+
</h1>
|
| 114 |
+
<div className="flex items-center gap-3 p-3 rounded-lg bg-secondary/10 border border-border inline-flex pr-6">
|
| 115 |
+
<div className="h-10 w-10 rounded-full bg-primary/20 flex items-center justify-center border-2 border-primary/50 text-lg font-bold">
|
| 116 |
+
{generation.user.name?.[0] || "U"}
|
| 117 |
+
</div>
|
| 118 |
+
<div>
|
| 119 |
+
<p className="font-bold text-sm leading-none">{generation.user.name || "Anonymous"}</p>
|
| 120 |
+
<p className="text-xs text-muted-foreground font-medium">@{generation.user.username || "user"}</p>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</div>
|
| 124 |
+
|
| 125 |
+
{/* Prompt */}
|
| 126 |
+
<div className="space-y-3">
|
| 127 |
+
<div className="flex items-center gap-2 text-xs font-bold uppercase tracking-widest text-primary">
|
| 128 |
+
<Paintbrush className="h-3 w-3" /> Prompt
|
| 129 |
+
</div>
|
| 130 |
+
<p className="text-lg font-medium leading-relaxed text-foreground/90 border-l-4 border-primary pl-4 py-1 italic">
|
| 131 |
+
"{generation.prompt}"
|
| 132 |
+
</p>
|
| 133 |
+
</div>
|
| 134 |
+
|
| 135 |
+
{/* Tech Specs */}
|
| 136 |
+
<div className="grid grid-cols-2 gap-3">
|
| 137 |
+
<div className="p-3 rounded-lg bg-secondary/10 border border-border">
|
| 138 |
+
<p className="text-[10px] uppercase font-bold text-muted-foreground mb-1">Model</p>
|
| 139 |
+
<p className="font-bold text-sm truncate">{generation.model}</p>
|
| 140 |
+
</div>
|
| 141 |
+
<div className="p-3 rounded-lg bg-secondary/10 border border-border">
|
| 142 |
+
<p className="text-[10px] uppercase font-bold text-muted-foreground mb-1">Date</p>
|
| 143 |
+
<p className="font-bold text-sm truncate">
|
| 144 |
+
{new Date(generation.createdAt).toLocaleDateString()}
|
| 145 |
+
</p>
|
| 146 |
+
</div>
|
| 147 |
+
<div className="p-3 rounded-lg bg-secondary/10 border border-border">
|
| 148 |
+
<p className="text-[10px] uppercase font-bold text-muted-foreground mb-1">Dimensions</p>
|
| 149 |
+
<p className="font-bold text-sm">{generation.width} x {generation.height}</p>
|
| 150 |
+
</div>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
{/* Actions */}
|
| 155 |
+
<div className="p-6 border-t border-border bg-background/80 md:sticky bottom-0">
|
| 156 |
+
<div className="flex flex-col gap-3">
|
| 157 |
+
<a
|
| 158 |
+
href={imageUrl}
|
| 159 |
+
target="_blank"
|
| 160 |
+
rel="noopener noreferrer"
|
| 161 |
+
className="w-full"
|
| 162 |
+
>
|
| 163 |
+
<Button className="w-full neo-brutalist h-12 text-sm font-bold uppercase tracking-wider">
|
| 164 |
+
<Download className="mr-2 h-4 w-4" /> Download Original
|
| 165 |
+
</Button>
|
| 166 |
+
</a>
|
| 167 |
+
|
| 168 |
+
<ShareMenu
|
| 169 |
+
artworkId={generation.id}
|
| 170 |
+
prompt={generation.prompt}
|
| 171 |
+
className="w-full neo-brutalist h-12 text-sm font-bold uppercase tracking-wider bg-background text-foreground hover:bg-secondary/20"
|
| 172 |
+
/>
|
| 173 |
+
</div>
|
| 174 |
+
</div>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
</div>
|
| 178 |
+
</main>
|
| 179 |
+
</div>
|
| 180 |
+
)
|
| 181 |
+
}
|
src/app/favicon.ico
ADDED
|
|
src/app/gallery/page.tsx
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { getPublicGenerations } from "@/lib/data"
|
| 2 |
+
import { GalleryMasonry } from "@/components/gallery-masonry"
|
| 3 |
+
import { Button } from "@/components/ui/button"
|
| 4 |
+
import Link from "next/link"
|
| 5 |
+
import { Sparkles, ArrowRight } from "lucide-react"
|
| 6 |
+
|
| 7 |
+
export const dynamic = "force-dynamic"
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
export default async function GalleryPage() {
|
| 11 |
+
const generations = await getPublicGenerations()
|
| 12 |
+
|
| 13 |
+
return (
|
| 14 |
+
<div className="min-h-screen bg-background font-sans selection:bg-primary selection:text-white">
|
| 15 |
+
{/* Background */}
|
| 16 |
+
<div className="fixed inset-0 -z-10 bg-background">
|
| 17 |
+
<div className="absolute inset-0 bg-[linear-gradient(rgba(255,255,255,.02)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,.02)_1px,transparent_1px)] bg-[size:64px_64px]" />
|
| 18 |
+
</div>
|
| 19 |
+
|
| 20 |
+
<div className="container px-4 md:px-6 py-24 lg:py-32">
|
| 21 |
+
<div className="flex flex-col md:flex-row justify-between items-end gap-6 mb-12 border-b-2 border-border pb-6">
|
| 22 |
+
<div className="space-y-4">
|
| 23 |
+
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-primary/10 border border-primary/30">
|
| 24 |
+
<Sparkles className="h-3 w-3 text-primary" />
|
| 25 |
+
<span className="text-xs font-bold uppercase tracking-widest text-primary">Community Showcase</span>
|
| 26 |
+
</div>
|
| 27 |
+
<h1 className="text-4xl md:text-5xl lg:text-6xl font-black tracking-tighter uppercase">
|
| 28 |
+
The <span className="text-primary">Gallery</span>
|
| 29 |
+
</h1>
|
| 30 |
+
<p className="text-muted-foreground font-medium max-w-xl text-lg">
|
| 31 |
+
Explore the wildest creations from our global community. <br />
|
| 32 |
+
Infinite imagination in every pixel.
|
| 33 |
+
</p>
|
| 34 |
+
</div>
|
| 35 |
+
<Button size="lg" className="neo-brutalist bg-primary text-white font-bold tracking-wide group" asChild>
|
| 36 |
+
<Link href="/create" className="flex items-center gap-2">
|
| 37 |
+
Submit Your Art <ArrowRight className="h-5 w-5 group-hover:translate-x-1 transition-transform" />
|
| 38 |
+
</Link>
|
| 39 |
+
</Button>
|
| 40 |
+
</div>
|
| 41 |
+
|
| 42 |
+
<GalleryMasonry generations={generations} />
|
| 43 |
+
</div>
|
| 44 |
+
</div>
|
| 45 |
+
)
|
| 46 |
+
}
|
src/app/globals.css
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@tailwind base;
|
| 2 |
+
@tailwind components;
|
| 3 |
+
@tailwind utilities;
|
| 4 |
+
|
| 5 |
+
@layer base {
|
| 6 |
+
:root {
|
| 7 |
+
/* Brutalist White / Paper */
|
| 8 |
+
--background: 210 40% 98%;
|
| 9 |
+
--foreground: 222 47% 11%;
|
| 10 |
+
|
| 11 |
+
--card: 0 0% 100%;
|
| 12 |
+
--card-foreground: 222 47% 11%;
|
| 13 |
+
|
| 14 |
+
--popover: 0 0% 100%;
|
| 15 |
+
--popover-foreground: 222 47% 11%;
|
| 16 |
+
|
| 17 |
+
/* New Scheme: Vibrant Blue & Emerald */
|
| 18 |
+
--primary: 221.2 83.2% 53.3%;
|
| 19 |
+
/* Professional Blue */
|
| 20 |
+
--primary-foreground: 210 40% 98%;
|
| 21 |
+
|
| 22 |
+
--secondary: 160 84% 39%;
|
| 23 |
+
/* Emerald Green */
|
| 24 |
+
--secondary-foreground: 210 40% 98%;
|
| 25 |
+
|
| 26 |
+
--muted: 210 40% 90%;
|
| 27 |
+
--muted-foreground: 215.4 16.3% 40%;
|
| 28 |
+
|
| 29 |
+
--accent: 30 90% 60%;
|
| 30 |
+
/* Orange Pop stays for contrast */
|
| 31 |
+
--accent-foreground: 210 40% 98%;
|
| 32 |
+
|
| 33 |
+
--destructive: 0 84.2% 60.2%;
|
| 34 |
+
--destructive-foreground: 210 40% 98%;
|
| 35 |
+
|
| 36 |
+
--border: 0 0% 0%;
|
| 37 |
+
/* Pitch black borders */
|
| 38 |
+
--input: 0 0% 0%;
|
| 39 |
+
--ring: 221.2 83.2% 53.3%;
|
| 40 |
+
/* Matches Primary */
|
| 41 |
+
|
| 42 |
+
--radius: 0rem;
|
| 43 |
+
/* Hard edges for brutalism */
|
| 44 |
+
--glass-border: 0 0% 0%;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.dark {
|
| 48 |
+
/* Deep Void Black */
|
| 49 |
+
--background: 222 47% 7%;
|
| 50 |
+
/* Slight blue tint to black */
|
| 51 |
+
--foreground: 210 40% 98%;
|
| 52 |
+
|
| 53 |
+
--card: 222 47% 10%;
|
| 54 |
+
--card-foreground: 210 40% 98%;
|
| 55 |
+
|
| 56 |
+
--popover: 222 47% 10%;
|
| 57 |
+
--popover-foreground: 210 40% 98%;
|
| 58 |
+
|
| 59 |
+
/* Neon Glows - Shifted to Cyans/Blues */
|
| 60 |
+
--primary: 217 91% 60%;
|
| 61 |
+
/* Electric Blue */
|
| 62 |
+
--primary-foreground: 0 0% 0%;
|
| 63 |
+
|
| 64 |
+
--secondary: 160 84% 39%;
|
| 65 |
+
/* Emerald */
|
| 66 |
+
--secondary-foreground: 0 0% 0%;
|
| 67 |
+
|
| 68 |
+
--muted: 217 32% 17%;
|
| 69 |
+
--muted-foreground: 215 20.2% 70%;
|
| 70 |
+
|
| 71 |
+
--accent: 30 90% 60%;
|
| 72 |
+
--accent-foreground: 0 0% 0%;
|
| 73 |
+
|
| 74 |
+
--destructive: 0 62.8% 30.6%;
|
| 75 |
+
--destructive-foreground: 210 40% 98%;
|
| 76 |
+
|
| 77 |
+
--border: 0 0% 100%;
|
| 78 |
+
/* Pure white borders */
|
| 79 |
+
--input: 0 0% 100%;
|
| 80 |
+
--ring: 217 91% 60%;
|
| 81 |
+
--glass-border: 0 0% 100%;
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
@layer base {
|
| 86 |
+
* {
|
| 87 |
+
border-color: hsl(var(--border));
|
| 88 |
+
outline-color: hsla(var(--ring) / 0.5);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
body {
|
| 92 |
+
@apply bg-background text-foreground antialiased selection:bg-primary selection:text-primary-foreground;
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
@layer utilities {
|
| 97 |
+
.glass-panel {
|
| 98 |
+
@apply bg-background/80 border-2 border-border shadow-sm backdrop-blur-md;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
.neo-brutalist {
|
| 102 |
+
@apply border-2 border-border shadow-sm transition-all;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.text-stroke {
|
| 106 |
+
-webkit-text-stroke: 1px currentColor;
|
| 107 |
+
color: transparent;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
.custom-scrollbar::-webkit-scrollbar {
|
| 111 |
+
width: 6px;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.custom-scrollbar::-webkit-scrollbar-track {
|
| 115 |
+
background: transparent;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
.custom-scrollbar::-webkit-scrollbar-thumb {
|
| 119 |
+
background: hsla(var(--primary) / 0.3);
|
| 120 |
+
border-radius: 3px;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
|
| 124 |
+
background: hsla(var(--primary) / 0.6);
|
| 125 |
+
}
|
| 126 |
+
}
|
src/app/layout.tsx
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Metadata } from "next";
|
| 2 |
+
import "./globals.css";
|
| 3 |
+
import { ThemeProvider } from "@/components/theme-provider";
|
| 4 |
+
import { Navbar } from "@/components/navbar";
|
| 5 |
+
import { Geist, Geist_Mono } from "next/font/google";
|
| 6 |
+
|
| 7 |
+
const geistSans = Geist({
|
| 8 |
+
variable: "--font-geist-sans",
|
| 9 |
+
subsets: ["latin"],
|
| 10 |
+
});
|
| 11 |
+
|
| 12 |
+
const geistMono = Geist_Mono({
|
| 13 |
+
variable: "--font-geist-mono",
|
| 14 |
+
subsets: ["latin"],
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
export const metadata: Metadata = {
|
| 18 |
+
title: "Imyra - Generate Amazing Images",
|
| 19 |
+
description: "Create stunning AI art with Flux and Stable Diffusion models.",
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
export default function RootLayout({
|
| 23 |
+
children,
|
| 24 |
+
}: Readonly<{
|
| 25 |
+
children: React.ReactNode;
|
| 26 |
+
}>) {
|
| 27 |
+
return (
|
| 28 |
+
<html lang="en" suppressHydrationWarning>
|
| 29 |
+
<body
|
| 30 |
+
className={`${geistSans.variable} ${geistMono.variable} antialiased min-h-screen flex flex-col`}
|
| 31 |
+
>
|
| 32 |
+
<ThemeProvider
|
| 33 |
+
attribute="class"
|
| 34 |
+
defaultTheme="light"
|
| 35 |
+
enableSystem
|
| 36 |
+
disableTransitionOnChange
|
| 37 |
+
>
|
| 38 |
+
<Navbar />
|
| 39 |
+
<main className="flex-1">
|
| 40 |
+
{children}
|
| 41 |
+
</main>
|
| 42 |
+
</ThemeProvider>
|
| 43 |
+
</body>
|
| 44 |
+
</html>
|
| 45 |
+
);
|
| 46 |
+
}
|
src/app/page.tsx
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import Link from "next/link"
|
| 3 |
+
import { Button } from "@/components/ui/button"
|
| 4 |
+
import { Sparkles, Zap, Palette, Shield, ArrowRight, Star } from "lucide-react"
|
| 5 |
+
import { getPlatformStats, getFeaturedImages } from "@/lib/data"
|
| 6 |
+
import { GalleryMasonry } from "@/components/gallery-masonry"
|
| 7 |
+
|
| 8 |
+
export const dynamic = "force-dynamic"
|
| 9 |
+
|
| 10 |
+
export default async function Home() {
|
| 11 |
+
const stats = await getPlatformStats()
|
| 12 |
+
const featuredImages = await getFeaturedImages(6)
|
| 13 |
+
|
| 14 |
+
const features = [
|
| 15 |
+
{
|
| 16 |
+
icon: Zap,
|
| 17 |
+
title: "Lightning Fast",
|
| 18 |
+
description: "Generate high-quality images in seconds. Our distributed AI infrastructure delivers blazing-fast results globally.",
|
| 19 |
+
color: "text-amber-500",
|
| 20 |
+
highlight: "< 20s generation"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
icon: Palette,
|
| 24 |
+
title: "Open Source Models",
|
| 25 |
+
description: "Powered by the best OSS models—Flux, Stable Diffusion, Dreamshaper & more. Community-driven, constantly improving.",
|
| 26 |
+
color: "text-blue-500",
|
| 27 |
+
highlight: "10+ AI models"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
icon: Shield,
|
| 31 |
+
title: "100 Free Daily",
|
| 32 |
+
description: "No subscriptions, no hidden fees. Get 100 free credits every day to create up to 20 stunning images.",
|
| 33 |
+
color: "text-emerald-500",
|
| 34 |
+
highlight: "Forever free"
|
| 35 |
+
}
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
return (
|
| 39 |
+
<div className="flex flex-col min-h-screen font-sans">
|
| 40 |
+
{/* Animated Background */}
|
| 41 |
+
{/* Background - Clean Grid */}
|
| 42 |
+
<div className="fixed inset-0 -z-10 bg-background">
|
| 43 |
+
<div className="absolute inset-0 bg-[linear-gradient(rgba(0,0,0,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(0,0,0,0.02)_1px,transparent_1px)] dark:bg-[linear-gradient(rgba(255,255,255,0.02)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,0.02)_1px,transparent_1px)] bg-[size:64px_64px]" />
|
| 44 |
+
</div>
|
| 45 |
+
|
| 46 |
+
{/* Hero Section */}
|
| 47 |
+
<section className="relative pt-24 pb-16 lg:pt-32 lg:pb-24 overflow-hidden">
|
| 48 |
+
<div className="container px-4 md:px-6 relative z-10">
|
| 49 |
+
<div className="max-w-5xl mx-auto text-center space-y-8">
|
| 50 |
+
{/* Badge */}
|
| 51 |
+
<div className="inline-flex items-center gap-2 px-4 py-2 border-2 border-primary bg-primary/5 shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] animate-in fade-in slide-in-from-bottom-4 duration-700">
|
| 52 |
+
<Sparkles className="h-4 w-4 text-primary" />
|
| 53 |
+
<span className="text-sm font-black uppercase tracking-widest text-primary">
|
| 54 |
+
AI-Powered Art Generation
|
| 55 |
+
</span>
|
| 56 |
+
</div>
|
| 57 |
+
|
| 58 |
+
{/* Main Heading */}
|
| 59 |
+
<h1 className="text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-black tracking-tighter leading-[1.1] animate-in fade-in slide-in-from-bottom-6 duration-700 delay-100 uppercase">
|
| 60 |
+
Transform Ideas Into
|
| 61 |
+
<br />
|
| 62 |
+
<span className="text-primary text-stroke-primary">
|
| 63 |
+
Stunning Visuals
|
| 64 |
+
</span>
|
| 65 |
+
</h1>
|
| 66 |
+
|
| 67 |
+
{/* Subtitle */}
|
| 68 |
+
<p className="mx-auto max-w-2xl text-lg md:text-xl text-muted-foreground font-medium leading-relaxed animate-in fade-in slide-in-from-bottom-8 duration-700 delay-200">
|
| 69 |
+
Create professional-quality AI art in seconds. Powered by Flux, Stable Diffusion, and cutting-edge models through our global edge network.
|
| 70 |
+
</p>
|
| 71 |
+
|
| 72 |
+
{/* CTA Buttons */}
|
| 73 |
+
<div className="flex flex-col sm:flex-row gap-4 justify-center items-center pt-4 animate-in fade-in slide-in-from-bottom-8 duration-700 delay-300">
|
| 74 |
+
<Button
|
| 75 |
+
size="lg"
|
| 76 |
+
className="h-14 px-8 text-lg bg-primary hover:bg-primary/90 text-white font-black uppercase tracking-wider rounded-none border-2 border-primary shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all group"
|
| 77 |
+
asChild
|
| 78 |
+
>
|
| 79 |
+
<Link href="/create" className="flex items-center gap-2">
|
| 80 |
+
Start Creating Free
|
| 81 |
+
<ArrowRight className="h-5 w-5 group-hover:translate-x-1 transition-transform" />
|
| 82 |
+
</Link>
|
| 83 |
+
</Button>
|
| 84 |
+
<Button
|
| 85 |
+
size="lg"
|
| 86 |
+
variant="outline"
|
| 87 |
+
className="h-14 px-8 text-lg bg-background hover:bg-accent hover:text-accent-foreground font-black uppercase tracking-wider rounded-none border-2 border-border shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 88 |
+
asChild
|
| 89 |
+
>
|
| 90 |
+
<Link href="/gallery">View Gallery</Link>
|
| 91 |
+
</Button>
|
| 92 |
+
</div>
|
| 93 |
+
|
| 94 |
+
{/* Social Proof with Real Numbers */}
|
| 95 |
+
<div className="flex flex-wrap items-center justify-center gap-6 pt-12 text-sm text-foreground animate-in fade-in duration-1000 delay-500">
|
| 96 |
+
<div className="flex items-center gap-2 px-4 py-2 border-2 border-border bg-card shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 97 |
+
<div className="flex -space-x-2">
|
| 98 |
+
{[...Array(4)].map((_, i) => (
|
| 99 |
+
<div key={i} className="h-8 w-8 rounded-full bg-primary border-2 border-background flex items-center justify-center text-xs font-bold text-white">
|
| 100 |
+
{String.fromCharCode(65 + i)}
|
| 101 |
+
</div>
|
| 102 |
+
))}
|
| 103 |
+
</div>
|
| 104 |
+
<span className="font-bold uppercase tracking-tight">{stats.totalArtists}+ Artists</span>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
<div className="flex items-center gap-2 px-4 py-2 border-2 border-border bg-card shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 108 |
+
<div className="flex items-center gap-1">
|
| 109 |
+
{[...Array(5)].map((_, i) => (
|
| 110 |
+
<Star key={i} className="h-4 w-4 fill-primary text-primary" />
|
| 111 |
+
))}
|
| 112 |
+
</div>
|
| 113 |
+
<span className="font-bold uppercase tracking-tight">{stats.averageRating}/5 Rating</span>
|
| 114 |
+
</div>
|
| 115 |
+
|
| 116 |
+
<div className="flex items-center gap-2 px-4 py-2 border-2 border-border bg-card shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)]">
|
| 117 |
+
<Zap className="h-4 w-4 text-primary" />
|
| 118 |
+
<span className="font-bold uppercase tracking-tight">{stats.totalImages}+ Images Created</span>
|
| 119 |
+
</div>
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</section>
|
| 124 |
+
|
| 125 |
+
{/* Featured Creations */}
|
| 126 |
+
<section className="py-16 lg:py-24 border-t-2 border-border bg-background">
|
| 127 |
+
<div className="container px-4 md:px-6">
|
| 128 |
+
<div className="text-center mb-12">
|
| 129 |
+
<h2 className="text-3xl md:text-5xl font-black tracking-tighter mb-4 uppercase">
|
| 130 |
+
Featured <span className="text-primary underline decoration-4 decoration-primary underline-offset-4">Creations</span>
|
| 131 |
+
</h2>
|
| 132 |
+
<p className="text-muted-foreground max-w-2xl mx-auto font-medium text-lg">
|
| 133 |
+
Check out what our community is creating right now.
|
| 134 |
+
</p>
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
<GalleryMasonry
|
| 138 |
+
generations={featuredImages}
|
| 139 |
+
className="columns-1 sm:columns-2 lg:columns-3 gap-6 space-y-6"
|
| 140 |
+
enableInfiniteScroll={false}
|
| 141 |
+
/>
|
| 142 |
+
|
| 143 |
+
<div className="flex justify-center mt-12">
|
| 144 |
+
<Button
|
| 145 |
+
variant="outline"
|
| 146 |
+
className="h-12 px-8 text-base bg-background hover:bg-accent hover:text-accent-foreground font-black uppercase tracking-wider rounded-none border-2 border-border shadow-[4px_4px_0px_0px_rgba(0,0,0,1)] dark:shadow-[4px_4px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 147 |
+
asChild
|
| 148 |
+
>
|
| 149 |
+
<Link href="/gallery">Explore Full Gallery</Link>
|
| 150 |
+
</Button>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
</section>
|
| 154 |
+
|
| 155 |
+
{/* Features Section */}
|
| 156 |
+
<section className="py-16 lg:py-24 border-t-2 border-border bg-muted/20">
|
| 157 |
+
<div className="container px-4 md:px-6">
|
| 158 |
+
<div className="text-center mb-12">
|
| 159 |
+
<h2 className="text-3xl md:text-5xl font-black tracking-tighter mb-4 uppercase">
|
| 160 |
+
Why Choose <span className="text-primary underline decoration-4 decoration-primary underline-offset-4">Imyra</span>?
|
| 161 |
+
</h2>
|
| 162 |
+
<p className="text-muted-foreground max-w-2xl mx-auto font-medium text-lg">
|
| 163 |
+
Built for creators who demand speed, quality, and freedom.
|
| 164 |
+
</p>
|
| 165 |
+
</div>
|
| 166 |
+
<div className="grid md:grid-cols-3 gap-8 lg:gap-12">
|
| 167 |
+
{features.map((feature, index) => (
|
| 168 |
+
<div
|
| 169 |
+
key={index}
|
| 170 |
+
className="group relative p-8 rounded-none border-2 border-border bg-card hover:border-primary transition-all duration-300 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-x-[2px] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)]"
|
| 171 |
+
>
|
| 172 |
+
{/* Highlight Badge */}
|
| 173 |
+
<div className="absolute top-0 right-0 p-3">
|
| 174 |
+
<span className="px-3 py-1 text-xs font-black border-2 border-border bg-white dark:bg-black uppercase tracking-wider">
|
| 175 |
+
{feature.highlight}
|
| 176 |
+
</span>
|
| 177 |
+
</div>
|
| 178 |
+
|
| 179 |
+
<div className="mb-4">
|
| 180 |
+
<feature.icon className={`h-8 w-8 ${feature.color}`} />
|
| 181 |
+
</div>
|
| 182 |
+
<h3 className="text-xl font-black mb-3 tracking-tight uppercase">{feature.title}</h3>
|
| 183 |
+
<p className="text-muted-foreground leading-relaxed font-medium">{feature.description}</p>
|
| 184 |
+
</div>
|
| 185 |
+
))}
|
| 186 |
+
</div>
|
| 187 |
+
</div>
|
| 188 |
+
</section>
|
| 189 |
+
|
| 190 |
+
{/* CTA Section */}
|
| 191 |
+
<section className="py-16 lg:py-24 border-t-2 border-border">
|
| 192 |
+
<div className="container px-4 md:px-6">
|
| 193 |
+
<div className="relative overflow-hidden border-2 border-border bg-primary/5 p-8 md:p-10 lg:p-12 shadow-[8px_8px_0px_0px_rgba(0,0,0,1)] dark:shadow-[8px_8px_0px_0px_rgba(255,255,255,1)]">
|
| 194 |
+
|
| 195 |
+
<div className="relative z-10 text-center max-w-3xl mx-auto space-y-8">
|
| 196 |
+
<h1 className="text-4xl md:text-5xl lg:text-5xl font-black tracking-tighter uppercase mb-6">
|
| 197 |
+
Create Stunning<br />
|
| 198 |
+
<span className="text-primary text-stroke-primary">
|
| 199 |
+
AI Art in Seconds
|
| 200 |
+
</span>
|
| 201 |
+
</h1>
|
| 202 |
+
<p className="text-xl text-muted-foreground font-medium">
|
| 203 |
+
Join thousands of artists using Imyra. Get 100 free credits daily—no credit card required.
|
| 204 |
+
</p>
|
| 205 |
+
<Button
|
| 206 |
+
size="lg"
|
| 207 |
+
className="h-16 px-12 text-xl bg-primary hover:bg-primary/90 text-white font-black uppercase tracking-wider rounded-none border-2 border-primary shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] dark:shadow-[6px_6px_0px_0px_rgba(255,255,255,1)] hover:translate-y-[2px] hover:shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:hover:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)] transition-all"
|
| 208 |
+
asChild
|
| 209 |
+
>
|
| 210 |
+
<Link href="/signup">Get Started Free</Link>
|
| 211 |
+
</Button>
|
| 212 |
+
</div>
|
| 213 |
+
</div>
|
| 214 |
+
</div>
|
| 215 |
+
</section>
|
| 216 |
+
|
| 217 |
+
{/* Footer */}
|
| 218 |
+
<footer className="border-t-2 border-border py-12 bg-muted/20">
|
| 219 |
+
<div className="container px-4 md:px-6">
|
| 220 |
+
<div className="flex flex-col md:flex-row justify-between items-center gap-6">
|
| 221 |
+
<div className="flex items-center gap-2">
|
| 222 |
+
<div className="p-2 border-2 border-border bg-primary text-white shadow-[2px_2px_0px_0px_rgba(0,0,0,1)] dark:shadow-[2px_2px_0px_0px_rgba(255,255,255,1)]">
|
| 223 |
+
<Sparkles className="h-6 w-6" />
|
| 224 |
+
</div>
|
| 225 |
+
<span className="font-black text-xl uppercase tracking-tight">Imyra</span>
|
| 226 |
+
</div>
|
| 227 |
+
|
| 228 |
+
<nav className="flex gap-8 text-sm font-bold uppercase tracking-wider">
|
| 229 |
+
<Link href="/" className="hover:text-primary transition-colors hover:underline decoration-2 underline-offset-4">Home</Link>
|
| 230 |
+
<Link href="/gallery" className="hover:text-primary transition-colors hover:underline decoration-2 underline-offset-4">Gallery</Link>
|
| 231 |
+
<Link href="/create" className="hover:text-primary transition-colors hover:underline decoration-2 underline-offset-4">Create</Link>
|
| 232 |
+
<Link href="/about" className="hover:text-primary transition-colors hover:underline decoration-2 underline-offset-4">About</Link>
|
| 233 |
+
</nav>
|
| 234 |
+
|
| 235 |
+
<p className="text-sm font-bold text-muted-foreground">
|
| 236 |
+
© {new Date().getFullYear()} Imyra.
|
| 237 |
+
</p>
|
| 238 |
+
</div>
|
| 239 |
+
</div>
|
| 240 |
+
</footer>
|
| 241 |
+
</div>
|
| 242 |
+
)
|
| 243 |
+
}
|
src/auth.config.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { NextAuthConfig } from "next-auth"
|
| 2 |
+
|
| 3 |
+
export const authConfig = {
|
| 4 |
+
trustHost: true,
|
| 5 |
+
pages: {
|
| 6 |
+
signIn: "/login",
|
| 7 |
+
},
|
| 8 |
+
callbacks: {
|
| 9 |
+
authorized({ auth, request: { nextUrl } }) {
|
| 10 |
+
const isLoggedIn = !!auth?.user
|
| 11 |
+
const isDashboard = nextUrl.pathname.startsWith("/create") ||
|
| 12 |
+
nextUrl.pathname.startsWith("/history") ||
|
| 13 |
+
nextUrl.pathname.startsWith("/profile")
|
| 14 |
+
|
| 15 |
+
const isAuthPage = nextUrl.pathname.startsWith("/login") ||
|
| 16 |
+
nextUrl.pathname.startsWith("/signup")
|
| 17 |
+
|
| 18 |
+
if (isDashboard) {
|
| 19 |
+
if (isLoggedIn) return true
|
| 20 |
+
return false // Redirect unauthenticated users to login page
|
| 21 |
+
} else if (isAuthPage && isLoggedIn) {
|
| 22 |
+
return Response.redirect(new URL("/create", nextUrl))
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
return true
|
| 26 |
+
},
|
| 27 |
+
async jwt({ token, user }) {
|
| 28 |
+
if (user) {
|
| 29 |
+
token.id = user.id
|
| 30 |
+
}
|
| 31 |
+
return token
|
| 32 |
+
},
|
| 33 |
+
async session({ session, token }) {
|
| 34 |
+
if (token && session.user) {
|
| 35 |
+
session.user.id = token.id as string
|
| 36 |
+
}
|
| 37 |
+
return session
|
| 38 |
+
},
|
| 39 |
+
},
|
| 40 |
+
providers: [], // Configured in auth.ts
|
| 41 |
+
} satisfies NextAuthConfig
|
src/auth.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import NextAuth from "next-auth"
|
| 2 |
+
import Credentials from "next-auth/providers/credentials"
|
| 3 |
+
import Google from "next-auth/providers/google"
|
| 4 |
+
import { PrismaAdapter } from "@auth/prisma-adapter"
|
| 5 |
+
import { prisma } from "@/lib/prisma"
|
| 6 |
+
import bcrypt from "bcryptjs"
|
| 7 |
+
import { z } from "zod"
|
| 8 |
+
import { authConfig } from "./auth.config"
|
| 9 |
+
|
| 10 |
+
export const { handlers, auth, signIn, signOut } = NextAuth({
|
| 11 |
+
...authConfig,
|
| 12 |
+
adapter: PrismaAdapter(prisma),
|
| 13 |
+
session: { strategy: "jwt" },
|
| 14 |
+
trustHost: true,
|
| 15 |
+
pages: {
|
| 16 |
+
signIn: "/login",
|
| 17 |
+
},
|
| 18 |
+
callbacks: {
|
| 19 |
+
async jwt({ token, user }) {
|
| 20 |
+
if (user) {
|
| 21 |
+
token.id = user.id
|
| 22 |
+
token.email = user.email
|
| 23 |
+
token.name = user.name
|
| 24 |
+
token.picture = user.image
|
| 25 |
+
token.username = (user as any).username
|
| 26 |
+
}
|
| 27 |
+
return token
|
| 28 |
+
},
|
| 29 |
+
async session({ session, token }) {
|
| 30 |
+
if (token && session.user) {
|
| 31 |
+
session.user.id = token.id as string
|
| 32 |
+
session.user.email = token.email as string
|
| 33 |
+
session.user.name = token.name
|
| 34 |
+
session.user.image = token.picture as string | null | undefined
|
| 35 |
+
if (token.username) {
|
| 36 |
+
(session.user as any).username = token.username as string
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
return session
|
| 40 |
+
}
|
| 41 |
+
},
|
| 42 |
+
providers: [
|
| 43 |
+
Credentials({
|
| 44 |
+
name: "Credentials",
|
| 45 |
+
credentials: {
|
| 46 |
+
email: { label: "Email", type: "email" },
|
| 47 |
+
password: { label: "Password", type: "password" },
|
| 48 |
+
},
|
| 49 |
+
authorize: async (credentials) => {
|
| 50 |
+
try {
|
| 51 |
+
const { email, password } = await z
|
| 52 |
+
.object({ email: z.string().email(), password: z.string().min(6) })
|
| 53 |
+
.parseAsync(credentials)
|
| 54 |
+
|
| 55 |
+
const user = await prisma.user.findUnique({
|
| 56 |
+
where: { email },
|
| 57 |
+
})
|
| 58 |
+
|
| 59 |
+
if (!user) {
|
| 60 |
+
return null
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// If user has no password (e.g. signed up via Google), they can't login with credentials unless they set one.
|
| 64 |
+
// But here we just return null if password doesn't match or doesn't exist.
|
| 65 |
+
if (!user.password) {
|
| 66 |
+
return null
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
const passwordsMatch = await bcrypt.compare(password, user.password)
|
| 70 |
+
|
| 71 |
+
if (!passwordsMatch) {
|
| 72 |
+
return null
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
return user
|
| 76 |
+
} catch (error) {
|
| 77 |
+
console.error("Auth error:", error)
|
| 78 |
+
return null
|
| 79 |
+
}
|
| 80 |
+
},
|
| 81 |
+
}),
|
| 82 |
+
Google({
|
| 83 |
+
clientId: process.env.GOOGLE_CLIENT_ID,
|
| 84 |
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
| 85 |
+
allowDangerousEmailAccountLinking: true,
|
| 86 |
+
}),
|
| 87 |
+
],
|
| 88 |
+
})
|
src/components/edit-profile-dialog.tsx
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState } from "react"
|
| 4 |
+
import { useRouter } from "next/navigation"
|
| 5 |
+
import { Button } from "@/components/ui/button"
|
| 6 |
+
import {
|
| 7 |
+
Dialog,
|
| 8 |
+
DialogContent,
|
| 9 |
+
DialogDescription,
|
| 10 |
+
DialogFooter,
|
| 11 |
+
DialogHeader,
|
| 12 |
+
DialogTitle,
|
| 13 |
+
DialogTrigger,
|
| 14 |
+
} from "@/components/ui/dialog"
|
| 15 |
+
import { Input } from "@/components/ui/input"
|
| 16 |
+
import { Label } from "@/components/ui/label"
|
| 17 |
+
import { useForm } from "react-hook-form"
|
| 18 |
+
import { zodResolver } from "@hookform/resolvers/zod"
|
| 19 |
+
import { z } from "zod"
|
| 20 |
+
import { AlertTriangle, Loader2 } from "lucide-react"
|
| 21 |
+
|
| 22 |
+
const profileSchema = z.object({
|
| 23 |
+
name: z.string().min(2, "Name must be at least 2 characters"),
|
| 24 |
+
username: z.string().min(3, "Username must be at least 3 characters").regex(/^[a-zA-Z0-9_]+$/, "Username must be alphanumeric"),
|
| 25 |
+
})
|
| 26 |
+
|
| 27 |
+
type ProfileFormValues = z.infer<typeof profileSchema>
|
| 28 |
+
|
| 29 |
+
interface EditProfileDialogProps {
|
| 30 |
+
user: {
|
| 31 |
+
name?: string | null
|
| 32 |
+
username?: string | null
|
| 33 |
+
email?: string | null
|
| 34 |
+
}
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
export function EditProfileDialog({ user }: EditProfileDialogProps) {
|
| 38 |
+
const router = useRouter()
|
| 39 |
+
const [open, setOpen] = useState(false)
|
| 40 |
+
const [isLoading, setIsLoading] = useState(false)
|
| 41 |
+
const [isDeleting, setIsDeleting] = useState(false)
|
| 42 |
+
|
| 43 |
+
const form = useForm<ProfileFormValues>({
|
| 44 |
+
resolver: zodResolver(profileSchema),
|
| 45 |
+
defaultValues: {
|
| 46 |
+
name: user.name || "",
|
| 47 |
+
username: user.username || "",
|
| 48 |
+
},
|
| 49 |
+
})
|
| 50 |
+
|
| 51 |
+
const onSubmit = async (data: ProfileFormValues) => {
|
| 52 |
+
setIsLoading(true)
|
| 53 |
+
try {
|
| 54 |
+
const res = await fetch("/api/user", {
|
| 55 |
+
method: "PUT",
|
| 56 |
+
headers: { "Content-Type": "application/json" },
|
| 57 |
+
body: JSON.stringify(data),
|
| 58 |
+
})
|
| 59 |
+
|
| 60 |
+
if (!res.ok) {
|
| 61 |
+
const error = await res.text()
|
| 62 |
+
// You might want to use a toast here
|
| 63 |
+
alert(error)
|
| 64 |
+
return
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
setOpen(false)
|
| 68 |
+
router.refresh()
|
| 69 |
+
} catch (error) {
|
| 70 |
+
console.error(error)
|
| 71 |
+
} finally {
|
| 72 |
+
setIsLoading(false)
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
const handleDeleteAccount = async () => {
|
| 77 |
+
if (!confirm("Are you ABSOLUTELY sure? This will permanently delete your account and all generated images. This action cannot be undone.")) {
|
| 78 |
+
return
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
setIsDeleting(true)
|
| 82 |
+
try {
|
| 83 |
+
const res = await fetch("/api/user", {
|
| 84 |
+
method: "DELETE",
|
| 85 |
+
})
|
| 86 |
+
|
| 87 |
+
if (!res.ok) throw new Error("Failed to delete account")
|
| 88 |
+
|
| 89 |
+
// Redirect to home/login after deletion
|
| 90 |
+
window.location.href = "/"
|
| 91 |
+
} catch (error) {
|
| 92 |
+
console.error(error)
|
| 93 |
+
alert("Failed to delete account. Please try again.")
|
| 94 |
+
setIsDeleting(false)
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
return (
|
| 99 |
+
<Dialog open={open} onOpenChange={setOpen}>
|
| 100 |
+
<DialogTrigger asChild>
|
| 101 |
+
<Button variant="outline">Edit Profile</Button>
|
| 102 |
+
</DialogTrigger>
|
| 103 |
+
<DialogContent className="sm:max-w-[425px] glass-panel border-2">
|
| 104 |
+
<DialogHeader>
|
| 105 |
+
<DialogTitle>Edit Profile</DialogTitle>
|
| 106 |
+
<DialogDescription>
|
| 107 |
+
Make changes to your profile here. Click save when you're done.
|
| 108 |
+
</DialogDescription>
|
| 109 |
+
</DialogHeader>
|
| 110 |
+
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6 py-4">
|
| 111 |
+
<div className="grid gap-2">
|
| 112 |
+
<Label htmlFor="name">Name</Label>
|
| 113 |
+
<Input
|
| 114 |
+
id="name"
|
| 115 |
+
{...form.register("name")}
|
| 116 |
+
className="neo-brutalist"
|
| 117 |
+
/>
|
| 118 |
+
{form.formState.errors.name && (
|
| 119 |
+
<p className="text-xs text-destructive">{form.formState.errors.name.message}</p>
|
| 120 |
+
)}
|
| 121 |
+
</div>
|
| 122 |
+
<div className="grid gap-2">
|
| 123 |
+
<Label htmlFor="username">Username</Label>
|
| 124 |
+
<Input
|
| 125 |
+
id="username"
|
| 126 |
+
{...form.register("username")}
|
| 127 |
+
className="neo-brutalist"
|
| 128 |
+
/>
|
| 129 |
+
{form.formState.errors.username && (
|
| 130 |
+
<p className="text-xs text-destructive">{form.formState.errors.username.message}</p>
|
| 131 |
+
)}
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<DialogFooter>
|
| 135 |
+
<Button type="submit" disabled={isLoading} className="neo-brutalist">
|
| 136 |
+
{isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
| 137 |
+
Save changes
|
| 138 |
+
</Button>
|
| 139 |
+
</DialogFooter>
|
| 140 |
+
</form>
|
| 141 |
+
|
| 142 |
+
<div className="border-t border-destructive/20 pt-4 mt-2">
|
| 143 |
+
<h4 className="text-sm font-bold text-destructive mb-2 flex items-center">
|
| 144 |
+
<AlertTriangle className="h-4 w-4 mr-2" />
|
| 145 |
+
Danger Zone
|
| 146 |
+
</h4>
|
| 147 |
+
<p className="text-xs text-muted-foreground mb-4">
|
| 148 |
+
Permanently delete your account and all associated data.
|
| 149 |
+
</p>
|
| 150 |
+
<Button
|
| 151 |
+
variant="destructive"
|
| 152 |
+
size="sm"
|
| 153 |
+
className="w-full neo-brutalist"
|
| 154 |
+
onClick={handleDeleteAccount}
|
| 155 |
+
disabled={isDeleting}
|
| 156 |
+
>
|
| 157 |
+
{isDeleting ? "Deleting..." : "Delete Account"}
|
| 158 |
+
</Button>
|
| 159 |
+
</div>
|
| 160 |
+
</DialogContent>
|
| 161 |
+
</Dialog>
|
| 162 |
+
)
|
| 163 |
+
}
|
src/components/gallery-grid.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState } from "react"
|
| 4 |
+
import Link from "next/link"
|
| 5 |
+
import Image from "next/image"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
import { GalleryModal } from "@/components/gallery-modal"
|
| 8 |
+
import { Search } from "lucide-react"
|
| 9 |
+
|
| 10 |
+
interface GalleryGridProps {
|
| 11 |
+
generations: any[]
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
export function GalleryGrid({ generations }: GalleryGridProps) {
|
| 15 |
+
const [selectedGen, setSelectedGen] = useState<any | null>(null)
|
| 16 |
+
|
| 17 |
+
return (
|
| 18 |
+
<>
|
| 19 |
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8">
|
| 20 |
+
{generations.map((gen) => (
|
| 21 |
+
<div
|
| 22 |
+
key={gen.id}
|
| 23 |
+
className="group relative neo-brutalist bg-card rounded-none overflow-hidden aspect-square border-2 border-border cursor-pointer"
|
| 24 |
+
onClick={() => setSelectedGen(gen)}
|
| 25 |
+
>
|
| 26 |
+
{/* Username Overlay - Always Visible */}
|
| 27 |
+
<div className="absolute top-3 left-3 z-10">
|
| 28 |
+
<div className="bg-black/70 backdrop-blur-md text-white px-3 py-1 text-xs font-bold uppercase tracking-wider rounded-full border border-white/20 flex items-center gap-2 shadow-lg">
|
| 29 |
+
<div className="h-2 w-2 rounded-full bg-green-500 animate-pulse" />
|
| 30 |
+
@{gen.user.username || "user"}
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
|
| 34 |
+
<Image
|
| 35 |
+
src={gen.imageUrl} // Direct URL
|
| 36 |
+
alt={gen.prompt}
|
| 37 |
+
fill
|
| 38 |
+
className="object-cover transition-transform duration-700 group-hover:scale-110 group-hover:rotate-1"
|
| 39 |
+
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
| 40 |
+
unoptimized
|
| 41 |
+
/>
|
| 42 |
+
|
| 43 |
+
{/* Hover Overlay */}
|
| 44 |
+
<div className="absolute inset-0 bg-background/80 backdrop-blur-sm opacity-0 group-hover:opacity-100 transition-all duration-300 flex flex-col justify-center items-center p-6 text-center border-2 border-transparent group-hover:border-primary/50 m-2">
|
| 45 |
+
<Search className="h-8 w-8 text-primary mb-4" />
|
| 46 |
+
<p className="font-bold line-clamp-3 text-foreground leading-tight">"{gen.prompt}"</p>
|
| 47 |
+
<p className="text-xs font-bold uppercase tracking-widest text-muted-foreground mt-4">Click to view details</p>
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
))}
|
| 51 |
+
</div>
|
| 52 |
+
|
| 53 |
+
{generations.length === 0 && (
|
| 54 |
+
<div className="glass-panel p-12 rounded-none border-2 border-dashed border-border text-center">
|
| 55 |
+
<p className="text-xl font-bold text-muted-foreground uppercase tracking-widest">No Masterpieces Yet</p>
|
| 56 |
+
<div className="mt-6">
|
| 57 |
+
<Button className="neo-brutalist" asChild><Link href="/create">Be The First</Link></Button>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
)}
|
| 61 |
+
|
| 62 |
+
<GalleryModal
|
| 63 |
+
isOpen={!!selectedGen}
|
| 64 |
+
onClose={() => setSelectedGen(null)}
|
| 65 |
+
generation={selectedGen}
|
| 66 |
+
/>
|
| 67 |
+
</>
|
| 68 |
+
)
|
| 69 |
+
}
|
src/components/gallery-masonry.tsx
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState } from "react"
|
| 4 |
+
import Link from "next/link"
|
| 5 |
+
import Image from "next/image"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
import { GalleryModal } from "@/components/gallery-modal"
|
| 8 |
+
import { Search } from "lucide-react"
|
| 9 |
+
|
| 10 |
+
interface GalleryMasonryProps {
|
| 11 |
+
generations: any[]
|
| 12 |
+
className?: string
|
| 13 |
+
enableInfiniteScroll?: boolean
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export function GalleryMasonry({ generations, className, enableInfiniteScroll = true }: GalleryMasonryProps) {
|
| 17 |
+
const [selectedGen, setSelectedGen] = useState<any | null>(null)
|
| 18 |
+
const [displayGenerations, setDisplayGenerations] = useState<any[]>(generations)
|
| 19 |
+
const [cursor, setCursor] = useState<string | null>(generations.length > 0 ? generations[generations.length - 1].id : null)
|
| 20 |
+
const [isLoading, setIsLoading] = useState(false)
|
| 21 |
+
const [hasMore, setHasMore] = useState(enableInfiniteScroll)
|
| 22 |
+
|
| 23 |
+
const loadMore = async () => {
|
| 24 |
+
if (!enableInfiniteScroll || !cursor || isLoading || !hasMore) return
|
| 25 |
+
|
| 26 |
+
setIsLoading(true)
|
| 27 |
+
try {
|
| 28 |
+
const res = await fetch(`/api/gallery?cursor=${cursor}&limit=20`)
|
| 29 |
+
if (!res.ok) throw new Error("Failed to fetch")
|
| 30 |
+
|
| 31 |
+
const data = await res.json()
|
| 32 |
+
|
| 33 |
+
if (data.data.length === 0) {
|
| 34 |
+
setHasMore(false)
|
| 35 |
+
} else {
|
| 36 |
+
setDisplayGenerations(prev => [...prev, ...data.data])
|
| 37 |
+
setCursor(data.nextCursor)
|
| 38 |
+
if (!data.nextCursor) setHasMore(false)
|
| 39 |
+
}
|
| 40 |
+
} catch (error) {
|
| 41 |
+
console.error("Error loading more:", error)
|
| 42 |
+
} finally {
|
| 43 |
+
setIsLoading(false)
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
return (
|
| 48 |
+
<>
|
| 49 |
+
{/* Masonry Layout using Columns */}
|
| 50 |
+
<div className={className || "columns-1 sm:columns-2 lg:columns-3 xl:columns-4 gap-4 space-y-4"}>
|
| 51 |
+
{displayGenerations.map((gen) => (
|
| 52 |
+
<div
|
| 53 |
+
key={gen.id}
|
| 54 |
+
className="break-inside-avoid group relative neo-brutalist bg-card rounded-none overflow-hidden border-2 border-border cursor-pointer mb-4"
|
| 55 |
+
onClick={() => setSelectedGen(gen)}
|
| 56 |
+
>
|
| 57 |
+
{/* Username Overlay */}
|
| 58 |
+
<div className="absolute top-3 left-3 z-20 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
|
| 59 |
+
<div className="bg-black/70 backdrop-blur-md text-white px-3 py-1 text-xs font-bold uppercase tracking-wider rounded-full border border-white/20 flex items-center gap-2 shadow-lg">
|
| 60 |
+
<div className="h-2 w-2 rounded-full bg-green-500 animate-pulse" />
|
| 61 |
+
@{gen.user?.username || "user"}
|
| 62 |
+
</div>
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
<div className="relative w-full">
|
| 66 |
+
<Image
|
| 67 |
+
src={gen.imageUrl}
|
| 68 |
+
alt={gen.prompt}
|
| 69 |
+
width={gen.width || 1024}
|
| 70 |
+
height={gen.height || 1024}
|
| 71 |
+
className="w-full h-auto object-cover transition-transform duration-700 group-hover:scale-105"
|
| 72 |
+
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
|
| 73 |
+
unoptimized
|
| 74 |
+
/>
|
| 75 |
+
|
| 76 |
+
{/* Hover Overlay */}
|
| 77 |
+
<div className="absolute inset-0 bg-background/20 backdrop-blur-[2px] opacity-0 group-hover:opacity-100 transition-all duration-300 flex flex-col justify-end p-4 border-2 border-transparent group-hover:border-primary/50">
|
| 78 |
+
<div className="bg-background/90 p-3 border-2 border-border neo-brutalist transform translate-y-4 group-hover:translate-y-0 transition-transform duration-300">
|
| 79 |
+
<p className="font-bold line-clamp-2 text-xs md:text-sm text-foreground leading-tight">
|
| 80 |
+
"{gen.prompt}"
|
| 81 |
+
</p>
|
| 82 |
+
</div>
|
| 83 |
+
</div>
|
| 84 |
+
</div>
|
| 85 |
+
</div>
|
| 86 |
+
))}
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
{/* Loading / End of List Indicators */}
|
| 90 |
+
<div className="py-8 flex justify-center w-full">
|
| 91 |
+
{isLoading && (
|
| 92 |
+
<div className="flex items-center gap-2 text-primary font-bold uppercase tracking-widest animate-pulse">
|
| 93 |
+
<div className="h-2 w-2 bg-primary rounded-full animate-bounce" style={{ animationDelay: "0ms" }} />
|
| 94 |
+
<div className="h-2 w-2 bg-primary rounded-full animate-bounce" style={{ animationDelay: "150ms" }} />
|
| 95 |
+
<div className="h-2 w-2 bg-primary rounded-full animate-bounce" style={{ animationDelay: "300ms" }} />
|
| 96 |
+
Loading More...
|
| 97 |
+
</div>
|
| 98 |
+
)}
|
| 99 |
+
|
| 100 |
+
{!isLoading && hasMore && (
|
| 101 |
+
<button
|
| 102 |
+
onClick={loadMore}
|
| 103 |
+
className="text-sm text-muted-foreground hover:text-primary uppercase tracking-widest font-bold border-b-2 border-transparent hover:border-primary transition-colors"
|
| 104 |
+
>
|
| 105 |
+
Load More Art
|
| 106 |
+
</button>
|
| 107 |
+
)}
|
| 108 |
+
|
| 109 |
+
{!hasMore && displayGenerations.length > 0 && (
|
| 110 |
+
<p className="text-muted-foreground text-sm font-bold uppercase tracking-widest">
|
| 111 |
+
You've reached the end
|
| 112 |
+
</p>
|
| 113 |
+
)}
|
| 114 |
+
</div>
|
| 115 |
+
|
| 116 |
+
{/* Intersection Element for auto-loading */}
|
| 117 |
+
{hasMore && !isLoading && (
|
| 118 |
+
<div ref={(node) => {
|
| 119 |
+
if (node) {
|
| 120 |
+
const observer = new IntersectionObserver(
|
| 121 |
+
(entries) => {
|
| 122 |
+
if (entries[0].isIntersecting) {
|
| 123 |
+
loadMore();
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
{ threshold: 0.1, rootMargin: "200px" }
|
| 127 |
+
);
|
| 128 |
+
observer.observe(node);
|
| 129 |
+
// Cleanup happens automatically when node unmounts usually, but for strictness we rely on React lifecycle if we used useEffect.
|
| 130 |
+
// Since this is a ref callback, it's slightly different. A useEffect is safer.
|
| 131 |
+
}
|
| 132 |
+
}} className="h-4 w-full" />
|
| 133 |
+
)}
|
| 134 |
+
|
| 135 |
+
{generations.length === 0 && (
|
| 136 |
+
<div className="glass-panel p-12 rounded-none border-2 border-dashed border-border text-center">
|
| 137 |
+
<p className="text-xl font-bold text-muted-foreground uppercase tracking-widest">No Masterpieces Yet</p>
|
| 138 |
+
<div className="mt-6">
|
| 139 |
+
<Button className="neo-brutalist" asChild><Link href="/create">Be The First</Link></Button>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
)}
|
| 143 |
+
|
| 144 |
+
<GalleryModal
|
| 145 |
+
isOpen={!!selectedGen}
|
| 146 |
+
onClose={() => setSelectedGen(null)}
|
| 147 |
+
generation={selectedGen}
|
| 148 |
+
/>
|
| 149 |
+
</>
|
| 150 |
+
)
|
| 151 |
+
}
|
src/components/gallery-modal.tsx
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"
|
| 4 |
+
import { VisuallyHidden } from "@radix-ui/react-visually-hidden"
|
| 5 |
+
import Image from "next/image"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
import { Download, Info, X, User, Calendar, Cpu } from "lucide-react"
|
| 8 |
+
import { ShareMenu } from "@/components/share-menu"
|
| 9 |
+
|
| 10 |
+
interface GalleryModalProps {
|
| 11 |
+
isOpen: boolean
|
| 12 |
+
onClose: () => void
|
| 13 |
+
generation: any
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
export function GalleryModal({ isOpen, onClose, generation }: GalleryModalProps) {
|
| 17 |
+
if (!generation) return null
|
| 18 |
+
|
| 19 |
+
const imageUrl = generation.imageUrl
|
| 20 |
+
|
| 21 |
+
return (
|
| 22 |
+
<Dialog open={isOpen} onOpenChange={onClose}>
|
| 23 |
+
<DialogContent className="max-w-6xl w-[95vw] p-0 overflow-hidden bg-background/98 backdrop-blur-xl border-2 border-border neo-brutalist gap-0 max-h-[95vh] flex flex-col">
|
| 24 |
+
<VisuallyHidden>
|
| 25 |
+
<DialogTitle>Artwork Details</DialogTitle>
|
| 26 |
+
</VisuallyHidden>
|
| 27 |
+
|
| 28 |
+
{/* Close Button */}
|
| 29 |
+
<Button
|
| 30 |
+
className="absolute top-3 right-3 z-50 rounded-full h-10 w-10 bg-background/80 backdrop-blur-sm border-2 border-border hover:bg-destructive hover:text-white transition-colors"
|
| 31 |
+
size="icon"
|
| 32 |
+
variant="ghost"
|
| 33 |
+
onClick={onClose}
|
| 34 |
+
>
|
| 35 |
+
<X className="h-5 w-5" />
|
| 36 |
+
</Button>
|
| 37 |
+
|
| 38 |
+
<div className="flex flex-col lg:flex-row h-full overflow-hidden flex-1">
|
| 39 |
+
{/* Image Section - Takes more space */}
|
| 40 |
+
<div className="relative bg-black/5 dark:bg-white/5 flex items-center justify-center lg:w-3/5 min-h-[250px] lg:min-h-0 flex-shrink-0">
|
| 41 |
+
<div className="absolute inset-0 bg-[linear-gradient(45deg,transparent_25%,rgba(255,255,255,.02)_25%,rgba(255,255,255,.02)_50%,transparent_50%,transparent_75%,rgba(255,255,255,.02)_75%)] bg-[size:20px_20px]" />
|
| 42 |
+
<Image
|
| 43 |
+
src={imageUrl}
|
| 44 |
+
alt={generation.prompt}
|
| 45 |
+
fill
|
| 46 |
+
className="object-contain p-2"
|
| 47 |
+
unoptimized
|
| 48 |
+
/>
|
| 49 |
+
</div>
|
| 50 |
+
|
| 51 |
+
{/* Details Section */}
|
| 52 |
+
<div className="flex flex-col lg:w-2/5 border-t lg:border-t-0 lg:border-l border-border bg-card overflow-hidden">
|
| 53 |
+
{/* Scrollable Content */}
|
| 54 |
+
<div className="flex-1 overflow-y-auto p-6 space-y-6 custom-scrollbar">
|
| 55 |
+
{/* Creator Info */}
|
| 56 |
+
<div className="flex items-center gap-3 p-4 rounded-xl bg-gradient-to-r from-primary/10 to-secondary/10 border border-primary/20">
|
| 57 |
+
<div className="h-12 w-12 rounded-full bg-gradient-to-br from-primary to-secondary flex items-center justify-center text-white text-lg font-bold shadow-lg">
|
| 58 |
+
{generation.user.name?.[0] || "U"}
|
| 59 |
+
</div>
|
| 60 |
+
<div>
|
| 61 |
+
<p className="font-bold text-lg">{generation.user.name || "Anonymous Creator"}</p>
|
| 62 |
+
<p className="text-sm text-muted-foreground">@{generation.user.username || "artist"}</p>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
|
| 66 |
+
{/* Prompt */}
|
| 67 |
+
<div className="space-y-3">
|
| 68 |
+
<div className="flex items-center gap-2 text-xs font-bold uppercase tracking-widest text-primary">
|
| 69 |
+
<Info className="h-3.5 w-3.5" />
|
| 70 |
+
Prompt
|
| 71 |
+
</div>
|
| 72 |
+
<div className="relative">
|
| 73 |
+
<div className="absolute left-0 top-0 bottom-0 w-1 bg-gradient-to-b from-primary via-secondary to-accent rounded-full" />
|
| 74 |
+
<p className="pl-4 text-base leading-relaxed text-foreground/90 max-h-48 overflow-y-auto custom-scrollbar">
|
| 75 |
+
{generation.prompt}
|
| 76 |
+
</p>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
|
| 80 |
+
{/* Metadata Grid */}
|
| 81 |
+
<div className="grid grid-cols-2 gap-3">
|
| 82 |
+
<div className="p-4 rounded-xl bg-secondary/5 border border-border space-y-1">
|
| 83 |
+
<div className="flex items-center gap-2 text-xs uppercase font-bold text-muted-foreground">
|
| 84 |
+
<Cpu className="h-3 w-3" /> Model
|
| 85 |
+
</div>
|
| 86 |
+
<p className="font-bold text-sm truncate" title={generation.model}>
|
| 87 |
+
{generation.model.split('/').pop()}
|
| 88 |
+
</p>
|
| 89 |
+
</div>
|
| 90 |
+
<div className="p-4 rounded-xl bg-secondary/5 border border-border space-y-1">
|
| 91 |
+
<div className="flex items-center gap-2 text-xs uppercase font-bold text-muted-foreground">
|
| 92 |
+
<Calendar className="h-3 w-3" /> Created
|
| 93 |
+
</div>
|
| 94 |
+
<p className="font-bold text-sm">
|
| 95 |
+
{new Date(generation.createdAt).toLocaleDateString()}
|
| 96 |
+
</p>
|
| 97 |
+
</div>
|
| 98 |
+
</div>
|
| 99 |
+
|
| 100 |
+
{/* Dimensions */}
|
| 101 |
+
<div className="flex items-center justify-center gap-4 p-3 rounded-xl bg-muted/30 text-sm">
|
| 102 |
+
<span className="font-medium text-muted-foreground">Resolution:</span>
|
| 103 |
+
<span className="font-bold">{generation.width} × {generation.height}</span>
|
| 104 |
+
</div>
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
{/* Fixed Action Bar - Always Visible */}
|
| 108 |
+
<div className="p-4 border-t border-border bg-background/80 backdrop-blur-sm flex gap-3 flex-shrink-0">
|
| 109 |
+
<Button
|
| 110 |
+
className="flex-1 h-11 neo-brutalist bg-primary hover:bg-primary/90 text-white font-bold text-sm uppercase tracking-wider"
|
| 111 |
+
onClick={() => {
|
| 112 |
+
const a = document.createElement('a')
|
| 113 |
+
a.href = imageUrl
|
| 114 |
+
a.download = `wildart-${generation.id}.jpg`
|
| 115 |
+
a.click()
|
| 116 |
+
}}
|
| 117 |
+
>
|
| 118 |
+
<Download className="mr-2 h-4 w-4" />
|
| 119 |
+
Download
|
| 120 |
+
</Button>
|
| 121 |
+
<ShareMenu
|
| 122 |
+
artworkId={generation.id}
|
| 123 |
+
prompt={generation.prompt}
|
| 124 |
+
className="flex-1 h-11 neo-brutalist font-bold text-sm uppercase tracking-wider"
|
| 125 |
+
/>
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
</div>
|
| 129 |
+
</DialogContent>
|
| 130 |
+
</Dialog>
|
| 131 |
+
)
|
| 132 |
+
}
|
src/components/history-card.tsx
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client"
|
| 2 |
+
|
| 3 |
+
import { useState } from "react"
|
| 4 |
+
import Image from "next/image"
|
| 5 |
+
import { useRouter } from "next/navigation"
|
| 6 |
+
import { Button } from "@/components/ui/button"
|
| 7 |
+
import { Download, Trash2, Loader2 } from "lucide-react"
|
| 8 |
+
|
| 9 |
+
interface HistoryCardProps {
|
| 10 |
+
generation: {
|
| 11 |
+
id: string
|
| 12 |
+
imageUrl: string
|
| 13 |
+
prompt: string
|
| 14 |
+
model: string
|
| 15 |
+
createdAt: Date
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
export function HistoryCard({ generation }: HistoryCardProps) {
|
| 20 |
+
const router = useRouter()
|
| 21 |
+
const [isDeleting, setIsDeleting] = useState(false)
|
| 22 |
+
|
| 23 |
+
const handleDelete = async () => {
|
| 24 |
+
if (!confirm("Delete this image? This cannot be undone.")) return
|
| 25 |
+
|
| 26 |
+
setIsDeleting(true)
|
| 27 |
+
try {
|
| 28 |
+
const res = await fetch(`/api/generation/${generation.id}`, {
|
| 29 |
+
method: "DELETE",
|
| 30 |
+
})
|
| 31 |
+
|
| 32 |
+
if (!res.ok) throw new Error("Failed to delete")
|
| 33 |
+
|
| 34 |
+
router.refresh()
|
| 35 |
+
} catch (error) {
|
| 36 |
+
console.error(error)
|
| 37 |
+
alert("Failed to delete image")
|
| 38 |
+
setIsDeleting(false)
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
return (
|
| 43 |
+
<div className="group relative neo-brutalist bg-card rounded-none overflow-hidden aspect-square border-2 border-border">
|
| 44 |
+
{/* Action Buttons Overlay */}
|
| 45 |
+
<div className="absolute top-2 right-2 z-10 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
| 46 |
+
<Button size="icon" variant="secondary" className="h-8 w-8 rounded-full border border-border shadow-sm" asChild>
|
| 47 |
+
<a href={generation.imageUrl} download={`wild-art-${generation.id}.jpg`}>
|
| 48 |
+
<Download className="h-4 w-4" />
|
| 49 |
+
</a>
|
| 50 |
+
</Button>
|
| 51 |
+
<Button
|
| 52 |
+
size="icon"
|
| 53 |
+
variant="destructive"
|
| 54 |
+
className="h-8 w-8 rounded-full border border-border shadow-sm"
|
| 55 |
+
onClick={handleDelete}
|
| 56 |
+
disabled={isDeleting}
|
| 57 |
+
>
|
| 58 |
+
{isDeleting ? <Loader2 className="h-4 w-4 animate-spin" /> : <Trash2 className="h-4 w-4" />}
|
| 59 |
+
</Button>
|
| 60 |
+
</div>
|
| 61 |
+
|
| 62 |
+
<Image
|
| 63 |
+
src={generation.imageUrl}
|
| 64 |
+
alt={generation.prompt}
|
| 65 |
+
fill
|
| 66 |
+
className="object-cover transition-transform duration-700 group-hover:scale-110"
|
| 67 |
+
unoptimized
|
| 68 |
+
/>
|
| 69 |
+
|
| 70 |
+
{/* Info Overlay */}
|
| 71 |
+
<div className="absolute inset-x-0 bottom-0 bg-background/90 backdrop-blur-md p-4 border-t-2 border-border translate-y-full group-hover:translate-y-0 transition-transform duration-300">
|
| 72 |
+
<p className="font-bold text-sm line-clamp-2 mb-2 leading-tight" title={generation.prompt}>{generation.prompt}</p>
|
| 73 |
+
<div className="flex items-center justify-between text-[10px] uppercase tracking-wider font-bold text-muted-foreground">
|
| 74 |
+
<span className="bg-secondary/10 px-2 py-0.5 rounded-sm text-secondary-foreground">{generation.model.split('/').pop()}</span>
|
| 75 |
+
<span>{new Date(generation.createdAt).toLocaleDateString()}</span>
|
| 76 |
+
</div>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
)
|
| 80 |
+
}
|