Skip to content

Commit

Permalink
feat(container): add redirection to new billing app
Browse files Browse the repository at this point in the history
ref: MANAGER-15026

Signed-off-by: Maxime Bajeux <[email protected]>
  • Loading branch information
Maxime Bajeux committed Dec 4, 2024
1 parent b0ec63c commit 33a02ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import constants from '../../account-sidebar/UsefulLinks/constants';
const kycIndiaFeature = 'identity-documents';
const kycFraudFeature = 'procedures:fraud';
const newAccount = 'new-account';
const accountFeatures = [kycIndiaFeature, kycFraudFeature, newAccount];
const newBilling = 'new-billing';
const accountFeatures = [kycIndiaFeature, kycFraudFeature, newAccount, newBilling];

export default function AccountSidebar() {
const [menu, setMenu] = useState<SidebarMenuItem>(undefined);
Expand All @@ -40,6 +41,7 @@ export default function AccountSidebar() {

const isEUOrCA = ['EU', 'CA'].includes(region);
const isNewAccountAvailable = !!availability['new-account'];
const isNewBillingAvailable = !!availability['new-billing'];

menu.push({
id: 'back-to-home',
Expand Down Expand Up @@ -83,7 +85,7 @@ export default function AccountSidebar() {
id: 'my-bills',
label: t('sidebar_billing'),
href: navigation.getURL(
'dedicated',
isNewBillingAvailable ? 'new-billing' : 'dedicated',
region === 'US' ? '/billing/payAsYouGo' : '/billing/history',
),
routeMatcher: new RegExp(
Expand All @@ -96,7 +98,7 @@ export default function AccountSidebar() {
id: 'my-services',
label: t('sidebar_billing_services'),
href: navigation.getURL(
'dedicated',
isNewBillingAvailable ? 'new-billing' : 'dedicated',
`/billing/autorenew${isEnterprise ? '/ssh' : '/'}`,
),
routeMatcher: new RegExp('^/billing/autorenew', 'i'),
Expand All @@ -106,13 +108,13 @@ export default function AccountSidebar() {
menu.push({
id: 'payment-method',
label: t('sidebar_billing_payment'),
href: navigation.getURL('dedicated', '/billing/payment'),
href: navigation.getURL(isNewBillingAvailable ? 'new-billing' : 'dedicated', '/billing/payment'),
routeMatcher: new RegExp('^/billing/payment[^s]'),
});
menu.push({
id: 'my-orders',
label: t('sidebar_orders'),
href: navigation.getURL('dedicated', '/billing/orders'),
href: navigation.getURL(isNewBillingAvailable ? 'new-billing' : 'dedicated', '/billing/orders'),
routeMatcher: new RegExp('^/billing/orders'),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const UserAccountMenu = ({
false,
);
const [isNewAccountAvailable, setIsNewAccountAvailable] = useState<boolean>(false);
const [isNewBillingAvailable, setIsNewBillingAvailable] = useState<boolean>(false);
const user = shell
.getPlugin('environment')
.getEnvironment()
Expand Down Expand Up @@ -75,7 +76,7 @@ const UserAccountMenu = ({
const getAllLinks = useMemo(
() => async () => {
let isIdentityDocumentsAvailable = false;
const featureAvailability = await fetchFeatureAvailabilityData(['new-account', 'identity-documents', 'procedures:fraud']);
const featureAvailability = await fetchFeatureAvailabilityData(['new-billing', 'new-account', 'identity-documents', 'procedures:fraud']);
if (featureAvailability['identity-documents']) {
const { status } = await reketInstance.get(`/me/procedure/identity`);
isIdentityDocumentsAvailable = ['required', 'open'].includes(status);
Expand All @@ -86,6 +87,7 @@ const UserAccountMenu = ({
}

setIsNewAccountAvailable(!!featureAvailability['new-account'])
setIsNewBillingAvailable(!!featureAvailability['new-billing'])

if (isNewAccountAvailable) {
setSupportLink(getUrl('new-account', '#/useraccount/support/level'));
Expand All @@ -96,6 +98,9 @@ const UserAccountMenu = ({
if (['user-account-menu-profile', 'myCommunications', 'myContacts'].includes(link.key)) {
link.app = isNewAccountAvailable ? 'new-account' : 'dedicated';
}
if (['myInvoices', 'myServices', 'myPaymentMethods', 'myCommands'].includes(link.key)) {
link.app = isNewBillingAvailable ? 'new-billing' : 'dedicated';
}
return link;
}),
...(isIdentityDocumentsAvailable
Expand Down
16 changes: 12 additions & 4 deletions packages/manager/apps/container/src/core/routing/redirections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function Rewrite({ to }: { to: string }): JSX.Element {

export function Redirections(configuration: Record<string, Application>): JSX.Element {
const isNewAccountAvailable = !!configuration?.['new-account'];
const isNewBillingAvailable = !!configuration?.['new-billing'];

return (
<>
Expand Down Expand Up @@ -46,10 +47,17 @@ export function Redirections(configuration: Record<string, Application>): JSX.El
element={<Rewrite to="/dedicated/useraccount/*" />}
/>
)}
<Route
path="/billing/*"
element={<Rewrite to="/dedicated/billing/*" />}
/>
{isNewBillingAvailable ? (
<Route
path="/dedicated/billing/*"
element={<Rewrite to="/billing/*" />}
/>
) : (
<Route
path="/billing/*"
element={<Rewrite to="/dedicated/billing/*" />}
/>
)}
<Route path="/freefax">
<Route path=":id/*" element={<Rewrite to="/telecom/freefax/:id/*" />} />
<Route index element={<Rewrite to="/telecom/freefax/" />} />
Expand Down

0 comments on commit 33a02ff

Please sign in to comment.