From 9dca9f3317e438ca6b836e0dc630e04a14610bc3 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Mon, 30 Aug 2021 10:42:39 +0200 Subject: [PATCH] feat: ensure to access dashboard user's subscription is active. --- client/src/common/registerWizard.js | 8 +- client/src/components/Alert/index.js | 17 +++ client/src/components/Alert/style.module.scss | 32 +++++ client/src/components/Dashboard/Dashboard.js | 42 ++++-- .../components/Dashboard/DashboardContent.js | 4 +- .../Dashboard/DashboardContentRoute.js | 52 +++++-- .../components/Dashboard/DashboardProvider.js | 5 +- .../components/Dashboard/DashboardTopbar.js | 105 +++++++++----- client/src/components/Dashboard/TopbarUser.js | 36 +++-- .../Guards/EnsureSubscriptionIsActive.js | 31 ++++ .../Guards/EnsureSubscriptionsIsActive.js | 31 ++++ .../Guards/EnsureSubscriptionsIsInactive.js | 31 ++++ .../Preferences/PreferencesContentRoute.js | 12 +- .../components/Sidebar/SidebarContainer.js | 13 +- client/src/components/Sidebar/SidebarMenu.js | 21 ++- client/src/components/Subscriptions/index.js | 135 +++++++++++++++++ client/src/components/index.js | 2 + client/src/config/sidebarMenu.js | 2 + .../PaymentViaVoucherDialogContent.js | 9 +- .../PaymentViaVoucherForm.js | 2 +- .../containers/GlobalErrors/GlobalErrors.js | 42 +++--- .../src/containers/Setup/SetupCongratsPage.js | 10 +- .../containers/Setup/SetupInitializingForm.js | 22 +-- .../src/containers/Setup/SetupLeftSection.js | 98 +++++++------ .../Setup/SetupOrganization.schema.js | 15 ++ .../containers/Setup/SetupOrganizationForm.js | 55 +++---- .../containers/Setup/SetupOrganizationPage.js | 62 +++----- .../src/containers/Setup/SetupSubscription.js | 20 +-- .../SetupSubscriptionForm.js | 16 +++ .../SubscriptionPaymentsMethodsSection.js | 19 +++ .../SubscriptionPeriodsSection.js | 43 ++++++ .../SubscriptionPlansSection.js | 41 ++++++ .../containers/Setup/SetupSubscriptionForm.js | 15 -- .../src/containers/Setup/WizardSetupSteps.js | 4 +- .../containers/Subscriptions/BillingForm.js | 52 +++++-- .../containers/Subscriptions/BillingPeriod.js | 4 +- .../Subscriptions/BillingPeriodsInput.js | 50 ++++--- .../containers/Subscriptions/BillingPlan.js | 6 +- .../Subscriptions/BillingPlansForm.js | 23 +-- .../Subscriptions/BillingPlansInput.js | 33 ++--- .../containers/Subscriptions/BillingTab.js | 8 +- .../Subscriptions/SubscriptionTabs.js | 12 +- .../Subscriptions/billingPaymentmethod.js | 6 +- client/src/containers/Subscriptions/utils.js | 8 ++ .../src/containers/Subscriptions/withPlans.js | 3 - .../Subscriptions/withSubscriptionss.js | 19 +++ client/src/hooks/query/settings.js | 13 +- client/src/lang/ar-ly/index.json | 73 +++++++++- client/src/lang/en/index.json | 110 ++++++++------ client/src/routes/dashboard.js | 66 ++++++++- client/src/store/plans/plans.reducer.js | 136 +++++++++++------- client/src/store/plans/plans.selectors.js | 10 -- .../subscription/subscription.selectors.js | 52 +++++-- .../style/containers/Dashboard/Sidebar.scss | 48 ++++--- .../src/style/pages/Billing/BillingPage.scss | 2 +- .../src/style/pages/Dashboard/Dashboard.scss | 11 ++ client/src/style/pages/Setup/Congrats.scss | 4 +- .../src/style/pages/Setup/Organization.scss | 4 +- client/src/style/pages/Setup/SetupPage.scss | 40 ++++-- 59 files changed, 1299 insertions(+), 546 deletions(-) create mode 100644 client/src/components/Alert/index.js create mode 100644 client/src/components/Alert/style.module.scss create mode 100644 client/src/components/Guards/EnsureSubscriptionIsActive.js create mode 100644 client/src/components/Guards/EnsureSubscriptionsIsActive.js create mode 100644 client/src/components/Guards/EnsureSubscriptionsIsInactive.js create mode 100644 client/src/components/Subscriptions/index.js create mode 100644 client/src/containers/Setup/SetupOrganization.schema.js create mode 100644 client/src/containers/Setup/SetupSubscription/SetupSubscriptionForm.js create mode 100644 client/src/containers/Setup/SetupSubscription/SubscriptionPaymentsMethodsSection.js create mode 100644 client/src/containers/Setup/SetupSubscription/SubscriptionPeriodsSection.js create mode 100644 client/src/containers/Setup/SetupSubscription/SubscriptionPlansSection.js delete mode 100644 client/src/containers/Setup/SetupSubscriptionForm.js create mode 100644 client/src/containers/Subscriptions/utils.js create mode 100644 client/src/containers/Subscriptions/withSubscriptionss.js diff --git a/client/src/common/registerWizard.js b/client/src/common/registerWizard.js index 900822f01..9b48223f4 100644 --- a/client/src/common/registerWizard.js +++ b/client/src/common/registerWizard.js @@ -2,15 +2,15 @@ import intl from 'react-intl-universal'; export const getSetupWizardSteps = () => [ { - label: intl.get('Plans & Payment'), + label: intl.get('setup.plan.plans'), }, { - label: intl.get('Initializing'), + label: intl.get('setup.plan.initializing'), }, { - label: intl.get('Getting started'), + label: intl.get('setup.plan.getting_started'), }, { - label: intl.get('Congratulations'), + label: intl.get('setup.plan.congrats'), }, ]; \ No newline at end of file diff --git a/client/src/components/Alert/index.js b/client/src/components/Alert/index.js new file mode 100644 index 000000000..680f8da5a --- /dev/null +++ b/client/src/components/Alert/index.js @@ -0,0 +1,17 @@ +import React from 'react'; +import clsx from 'classnames'; + +import Style from './style.module.scss'; + +export function Alert({ title, description, intent }) { + return ( +
+ {title &&

{title}

} + {description &&

{description}

} +
+ ); +} diff --git a/client/src/components/Alert/style.module.scss b/client/src/components/Alert/style.module.scss new file mode 100644 index 000000000..be866addf --- /dev/null +++ b/client/src/components/Alert/style.module.scss @@ -0,0 +1,32 @@ +.root { + border: 1px solid rgb(223, 227, 230); + padding: 12px; + border-radius: 6px; + margin-bottom: 20px; + + &_danger { + border-color: rgb(249, 198, 198); + background: rgb(255, 248, 248); + + .description { + color: #d95759; + } + + .title { + color: rgb(205, 43, 49); + } + } +} + + +.title { + color: rgb(17, 24, 28); + margin-bottom: 4px; + font-size: 14px; + font-weight: 600; +} + +.description { + color: rgb(104, 112, 118); + margin: 0; +} \ No newline at end of file diff --git a/client/src/components/Dashboard/Dashboard.js b/client/src/components/Dashboard/Dashboard.js index 4f43bb287..5815fafab 100644 --- a/client/src/components/Dashboard/Dashboard.js +++ b/client/src/components/Dashboard/Dashboard.js @@ -12,6 +12,33 @@ import DashboardSplitPane from 'components/Dashboard/DashboardSplitePane'; import GlobalHotkeys from './GlobalHotkeys'; import DashboardProvider from './DashboardProvider'; import DrawersContainer from 'components/DrawersContainer'; +import EnsureSubscriptionIsActive from '../Guards/EnsureSubscriptionIsActive'; + +/** + * Dashboard preferences. + */ +function DashboardPreferences() { + return ( + + + + + + + ); +} + +/** + * Dashboard other routes. + */ +function DashboardAnyPage() { + return ( + + + + + ); +} /** * Dashboard page. @@ -20,19 +47,8 @@ export default function Dashboard() { return ( - - - - - - - - - - - - - + + diff --git a/client/src/components/Dashboard/DashboardContent.js b/client/src/components/Dashboard/DashboardContent.js index a783f1af3..3c75d2288 100644 --- a/client/src/components/Dashboard/DashboardContent.js +++ b/client/src/components/Dashboard/DashboardContent.js @@ -1,7 +1,7 @@ import React from 'react'; import { ErrorBoundary } from 'react-error-boundary'; import DashboardTopbar from 'components/Dashboard/DashboardTopbar'; -import DashboardContentRoute from 'components/Dashboard/DashboardContentRoute'; +import DashboardContentRoutes from 'components/Dashboard/DashboardContentRoute'; import DashboardFooter from 'components/Dashboard/DashboardFooter'; import DashboardErrorBoundary from './DashboardErrorBoundary'; @@ -10,7 +10,7 @@ export default React.forwardRef(({}, ref) => {
- +
diff --git a/client/src/components/Dashboard/DashboardContentRoute.js b/client/src/components/Dashboard/DashboardContentRoute.js index c214699c5..dfdafa711 100644 --- a/client/src/components/Dashboard/DashboardContentRoute.js +++ b/client/src/components/Dashboard/DashboardContentRoute.js @@ -2,8 +2,43 @@ import React from 'react'; import { Route, Switch } from 'react-router-dom'; import { getDashboardRoutes } from 'routes/dashboard'; +import EnsureSubscriptionsIsActive from '../Guards/EnsureSubscriptionsIsActive'; +import EnsureSubscriptionsIsInactive from '../Guards/EnsureSubscriptionsIsInactive'; import DashboardPage from './DashboardPage'; +/** + * Dashboard inner route content. + */ +function DashboardContentRouteContent({ route }) { + const content = ( + + ); + return route.subscriptionActive ? ( + + ) : route.subscriptionInactive ? ( + + ) : ( + content + ); +} + /** * Dashboard content route. */ @@ -14,21 +49,8 @@ export default function DashboardContentRoute() { {routes.map((route, index) => ( - - + + ))} diff --git a/client/src/components/Dashboard/DashboardProvider.js b/client/src/components/Dashboard/DashboardProvider.js index ee2f0ed65..6f454214f 100644 --- a/client/src/components/Dashboard/DashboardProvider.js +++ b/client/src/components/Dashboard/DashboardProvider.js @@ -1,15 +1,12 @@ import React from 'react'; import DashboardLoadingIndicator from './DashboardLoadingIndicator'; -import { useSettings } from 'hooks/query'; /** * Dashboard provider. */ export default function DashboardProvider({ children }) { - const { isLoading } = useSettings(); - return ( - + { children } ) diff --git a/client/src/components/Dashboard/DashboardTopbar.js b/client/src/components/Dashboard/DashboardTopbar.js index 74126d6db..2a4535e6a 100644 --- a/client/src/components/Dashboard/DashboardTopbar.js +++ b/client/src/components/Dashboard/DashboardTopbar.js @@ -23,6 +23,43 @@ import withSettings from 'containers/Settings/withSettings'; import QuickNewDropdown from 'containers/QuickNewDropdown/QuickNewDropdown'; import { compose } from 'utils'; +import withSubscriptions from '../../containers/Subscriptions/withSubscriptions'; + +function DashboardTopbarSubscriptionMessage() { + return ( +
+ + + +
+ ); +} + +function DashboardHamburgerButton({ ...props }) { + return ( +