Skip to content

Commit

Permalink
fix: Remove fetchStripeCustomerPortalURL related logic
Browse files Browse the repository at this point in the history
  • Loading branch information
julianajlk committed Jul 30, 2024
1 parent 6fe4f62 commit a8da25d
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/store/__mocks__/mockEmptyStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = {
loading: false,
loadingError: false,
subscriptions: [],
stripeCustomerPortalURL: null,
stripeError: false,
stripeLoading: false,
shouldShowSubscriptionsSection: true,
Expand Down
1 change: 0 additions & 1 deletion src/store/__mocks__/subscriptions.mockStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module.exports = {
loadingError: false,
stripeLoading: false,
stripeError: false,
stripeCustomerPortalURL: null,
shouldShowSubscriptionsSection: true,
subscriptions: [
{
Expand Down
3 changes: 0 additions & 3 deletions src/subscriptions/actions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { createRoutine } from 'redux-saga-routines';

export const fetchSubscriptions = createRoutine('FETCH_SUBSCRIPTIONS');
export const fetchStripeCustomerPortalURL = createRoutine(
'FETCH_STRIPE_CUSTOMER_PORTAL_URL',
);

export const clearStripeError = () => ({
type: 'CLEAR_STRIPE_ERROR',
Expand Down
24 changes: 1 addition & 23 deletions src/subscriptions/reducer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { fetchStripeCustomerPortalURL, fetchSubscriptions } from './actions';
import { fetchSubscriptions } from './actions';

export const initialState = {
loading: true,
loadingError: false,
subscriptions: [],
stripeCustomerPortalURL: null,
stripeError: false,
stripeLoading: false,
shouldShowSubscriptionsSection: true,
Expand Down Expand Up @@ -33,27 +32,6 @@ const subscriptionsReducer = (state = initialState, action = {}) => {
...state,
loading: false,
};
case fetchStripeCustomerPortalURL.TRIGGER:
return {
...state,
stripeLoading: true,
stripeCustomerPortalURL: null,
};
case fetchStripeCustomerPortalURL.SUCCESS:
return {
...state,
stripeCustomerPortalURL: action.payload,
};
case fetchStripeCustomerPortalURL.FAILURE:
return {
...state,
stripeError: true,
};
case fetchStripeCustomerPortalURL.FULFILL:
return {
...state,
stripeLoading: false,
};
case 'CLEAR_STRIPE_ERROR':
return {
...state,
Expand Down
15 changes: 2 additions & 13 deletions src/subscriptions/saga.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { put, takeLatest, call } from 'redux-saga/effects';

import { createFetchHandler } from '../utils';

import { fetchSubscriptions, fetchStripeCustomerPortalURL, hideSubscriptionSection } from './actions';
import { getSubscriptions, getStripeCustomerPortalURL } from './service';
import { fetchSubscriptions, hideSubscriptionSection } from './actions';
import { getSubscriptions } from './service';

function* handleFetchSubscriptions() {
try {
Expand All @@ -27,15 +25,6 @@ function* handleFetchSubscriptions() {
}
}

const handleFetchStripeCustomerPortalURL = createFetchHandler(
fetchStripeCustomerPortalURL,
getStripeCustomerPortalURL,
);

export default function* subscriptionSaga() {
yield takeLatest(fetchSubscriptions.TRIGGER, handleFetchSubscriptions);
yield takeLatest(
fetchStripeCustomerPortalURL.TRIGGER,
handleFetchStripeCustomerPortalURL,
);
}
10 changes: 0 additions & 10 deletions src/subscriptions/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,3 @@ export async function getSubscriptions() {
: subscription.subscription_state?.toLowerCase(),
}));
}

export async function getStripeCustomerPortalURL() {
const httpClient = getAuthenticatedHttpClient();

const stripePortalURL = createURL('/stripe-portal/');

const { data } = await httpClient.post(stripePortalURL);

return data.portal_url;
}

0 comments on commit a8da25d

Please sign in to comment.