mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 20:26:17 +00:00
fix: navbar billing redirect
This commit is contained in:
@@ -195,7 +195,7 @@ export const Navbar = () => {
|
|||||||
const matches = useRouterState({ select: (s) => s.matches.at(-1)?.context });
|
const matches = useRouterState({ select: (s) => s.matches.at(-1)?.context });
|
||||||
const breadcrumbs = matches && "breadcrumbs" in matches ? matches.breadcrumbs : undefined;
|
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 });
|
queryClient.removeQueries({ queryKey: authKeys.getAuthToken });
|
||||||
|
|
||||||
const { token, isMfaEnabled, mfaMethod } = await selectOrganization({
|
const { token, isMfaEnabled, mfaMethod } = await selectOrganization({
|
||||||
@@ -208,7 +208,9 @@ export const Navbar = () => {
|
|||||||
setRequiredMfaMethod(mfaMethod);
|
setRequiredMfaMethod(mfaMethod);
|
||||||
}
|
}
|
||||||
toggleShowMfa.on();
|
toggleShowMfa.on();
|
||||||
setMfaSuccessCallback(() => () => handleOrgChange(orgId));
|
setMfaSuccessCallback(() => async () => {
|
||||||
|
await handleOrgChange(orgId, onSuccess);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +221,26 @@ export const Navbar = () => {
|
|||||||
await router.invalidate();
|
await router.invalidate();
|
||||||
await navigateUserToOrg(navigate, orgId);
|
await navigateUserToOrg(navigate, orgId);
|
||||||
queryClient.removeQueries({ queryKey: subOrgQuery.queryKey });
|
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) => {
|
const handleSubOrgChange = async (subOrgId: string) => {
|
||||||
@@ -807,19 +829,13 @@ export const Navbar = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<div className="flex space-x-3">
|
<div className="flex space-x-3">
|
||||||
<Link
|
<Button
|
||||||
to="/organizations/$orgId/billing"
|
colorSchema="primary"
|
||||||
params={{ orgId: rootOrg.id }}
|
variant="solid"
|
||||||
className="inline-flex"
|
onClick={handleNavigateToRootOrgBilling}
|
||||||
>
|
>
|
||||||
<Button
|
Update Payment Method
|
||||||
colorSchema="primary"
|
</Button>
|
||||||
variant="solid"
|
|
||||||
onClick={() => setShowCardDeclinedModal(false)}
|
|
||||||
>
|
|
||||||
Update Payment Method
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
{!isModalIntrusive && (
|
{!isModalIntrusive && (
|
||||||
<Button
|
<Button
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
|
|||||||
Reference in New Issue
Block a user