"use client"; import React, { useState, useEffect } from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import { Settings, Clock, Zap, Info, Workflow } from "lucide-react"; import { ComponentData } from "@/types/screen"; import { getNodeFlows, NodeFlow } from "@/lib/api/nodeFlows"; interface ImprovedButtonControlConfigPanelProps { component: ComponentData; onUpdateProperty: (path: string, value: any) => void; } /** * ๐Ÿ”ฅ ๋‹จ์ˆœํ™”๋œ ๋ฒ„ํŠผ ์ œ์–ด ์„ค์ • ํŒจ๋„ * * ๋…ธ๋“œ ํ”Œ๋กœ์šฐ ์‹คํ–‰๋งŒ ์ง€์›: * - ํ”Œ๋กœ์šฐ ์„ ํƒ ๋ฐ ์‹คํ–‰ ํƒ€์ด๋ฐ ์„ค์ • */ export const ImprovedButtonControlConfigPanel: React.FC = ({ component, onUpdateProperty, }) => { const config = component.webTypeConfig || {}; const dataflowConfig = config.dataflowConfig || {}; // ๐Ÿ”ฅ State ๊ด€๋ฆฌ const [flows, setFlows] = useState([]); const [loading, setLoading] = useState(false); // ๐Ÿ”ฅ ํ”Œ๋กœ์šฐ ๋ชฉ๋ก ๋กœ๋”ฉ useEffect(() => { if (config.enableDataflowControl) { loadFlows(); } }, [config.enableDataflowControl]); /** * ๐Ÿ”ฅ ํ”Œ๋กœ์šฐ ๋ชฉ๋ก ๋กœ๋“œ */ const loadFlows = async () => { try { setLoading(true); console.log("๐Ÿ” ํ”Œ๋กœ์šฐ ๋ชฉ๋ก ๋กœ๋”ฉ..."); const flowList = await getNodeFlows(); setFlows(flowList); console.log(`โœ… ํ”Œ๋กœ์šฐ ${flowList.length}๊ฐœ ๋กœ๋”ฉ ์™„๋ฃŒ`); } catch (error) { console.error("โŒ ํ”Œ๋กœ์šฐ ๋ชฉ๋ก ๋กœ๋”ฉ ์‹คํŒจ:", error); setFlows([]); } finally { setLoading(false); } }; /** * ๐Ÿ”ฅ ํ”Œ๋กœ์šฐ ์„ ํƒ ํ•ธ๋“ค๋Ÿฌ */ const handleFlowSelect = (flowId: string) => { const selectedFlow = flows.find((f) => f.flowId.toString() === flowId); if (selectedFlow) { onUpdateProperty("webTypeConfig.dataflowConfig.flowConfig", { flowId: selectedFlow.flowId, flowName: selectedFlow.flowName, executionTiming: "before", // ๊ธฐ๋ณธ๊ฐ’ contextData: {}, }); } }; /** * ๐Ÿ”ฅ ์ œ์–ด ํƒ€์ž… ๋ณ€๊ฒฝ ํ•ธ๋“ค๋Ÿฌ */ const handleControlTypeChange = (controlType: string) => { // ๊ธฐ์กด ์„ค์ • ์ดˆ๊ธฐํ™” onUpdateProperty("webTypeConfig.dataflowConfig", { controlMode: controlType, flowConfig: controlType === "flow" ? undefined : null, }); }; return (
{/* ๐Ÿ”ฅ ์ œ์–ด๊ด€๋ฆฌ ํ™œ์„ฑํ™” ์Šค์œ„์น˜ */}

๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ์ถ”๊ฐ€ ์ž‘์—…์„ ์ž๋™์œผ๋กœ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค

onUpdateProperty("webTypeConfig.enableDataflowControl", checked)} />
{/* ๐Ÿ”ฅ ์ œ์–ด๊ด€๋ฆฌ๊ฐ€ ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ์—๋งŒ ์„ค์ • ํ‘œ์‹œ */} {config.enableDataflowControl && ( ๋ฒ„ํŠผ ์ œ์–ด ์„ค์ • ์ œ์–ด ์—†์Œ ๋…ธ๋“œ ํ”Œ๋กœ์šฐ

์ถ”๊ฐ€ ์ œ์–ด ์—†์ด ๊ธฐ๋ณธ ๋ฒ„ํŠผ ์•ก์…˜๋งŒ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

{dataflowConfig.flowConfig && (
onUpdateProperty("webTypeConfig.dataflowConfig.flowConfig.executionTiming", timing) } />

๋…ธ๋“œ ํ”Œ๋กœ์šฐ ์‹คํ–‰ ์ •๋ณด:

์„ ํƒํ•œ ํ”Œ๋กœ์šฐ์˜ ๋ชจ๋“  ๋…ธ๋“œ๊ฐ€ ์ˆœ์ฐจ์ /๋ณ‘๋ ฌ๋กœ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

โ€ข ๋…๋ฆฝ ํŠธ๋žœ์žญ์…˜: ๊ฐ ์•ก์…˜์€ ๋…๋ฆฝ์ ์œผ๋กœ ์ปค๋ฐ‹/๋กค๋ฐฑ

โ€ข ์—ฐ์‡„ ์ค‘๋‹จ: ๋ถ€๋ชจ ๋…ธ๋“œ ์‹คํŒจ ์‹œ ์ž์‹ ๋…ธ๋“œ ์Šคํ‚ต

)}
)}
); }; /** * ๐Ÿ”ฅ ํ”Œ๋กœ์šฐ ์„ ํƒ ์ปดํฌ๋„ŒํŠธ */ const FlowSelector: React.FC<{ flows: NodeFlow[]; selectedFlowId?: number; onSelect: (flowId: string) => void; loading: boolean; }> = ({ flows, selectedFlowId, onSelect, loading }) => { return (
); }; /** * ๐Ÿ”ฅ ์‹คํ–‰ ํƒ€์ด๋ฐ ์„ ํƒ ์ปดํฌ๋„ŒํŠธ */ const ExecutionTimingSelector: React.FC<{ value: string; onChange: (timing: "before" | "after" | "replace") => void; }> = ({ value, onChange }) => { return (
); };