refactor: rename 'credits' to 'amount' in credit-related configurations and components for consistency
This commit is contained in:
parent
96d630f3ac
commit
e6bc1ea9e8
@ -48,7 +48,7 @@ export const createCreditCheckoutSession = userActionClient
|
|||||||
...metadata,
|
...metadata,
|
||||||
type: 'credit_purchase',
|
type: 'credit_purchase',
|
||||||
packageId,
|
packageId,
|
||||||
credits: creditPackage.credits.toString(),
|
credits: creditPackage.amount.toString(),
|
||||||
userId: currentUser.id,
|
userId: currentUser.id,
|
||||||
userName: currentUser.name,
|
userName: currentUser.name,
|
||||||
};
|
};
|
||||||
|
@ -84,7 +84,7 @@ export function CreditPackages() {
|
|||||||
<div className="text-left">
|
<div className="text-left">
|
||||||
<div className="text-2xl font-semibold flex items-center gap-2">
|
<div className="text-2xl font-semibold flex items-center gap-2">
|
||||||
<CoinsIcon className="h-4 w-4 text-muted-foreground" />
|
<CoinsIcon className="h-4 w-4 text-muted-foreground" />
|
||||||
{creditPackage.credits.toLocaleString()}
|
{creditPackage.amount.toLocaleString()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right">
|
<div className="text-right">
|
||||||
|
@ -158,14 +158,14 @@ export const websiteConfig: WebsiteConfig = {
|
|||||||
enablePackagesForFreePlan: false,
|
enablePackagesForFreePlan: false,
|
||||||
registerGiftCredits: {
|
registerGiftCredits: {
|
||||||
enable: true,
|
enable: true,
|
||||||
credits: 50,
|
amount: 50,
|
||||||
expireDays: 30,
|
expireDays: 30,
|
||||||
},
|
},
|
||||||
packages: {
|
packages: {
|
||||||
basic: {
|
basic: {
|
||||||
id: 'basic',
|
id: 'basic',
|
||||||
popular: false,
|
popular: false,
|
||||||
credits: 100,
|
amount: 100,
|
||||||
expireDays: 30,
|
expireDays: 30,
|
||||||
price: {
|
price: {
|
||||||
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_BASIC!,
|
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_BASIC!,
|
||||||
@ -177,7 +177,7 @@ export const websiteConfig: WebsiteConfig = {
|
|||||||
standard: {
|
standard: {
|
||||||
id: 'standard',
|
id: 'standard',
|
||||||
popular: true,
|
popular: true,
|
||||||
credits: 200,
|
amount: 200,
|
||||||
expireDays: 30,
|
expireDays: 30,
|
||||||
price: {
|
price: {
|
||||||
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_STANDARD!,
|
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_STANDARD!,
|
||||||
@ -189,7 +189,7 @@ export const websiteConfig: WebsiteConfig = {
|
|||||||
premium: {
|
premium: {
|
||||||
id: 'premium',
|
id: 'premium',
|
||||||
popular: false,
|
popular: false,
|
||||||
credits: 500,
|
amount: 500,
|
||||||
expireDays: 30,
|
expireDays: 30,
|
||||||
price: {
|
price: {
|
||||||
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_PREMIUM!,
|
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_PREMIUM!,
|
||||||
@ -201,7 +201,7 @@ export const websiteConfig: WebsiteConfig = {
|
|||||||
enterprise: {
|
enterprise: {
|
||||||
id: 'enterprise',
|
id: 'enterprise',
|
||||||
popular: false,
|
popular: false,
|
||||||
credits: 1000,
|
amount: 1000,
|
||||||
expireDays: 30,
|
expireDays: 30,
|
||||||
price: {
|
price: {
|
||||||
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_ENTERPRISE!,
|
priceId: process.env.NEXT_PUBLIC_STRIPE_PRICE_CREDITS_ENTERPRISE!,
|
||||||
|
@ -450,7 +450,7 @@ export async function addRegisterGiftCredits(userId: string) {
|
|||||||
|
|
||||||
// add register gift credits if user has not received them yet
|
// add register gift credits if user has not received them yet
|
||||||
if (record.length === 0) {
|
if (record.length === 0) {
|
||||||
const credits = websiteConfig.credits.registerGiftCredits.credits;
|
const credits = websiteConfig.credits.registerGiftCredits.amount;
|
||||||
const expireDays = websiteConfig.credits.registerGiftCredits.expireDays;
|
const expireDays = websiteConfig.credits.registerGiftCredits.expireDays;
|
||||||
await addCredits({
|
await addCredits({
|
||||||
userId,
|
userId,
|
||||||
|
@ -26,7 +26,7 @@ export interface CreditPackagePrice {
|
|||||||
*/
|
*/
|
||||||
export interface CreditPackage {
|
export interface CreditPackage {
|
||||||
id: string; // Unique identifier for the package
|
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
|
price: CreditPackagePrice; // Price of the package
|
||||||
popular: boolean; // Whether the package is popular
|
popular: boolean; // Whether the package is popular
|
||||||
name?: string; // Display name of the package
|
name?: string; // Display name of the package
|
||||||
|
@ -190,7 +190,7 @@ async function onCreateUser(user: User) {
|
|||||||
if (
|
if (
|
||||||
websiteConfig.credits.enableCredits &&
|
websiteConfig.credits.enableCredits &&
|
||||||
websiteConfig.credits.registerGiftCredits.enable &&
|
websiteConfig.credits.registerGiftCredits.enable &&
|
||||||
websiteConfig.credits.registerGiftCredits.credits > 0
|
websiteConfig.credits.registerGiftCredits.amount > 0
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
await addRegisterGiftCredits(user.id);
|
await addRegisterGiftCredits(user.id);
|
||||||
|
2
src/types/index.d.ts
vendored
2
src/types/index.d.ts
vendored
@ -172,7 +172,7 @@ export interface CreditsConfig {
|
|||||||
enablePackagesForFreePlan: boolean;// Whether to enable purchase credits for free plan users
|
enablePackagesForFreePlan: boolean;// Whether to enable purchase credits for free plan users
|
||||||
registerGiftCredits: {
|
registerGiftCredits: {
|
||||||
enable: boolean; // Whether to enable register gift credits
|
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
|
expireDays?: number; // The number of days to expire the credits, undefined means no expire
|
||||||
};
|
};
|
||||||
packages: Record<string, CreditPackage>; // Packages indexed by ID
|
packages: Record<string, CreditPackage>; // Packages indexed by ID
|
||||||
|
Loading…
Reference in New Issue
Block a user