UNPKG

@coursebuilder/commerce-next

Version:

Commerce Functionality for Course Builder with Next.js

25 lines (24 loc) 700 B
'use server'; import { revalidatePath } from 'next/cache'; export async function redeemFullPriceCoupon({ email, couponId, productIds, sendEmail = true, }) { return await fetch(`${process.env.NEXT_PUBLIC_URL}/api/coursebuilder/redeem/coupon`, { method: 'post', body: JSON.stringify({ email, couponId, productIds, sendEmail, }), headers: { 'Content-Type': 'application/json', }, }) .then((response) => { revalidatePath('/'); return response.json(); }) .catch((e) => { console.error('Error redeeming full price coupon', e); throw e; }); }