1- import React from 'react'
1+ "use client" ;
2+
3+ import { useCodeEditorState } from "@/store/useCodeEditorStore" ;
4+ import {
5+ AlertTriangle ,
6+ CheckCircle ,
7+ Clock ,
8+ Copy ,
9+ Terminal ,
10+ } from "lucide-react" ;
11+ import React from "react" ;
12+ import RunningCodeSkeleton from "./RunningCodeLoading" ;
213
314function OutputPanel ( ) {
15+ const { output, error, isRunning } = useCodeEditorState ( ) ;
16+ const [ isCopied , setIsCopied ] = React . useState ( false ) ;
17+
18+ const hasContent = error || output ;
19+
20+ const handleCopy = async ( ) => {
21+ if ( ! hasContent ) return ;
22+
23+ await navigator . clipboard . writeText ( error || output || "" ) ;
24+ setIsCopied ( true ) ;
25+
26+ setTimeout ( ( ) => {
27+ setIsCopied ( false ) ;
28+ } , 2000 ) ;
29+ } ;
30+
431 return (
5- < div > OutputPanel</ div >
6- )
32+ < div className = "relative bg-[#181825] rounded-xl p-4 ring-1 ring-gray-800/50" >
33+ { /* Header */ }
34+ < div className = "flex items-center justify-between mb-3" >
35+ < div className = "flex items-center gap-2" >
36+ < div className = "flex items-center justify-center w-6 h-6 rounded-lg bg-[#1e1e2e] ring-1 ring-gray-800/50" >
37+ < Terminal className = "w-4 h-4 text-blue-400" />
38+ </ div >
39+ < span className = "text-sm font-medium text-gray-300" > Output</ span >
40+ </ div >
41+
42+ { hasContent && (
43+ < button
44+ onClick = { handleCopy }
45+ className = "flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-gray-400 hover:text-gray-300 bg-[#1e1e2e]
46+ rounded-lg ring-1 ring-gray-800/50 hover:ring-gray-700/50 transition-all"
47+ >
48+ { isCopied ? (
49+ < >
50+ < CheckCircle className = "w-3.5 h-3.5" />
51+ Copied!
52+ </ >
53+ ) : (
54+ < >
55+ < Copy className = "w-3.5 h-3.5" />
56+ Copy
57+ </ >
58+ ) }
59+ </ button >
60+ ) }
61+ </ div >
62+
63+ < div className = "relative" >
64+ < div
65+ className = "relative bg-[#1e1e2e]/50 backdrop-blur-sm border border-[#313244]
66+ rounded-xl p-4 h-[600px] overflow-auto font-mono text-sm"
67+ >
68+ { isRunning ? (
69+ < RunningCodeSkeleton />
70+ ) : error ? (
71+ < div className = "flex items-start gap-3 text-red-400" >
72+ < AlertTriangle className = "w-5 h-5 flex-shrink-0 mt-1" />
73+ < div className = "space-y-1" >
74+ < div className = "font-medium" > Execution Error</ div >
75+ < pre className = "whitespace-pre-wrap text-red-400/80" >
76+ { error }
77+ </ pre >
78+ </ div >
79+ </ div >
80+ ) : output ? (
81+ < div className = "space-y-2" >
82+ < div className = "flex items-center gap-2 text-emerald-400 mb-3" >
83+ < CheckCircle className = "w-5 h-5" />
84+ < span className = "font-medium" > Execution Successful</ span >
85+ </ div >
86+ < pre className = "whitespace-pre-wrap text-gray-300" > { output } </ pre >
87+ </ div >
88+ ) : (
89+ < div className = "h-full flex flex-col items-center justify-center text-gray-500" >
90+ < div className = "flex items-center justify-center w-12 h-12 rounded-xl bg-gray-800/50 ring-1 ring-gray-700/50 mb-4" >
91+ < Clock className = "w-6 h-6" />
92+ </ div >
93+ < p className = "text-center" >
94+ Run to Check, Submit only if you are satisfied
95+ </ p >
96+ </ div >
97+ ) }
98+ </ div >
99+ </ div >
100+ </ div >
101+ ) ;
7102}
8103
9- export default OutputPanel
104+ export default OutputPanel ;
0 commit comments