2021-09-30 22:59:35 +00:00
|
|
|
import { resolver } from "blitz";
|
2021-09-26 22:44:26 +00:00
|
|
|
|
2021-10-01 22:19:06 +00:00
|
|
|
import db, { SubscriptionStatus } from "db";
|
2021-09-26 22:44:26 +00:00
|
|
|
|
2021-09-30 22:59:35 +00:00
|
|
|
export default resolver.pipe(resolver.authorize(), async (_ = null, { session }) => {
|
2021-09-26 22:44:26 +00:00
|
|
|
if (!session.orgId) return null;
|
|
|
|
|
2021-10-01 22:19:06 +00:00
|
|
|
return db.subscription.findFirst({
|
|
|
|
where: {
|
|
|
|
organizationId: session.orgId,
|
|
|
|
status: { not: SubscriptionStatus.deleted },
|
|
|
|
},
|
|
|
|
});
|
2021-09-30 22:59:35 +00:00
|
|
|
});
|