"use client"; import { useEffect, useRef, useState } from "react"; import { ArrowRight, CircleDollarSign, CircleHelp, Gift, Images, LoaderCircle, MessageSquareWarning, UserRound, WalletCards, X, type LucideIcon, } from "lucide-react"; import type { ChatAction } from "@/data/schemas/chat"; import styles from "./chat-area.module.css"; const ACTION_ICONS: Record = { giftOffer: Gift, privateAlbumOffer: Images, openProfile: UserRound, openWallet: WalletCards, openCoinsRules: WalletCards, activateVip: CircleDollarSign, topUp: CircleDollarSign, openFeedback: MessageSquareWarning, resumePayment: CircleHelp, }; export interface ChatActionCardProps { action: ChatAction; onViewed?: (action: ChatAction) => void; onActivate?: (action: ChatAction) => void | Promise; onDismiss?: (action: ChatAction) => void; } export function ChatActionCard({ action, onViewed, onActivate, onDismiss, }: ChatActionCardProps) { const [dismissed, setDismissed] = useState(false); const [activating, setActivating] = useState(false); const [activationError, setActivationError] = useState(null); const viewedActionIdRef = useRef(null); useEffect(() => { if (viewedActionIdRef.current === action.actionId) return; viewedActionIdRef.current = action.actionId; onViewed?.(action); }, [action, onViewed]); if (dismissed) return null; const Icon = ACTION_ICONS[action.type]; return ( ); }