Skip to content

Commit cd99cf9

Browse files
committed
Resolve merge: keep reset-request route deletion
2 parents 63c1a02 + 2f42a35 commit cd99cf9

19 files changed

Lines changed: 644 additions & 45 deletions

File tree

README.md

Lines changed: 451 additions & 1 deletion
Large diffs are not rendered by default.

app/api/admin/activate/route.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NextResponse } from "next/server";
2+
import { TransactionGateway, TransactionStatus } from "@prisma/client";
23
import { isAdminEmail } from "@/lib/access";
34
import { getSessionEmail } from "@/lib/session";
45
import { prisma } from "@/lib/prisma";
@@ -14,21 +15,31 @@ export async function POST(req: Request) {
1415
const email = String(formData.get("email") || "").trim().toLowerCase();
1516
const plan = String(formData.get("plan") || "").trim().toLowerCase();
1617

17-
if (!email || !["starter", "pro", "agency"].includes(plan)) {
18+
const validPlans = ["free", "pro_monthly", "agency_monthly", "pro_yearly", "agency_yearly", "pro_lifetime", "agency_lifetime"];
19+
if (!email || !validPlans.includes(plan)) {
1820
return NextResponse.json({ error: "Invalid request" }, { status: 400 });
1921
}
2022

23+
const user = await prisma.user.findUnique({ where: { email } });
24+
if (!user) {
25+
return NextResponse.json({ error: "User not found" }, { status: 404 });
26+
}
27+
2128
await prisma.user.update({
22-
where: { email },
29+
where: { id: user.id },
2330
data: { plan, status: "active" },
2431
});
2532

26-
await (prisma as any).billingEvent.create({
33+
await prisma.transaction.create({
2734
data: {
28-
email,
29-
provider: "admin",
30-
plan,
31-
status: "completed",
35+
userId: user.id,
36+
gateway: TransactionGateway.ADMIN,
37+
status: TransactionStatus.COMPLETED,
38+
planId: plan,
39+
amountUSD: 0,
40+
paymentRef: `admin-${email}-${Date.now()}`,
41+
creditsAdded: 0,
42+
metadata: { email, provider: "admin" },
3243
},
3344
});
3445

app/api/admin/data/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function GET() {
2121
posts: { select: { id: true } },
2222
},
2323
}),
24-
(prisma as any).billingEvent.findMany({
24+
prisma.transaction.findMany({
2525
orderBy: { createdAt: 'desc' },
2626
take: 100,
2727
include: { user: { select: { email: true } } },

app/api/admin/lifetime/route.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NextResponse } from "next/server";
2+
import { TransactionGateway, TransactionStatus } from "@prisma/client";
23
import { prisma } from "@/lib/prisma";
34
import { getSessionEmail } from "@/lib/session";
45
import { isAdminEmail } from "@/lib/access";
@@ -16,22 +17,29 @@ export async function POST(req: Request) {
1617
return NextResponse.json({ error: "Email is required" }, { status: 400 });
1718
}
1819

19-
await (prisma as any).user.update({
20-
where: { email },
20+
const user = await prisma.user.findUnique({ where: { email } });
21+
if (!user) {
22+
return NextResponse.json({ error: "User not found" }, { status: 404 });
23+
}
24+
25+
await prisma.user.update({
26+
where: { id: user.id },
2127
data: {
22-
plan: "agency",
28+
plan: "agency_lifetime",
2329
status: "active",
24-
isLifetime: true,
25-
billingCycle: "lifetime",
2630
},
2731
});
2832

29-
await (prisma as any).billingEvent.create({
33+
await prisma.transaction.create({
3034
data: {
31-
email,
32-
provider: "admin-lifetime",
33-
plan: "lifetime",
34-
status: "completed",
35+
userId: user.id,
36+
gateway: TransactionGateway.ADMIN,
37+
status: TransactionStatus.COMPLETED,
38+
planId: "agency_lifetime",
39+
amountUSD: 0,
40+
paymentRef: `admin-lifetime-${email}-${Date.now()}`,
41+
creditsAdded: 999999,
42+
metadata: { email, provider: "admin-lifetime" },
3543
},
3644
});
3745

app/api/admin/manual-activate/route.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NextResponse } from 'next/server';
2+
import { TransactionGateway, TransactionStatus } from '@prisma/client';
23
import { prisma } from '@/lib/prisma';
34
import { getSessionEmail } from '@/lib/session';
45
import { isAdminEmail } from '@/lib/access';
@@ -13,7 +14,8 @@ export async function POST(req: Request) {
1314
const email = String(formData.get('email') || '').trim().toLowerCase();
1415
const plan = String(formData.get('plan') || '').trim().toLowerCase();
1516

16-
if (!email || !['starter', 'pro', 'agency'].includes(plan)) {
17+
const validPlans = ['free', 'pro_monthly', 'agency_monthly', 'pro_yearly', 'agency_yearly', 'pro_lifetime', 'agency_lifetime'];
18+
if (!email || !validPlans.includes(plan)) {
1719
return NextResponse.json({ error: 'Invalid request' }, { status: 400 });
1820
}
1921

@@ -27,13 +29,16 @@ export async function POST(req: Request) {
2729
data: { plan, status: 'active' },
2830
});
2931

30-
await (prisma as any).billingEvent.create({
32+
await prisma.transaction.create({
3133
data: {
3234
userId: targetUser.id,
33-
provider: 'manual-admin',
34-
plan,
35-
amount: null,
36-
status: 'confirmed',
35+
gateway: TransactionGateway.ADMIN,
36+
status: TransactionStatus.COMPLETED,
37+
planId: plan,
38+
amountUSD: 0,
39+
paymentRef: `manual-admin-${email}-${Date.now()}`,
40+
creditsAdded: 0,
41+
metadata: { email, provider: 'manual-admin' },
3742
},
3843
});
3944

app/api/admin/route.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export async function GET(req: NextRequest) {
1515

1616
const users = await listUsers();
1717

18+
const activePlans = ["pro_monthly", "pro_yearly", "pro_lifetime", "agency_monthly", "agency_yearly", "agency_lifetime"];
19+
1820
const stats = {
1921
total: users.length,
20-
starter: users.filter((u) => u.plan === "starter").length,
21-
pro: users.filter((u) => u.plan === "pro").length,
22-
agency: users.filter((u) => u.plan === "agency").length,
23-
active: users.filter((u) => u.plan !== "starter").length,
24-
trial: users.filter((u) => u.plan === "starter").length,
22+
pro: users.filter((u) => activePlans.includes(u.plan)).length,
23+
active: users.filter((u) => activePlans.includes(u.plan)).length,
24+
trial: users.filter((u) => u.plan === "free").length,
2525
blocked: 0,
2626
};
2727

app/api/audit/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const dynamic = "force-dynamic";
66

77
export async function GET() {
88
try {
9-
const auditLogs = await (prisma as any).auditLog.findMany({
9+
const auditLogs = await prisma.auditLog.findMany({
1010
take: 100,
1111
orderBy: { createdAt: "desc" },
1212
include: {

app/layout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const metadata: Metadata = {
3535
url: siteUrl,
3636
images: [
3737
{
38-
url: `${siteUrl}/og-image.png`,
38+
url: `${siteUrl}/og-image.svg`,
3939
width: 1200,
4040
height: 630,
4141
alt: "Teos AI Engine — Sovereign AI Content Engine",
@@ -47,7 +47,7 @@ export const metadata: Metadata = {
4747
title: "Teos AI Engine — Egypt's Sovereign AI Content Engine",
4848
description:
4949
"Generate on-brand social content across X, LinkedIn, Instagram & more with Egypt's first sovereign AI content engine.",
50-
images: [`${siteUrl}/og-image.png`],
50+
images: [`${siteUrl}/og-image.svg`],
5151
creator: "@king_teos",
5252
},
5353
robots: {
@@ -62,8 +62,8 @@ export const metadata: Metadata = {
6262
},
6363
},
6464
icons: {
65-
icon: "/favicon.ico",
66-
apple: "/apple-icon.png",
65+
icon: "/favicon.svg",
66+
apple: "/favicon.svg",
6767
},
6868
other: {
6969
"application/ld+json": JSON.stringify({

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export default function Home() {
306306
const res = await fetch("/api/generate", {
307307
method: "POST",
308308
headers: { "Content-Type": "application/json" },
309-
body: JSON.stringify({ topic, platform, tone }),
309+
body: JSON.stringify({ prompt: topic, platform }),
310310
});
311311
const data = await res.json();
312312
if (!res.ok) throw new Error(data.error || "Generation failed.");

app/reset-password/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function ResetPasswordForm() {
5454
setLoading(true);
5555

5656
try {
57-
const res = await fetch("/api/auth/reset-password", {
57+
const res = await fetch("/api/auth/reset-confirm", {
5858
method: "POST",
5959
headers: { "Content-Type": "application/json" },
6060
body: JSON.stringify({ token, email, password }),

0 commit comments

Comments
 (0)