Add paycheck tracking workflow for v1
This commit is contained in:
23
src/app/paychecks/[id]/route.ts
Normal file
23
src/app/paychecks/[id]/route.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
import { removePaycheck } from "@/lib/paychecks";
|
||||
|
||||
type RouteContext = {
|
||||
params: Promise<{ id: string }>;
|
||||
};
|
||||
|
||||
export async function DELETE(_: Request, context: RouteContext) {
|
||||
const { id } = await context.params;
|
||||
|
||||
try {
|
||||
await removePaycheck(id);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
} catch (error) {
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === "P2025") {
|
||||
return NextResponse.json({ error: "Paycheck not found." }, { status: 404 });
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user