refactor: rename 'credits' to 'amount' in credit-related configurations and components for consistency

This commit is contained in:
javayhu 2025-08-24 01:16:39 +08:00
parent 96d630f3ac
commit e6bc1ea9e8
7 changed files with 11 additions and 11 deletions

View File

@ -48,7 +48,7 @@ export const createCreditCheckoutSession = userActionClient
...metadata,
type: 'credit_purchase',
packageId,
credits: creditPackage.credits.toString(),
credits: creditPackage.amount.toString(),
userId: currentUser.id,
userName: currentUser.name,
};

View File

@ -84,7 +84,7 @@ export function CreditPackages() {
<div className="text-left">
<div className="text-2xl font-semibold flex items-center gap-2">
<CoinsIcon className="h-4 w-4 text-muted-foreground" />
{creditPackage.credits.toLocaleString()}
{creditPackage.amount.toLocaleString()}
</div>
</div>
<div className="text-right">

View File

@ -158,14 +158,14 @@ export const websiteConfig: WebsiteConfig = {
enablePackagesForFreePlan: false,
registerGiftCredits: {
enable: true,
credits: 50,
amount: 50,
expireDays: 30,
},
packages: {
basic: {
id: 'basic',
popular: false,
credits: 100,
amount: 100,
expireDays: 30,
price: {
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_BASIC!,
@ -177,7 +177,7 @@ export const websiteConfig: WebsiteConfig = {
standard: {
id: 'standard',
popular: true,
credits: 200,
amount: 200,
expireDays: 30,
price: {
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_STANDARD!,
@ -189,7 +189,7 @@ export const websiteConfig: WebsiteConfig = {
premium: {
id: 'premium',
popular: false,
credits: 500,
amount: 500,
expireDays: 30,
price: {
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_PREMIUM!,
@ -201,7 +201,7 @@ export const websiteConfig: WebsiteConfig = {
enterprise: {
id: 'enterprise',
popular: false,
credits: 1000,
amount: 1000,
expireDays: 30,
price: {
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_ENTERPRISE!,

View File

@ -450,7 +450,7 @@ export async function addRegisterGiftCredits(userId: string) {
// add register gift credits if user has not received them yet
if (record.length === 0) {
const credits = websiteConfig.credits.registerGiftCredits.credits;
const credits = websiteConfig.credits.registerGiftCredits.amount;
const expireDays = websiteConfig.credits.registerGiftCredits.expireDays;
await addCredits({
userId,

View File

@ -26,7 +26,7 @@ export interface CreditPackagePrice {
*/
export interface CreditPackage {
id: string; // Unique identifier for the package
credits: number; // Number of credits in the package
amount: number; // Amount of credits in the package
price: CreditPackagePrice; // Price of the package
popular: boolean; // Whether the package is popular
name?: string; // Display name of the package

View File

@ -190,7 +190,7 @@ async function onCreateUser(user: User) {
if (
websiteConfig.credits.enableCredits &&
websiteConfig.credits.registerGiftCredits.enable &&
websiteConfig.credits.registerGiftCredits.credits > 0
websiteConfig.credits.registerGiftCredits.amount > 0
) {
try {
await addRegisterGiftCredits(user.id);

View File

@ -172,7 +172,7 @@ export interface CreditsConfig {
enablePackagesForFreePlan: boolean;// Whether to enable purchase credits for free plan users
registerGiftCredits: {
enable: boolean; // Whether to enable register gift credits
credits: number; // The number of credits to give to the user
amount: number; // The amount of credits to give to the user
expireDays?: number; // The number of days to expire the credits, undefined means no expire
};
packages: Record<string, CreditPackage>; // Packages indexed by ID