smol changes
This commit is contained in:
parent
771fea4d7b
commit
300bfa8e65
@ -26,7 +26,7 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
useEffect(() => {
|
||||
if (session.userId) {
|
||||
Sentry.setUser({
|
||||
id: session.userId.toString(),
|
||||
id: session.userId,
|
||||
orgId: session.orgId,
|
||||
});
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async ({ req, res }
|
||||
const subscription = await db.subscription.findFirst({
|
||||
where: {
|
||||
organizationId: session.orgId,
|
||||
status: SubscriptionStatus.active,
|
||||
status: { not: SubscriptionStatus.deleted },
|
||||
},
|
||||
});
|
||||
if (!subscription) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { resolver } from "blitz";
|
||||
|
||||
import db, { SubscriptionStatus } from "db";
|
||||
import db from "db";
|
||||
import { getPayments } from "integrations/paddle";
|
||||
|
||||
export default resolver.pipe(resolver.authorize(), async (_ = null, { session }) => {
|
||||
@ -8,13 +8,14 @@ export default resolver.pipe(resolver.authorize(), async (_ = null, { session })
|
||||
return [];
|
||||
}
|
||||
|
||||
const subscription = await db.subscription.findFirst({
|
||||
where: { organizationId: session.orgId, status: SubscriptionStatus.active },
|
||||
});
|
||||
if (!subscription) {
|
||||
const subscriptions = await db.subscription.findMany({ where: { organizationId: session.orgId } });
|
||||
if (subscriptions.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const payments = await getPayments({ subscriptionId: subscription.paddleSubscriptionId });
|
||||
const paymentsBySubscription = await Promise.all(
|
||||
subscriptions.map((subscription) => getPayments({ subscriptionId: subscription.paddleSubscriptionId })),
|
||||
);
|
||||
const payments = paymentsBySubscription.flat();
|
||||
return payments.sort((a, b) => b.payout_date.localeCompare(a.payout_date));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user