Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

window.open → router.push

Steven Tey6414768edf0e
diff --git a/apps/web/ui/partners/connect-payout-button.tsx b/apps/web/ui/partners/connect-payout-button.tsx
index beb4882321..155d61dda0 100644
--- a/apps/web/ui/partners/connect-payout-button.tsx
+++ b/apps/web/ui/partners/connect-payout-button.tsx
@@ -10,10 +10,12 @@ import {
PAYPAL_SUPPORTED_COUNTRIES,
} from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
+import { useRouter } from "next/navigation";
import { useCallback, useMemo } from "react";
import { toast } from "sonner";
export function ConnectPayoutButton(props: ButtonProps) {
+ const router = useRouter();
const { partner } = usePartnerProfile();
const { executeAsync: executeStripeAsync, isPending: isStripePending } =
@@ -23,8 +25,7 @@ export function ConnectPayoutButton(props: ButtonProps) {
toast.error("Unable to create account link. Please contact support.");
return;
}
-
- window.open(data.url, "_blank");
+ router.push(data.url);
},
onError: ({ error }) => {
toast.error(error.serverError);
@@ -38,8 +39,7 @@ export function ConnectPayoutButton(props: ButtonProps) {
toast.error("Unable to redirect to Paypal. Please contact support.");
return;
}
-
- window.open(data.url, "_blank");
+ router.push(data.url);
},
onError: ({ error }) => {
toast.error(error.serverError);
diff --git a/apps/web/ui/partners/payout-methods-dropdown.tsx b/apps/web/ui/partners/payout-methods-dropdown.tsx
index 419c764ee8..ba299cc819 100644
--- a/apps/web/ui/partners/payout-methods-dropdown.tsx
+++ b/apps/web/ui/partners/payout-methods-dropdown.tsx
@@ -19,12 +19,14 @@ import {
} from "@dub/utils";
import { ChevronsUpDown } from "lucide-react";
import { useAction } from "next-safe-action/hooks";
+import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
import type { Stripe } from "stripe";
import useSWR from "swr";
export function PayoutMethodsDropdown() {
+ const router = useRouter();
const [openPopover, setOpenPopover] = useState(false);
const { partner, loading: isPartnerLoading } = usePartnerProfile();
@@ -41,7 +43,7 @@ export function PayoutMethodsDropdown() {
toast.error("Unable to create account link. Please contact support.");
return;
}
- window.open(data.url, "_blank");
+ router.push(data.url);
},
onError: ({ error }) => {
toast.error(error.serverError);
@@ -55,7 +57,7 @@ export function PayoutMethodsDropdown() {
toast.error("Unable to redirect to Paypal. Please contact support.");
return;
}
- window.open(data.url, "_blank");
+ router.push(data.url);
},
onError: ({ error }) => {
toast.error(error.serverError);