"use client"; import { useTheme } from "next-themes"; import EmojiPicker, { Theme } from "emoji-picker-react"; import { BACKGROUND_COLORS } from "lib/const"; import { createDebounce, cn } from "lib/utils"; import { Avatar, AvatarFallback, AvatarImage } from "ui/avatar"; import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, } from "ui/dropdown-menu"; import { AgentIcon } from "app-types/agent"; const colorUpdateDebounce = createDebounce(); interface AgentIconPickerProps { icon?: AgentIcon; disabled?: boolean; onChange: (icon: AgentIcon) => void; } export function AgentIconPicker({ icon, disabled = false, onChange, }: AgentIconPickerProps) { const { theme } = useTheme(); const handleColorChange = (color: string) => { onChange({ ...icon!, style: { backgroundColor: color }, }); }; const handleEmojiSelect = (emoji: any) => { onChange({ ...icon!, value: emoji.imageUrl, type: "emoji", }); }; return (
{BACKGROUND_COLORS.map((color, index) => (
handleColorChange(color)} style={{ backgroundColor: color }} /> ))}
{ colorUpdateDebounce(() => { handleColorChange(e.target.value); }, 100); }} />
); }