mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
fix 3 test case FAIL issue
This commit is contained in:
@@ -5,6 +5,7 @@ import { ArrowLeft, House, Plus, Save, ClipboardList, ChevronUp, ChevronDown, Al
|
|||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { useCourses } from "@/contexts/AdminCoursesContext";
|
import { useCourses } from "@/contexts/AdminCoursesContext";
|
||||||
import { useAuth } from "@/contexts/AuthContext";
|
import { useAuth } from "@/contexts/AuthContext";
|
||||||
|
import { useUnsavedChangesGuard } from "@/hooks/useUnsavedChangesGuard";
|
||||||
import { PageMeta } from "@/contexts/MetadataContext";
|
import { PageMeta } from "@/contexts/MetadataContext";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -421,6 +422,8 @@ export default function CourseAssessment() {
|
|||||||
? questions.length > 0
|
? questions.length > 0
|
||||||
: snapAssessment({ title, passingScore, timeLimit, isRequired, maxQuestions, maxAttempts, cooldownHours, shuffleQuestions, questions }) !== initialSnapshot.current;
|
: snapAssessment({ title, passingScore, timeLimit, isRequired, maxQuestions, maxAttempts, cooldownHours, shuffleQuestions, questions }) !== initialSnapshot.current;
|
||||||
|
|
||||||
|
const { dialog: unsavedChangesDialog } = useUnsavedChangesGuard(isDirty);
|
||||||
|
|
||||||
// ── Auto-save unsaved changes to localStorage as a draft ───────────────────
|
// ── Auto-save unsaved changes to localStorage as a draft ───────────────────
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (initializing) return;
|
if (initializing) return;
|
||||||
@@ -832,6 +835,8 @@ export default function CourseAssessment() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{unsavedChangesDialog}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
// ─── utils/exportToExcel.js ───────────────────────────────────────────────────
|
// ─── utils/exportToExcel.js ───────────────────────────────────────────────────
|
||||||
import XLSX from "xlsx-js-style";
|
import XLSX from "xlsx-js-style";
|
||||||
|
import { toast } from "sonner";
|
||||||
import { BOOLEAN_FIELD_LABELS } from "@/utils/table.util";
|
import { BOOLEAN_FIELD_LABELS } from "@/utils/table.util";
|
||||||
import { isIsoDateTimeString, fmtDateTimeCompact, fmtDateTimeWithOffset } from "@/utils/datetime.util";
|
import { isIsoDateTimeString, fmtDateTimeCompact, fmtDateTimeWithOffset } from "@/utils/datetime.util";
|
||||||
|
|
||||||
@@ -234,7 +235,7 @@ export function exportToExcel({
|
|||||||
footerNote = "Confidential – For authorized personnel only.",
|
footerNote = "Confidential – For authorized personnel only.",
|
||||||
} = {}) {
|
} = {}) {
|
||||||
if (!data.length || !columns.length) {
|
if (!data.length || !columns.length) {
|
||||||
console.warn("exportToExcel: no data or columns to export.");
|
toast("Nothing to export — the table has no rows.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user