fix(chat): prompt guests to log in at quota limit
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import { useAuthState } from "@/stores/auth/auth-context";
|
import { useAuthState } from "@/stores/auth/auth-context";
|
||||||
import type { LoginStatus } from "@/data/dto/auth";
|
import type { LoginStatus } from "@/data/dto/auth";
|
||||||
@@ -37,6 +38,7 @@ export function ChatScreen() {
|
|||||||
const state = useChatState();
|
const state = useChatState();
|
||||||
const chatDispatch = useChatDispatch();
|
const chatDispatch = useChatDispatch();
|
||||||
const authState = useAuthState();
|
const authState = useAuthState();
|
||||||
|
const router = useRouter();
|
||||||
const [showExternalBrowserDialog, setShowExternalBrowserDialog] =
|
const [showExternalBrowserDialog, setShowExternalBrowserDialog] =
|
||||||
useState(false);
|
useState(false);
|
||||||
|
|
||||||
@@ -52,6 +54,7 @@ export function ChatScreen() {
|
|||||||
state.paywallReason === "total_limit"
|
state.paywallReason === "total_limit"
|
||||||
? "The limit for free chat times\nhas been reached"
|
? "The limit for free chat times\nhas been reached"
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const messageLimitCta = isGuest ? "Log in to continue chatting" : undefined;
|
||||||
const showPhotoPaywallBanner =
|
const showPhotoPaywallBanner =
|
||||||
state.paywallTriggered && state.paywallReason === "photo_paywall";
|
state.paywallTriggered && state.paywallReason === "photo_paywall";
|
||||||
const showPrivatePaywallBanner =
|
const showPrivatePaywallBanner =
|
||||||
@@ -140,6 +143,14 @@ export function ChatScreen() {
|
|||||||
chatDispatch({ type: "ChatUnlockPrivateMessage", messageId });
|
chatDispatch({ type: "ChatUnlockPrivateMessage", messageId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleMessageLimitUnlock(): void {
|
||||||
|
if (isGuest) {
|
||||||
|
router.push(ROUTES.auth);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
router.push(`${ROUTES.subscription}?type=vip`);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MobileShell>
|
<MobileShell>
|
||||||
<div className={styles.shell}>
|
<div className={styles.shell}>
|
||||||
@@ -176,6 +187,8 @@ export function ChatScreen() {
|
|||||||
{showMessageLimitBanner ? (
|
{showMessageLimitBanner ? (
|
||||||
<ChatQuotaExhaustedBanner
|
<ChatQuotaExhaustedBanner
|
||||||
title={messageLimitTitle}
|
title={messageLimitTitle}
|
||||||
|
ctaLabel={messageLimitCta}
|
||||||
|
onUnlock={handleMessageLimitUnlock}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ChatInputBar disabled={state.isReplyingAI} />
|
<ChatInputBar disabled={state.isReplyingAI} />
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
.text {
|
.text {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 1rem;
|
font-size: 1.125rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
margin: 0 0 var(--spacing-lg, 16px);
|
margin: 0 0 var(--spacing-lg, 16px);
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: linear-gradient(135deg, #ffb8e0 0%, #f57ec0 100%);
|
background: linear-gradient(135deg, #ffb8e0 0%, #f57ec0 100%);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 1rem;
|
font-size: 1.125rem;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||||
|
|||||||
Reference in New Issue
Block a user