"use client"; import { cn } from "@/lib/utils"; import { useState } from "react"; import { judge } from "@/app/actions/judge"; import { Button } from "@/components/ui/button"; import { LoaderCircleIcon, PlayIcon } from "lucide-react"; import { useCodeEditorState } from "@/store/useCodeEditor"; interface RunCodeProps { className?: string; } export default function RunCode({ className, ...props }: RunCodeProps) { const { language, editor } = useCodeEditorState(); const [isLoading, setIsLoading] = useState(false); const handleJudge = async () => { if (!editor) return; const code = editor.getValue() || ""; setIsLoading(true); try { const judgeResult = await judge(language, code); console.log(judgeResult); } catch (error) { console.error("Error occurred while judging the code:"); console.error(error); } finally { setIsLoading(false); } }; return ( ); }