@@ -85,7 +85,11 @@ export default function Assignment({ courseId }: AssignmentProps) {
85
85
}
86
86
} , [ courseId ] ) ;
87
87
88
+ const [ envLoading , setEnvLoading ] = useState ( false ) ;
89
+
88
90
const handleStartAssignment = async ( assignmentId : string ) => {
91
+ setError ( null ) ;
92
+ setEnvLoading ( true ) ;
89
93
var result : any ;
90
94
try {
91
95
const formData = new FormData ( ) ;
@@ -104,11 +108,13 @@ export default function Assignment({ courseId }: AssignmentProps) {
104
108
result = await response . json ( ) ;
105
109
if ( result . message == "Require group" && ! ( courseId in myGroups ) ) {
106
110
setError ( 'You need to join a group to start this assignment.' ) ;
111
+ setEnvLoading ( false ) ;
107
112
return ;
108
113
}
109
114
} catch ( error ) {
110
115
console . error ( 'Error starting assignment environment:' , error ) ;
111
116
setError ( 'Failed to start assignment environment. Please try again later.' ) ;
117
+ setEnvLoading ( false ) ;
112
118
return ;
113
119
}
114
120
const environmentId = result . environment_id ;
@@ -121,8 +127,38 @@ export default function Assignment({ courseId }: AssignmentProps) {
121
127
icon : "CodeXml"
122
128
}
123
129
] ) ;
130
+ setEnvLoading ( false ) ;
124
131
} ;
125
132
133
+ // Loading popout overlay
134
+ if ( envLoading ) {
135
+ return (
136
+ < div className = "fixed inset-0 z-50 flex items-center justify-center bg-black/40" >
137
+ < Card className = "p-8 flex flex-col items-center gap-4 shadow-2xl" >
138
+ < div className = "animate-spin mb-2" >
139
+ < svg className = "h-10 w-10 text-primary" viewBox = "0 0 24 24" fill = "none" >
140
+ < circle
141
+ className = "opacity-25"
142
+ cx = "12"
143
+ cy = "12"
144
+ r = "10"
145
+ stroke = "currentColor"
146
+ strokeWidth = "4"
147
+ />
148
+ < path
149
+ className = "opacity-75"
150
+ fill = "currentColor"
151
+ d = "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"
152
+ />
153
+ </ svg >
154
+ </ div >
155
+ < h3 className = "text-lg font-semibold" > Preparing your coding environment...</ h3 >
156
+ < p className = "text-muted-foreground text-center text-sm" > This may take a few moments. Please wait.</ p >
157
+ </ Card >
158
+ </ div >
159
+ ) ;
160
+ }
161
+
126
162
// Sort assignments: active ones by deadline (earliest first), then completed ones
127
163
const sortedAssignments = data ?. assignments
128
164
? [ ...data . assignments ] . sort ( ( a , b ) => {
0 commit comments