import React, { useState } from "react"; import { View, TouchableOpacity, Text, StyleSheet } from "react-native"; import { ThumbsUp, ThumbsDown, Copy, Check } from "lucide-react-native"; import Clipboard from "@react-native-clipboard/clipboard"; import type { ReactionType, OperoChatStyles } from "../types"; import { mergeStyles } from "../utils/helpers"; export interface OperoMessageActionsProps { messageId?: string; messageContent: string; currentReaction?: ReactionType; onReaction: (reactionType: ReactionType) => void; customStyles?: OperoChatStyles; } export const OperoMessageActions: React.FC = ({ messageId, messageContent, currentReaction, onReaction, customStyles, }) => { const [copiedState, setCopiedState] = useState(false); const styles = createStyles(mergeStyles(customStyles)); const handleCopy = async () => { Clipboard.setString(messageContent); setCopiedState(true); setTimeout(() => setCopiedState(false), 2000); }; const handleReaction = (type: ReactionType) => { if (!messageId) return; // Can't react without message ID onReaction(type); }; return ( {/* Feedback buttons - only if we have message_id */} {messageId && ( handleReaction("thumbs_up")} accessibilityLabel="Mark as helpful" accessibilityRole="button" accessibilityState={{ selected: currentReaction === "thumbs_up" }} > Helpful handleReaction("thumbs_down")} accessibilityLabel="Mark as not helpful" accessibilityRole="button" accessibilityState={{ selected: currentReaction === "thumbs_down" }} > Not helpful )} {/* Copy button */} {copiedState ? ( <> Copied ) : ( <> Copy )} ); }; const createStyles = (_theme: OperoChatStyles) => StyleSheet.create({ container: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", marginTop: 8, paddingHorizontal: 4, gap: 8, }, feedbackButtons: { flexDirection: "row", gap: 8, }, actionButton: { flexDirection: "row", alignItems: "center", paddingVertical: 6, paddingHorizontal: 10, backgroundColor: "#f9fafb", borderRadius: 8, borderWidth: 1, borderColor: "#e5e7eb", gap: 4, minWidth: 44, minHeight: 44, }, thumbsUpActive: { backgroundColor: "#dcfce7", borderColor: "#86efac", }, thumbsDownActive: { backgroundColor: "#fee2e2", borderColor: "#fca5a5", }, actionText: { fontSize: 12, color: "#6b7280", fontWeight: "500", }, thumbsUpText: { color: "#16a34a", }, thumbsDownText: { color: "#dc2626", }, copyButton: { flexDirection: "row", alignItems: "center", paddingVertical: 6, paddingHorizontal: 10, backgroundColor: "#f9fafb", borderRadius: 8, borderWidth: 1, borderColor: "#e5e7eb", gap: 4, minWidth: 44, minHeight: 44, }, copiedText: { fontSize: 12, color: "#16a34a", fontWeight: "500", }, });