feat(chat): add quota-exhausted banner for guest users
Introduce ChatQuotaExhaustedBanner component that displays a pink gradient banner with an "Unlock your membership to continue" CTA when a guest user's free chat quota has been exhausted. The banner is shown in ChatScreen when isGuest is true, quota has loaded, and the chat state machine's quotaExceededTrigger has been incremented by a quota guard. Default click navigates to /subscription, with an optional onUnlock callback for overrides/tests. Styles align with the existing splash and sidebar VIP card visual language.
This commit is contained in:
@@ -33,7 +33,8 @@
|
||||
import { setup, assign } from "xstate";
|
||||
|
||||
import { ChatStorage } from "@/data/storage/chat/chat_storage";
|
||||
import { formatDate } from "@/utils/date";
|
||||
import { formatDate, todayString } from "@/utils/date";
|
||||
|
||||
|
||||
import { ChatState, initialState } from "./chat-state";
|
||||
import type { ChatEvent } from "./chat-events";
|
||||
@@ -85,8 +86,9 @@ export const chatMachine = setup({
|
||||
|
||||
// 持久化两个额度( fire-and-forget,不 await —— assign 是 sync)
|
||||
// daily quota 需要 today 字符串(让 ChatStorage 跨天判断 reset)
|
||||
const today = formatDate();
|
||||
const today = todayString();
|
||||
ChatStorage.getInstance().setGuestDailyChatQuota(newRemaining, today);
|
||||
|
||||
ChatStorage.getInstance().setGuestTotalQuota(newTotal);
|
||||
|
||||
console.log("[chat-machine] appendUserMessage", {
|
||||
@@ -124,9 +126,12 @@ export const chatMachine = setup({
|
||||
const newTotal = context.wsConnected
|
||||
? context.guestTotalQuota
|
||||
: Math.max(0, context.guestTotalQuota - 1);
|
||||
const today = formatDate();
|
||||
|
||||
const today = todayString();
|
||||
void ChatStorage.getInstance().setGuestDailyChatQuota(newRemaining, today);
|
||||
|
||||
void ChatStorage.getInstance().setGuestTotalQuota(newTotal);
|
||||
|
||||
console.log("[chat-machine] appendUserImage", {
|
||||
oldMessagesCount: context.messages.length,
|
||||
wsConnected: context.wsConnected,
|
||||
|
||||
Reference in New Issue
Block a user