Skip to content

Commit

Permalink
fix: ensure finalPrice defaults to basePrice if not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
joywin2003 committed Nov 19, 2024
1 parent 29058ed commit a0409f4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/api/submit-form/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { RegistrationFormSchema, TRegistrationForm } from "@/utils/zod-schemas";
import prisma from "@/server/db";
import { getPrice } from "@/app/actions/get-price";
import getErrorMessage from "@/utils/getErrorMessage";
import {basePrice} from "@/constants";

export async function GET() {
return NextResponse.json({ message: "Hello from the API!" });
Expand Down Expand Up @@ -36,6 +37,7 @@ export async function POST(req: NextRequest, res: NextResponse) {
} = body;

let { finalPrice } = await getPrice(referralUsed);
finalPrice = finalPrice ?? basePrice; // Ensure finalPrice is a number

await prisma.$transaction(async (tx) => {
prisma.referral.update({
Expand Down

0 comments on commit a0409f4

Please sign in to comment.