Skip to content

Commit

Permalink
feat: Move billing to preferences (#566)
Browse files Browse the repository at this point in the history
* feat: move billing to preferences

* chore: remove the commented lines
  • Loading branch information
abouolia authored Aug 6, 2024
1 parent 3cbcfac commit f21b01b
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 32 deletions.
11 changes: 1 addition & 10 deletions packages/webapp/src/components/Dashboard/TopbarUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useAuthActions } from '@/hooks/state';

import withDialogActions from '@/containers/Dialog/withDialogActions';

import { useAuthenticatedAccount, useDashboardMeta } from '@/hooks/query';
import { useAuthenticatedAccount } from '@/hooks/query';
import { firstLettersArgs, compose } from '@/utils';

/**
Expand All @@ -31,9 +31,6 @@ function DashboardTopbarUser({
// Retrieve authenticated user information.
const { data: user } = useAuthenticatedAccount();

const { data: dashboardMeta } = useDashboardMeta({
keepPreviousData: true,
});
const onClickLogout = () => {
setLogout();
};
Expand Down Expand Up @@ -61,12 +58,6 @@ function DashboardTopbarUser({
}
/>
<MenuDivider />
{dashboardMeta.is_bigcapital_cloud && (
<MenuItem
text={'Billing'}
onClick={() => history.push('/billing')}
/>
)}
<MenuItem
text={<T id={'keyboard_shortcuts'} />}
onClick={onKeyboardShortcut}
Expand Down
4 changes: 4 additions & 0 deletions packages/webapp/src/constants/preferencesMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export default [
disabled: false,
href: '/preferences/general',
},
{
text: 'Billing',
href: '/preferences/billing',
},
{
text: <T id={'users'} />,
href: '/preferences/users',
Expand Down
28 changes: 20 additions & 8 deletions packages/webapp/src/containers/Subscriptions/BillingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
// @ts-nocheck
import { useEffect } from 'react';
import * as R from 'ramda';
import { Redirect } from 'react-router-dom';
import { BillingPageBoot } from './BillingPageBoot';
import { BillingPageContent } from './BillingPageContent';
import { DashboardInsider } from '@/components';
import { useDashboardMeta } from '@/hooks/query';
import withAlertActions from '../Alert/withAlertActions';
import withDashboardActions from '../Dashboard/withDashboardActions';

function BillingPageRoot({ openAlert }) {
function BillingPageRoot({
openAlert,

// #withAlertActions
changePreferencesPageTitle,
}) {
const { data: dashboardMeta } = useDashboardMeta({
keepPreviousData: true,
});

useEffect(() => {
changePreferencesPageTitle('Billing');
}, [changePreferencesPageTitle]);

// In case the edition is not Bigcapital Cloud, redirect to the homepage.
if (!dashboardMeta.is_bigcapital_cloud) {
return <Redirect to={{ pathname: '/' }} />;
}

return (
<DashboardInsider>
<BillingPageBoot>
<BillingPageContent />
</BillingPageBoot>
</DashboardInsider>
<BillingPageBoot>
<BillingPageContent />
</BillingPageBoot>
);
}

export default R.compose(withAlertActions)(BillingPageRoot);
export default R.compose(
withAlertActions,
withDashboardActions,
)(BillingPageRoot);
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.root {
display: flex;
flex-direction: column;
padding: 32px 40px;
min-width: 800px;
max-width: 900px;
width: 75%;
padding: 20px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
width: 450px;
background: #fff;
border-radius: 5px;
box-shadow: 0 -8px 0 0px #BFCCD6, rgb(0 8 36 / 9%) 0px 4px 20px -5px;
border: 1px solid #C4D2D7;
box-shadow: 0 -6px 0 0px #ccd6dd;
border: 1px solid #d2dde1;
min-height: 420px;
display: flex;
flex-direction: column;
Expand Down
7 changes: 0 additions & 7 deletions packages/webapp/src/routes/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1231,13 +1231,6 @@ export const getDashboardRoutes = () => [
breadcrumb: 'Bank Rules',
subscriptionActive: [SUBSCRIPTION_TYPE.MAIN],
},
{
path: '/billing',
component: lazy(() => import('@/containers/Subscriptions/BillingPage')),
pageTitle: 'Billing',
breadcrumb: 'Billing',
subscriptionActive: [SUBSCRIPTION_TYPE.MAIN],
},
// Homepage
{
path: `/`,
Expand Down
10 changes: 9 additions & 1 deletion packages/webapp/src/routes/preferences.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-nocheck
import { lazy } from 'react';
import General from '@/containers/Preferences/General/General';
import Users from '../containers/Preferences/Users/Users';
import Roles from '../containers/Preferences/Users/Roles/RolesForm/RolesFormPage';
Expand All @@ -12,7 +13,9 @@ import Branches from '../containers/Preferences/Branches';
import Invoices from '../containers/Preferences/Invoices/PreferencesInvoices';
import { PreferencesCreditNotes } from '../containers/Preferences/CreditNotes/PreferencesCreditNotes';
import { PreferencesEstimates } from '@/containers/Preferences/Estimates/PreferencesEstimates';
import{ PreferencesReceipts } from '@/containers/Preferences/Receipts/PreferencesReceipts'
import { PreferencesReceipts } from '@/containers/Preferences/Receipts/PreferencesReceipts';

import BillingPage from '@/containers/Subscriptions/BillingPage';

const BASE_URL = '/preferences';

Expand Down Expand Up @@ -87,6 +90,11 @@ export default [
component: SMSIntegration,
exact: true,
},
{
path: `${BASE_URL}/billing`,
component: BillingPage,
exact: true,
},
{
path: `${BASE_URL}/`,
component: DefaultRoute,
Expand Down

0 comments on commit f21b01b

Please sign in to comment.