🐛 fix: replace window.location with navigate for payment redirection in recharge, renewal, and reset-traffic components
This commit is contained in:
parent
cc41debb33
commit
3862007b54
@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { Button } from "@workspace/ui/components/button";
|
import { Button } from "@workspace/ui/components/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@ -24,6 +25,7 @@ export default function Recharge(
|
|||||||
) {
|
) {
|
||||||
const { t } = useTranslation("subscribe");
|
const { t } = useTranslation("subscribe");
|
||||||
const { common } = useGlobalStore();
|
const { common } = useGlobalStore();
|
||||||
|
const navigate = useNavigate();
|
||||||
const { currency } = common;
|
const { currency } = common;
|
||||||
|
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
@ -86,7 +88,10 @@ export default function Recharge(
|
|||||||
const response = await recharge(params);
|
const response = await recharge(params);
|
||||||
const orderNo = response.data.data?.order_no;
|
const orderNo = response.data.data?.order_no;
|
||||||
if (orderNo) {
|
if (orderNo) {
|
||||||
window.location.href = `/#/payment?order_no=${orderNo}`;
|
navigate({
|
||||||
|
to: "/payment",
|
||||||
|
search: { order_no: String(orderNo) },
|
||||||
|
});
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { Button } from "@workspace/ui/components/button";
|
import { Button } from "@workspace/ui/components/button";
|
||||||
import { Card, CardContent } from "@workspace/ui/components/card";
|
import { Card, CardContent } from "@workspace/ui/components/card";
|
||||||
import {
|
import {
|
||||||
@ -30,6 +31,7 @@ interface RenewalProps {
|
|||||||
export default function Renewal({ id, subscribe }: Readonly<RenewalProps>) {
|
export default function Renewal({ id, subscribe }: Readonly<RenewalProps>) {
|
||||||
const { t } = useTranslation("subscribe");
|
const { t } = useTranslation("subscribe");
|
||||||
const { getUserInfo } = useGlobalStore();
|
const { getUserInfo } = useGlobalStore();
|
||||||
|
const navigate = useNavigate();
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
const [params, setParams] = useState<Partial<API.RenewalOrderRequest>>({
|
const [params, setParams] = useState<Partial<API.RenewalOrderRequest>>({
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
@ -90,13 +92,13 @@ export default function Renewal({ id, subscribe }: Readonly<RenewalProps>) {
|
|||||||
const orderNo = response.data.data?.order_no;
|
const orderNo = response.data.data?.order_no;
|
||||||
if (orderNo) {
|
if (orderNo) {
|
||||||
getUserInfo();
|
getUserInfo();
|
||||||
window.location.href = `/#/payment?order_no=${orderNo}`;
|
navigate({ to: "/payment", search: { order_no: String(orderNo) } });
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [params, getUserInfo]);
|
}, [params, getUserInfo, navigate]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog onOpenChange={setOpen} open={open}>
|
<Dialog onOpenChange={setOpen} open={open}>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { Button } from "@workspace/ui/components/button";
|
import { Button } from "@workspace/ui/components/button";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@ -27,6 +28,7 @@ export default function ResetTraffic({
|
|||||||
}: Readonly<ResetTrafficProps>) {
|
}: Readonly<ResetTrafficProps>) {
|
||||||
const { t } = useTranslation("subscribe");
|
const { t } = useTranslation("subscribe");
|
||||||
const { getUserInfo } = useGlobalStore();
|
const { getUserInfo } = useGlobalStore();
|
||||||
|
const navigate = useNavigate();
|
||||||
const [open, setOpen] = useState<boolean>(false);
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
const [params, setParams] = useState<API.ResetTrafficOrderRequest>({
|
const [params, setParams] = useState<API.ResetTrafficOrderRequest>({
|
||||||
payment: -1,
|
payment: -1,
|
||||||
@ -88,7 +90,10 @@ export default function ResetTraffic({
|
|||||||
const orderNo = response.data.data?.order_no;
|
const orderNo = response.data.data?.order_no;
|
||||||
if (orderNo) {
|
if (orderNo) {
|
||||||
getUserInfo();
|
getUserInfo();
|
||||||
window.location.href = `/#/payment?order_no=${orderNo}`;
|
navigate({
|
||||||
|
to: "/payment",
|
||||||
|
search: { order_no: String(orderNo) },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user