Skip to content

Commit d247b57

Browse files
committed
fix: url
1 parent f666733 commit d247b57

File tree

1 file changed

+7
-2
lines changed
  • src/components/billing/pricing-modal

1 file changed

+7
-2
lines changed

src/components/billing/pricing-modal/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { PricingPlanInterval, PricingType } from "@/prisma/enums";
1212
import { api } from "@/trpc/react";
1313
import type { TypeZodStripePortalMutationSchema } from "@/trpc/routers/billing-router/schema";
1414
import type { RouterOutputs } from "@/trpc/shared";
15-
import { useRouter, useSearchParams } from "next/navigation";
15+
import { usePathname, useRouter, useSearchParams } from "next/navigation";
1616
import { useEffect, useState } from "react";
1717
import { EmptyPlans } from "./empty-plans";
1818
import { PricingButton } from "./pricing-button";
@@ -178,19 +178,24 @@ export function PricingModal({ products, subscription }: PricingModalProps) {
178178
const [open, setOpen] = useState(false);
179179
const router = useRouter();
180180
const searchParams = useSearchParams();
181+
const path = usePathname();
181182
const upgrade = searchParams.get("upgrade");
183+
182184
useEffect(() => {
183185
const isOpen = upgrade === "true";
184186
if (isOpen) {
185187
setOpen(true);
186188
}
189+
return () => {
190+
setOpen(false);
191+
};
187192
}, [upgrade]);
188193

189194
return (
190195
<Dialog
191196
open={open}
192197
onOpenChange={() => {
193-
router.back();
198+
router.push(path);
194199
}}
195200
>
196201
<DialogContent className="max-w-[95vw]">

0 commit comments

Comments
 (0)