mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
fix: ai balance for unlimited plan
This commit is contained in:
@@ -6,7 +6,7 @@ import { buildLLMPrompt } from "@/ai/prompt"
|
||||
import { fieldsToJsonSchema } from "@/ai/schema"
|
||||
import { transactionFormSchema } from "@/forms/transactions"
|
||||
import { ActionState } from "@/lib/actions"
|
||||
import { getCurrentUser, isSubscriptionExpired } from "@/lib/auth"
|
||||
import { getCurrentUser, isAiBalanceExhausted, isSubscriptionExpired } from "@/lib/auth"
|
||||
import config from "@/lib/config"
|
||||
import { getTransactionFileUploadPath, getUserUploadsDirectory } from "@/lib/files"
|
||||
import { DEFAULT_PROMPT_ANALYSE_NEW_FILE } from "@/models/defaults"
|
||||
@@ -36,19 +36,17 @@ export async function analyzeFileAction(
|
||||
return { success: false, error: "OpenAI API key is not set" }
|
||||
}
|
||||
|
||||
if (!config.selfHosted.isEnabled) {
|
||||
if (user.aiBalance <= 0) {
|
||||
return {
|
||||
success: false,
|
||||
error: "You used all of your pre-paid AI scans, please upgrade your account or buy new subscription plan",
|
||||
}
|
||||
if (isAiBalanceExhausted(user)) {
|
||||
return {
|
||||
success: false,
|
||||
error: "You used all of your pre-paid AI scans, please upgrade your account or buy new subscription plan",
|
||||
}
|
||||
}
|
||||
|
||||
if (isSubscriptionExpired(user)) {
|
||||
return {
|
||||
success: false,
|
||||
error: "Your subscription has expired, please upgrade your account or buy new subscription plan",
|
||||
}
|
||||
if (isSubscriptionExpired(user)) {
|
||||
return {
|
||||
success: false,
|
||||
error: "Your subscription has expired, please upgrade your account or buy new subscription plan",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -323,9 +323,6 @@ export default function LandingPage() {
|
||||
<section className="py-20 px-8 bg-gradient-to-b from-white to-gray-50 mt-28">
|
||||
<div className="max-w-7xl mx-auto">
|
||||
<div className="text-center mb-16">
|
||||
<div className="inline-block px-4 py-2 rounded-full bg-purple-50 text-purple-600 text-sm font-medium mb-6">
|
||||
🚀 Under Active Development
|
||||
</div>
|
||||
<h2 className="text-3xl font-bold mb-4 bg-gradient-to-r from-gray-900 to-gray-600 bg-clip-text text-transparent">
|
||||
Upcoming Features
|
||||
</h2>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import config from "@/lib/config"
|
||||
import { getSelfHostedUser, getUserByEmail, getUserById } from "@/models/users"
|
||||
import { getSelfHostedUser, getUserByEmail, getUserById, SELF_HOSTED_USER } from "@/models/users"
|
||||
import { User } from "@prisma/client"
|
||||
import { betterAuth } from "better-auth"
|
||||
import { prismaAdapter } from "better-auth/adapters/prisma"
|
||||
@@ -101,3 +101,10 @@ export function isSubscriptionExpired(user: User) {
|
||||
}
|
||||
return user.membershipExpiresAt && user.membershipExpiresAt < new Date()
|
||||
}
|
||||
|
||||
export function isAiBalanceExhausted(user: User) {
|
||||
if (config.selfHosted.isEnabled || user.membershipPlan === SELF_HOSTED_USER.membershipPlan) {
|
||||
return false
|
||||
}
|
||||
return user.aiBalance <= 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user