refactor(router): introduce app navigation manager
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
"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";
|
||||
|
||||
export interface ExternalBrowserPromptState {
|
||||
@@ -31,41 +29,8 @@ export function shouldStartExternalBrowserPrompt({
|
||||
);
|
||||
}
|
||||
|
||||
export function getChatPaywallSubscriptionUrl(
|
||||
payChannel: PayChannel = "stripe",
|
||||
): string {
|
||||
return ROUTE_BUILDERS.subscription("vip", {
|
||||
payChannel,
|
||||
returnTo: "chat",
|
||||
});
|
||||
}
|
||||
|
||||
export function getChatCreditsTopUpSubscriptionUrl(
|
||||
payChannel: PayChannel = "stripe",
|
||||
): string {
|
||||
return ROUTE_BUILDERS.subscription("topup", {
|
||||
payChannel,
|
||||
returnTo: "chat",
|
||||
});
|
||||
}
|
||||
|
||||
export function getInsufficientCreditsSubscriptionType(
|
||||
isVip: boolean,
|
||||
): "vip" | "topup" {
|
||||
return isVip ? "topup" : "vip";
|
||||
}
|
||||
|
||||
export function getChatPaywallNavigationUrl(
|
||||
loginStatus: LoginStatus,
|
||||
type: "vip" | "topup" = "vip",
|
||||
payChannel: PayChannel = "stripe",
|
||||
): string {
|
||||
const subscriptionUrl =
|
||||
type === "topup"
|
||||
? getChatCreditsTopUpSubscriptionUrl(payChannel)
|
||||
: getChatPaywallSubscriptionUrl(payChannel);
|
||||
if (deriveIsGuest(loginStatus)) {
|
||||
return ROUTE_BUILDERS.authWithRedirect(subscriptionUrl);
|
||||
}
|
||||
return subscriptionUrl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user