Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 95b9f85a14 |
Binary file not shown.
|
Before Width: | Height: | Size: 663 KiB After Width: | Height: | Size: 2.0 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 468 KiB After Width: | Height: | Size: 2.1 MiB |
@@ -1,14 +0,0 @@
|
|||||||
import { renderToStaticMarkup } from "react-dom/server";
|
|
||||||
import { describe, expect, it, vi } from "vitest";
|
|
||||||
|
|
||||||
vi.mock("next/navigation", () => ({
|
|
||||||
useRouter: () => ({ replace: vi.fn() }),
|
|
||||||
}));
|
|
||||||
|
|
||||||
import SubscriptionReturnPage from "../page";
|
|
||||||
|
|
||||||
describe("SubscriptionReturnPage", () => {
|
|
||||||
it("renders outside CharacterProvider", () => {
|
|
||||||
expect(() => renderToStaticMarkup(<SubscriptionReturnPage />)).not.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
import { MobileShell } from "@/app/_components/core";
|
import { MobileShell } from "@/app/_components/core";
|
||||||
import {
|
import {
|
||||||
@@ -9,11 +8,12 @@ import {
|
|||||||
getPendingPaymentOrder,
|
getPendingPaymentOrder,
|
||||||
} from "@/lib/payment/pending_payment_order";
|
} from "@/lib/payment/pending_payment_order";
|
||||||
import { ROUTES } from "@/router/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
|
import { useAppNavigator } from "@/router/use-app-navigator";
|
||||||
|
|
||||||
type ReturnStatus = "loading" | "missing";
|
type ReturnStatus = "loading" | "missing";
|
||||||
|
|
||||||
export default function SubscriptionReturnPage() {
|
export default function SubscriptionReturnPage() {
|
||||||
const router = useRouter();
|
const navigator = useAppNavigator();
|
||||||
const [status, setStatus] = useState<ReturnStatus>("loading");
|
const [status, setStatus] = useState<ReturnStatus>("loading");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -24,7 +24,7 @@ export default function SubscriptionReturnPage() {
|
|||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
|
||||||
if (result.success && result.data !== null) {
|
if (result.success && result.data !== null) {
|
||||||
router.replace(buildPendingPaymentSubscriptionUrl(result.data));
|
navigator.replace(buildPendingPaymentSubscriptionUrl(result.data));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export default function SubscriptionReturnPage() {
|
|||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
};
|
};
|
||||||
}, [router]);
|
}, [navigator]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MobileShell>
|
<MobileShell>
|
||||||
@@ -62,7 +62,7 @@ export default function SubscriptionReturnPage() {
|
|||||||
{status === "missing" ? (
|
{status === "missing" ? (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => router.replace(ROUTES.subscription)}
|
onClick={() => navigator.replace(ROUTES.subscription)}
|
||||||
style={{
|
style={{
|
||||||
marginTop: "0.5rem",
|
marginTop: "0.5rem",
|
||||||
padding: "0.75rem 1.5rem",
|
padding: "0.75rem 1.5rem",
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
import { usePaymentRouteFlow } from "@/app/_hooks/use-payment-route-flow";
|
import { usePaymentRouteFlow } from "@/app/_hooks/use-payment-route-flow";
|
||||||
|
import { useAppNavigator } from "@/router/use-app-navigator";
|
||||||
import type { PayChannel } from "@/data/schemas/payment";
|
import type { PayChannel } from "@/data/schemas/payment";
|
||||||
import { DEFAULT_CHARACTER_SLUG } from "@/data/constants/character";
|
import { DEFAULT_CHARACTER_SLUG } from "@/data/constants/character";
|
||||||
import {
|
import type { SubscriptionReturnTo } from "@/lib/navigation/subscription_exit";
|
||||||
consumeSubscriptionExitUrl,
|
|
||||||
resolveSubscriptionSuccessExitUrl,
|
|
||||||
type SubscriptionReturnTo,
|
|
||||||
} from "@/lib/navigation/subscription_exit";
|
|
||||||
|
|
||||||
import type { SubscriptionType } from "./subscription-screen.helpers";
|
import type { SubscriptionType } from "./subscription-screen.helpers";
|
||||||
|
|
||||||
@@ -29,7 +25,7 @@ export function useSubscriptionPaymentFlow({
|
|||||||
initialPayChannel,
|
initialPayChannel,
|
||||||
characterSlug = DEFAULT_CHARACTER_SLUG,
|
characterSlug = DEFAULT_CHARACTER_SLUG,
|
||||||
}: UseSubscriptionPaymentFlowInput) {
|
}: UseSubscriptionPaymentFlowInput) {
|
||||||
const router = useRouter();
|
const navigator = useAppNavigator();
|
||||||
const { payment, paymentDispatch } = usePaymentRouteFlow({
|
const { payment, paymentDispatch } = usePaymentRouteFlow({
|
||||||
initialPayChannel,
|
initialPayChannel,
|
||||||
paymentType: subscriptionType,
|
paymentType: subscriptionType,
|
||||||
@@ -48,21 +44,13 @@ export function useSubscriptionPaymentFlow({
|
|||||||
}, [payment.currentOrderId, payment.isPaid]);
|
}, [payment.currentOrderId, payment.isPaid]);
|
||||||
|
|
||||||
const handleBackClick = () => {
|
const handleBackClick = () => {
|
||||||
void (async () => {
|
navigator.exitSubscription(returnTo, characterSlug);
|
||||||
router.replace(
|
|
||||||
await consumeSubscriptionExitUrl(returnTo, characterSlug),
|
|
||||||
);
|
|
||||||
})();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePaymentSuccessClose = () => {
|
const handlePaymentSuccessClose = () => {
|
||||||
setShowPaymentSuccessDialog(false);
|
setShowPaymentSuccessDialog(false);
|
||||||
paymentDispatch({ type: "PaymentReset" });
|
paymentDispatch({ type: "PaymentReset" });
|
||||||
void (async () => {
|
navigator.exitSubscriptionAfterSuccess(returnTo, characterSlug);
|
||||||
router.replace(
|
|
||||||
await resolveSubscriptionSuccessExitUrl(returnTo, characterSlug),
|
|
||||||
);
|
|
||||||
})();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user