Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: navbar billing redirect

Piyush Gupta219983d8ed87
diff --git a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
index e9d6031698..25e36edef6 100644
--- a/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx
@@ -195,7 +195,7 @@ export const Navbar = () => {
const matches = useRouterState({ select: (s) => s.matches.at(-1)?.context });
const breadcrumbs = matches && "breadcrumbs" in matches ? matches.breadcrumbs : undefined;
- const handleOrgChange = async (orgId: string) => {
+ const handleOrgChange = async (orgId: string, onSuccess?: () => void | Promise<void>) => {
queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
const { token, isMfaEnabled, mfaMethod } = await selectOrganization({
@@ -208,7 +208,9 @@ export const Navbar = () => {
setRequiredMfaMethod(mfaMethod);
}
toggleShowMfa.on();
- setMfaSuccessCallback(() => () => handleOrgChange(orgId));
+ setMfaSuccessCallback(() => async () => {
+ await handleOrgChange(orgId, onSuccess);
+ });
return;
}
@@ -219,6 +221,26 @@ export const Navbar = () => {
await router.invalidate();
await navigateUserToOrg(navigate, orgId);
queryClient.removeQueries({ queryKey: subOrgQuery.queryKey });
+
+ if (onSuccess) {
+ await onSuccess();
+ }
+ };
+
+ const handleNavigateToRootOrgBilling = async () => {
+ const navigateToBilling = async () => {
+ navigate({
+ to: "/organizations/$orgId/billing",
+ params: { orgId: rootOrg.id }
+ });
+ setShowCardDeclinedModal(false);
+ };
+
+ if (currentOrg.id !== rootOrg.id) {
+ await handleOrgChange(rootOrg.id, navigateToBilling);
+ } else {
+ await navigateToBilling();
+ }
};
const handleSubOrgChange = async (subOrgId: string) => {
@@ -807,19 +829,13 @@ export const Navbar = () => {
</div>
<div className="mt-4">
<div className="flex space-x-3">
- <Link
- to="/organizations/$orgId/billing"
- params={{ orgId: rootOrg.id }}
- className="inline-flex"
+ <Button
+ colorSchema="primary"
+ variant="solid"
+ onClick={handleNavigateToRootOrgBilling}
>
- <Button
- colorSchema="primary"
- variant="solid"
- onClick={() => setShowCardDeclinedModal(false)}
- >
- Update Payment Method
- </Button>
- </Link>
+ Update Payment Method
+ </Button>
{!isModalIntrusive && (
<Button
colorSchema="secondary"