fix: make sure we were able to detect the pricing plan correct when not in a org
This commit is contained in:
parent
6f0499c657
commit
8305134a8e
@ -89,7 +89,7 @@ export async function POST(req: Request) {
|
||||
.insert(subscriptionStatusTable)
|
||||
.values({
|
||||
stripe_customer_id: customerId,
|
||||
org_id: orgId,
|
||||
org_id: orgId && orgId.length > 0 && orgId != "null" ? orgId : null,
|
||||
user_id: userId,
|
||||
subscription_id: subscriptionId,
|
||||
plan: plan as "pro" | "enterprise" | "basic",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { db } from "@/db/db";
|
||||
import { and, desc, eq, isNull } from "drizzle-orm";
|
||||
import { and, desc, eq, isNull, or } from "drizzle-orm";
|
||||
import { subscriptionStatusTable } from "@/db/schema";
|
||||
import { APIKeyUserType } from "@/server/APIKeyBodyRequest";
|
||||
import { auth } from "@clerk/nextjs";
|
||||
@ -23,7 +23,7 @@ export async function getCurrentPlan({ user_id, org_id }: APIKeyUserType) {
|
||||
eq(subscriptionStatusTable.user_id, user_id),
|
||||
org_id
|
||||
? eq(subscriptionStatusTable.org_id, org_id)
|
||||
: isNull(subscriptionStatusTable.org_id),
|
||||
: or(isNull(subscriptionStatusTable.org_id), eq(subscriptionStatusTable.org_id, "")),
|
||||
),
|
||||
orderBy: desc(subscriptionStatusTable.created_at),
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user