feat: setup subscriptions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 },
|
||||
}),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user