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