Skip to content

Commit

Permalink
Merge pull request #1213 from internxt/bugfix/PB-2418-upgrade-now-but…
Browse files Browse the repository at this point in the history
…ton-not-working

[PB-2418] Upgrade now" button below space gauge doesn't redirect correctly
  • Loading branch information
CandelR authored Jul 30, 2024
2 parents 2317ff2 + 62ebf59 commit 66ded65
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/app/drive/components/PlanUsage/PlanUsage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import navigationService from 'app/core/services/navigation.service';
import limitService from 'app/drive/services/limit.service';
import { bytesToString } from 'app/drive/services/size.service';
import usageService from 'app/drive/services/usage.service';
import navigationService from 'app/core/services/navigation.service';
import { AppView } from 'app/core/types';
import { useTranslationContext } from 'app/i18n/provider/TranslationProvider';
import { useDispatch } from 'react-redux';
import { useAppSelector } from '../../../store/hooks';
import { uiActions } from '../../../store/slices/ui';
import workspacesSelectors from '../../../store/slices/workspaces/workspaces.selectors';

export default function PlanUsage({
limit,
Expand All @@ -19,13 +22,20 @@ export default function PlanUsage({
className?: string;
}): JSX.Element {
const { translate } = useTranslationContext();
const dispatch = useDispatch();
const usagePercent = usageService.getUsagePercent(usage, limit);
const selectedWorkspace = useAppSelector(workspacesSelectors.getSelectedWorkspace);

const isLimitReached = usage >= limit;
const componentColor = isLimitReached ? 'bg-red' : 'bg-primary';

const onUpgradeButtonClicked = () => {
navigationService.push(AppView.Preferences, { tab: 'plans' });
navigationService.openPreferencesDialog({
section: 'account',
subsection: 'plans',
workspaceUuid: selectedWorkspace?.workspaceUser.workspaceId,
});
dispatch(uiActions.setIsPreferencesDialogOpen(true));
};

return (
Expand Down

0 comments on commit 66ded65

Please sign in to comment.