feat: setup subscriptions

This commit is contained in:
Henry
2025-09-01 22:17:09 +01:00
parent fecc6cf742
commit a7c68db90e
16 changed files with 6045 additions and 3445 deletions

View File

@@ -100,6 +100,19 @@ export const memberRouter = createTRPCRouter({
});
}
if (process.env.NEXT_PUBLIC_KAN_ENV === "cloud") {
const subscriptions = await ctx.auth.api.listActiveSubscriptions({
userId,
});
// get the active subscription
const activeSubscription = subscriptions.find(
(sub) => sub.status === "active" || sub.status === "trialing",
);
// @todo: update the subscription with the new seat
}
return invite;
}),
delete: protectedProcedure

View File

@@ -28,10 +28,17 @@ const createAuthWithHeaders = (
api: {
getSession: () => auth.api.getSession({ headers }),
signInMagicLink: (input: { email: string; callbackURL: string }) =>
// @ts-expect-error - types need fixing
auth.api.signInMagicLink({
headers,
body: { email: input.email, callbackURL: input.callbackURL },
}),
listActiveSubscriptions: (input: { userId: string }) =>
// @ts-expect-error - types need fixing
auth.api.listActiveSubscriptions({
headers,
query: { referenceId: input.userId },
}),
},
};
};