fix(subscription): preselect pay channel before navigation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import type { LoginStatus } from "@/data/dto/auth";
|
||||
import type { PayChannel } from "@/data/dto/payment";
|
||||
import { ROUTE_BUILDERS } from "@/router/routes";
|
||||
import { AppEnvUtil, BrowserDetector } from "@/utils";
|
||||
|
||||
@@ -30,14 +31,20 @@ export function shouldStartExternalBrowserPrompt({
|
||||
);
|
||||
}
|
||||
|
||||
export function getChatPaywallSubscriptionUrl(): string {
|
||||
export function getChatPaywallSubscriptionUrl(
|
||||
payChannel: PayChannel = "stripe",
|
||||
): string {
|
||||
return ROUTE_BUILDERS.subscription("vip", {
|
||||
payChannel,
|
||||
returnTo: "chat",
|
||||
});
|
||||
}
|
||||
|
||||
export function getChatCreditsTopUpSubscriptionUrl(): string {
|
||||
export function getChatCreditsTopUpSubscriptionUrl(
|
||||
payChannel: PayChannel = "stripe",
|
||||
): string {
|
||||
return ROUTE_BUILDERS.subscription("topup", {
|
||||
payChannel,
|
||||
returnTo: "chat",
|
||||
});
|
||||
}
|
||||
@@ -51,11 +58,12 @@ export function getInsufficientCreditsSubscriptionType(
|
||||
export function getChatPaywallNavigationUrl(
|
||||
loginStatus: LoginStatus,
|
||||
type: "vip" | "topup" = "vip",
|
||||
payChannel: PayChannel = "stripe",
|
||||
): string {
|
||||
const subscriptionUrl =
|
||||
type === "topup"
|
||||
? getChatCreditsTopUpSubscriptionUrl()
|
||||
: getChatPaywallSubscriptionUrl();
|
||||
? getChatCreditsTopUpSubscriptionUrl(payChannel)
|
||||
: getChatPaywallSubscriptionUrl(payChannel);
|
||||
if (deriveIsGuest(loginStatus)) {
|
||||
return ROUTE_BUILDERS.authWithRedirect(subscriptionUrl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user