mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-15 05:45:20 +00:00
* add side bar nav in settings page * improve styling of members page * wip adding stripe checkout button * wip onboarding flow * add stripe subscription id to org * save stripe session id and add manage subscription button in settings * properly block access to pages if user isn't in an org * wip add paywall * Domain support * add back paywall and also add support for incrememnting seat count on invite redemption * prevent self invite * action button styling in settings and toast on copy * add ability to remove member from org * move stripe product id to env var * add await for blocking loop in backend * add subscription info to billing page * handle trial case in billing info page * add trial duration indicator to nav bar * check if domain starts or ends with dash * remove unused no org component * remove package lock file and fix prisma dep version * revert dep version updates * fix yarn.lock * add auth and membership check to fetchSubscription * properly handle invite redeem with no valid subscription case * change back fetch subscription to not require org membership * add back subscription check in invite redeem page --------- Co-authored-by: bkellam <bshizzle1234@gmail.com>
51 lines
No EOL
1.5 KiB
TypeScript
51 lines
No EOL
1.5 KiB
TypeScript
import { ErrorPage } from "../components/errorPage";
|
|
import { auth } from "@/auth";
|
|
import { getUser } from "@/data/user";
|
|
import { createOrg, switchActiveOrg, fetchStripeSession } from "../../../actions";
|
|
import { isServiceError } from "@/lib/utils";
|
|
import { redirect } from 'next/navigation';
|
|
|
|
interface OnboardCompleteProps {
|
|
searchParams?: {
|
|
session_id?: string;
|
|
org_name?: string;
|
|
org_domain?: string;
|
|
};
|
|
}
|
|
|
|
export default async function OnboardComplete({ searchParams }: OnboardCompleteProps) {
|
|
const sessionId = searchParams?.session_id;
|
|
const orgName = searchParams?.org_name;
|
|
const orgDomain = searchParams?.org_domain;
|
|
|
|
const session = await auth();
|
|
let user = undefined;
|
|
if (!session) {
|
|
return null;
|
|
}
|
|
|
|
user = await getUser(session.user.id);
|
|
if (!user) {
|
|
return null;
|
|
}
|
|
|
|
if (!sessionId || !orgName || !orgDomain) {
|
|
console.error("Missing required parameters");
|
|
return <ErrorPage />;
|
|
}
|
|
|
|
const stripeSession = await fetchStripeSession(sessionId);
|
|
if(stripeSession.payment_status !== "paid") {
|
|
console.error("Invalid stripe session");
|
|
return <ErrorPage />;
|
|
}
|
|
|
|
const stripeCustomerId = stripeSession.customer as string;
|
|
const res = await createOrg(orgName, orgDomain, stripeCustomerId);
|
|
if (isServiceError(res)) {
|
|
console.error("Failed to create org");
|
|
return <ErrorPage />;
|
|
}
|
|
|
|
redirect("/");
|
|
} |