Skip to content

Commit

Permalink
Sort Active Subscriptions (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-gordon authored Sep 15, 2023
1 parent 7765812 commit e5dedd7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/customer-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export default async function customerInfo(
return validStripePrices.includes(priceId);
});

// Sort active subscriptions to the top
validSubscriptions.sort((a, b) => {
if (a.status === "active") return -1;
if (b.status === "active") return 1;
return 0;
});

const subscription = validSubscriptions.length
? validSubscriptions[0]
: undefined;
Expand Down

0 comments on commit e5dedd7

Please sign in to comment.