The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update route.ts
Kiran Kcf72878f9094
diff --git a/apps/web/app/(ee)/api/discount-codes/[discountCodeId]/route.ts b/apps/web/app/(ee)/api/discount-codes/[discountCodeId]/route.tsindex 887bc67e80..2a1016d6fe 100644--- a/apps/web/app/(ee)/api/discount-codes/[discountCodeId]/route.ts+++ b/apps/web/app/(ee)/api/discount-codes/[discountCodeId]/route.ts@@ -9,35 +9,6 @@ import { DiscountProvider } from "@prisma/client";import { waitUntil } from "@vercel/functions";import { NextResponse } from "next/server";-// PATCH /api/discount-codes/[discountCodeId] - update a discount code-export const PATCH = withWorkspace(- async ({ workspace, params, session }) => {- const { discountCodeId } = params;- const programId = getDefaultProgramIdOrThrow(workspace);-- const discountCode = await getDiscountCodeOrThrow({- discountCodeId,- programId,- });-- if (discountCode.discount.provider !== DiscountProvider.custom) {- throw new DubApiError({- code: "bad_request",- message: `This operation is only available for "custom" discount provider.`,- });- }-- // TODO:- // - Update the discount code-- return NextResponse.json({ id: discountCode.id });- },- {- requiredPlan: ["business", "advanced", "enterprise"],- requiredRoles: ["owner", "member"],- },-);-// DELETE /api/discount-codes/[discountCodeId] - soft delete a discount codeexport const DELETE = withWorkspace(async ({ workspace, params, session }) => {@@ -86,3 +57,32 @@ export const DELETE = withWorkspace(requiredRoles: ["owner", "member"],},);++// PATCH /api/discount-codes/[discountCodeId] - update a discount code+export const PATCH = withWorkspace(+ async ({ workspace, params, session }) => {+ const { discountCodeId } = params;+ const programId = getDefaultProgramIdOrThrow(workspace);++ const discountCode = await getDiscountCodeOrThrow({+ discountCodeId,+ programId,+ });++ if (discountCode.discount.provider !== DiscountProvider.custom) {+ throw new DubApiError({+ code: "bad_request",+ message: `This operation is only available for "custom" discount provider.`,+ });+ }++ // TODO:+ // - Update the discount code++ return NextResponse.json({ id: discountCode.id });+ },+ {+ requiredPlan: ["business", "advanced", "enterprise"],+ requiredRoles: ["owner", "member"],+ },+);