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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions app/api/applications/org/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
export const runtime = "nodejs";

import { NextResponse } from "next/server";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

export async function POST(request: Request) {
try {
const body = await request.json();

const { companyName, projectTitle, budget, description } = body;

// Server validation
if (!companyName || !projectTitle || !budget || !description) {
return NextResponse.json(
{ error: "Missing required fields" },
{ status: 400 },
);
}

const parsedBudget = Number(String(budget).replace(/[^0-9.-]+/g, ""));

if (isNaN(parsedBudget)) {
return NextResponse.json(
{ error: "Budget must be a valid number" },
{ status: 400 },
);
}

const application = await prisma.application.create({
data: {
type: "ORG",
status: "PENDING",

submitterName: companyName,
submitterEmail: "N/A", // must be non-null, can change later

payload: {
companyName,
projectTitle,
budget: parsedBudget,
description,
},
},
});

return NextResponse.json(
{
success: true,
id: application.id,
},
{ status: 201 },
);
} catch (error) {
console.error(error);

return NextResponse.json(
{ error: "Failed to create application" },
{ status: 500 },
);
}
}
5 changes: 1 addition & 4 deletions app/apply/org/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ export default function OrgApplyPage() {
return (
<PublicLayout>
<div className="mx-auto max-w-3xl px-6 py-12">
<h1 className="text-2xl font-semibold">
Organization Application
</h1>
<h1 className="text-2xl font-semibold">Organization Application</h1>
<p className="mt-2 text-gray-600">Coming soon.</p>

<Link href="/apply" className="mt-6 inline-block underline">
Expand All @@ -17,4 +15,3 @@ export default function OrgApplyPage() {
</PublicLayout>
);
}

17 changes: 13 additions & 4 deletions app/apply/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,27 @@ export default function ApplyPage() {
<section className="mt-10">
<h2 className="text-2xl font-semibold mb-3">Application Types</h2>
<div className="flex flex-col gap-4">
<Link href="/apply/startup" className="underline text-gray-700 hover:text-black">
<Link
href="/apply/startup"
className="underline text-gray-700 hover:text-black"
>
Startup Application
</Link>
<Link href="/apply/org" className="underline text-gray-700 hover:text-black">
<Link
href="/apply/organization"
className="underline text-gray-700 hover:text-black"
>
Org Application
</Link>
<Link href="/apply/team" className="underline text-gray-700 hover:text-black">
<Link
href="/apply/team"
className="underline text-gray-700 hover:text-black"
>
Team Application
</Link>
</div>
</section>
</div>
</PublicLayout>
);
}
}
1 change: 1 addition & 0 deletions auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export const { auth, handlers, signIn, signOut } = NextAuth({
strategy: "jwt",
maxAge: 30 * 24 * 60 * 60, // 30 days
},
secret: process.env.AUTH_SECRET,
});
2 changes: 1 addition & 1 deletion components/layout/PublicLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function PublicLayout({
<main>{children}</main>

<footer>
<h3>Public Footer</h3>
<h3>Footer placeholder</h3>
</footer>
</>
);
Expand Down
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.