import React from 'react'; import { Handle, Position } from '@xyflow/react'; import { motion } from 'framer-motion'; import { useTranslation } from 'react-i18next'; import { Layers, Settings, CheckCircle2, Circle, ChevronRight, ArrowRight, Sparkles } from 'lucide-react'; import { useTheme } from '../../../../context/ThemeContext'; const PALETTE = { purple: { light: '#f3e8ff', dark: '#210638', border: '#a855f7' }, blue: { light: '#dbeafe', dark: '#111827', border: '#3b82f6' }, green: { light: '#dcfce7', dark: '#062f17', border: '#22c55e' }, yellow: { light: '#fef9c3', dark: '#2e2b14', border: '#eab308' }, pink: { light: '#fce7f3', dark: '#37061d', border: '#ec4899' }, orange: { light: '#ffedd5', dark: '#2e1208', border: '#f97316' }, white: { light: '#ffffff', dark: '#1c1917', border: '#78716c' }, }; // A collapsed group of quests. Double-click (or "Open") shows what is inside. const GroupNode = ({ id, data, selected }) => { const { t } = useTranslation(); const { isDarkMode } = useTheme(); const colors = PALETTE[data.color] || PALETTE.purple; const stats = data.groupStats || { total: 0, done: 0, xpEarned: 0, xpTotal: 0, groups: 0, preview: [] }; const progress = stats.total ? stats.done / stats.total : 0; const complete = stats.total > 0 && stats.done === stats.total; const open = (e) => { e.stopPropagation(); window.dispatchEvent(new CustomEvent('open-group-node', { detail: { nodeId: id } })); }; const configure = (e) => { e.stopPropagation(); window.dispatchEvent(new CustomEvent('configure-group-node', { detail: { nodeId: id } })); }; const bg = isDarkMode ? colors.dark : colors.light; return (
{/* Stacked sheets: a group holds many cards */}
{t('groups.badge', 'Group')}
{data.label || t('groups.untitled', 'New group')}
{data.isNextStep && !complete && }
{data.description && (

{data.description}

)} {/* Progress */}
{t('groups.quests_done', { done: stats.done, total: stats.total, defaultValue: `${stats.done}/${stats.total} quests` })} {stats.xpEarned}/{stats.xpTotal} XP
{/* Peek inside */} {stats.preview.length > 0 && (
    {stats.preview.map((q) => (
  • {q.done ? : } {q.label || t('canvas.new_goal', 'New Goal')}
  • ))} {stats.total > stats.preview.length && (
  • {t('groups.more', { count: stats.total - stats.preview.length, defaultValue: `+${stats.total - stats.preview.length} more` })}
  • )}
)}
); }; export default GroupNode;