Spaces:
Running
Running
File size: 6,722 Bytes
c2ea5ed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
import React, { useState } from "react";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { Separator } from "@/components/ui/separator";
import { ScrollArea } from "@/components/ui/scroll-area";
import {
Info,
PlayCircle,
Star,
CheckCircle,
AlertCircle,
ChevronRight,
Lightbulb,
} from "lucide-react";
import { welcomeGuideConfig } from "@/lib/welcomeGuideConfig";
import { WelcomeGuideSection } from "@/types";
import { AgentGraphImpact } from "@/components/features/dashboard/visualizations/AgentGraphImpact";
interface WelcomeGuideModalProps {
open: boolean;
onOpenChange: (open: boolean) => void;
}
const iconMap = {
Info,
PlayCircle,
Star,
CheckCircle,
AlertCircle,
};
export function WelcomeGuideModal({
open,
onOpenChange,
}: WelcomeGuideModalProps) {
const [activeSection, setActiveSection] = useState<string>("overview");
const renderSection = (section: WelcomeGuideSection) => {
const IconComponent = iconMap[section.icon as keyof typeof iconMap] || Info;
// Special rendering for AgentGraph Impact section
if (section.id === "agentgraph-impact") {
return (
<div key={section.id} className="mb-6">
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<IconComponent className="h-5 w-5 text-primary" />
{section.title}
</CardTitle>
</CardHeader>
<CardContent>
<p className="text-muted-foreground leading-relaxed mb-6">
{section.content}
</p>
<AgentGraphImpact className="w-full" />
</CardContent>
</Card>
</div>
);
}
// Default rendering for other sections
return (
<Card key={section.id} className="mb-6">
<CardHeader>
<CardTitle className="flex items-center gap-2">
<IconComponent className="h-5 w-5 text-primary" />
{section.title}
</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<p className="text-muted-foreground leading-relaxed">
{section.content}
</p>
{section.steps && section.steps.length > 0 && (
<div className="space-y-4">
{section.steps.map((step) => (
<div
key={step.number}
className="border-l-2 border-primary/20 pl-4"
>
<div className="flex items-start gap-3">
<Badge
variant="outline"
className="shrink-0 w-8 h-8 rounded-full flex items-center justify-center p-0 font-semibold"
>
{step.number}
</Badge>
<div className="flex-1 space-y-2">
<h4 className="font-semibold text-foreground">
{step.title}
</h4>
<p className="text-sm text-muted-foreground leading-relaxed">
{step.description}
</p>
{step.tips && step.tips.length > 0 && (
<div className="bg-muted/50 p-3 rounded-lg">
<div className="flex items-center gap-2 mb-2">
<Lightbulb className="h-4 w-4 text-yellow-600" />
<span className="text-sm font-medium">Tips</span>
</div>
<ul className="text-xs text-muted-foreground space-y-1">
{step.tips.map((tip, index) => (
<li
key={index}
className="flex items-start gap-2"
>
<ChevronRight className="h-3 w-3 mt-0.5 shrink-0" />
{tip}
</li>
))}
</ul>
</div>
)}
</div>
</div>
</div>
))}
</div>
)}
</CardContent>
</Card>
);
};
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-4xl max-h-[90vh] p-0">
<DialogHeader className="p-6 pb-0">
<DialogTitle className="text-2xl font-bold">
{welcomeGuideConfig.title}
</DialogTitle>
<DialogDescription className="text-base">
{welcomeGuideConfig.subtitle}
</DialogDescription>
</DialogHeader>
<div className="flex flex-1 min-h-0">
{/* Navigation Sidebar */}
<div className="w-64 border-r bg-muted/20 p-4">
<nav className="space-y-2">
{welcomeGuideConfig.sections.map((section) => {
const IconComponent =
iconMap[section.icon as keyof typeof iconMap] || Info;
return (
<Button
key={section.id}
variant={
activeSection === section.id ? "secondary" : "ghost"
}
className="w-full justify-start gap-2 h-auto p-3"
onClick={() => setActiveSection(section.id)}
>
<IconComponent className="h-4 w-4" />
<span className="text-sm font-medium">{section.title}</span>
</Button>
);
})}
</nav>
</div>
{/* Content Area */}
<div className="flex-1 min-w-0">
<ScrollArea className="h-[70vh] p-6">
{welcomeGuideConfig.sections
.filter((section) => section.id === activeSection)
.map((section) => renderSection(section))}
</ScrollArea>
</div>
</div>
<Separator />
<div className="p-6 pt-4 flex justify-between items-center">
<div className="text-sm text-muted-foreground">
Navigate through sections using the sidebar or scroll through all
content
</div>
<Button onClick={() => onOpenChange(false)}>Got it, thanks!</Button>
</div>
</DialogContent>
</Dialog>
);
}
|