Refactor subscription logic and replace quill-sense references with ritor equivalents
- Updated `getCurrentSubscription` and related functions to reflect terminology changes. - Adjusted subscription levels and access checks to streamline logic. - Removed unused cases in `getSubLevel` and optimized conditionals for clarity.
This commit is contained in:
@@ -3,9 +3,9 @@ import {Subscription} from "@/lib/types/user";
|
||||
import {getCurrentSubscription} from "@/lib/utils/user";
|
||||
|
||||
export function getSubLevel(session: SessionProps): number {
|
||||
let currentSub: Subscription | null = getCurrentSubscription(session?.user, 'quill-sense');
|
||||
let currentSub: Subscription | null = getCurrentSubscription(session?.user, 'ritor-subscription');
|
||||
if (!currentSub) {
|
||||
currentSub = getCurrentSubscription(session?.user, 'quill-trial');
|
||||
currentSub = getCurrentSubscription(session?.user, 'ritor-trial');
|
||||
if (!currentSub) {
|
||||
return 0;
|
||||
}
|
||||
@@ -15,8 +15,6 @@ export function getSubLevel(session: SessionProps): number {
|
||||
return 1;
|
||||
case 2:
|
||||
return 2;
|
||||
case 3:
|
||||
return 3;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -24,8 +22,7 @@ export function getSubLevel(session: SessionProps): number {
|
||||
|
||||
export function isBringYourKeys(session: SessionProps): boolean {
|
||||
if (!session?.user) return false;
|
||||
const currentSub: Subscription | null = getCurrentSubscription(session?.user, 'use-your-keys');
|
||||
return currentSub?.status || session.user.groupId <= 4;
|
||||
return session.user.apiKeys.openai || session.user.apiKeys.anthropic || session.user.apiKeys.gemini;
|
||||
}
|
||||
|
||||
export function isGeminiEnabled(session: SessionProps): boolean {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {GuideTour, Subscription, UserProps} from "@/lib/types/user";
|
||||
import {SessionProps} from "@/lib/types/session";
|
||||
|
||||
export function getCurrentSubscription(user: UserProps | null, type: "quill-sense" | "use-your-keys" | "quill-trial"): Subscription | null {
|
||||
export function getCurrentSubscription(user: UserProps | null, type: "ritor-subscription" | "use-your-keys" | "ritor-trial"): Subscription | null {
|
||||
if (!user || !user.subscription || user.subscription.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user