Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions packages/app/src/app/overmind/internalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
TabType,
} from '@codesandbox/common/lib/types';
import history from 'app/utils/history';
import { patronUrl } from '@codesandbox/common/lib/utils/url-generator';
import { NotificationMessage } from '@codesandbox/notifications/lib/state';
import { NotificationStatus } from '@codesandbox/notifications';
import { hasPermission } from '@codesandbox/common/lib/utils/permission';
Expand Down Expand Up @@ -492,32 +491,6 @@ export const handleError = (
state.signInModalOpen = true;
},
};
} else if (error.message.startsWith('You reached the maximum of')) {
effects.analytics.track('Non-Patron Sandbox Limit Reached', {
errorMessage: error.message,
});

notificationActions.primary = {
label: 'Open Patron Page',
run: () => {
window.open(patronUrl(), '_blank');
},
};
} else if (
error.message.startsWith(
'You reached the limit of server sandboxes, you can create more server sandboxes as a patron.'
)
) {
effects.analytics.track('Non-Patron Server Sandbox Limit Reached', {
errorMessage: error.message,
});

notificationActions.primary = {
label: 'Open Patron Page',
run: () => {
window.open(patronUrl(), '_blank');
},
};
} else if (
error.message.startsWith(
'You reached the limit of server sandboxes, we will increase the limit in the future. Please contact support@codesandbox.io for more server sandboxes.'
Expand Down
94 changes: 0 additions & 94 deletions packages/app/src/app/overmind/namespaces/patron/actions.ts
Original file line number Diff line number Diff line change
@@ -1,100 +1,6 @@
import { Context } from 'app/overmind';
import { withLoadApp } from 'app/overmind/factories';
import { StripeErrorCode } from '@codesandbox/common/lib/types';
import { NotificationStatus } from '@codesandbox/notifications';

export const patronMounted = withLoadApp();

export const priceChanged = (
{ state }: Context,
{ price }: { price: number }
) => {
state.patron.price = price;
};

export const createSubscriptionClicked = async (
{ state, effects, actions }: Context,
{
token,
coupon,
duration,
}: {
token: string;
coupon: string;
duration: 'yearly' | 'monthly';
}
) => {
effects.analytics.track('Create Patron Subscription', { duration });
state.patron.error = null;
state.patron.isUpdatingSubscription = true;
try {
state.user = await effects.api.createPatronSubscription(
token,
state.patron.price,
duration,
coupon
);
effects.notificationToast.success('Thank you very much for your support!');
} catch (error) {
if (
error.error_code &&
error.error_code === StripeErrorCode.REQUIRES_ACTION
) {
try {
await effects.stripe.handleCardPayment(error.data.client_secret);
state.user = await effects.api.getCurrentUser();
state.patron.error = null;
} catch (e) {
actions.internal.handleError({
message: 'Could not create subscription',
error: e,
});

state.patron.error = e.message;

effects.analytics.track('Create Subscription Error', {
error: e.message,
});
}
} else {
actions.internal.handleError({
message: 'Could not create subscription',
error,
});

state.patron.error = error.message;

effects.analytics.track('Create Subscription Error', {
error: error.message,
});
}
}
state.patron.isUpdatingSubscription = false;
};

export const updateSubscriptionClicked = async (
{ state, effects }: Context,
{
coupon,
}: {
coupon: string;
}
) => {
effects.analytics.track('Update Patron Subscription');
state.patron.error = null;
state.patron.isUpdatingSubscription = true;
try {
state.user = await effects.api.updatePatronSubscription(
state.patron.price,
coupon
);
effects.notificationToast.success('Subscription updated!');
} catch (error) {
state.patron.error = error.message;
}
state.patron.isUpdatingSubscription = false;
};

export const cancelSubscriptionClicked = async ({
state,
effects,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 0 additions & 13 deletions packages/app/src/app/pages/Patron/PricingModal/Badge/elements.ts

This file was deleted.

Loading