From c28720be5ad972375b87c8818a5bc7362d835c4f Mon Sep 17 00:00:00 2001 From: Mike Johnston Date: Fri, 20 Mar 2026 12:49:12 -0400 Subject: [PATCH] fix: refactor user creation to store user in a variable before trade creation --- src/app/api/auth/register/route.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/api/auth/register/route.ts b/src/app/api/auth/register/route.ts index d575a4a..b1001e8 100644 --- a/src/app/api/auth/register/route.ts +++ b/src/app/api/auth/register/route.ts @@ -36,9 +36,20 @@ export async function POST(req: NextRequest) { const passwordHash = await bcrypt.hash(password, 12) - await prisma.user.create({ + const user = await prisma.user.create({ data: { username, displayUsername, passwordHash }, }) + await prisma.trade.create({ + data: { + userId: user.id, + type: 'ACCOUNT_OPEN', + shares: 0, + price: 0, + total: 2000, + profit: 2000, + }, + }) + return NextResponse.json({ ok: true }, { status: 201 }) }