From 0e062c1093ab21aa2820913f9ab939d55726fd3e Mon Sep 17 00:00:00 2001 From: Abhinav-grd Date: Thu, 18 Mar 2021 20:52:34 +0530 Subject: [PATCH] renamed subcription service to billing service --- src/components/Sidebar.tsx | 8 +++----- src/pages/gallery/components/PlanSelector.tsx | 9 +++------ src/pages/gallery/index.tsx | 6 +++--- src/pages/success.tsx | 8 +++----- .../{subscriptionService.ts => billingService.ts} | 4 ++-- src/utils/billingUtil.ts | 2 +- src/utils/strings/englishConstants.tsx | 2 +- 7 files changed, 16 insertions(+), 23 deletions(-) rename src/services/{subscriptionService.ts => billingService.ts} (98%) diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index c4c44eeaa..955276b77 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -3,9 +3,7 @@ import React, { useEffect, useState } from 'react'; import { slide as Menu } from 'react-burger-menu'; import ConfirmDialog from 'components/ConfirmDialog'; import Spinner from 'react-bootstrap/Spinner'; -import subscriptionService, { - Subscription, -} from 'services/subscriptionService'; +import billingService, { Subscription } from 'services/billingService'; import constants from 'utils/strings/constants'; import { logoutUser } from 'services/userService'; import { getData, LS_KEYS } from 'utils/storage/localStorage'; @@ -49,7 +47,7 @@ export default function Sidebar(props: Props) { if (!isOpen) { return; } - const usage = await subscriptionService.getUsage(); + const usage = await billingService.getUsage(); SetUsage(usage); setSubscription(getUserSubscription()); @@ -68,7 +66,7 @@ export default function Sidebar(props: Props) { setConfirmModalView(false); setIsOpen(false); try { - await subscriptionService.cancelSubscription(); + await billingService.cancelSubscription(); } catch (e) { props.setBannerMessage({ message: constants.SUBSCRIPTION_CANCEL_FAILED, diff --git a/src/pages/gallery/components/PlanSelector.tsx b/src/pages/gallery/components/PlanSelector.tsx index 3ddc9c474..46915c89c 100644 --- a/src/pages/gallery/components/PlanSelector.tsx +++ b/src/pages/gallery/components/PlanSelector.tsx @@ -2,10 +2,7 @@ import React, { useState } from 'react'; import { Modal, Spinner } from 'react-bootstrap'; import constants from 'utils/strings/constants'; import styled from 'styled-components'; -import subscriptionService, { - Plan, - Subscription, -} from 'services/subscriptionService'; +import billingService, { Plan, Subscription } from 'services/billingService'; import { getData, LS_KEYS } from 'utils/storage/localStorage'; import { convertBytesToGBs, @@ -56,9 +53,9 @@ function PlanSelector(props: Props) { if (isUserRenewingPlan(plan, subscription)) { return; } - await subscriptionService.updateSubscription(plan.stripeID); + await billingService.updateSubscription(plan.stripeID); } else { - await subscriptionService.buySubscription(plan.stripeID); + await billingService.buySubscription(plan.stripeID); } bannerMessage = { message: constants.SUBSCRIPTION_UPDATE_SUCCESS, diff --git a/src/pages/gallery/index.tsx b/src/pages/gallery/index.tsx index 7974b1f39..eb817c07f 100644 --- a/src/pages/gallery/index.tsx +++ b/src/pages/gallery/index.tsx @@ -25,7 +25,7 @@ import { import constants from 'utils/strings/constants'; import AlertBanner from './components/AlertBanner'; import { Alert, Button, Jumbotron } from 'react-bootstrap'; -import subscriptionService from 'services/subscriptionService'; +import billingService from 'services/billingService'; import PlanSelector from './components/PlanSelector'; import { hasRenewingPaidPlan } from 'utils/billingUtil'; @@ -180,8 +180,8 @@ export default function Gallery(props: Props) { data ); const favItemIds = await getFavItemIds(data); - await subscriptionService.updatePlans(); - await subscriptionService.syncSubscription(); + await billingService.updatePlans(); + await billingService.syncSubscription(); setCollections(nonEmptyCollections); if (isUpdated) { diff --git a/src/pages/success.tsx b/src/pages/success.tsx index ae752018a..fae2dca78 100644 --- a/src/pages/success.tsx +++ b/src/pages/success.tsx @@ -2,9 +2,7 @@ import Container from 'components/Container'; import router from 'next/router'; import { useEffect, useState } from 'react'; import { Button, Spinner } from 'react-bootstrap'; -import subscriptionService, { - Subscription, -} from 'services/subscriptionService'; +import billingService, { Subscription } from 'services/billingService'; import constants from 'utils/strings/constants'; export default function SuccessRedirect() { @@ -14,7 +12,7 @@ export default function SuccessRedirect() { const sessionId = urlParams.get('session_id'); if (sessionId) { (async () => { - const subscription = await subscriptionService.verifySubscription( + const subscription = await billingService.verifySubscription( sessionId ); setSubscription(subscription); @@ -28,7 +26,7 @@ export default function SuccessRedirect() { <>

Your payment succeeded

- {constants.PAID_SUBSCRIPTION_INFO( + {constants.RENEWAL_ACTIVE_SUBSCRIPTION_INFO( subscription?.expiryTime )}

diff --git a/src/services/subscriptionService.ts b/src/services/billingService.ts similarity index 98% rename from src/services/subscriptionService.ts rename to src/services/billingService.ts index 3af8a19a9..7d21322e7 100644 --- a/src/services/subscriptionService.ts +++ b/src/services/billingService.ts @@ -24,7 +24,7 @@ export interface Plan { stripeID: string; } export const FREE_PLAN = 'free'; -class SubscriptionService { +class billingService { private stripe; constructor() { let publishableKey = process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY; @@ -168,4 +168,4 @@ class SubscriptionService { } } -export default new SubscriptionService(); +export default new billingService(); diff --git a/src/utils/billingUtil.ts b/src/utils/billingUtil.ts index 22f947121..f93d9b153 100644 --- a/src/utils/billingUtil.ts +++ b/src/utils/billingUtil.ts @@ -1,4 +1,4 @@ -import { FREE_PLAN, Plan, Subscription } from 'services/subscriptionService'; +import { FREE_PLAN, Plan, Subscription } from 'services/billingService'; import { getData, LS_KEYS } from './storage/localStorage'; export function convertBytesToGBs(bytes, precision?): string { diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 27429aef7..c3adf02f0 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -1,4 +1,4 @@ -import { Subscription } from 'services/subscriptionService'; +import { Subscription } from 'services/billingService'; import { template } from './vernacularStrings'; /**