-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek 16
More file actions
91 lines (84 loc) · 4.26 KB
/
Copy pathweek 16
File metadata and controls
91 lines (84 loc) · 4.26 KB
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
{/* ส่วนแสดงผลลัพธ์การ Submission */}
{submissionResult && (
<div className={`rounded-2xl p-4 ${submissionResult.success ? 'bg-green-800' : 'bg-red-800'}`}>
<h1 className="text-4xl font-medium mb-3">
{submissionResult.success ? '✅ ผลลัพธ์: ผ่าน' : '❌ ผลลัพธ์: ไม่ผ่าน'}
</h1>
<p className="text-medium mb-3">** {submissionResult.message} **</p>
<h2 className="text-lg font-semibold mb-1">รายละเอียด Testcase :</h2>
<div className="space-y-2 max-h-48 overflow-y-auto">
{submissionResult.results?.map((result, index) => (
<div key={index} className={`p-2 rounded-lg text-xs ${result.satisfied ? 'bg-green-400/50' : 'bg-red-400/50'}`}>
<span className="font-bold mr-2">{result.satisfied ? '✅' : '❌'} Test {index + 1} :</span>
<span className="break-all">{result.satisfied ? 'ผ่าน' : 'ไม่ผ่าน'}</span>
{!result.satisfied && (
<div className='mt-1 text-gray-200'>
<div>**Input:** {result.testCaseInput}</div>
<div>**Expected:** {result.expectedOutput}</div>
<div>**Received:** {result.realOutput}</div>
</div>
)}
</div>
))}
</div>
</div>
)}
{/* สิ้นสุดส่วนแสดงผลลัพธ์ */}
{currProblem.testcases?.length > 0 && (
<div className="bg-slate-700 rounded-2xl p-4">
<h1 className="text-xl font-medium">ตัวอย่าง</h1>
<div className="space-y-4 mt-2">
{currProblem.testcases.map((testcase, index) => (
<div key={index} className="bg-slate-800 p-3 rounded-lg">
<h3 className="font-semibold text-sm mb-1">ตัวอย่างที่ {index + 1}</h3>
<div className="mt-2 text-sm">
<h2 className="font-semibold">Input:</h2>
<pre className="bg-slate-900 p-2 rounded-md mt-1 overflow-auto whitespace-pre-wrap">{testcase.input}</pre>
</div>
<div className="mt-2 text-sm">
<h2 className="font-semibold">Output:</h2>
<pre className="bg-slate-900 p-2 rounded-md mt-1 overflow-auto whitespace-pre-wrap">{testcase.output}</pre>
</div>
</div>
))}
</div>
</div>
)}
{/* Submit Buttons */}
<div className="flex gap-4 mt-auto">
<button id='submitBtn'
onClick={handleSubmissionCode}
className={`
flex-1 bg-green-600 text-white p-3 rounded-lg font-medium
hover:bg-green-700 transition-colors
disabled:bg-gray-500
${currProblem.passCheck ? 'cursor-not-allowed' : 'cursor-pointer'}
`}
disabled={(currProblem.passCheck) || (!currProblem._id) || isSubmitting}
>
{
isSubmitting
? 'กำลังประมวลผล...'
: currProblem.passCheck
? '✅ ผ่านโจทย์นี้แล้ว'
: 'ส่งคำตอบ'
}
</button>
{/* Next Problem Buttons */}
<button
onClick={goNextProblem}
className="flex-1 bg-blue-600 text-white p-3 rounded-lg font-medium hover:bg-blue-700 transition-colors cursor-pointer"
>
โจทย์ถัดไป
</button>
</div>
</div>
{/* Right Side: Code Editor Component */}
<div className="w-full md:w-1/2 lg:w-[60%] h-auto bg-slate-800 rounded-2xl p-4 mb-5">
<h1 className="text-white text-xl font-medium mb-2">โค้ดของคุณ: Javascript</h1>
<CodeEditor onCodeChange={setUserCode} />
</div>
</div>
</div>
);
}