Skip to content

Commit 44dd4ea

Browse files
authored
more cleanup for new help request errors (#595)
1 parent cc0e13a commit 44dd4ea

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

app/course/[course_id]/office-hours/[queue_id]/new/newRequestForm.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,12 @@ export default function HelpRequestForm() {
695695
);
696696
}
697697

698+
// Compute hasErrors, ignoring empty root object left by React Hook Form
699+
const hasErrors = Object.keys(errors).some(
700+
(key) =>
701+
key !== "root" || (key === "root" && Object.keys((errors as Record<string, unknown>).root || {}).length > 0)
702+
);
703+
698704
return (
699705
<form onSubmit={onSubmit} aria-label="New Help Request Form">
700706
<Toaster />
@@ -1229,7 +1235,7 @@ export default function HelpRequestForm() {
12291235
<Button
12301236
type="submit"
12311237
loading={isSubmitting || isSubmittingGuard}
1232-
disabled={isSubmitting || isSubmittingGuard || Object.keys(errors).length > 0}
1238+
disabled={isSubmitting || isSubmittingGuard || hasErrors}
12331239
mt={4}
12341240
>
12351241
Submit Request

lib/test-insights/RegradeSubmissionsDialog.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ export function RegradeSubmissionsDialog({
217217

218218
// Handle regrade action
219219
const handleRegrade = useCallback(async () => {
220+
// Early guard to prevent duplicate calls
221+
if (isRegrading) {
222+
return;
223+
}
224+
220225
if (errorGroup.affected_submission_ids.length === 0) {
221226
toaster.error({
222227
title: "Error",
@@ -254,7 +259,16 @@ export function RegradeSubmissionsDialog({
254259
} finally {
255260
setIsRegrading(false);
256261
}
257-
}, [errorGroup.affected_submission_ids, courseId, manualSha, selectedCommit, autoPromote, supabase, onClose]);
262+
}, [
263+
errorGroup.affected_submission_ids,
264+
courseId,
265+
manualSha,
266+
selectedCommit,
267+
autoPromote,
268+
supabase,
269+
onClose,
270+
isRegrading
271+
]);
258272

259273
return (
260274
<Dialog.Root open={isOpen} onOpenChange={({ open }) => !open && onClose()} size="xl">
@@ -453,7 +467,7 @@ export function RegradeSubmissionsDialog({
453467
colorPalette="green"
454468
onClick={handleRegrade}
455469
loading={isRegrading}
456-
disabled={errorGroup.affected_submission_ids.length === 0}
470+
disabled={isRegrading || errorGroup.affected_submission_ids.length === 0}
457471
>
458472
<Icon as={FaPlay} mr={2} />
459473
Regrade {errorGroup.affected_submission_ids.length} Submissions

0 commit comments

Comments
 (0)