Skip to content

Dry up subscription status #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 24, 2025
Merged

Dry up subscription status #382

merged 10 commits into from
Feb 24, 2025

Conversation

sodic
Copy link
Collaborator

@sodic sodic commented Feb 21, 2025

Subscription statuses were repeated all over the app.

They're now defined in a single place and imported where necessary.

@sodic sodic changed the base branch from main to filip-refactor-users-table February 21, 2025 13:37
Comment on lines 92 to 104
const selectedValue = e.target.value == '' ? null : e.target.value;

if (selectedValue === 'clear-all') {
setSubcriptionStatusFilter([]);
} else {
setSubcriptionStatusFilter((prevValue) => {
if (prevValue.includes(selectedValue as SubscriptionStatus)) {
return prevValue.filter((val) => val !== selectedValue);
} else {
return [...prevValue, selectedValue as SubscriptionStatus];
}
});
}
Copy link
Collaborator Author

@sodic sodic Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ideal but best we can do for the time being.

// becomes 'unpaid' and finally 'expired' (i.e. 'deleted').
// NOTE: ability to pause or trial a subscription is something that has to be additionally configured in the lemon squeezy dashboard.
// becomes 'unpaid' and finally 'expired' (i.e. 'deleted').
// NOTE: ability to pause or trial a subscription is something that has to be additionally configured in the lemon squeezy dashboard.
// If you do enable these features, make sure to handle these statuses here.
if (status === 'past_due' || status === 'active') {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't change these because they're lemonSqueezy status strings, not ours (although lexically the same at the moment).

Same goes for Stripe.

@sodic sodic requested review from vincanger and infomiho February 21, 2025 14:03
@sodic sodic mentioned this pull request Feb 21, 2025
3 tasks
@sodic sodic changed the title Filip dry subscription status Dry up subscription status Feb 21, 2025
@@ -106,7 +109,7 @@ async function handleSubscriptionCreated(data: Subscription, userId: string, pri
lemonSqueezyId,
userId,
subscriptionPlan: planId,
subscriptionStatus: status,
subscriptionStatus: status as SubscriptionStatus,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some of these assertions won't be necessary once we merge #377

@@ -1,6 +1,11 @@
import { requireNodeEnvVar } from '../server/utils';

export type SubscriptionStatus = 'past_due' | 'cancel_at_period_end' | 'active' | 'deleted';
export enum SubscriptionStatus {
Copy link
Collaborator

@infomiho infomiho Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the enum for the definition, and referenced the enum in Zod during validation using z.nativeEnum.

Copy link
Collaborator

@infomiho infomiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We gonna have some merge conflicts, but I think it's better for me to merge the validations after you merge this because my validations are based on existing code which you improve in this PR.

Base automatically changed from filip-refactor-users-table to main February 24, 2025 16:03
@sodic sodic merged commit dd334e2 into main Feb 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants