From 1ff42009d879e516553a84501ce3ca0e20c31378 Mon Sep 17 00:00:00 2001 From: javayhu Date: Sat, 23 Aug 2025 20:07:32 +0800 Subject: [PATCH] chore: update function parameters planId instead of priceId --- src/credits/credits.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/credits/credits.ts b/src/credits/credits.ts index 3d6e043..763370d 100644 --- a/src/credits/credits.ts +++ b/src/credits/credits.ts @@ -2,7 +2,7 @@ import { randomUUID } from 'crypto'; import { websiteConfig } from '@/config/website'; import { getDb } from '@/db'; import { creditTransaction, userCredit } from '@/db/schema'; -import { findPlanByPriceId } from '@/lib/price-plan'; +import { findPlanByPlanId, findPlanByPriceId } from '@/lib/price-plan'; import { addDays, isAfter } from 'date-fns'; import { and, asc, eq, gt, isNull, not, or } from 'drizzle-orm'; import { CREDIT_TRANSACTION_TYPE } from './types'; @@ -442,11 +442,11 @@ export async function addRegisterGiftCredits(userId: string) { /** * Add free monthly credits * @param userId - User ID - * @param priceId - Price ID + * @param planId - Plan ID */ -export async function addMonthlyFreeCredits(userId: string, priceId: string) { +export async function addMonthlyFreeCredits(userId: string, planId: string) { // NOTICE: make sure the free plan is not disabled and has credits enabled - const pricePlan = findPlanByPriceId(priceId); + const pricePlan = findPlanByPlanId(planId); if ( !pricePlan || pricePlan.disabled || @@ -455,7 +455,7 @@ export async function addMonthlyFreeCredits(userId: string, priceId: string) { !pricePlan.credits.enable ) { console.log( - `addMonthlyFreeCredits, no credits configured for plan ${priceId}` + `addMonthlyFreeCredits, no credits configured for plan ${planId}` ); return; }