) : null}
@@ -445,34 +479,42 @@ export default function Quizzes() {
) : (
-
-
+
+
+
+
+
+
+
+
{(courses as any[]).map((course) => (
+
+ {generating
+ ? "Generating five questions from indexed course materials."
+ : !selectedCourse
+ ? "Select a course to continue."
+ : !selectedCourseHasIndexedMaterials
+ ? "Upload and index course materials before generating a quiz."
+ : quizAlreadyGeneratedToday
+ ? "Your next quiz will be available tomorrow."
+ : "Ready to generate a five-question quiz."}
+
)}
diff --git a/src/views/Schedule.tsx b/src/views/Schedule.tsx
index fe174c0..eeed41a 100644
--- a/src/views/Schedule.tsx
+++ b/src/views/Schedule.tsx
@@ -2,11 +2,12 @@
import { useEffect, useState, useMemo } from "react";
import { motion } from "framer-motion";
-import { ChevronLeft, ChevronRight, Plus, Clock, Trash2, Sparkles, MapPin, CalendarDays, GraduationCap, Star, BookOpen, Pencil } from "lucide-react";
+import { AlertTriangle, ChevronLeft, ChevronRight, Plus, Clock, Trash2, Sparkles, MapPin, CalendarDays, GraduationCap, Star, BookOpen, Pencil, RefreshCw } from "lucide-react";
import ScheduleScreenshotImport from "@/components/ScheduleScreenshotImport";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
+import { Skeleton } from "@/components/ui/skeleton";
import { Badge } from "@/components/ui/badge";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Label } from "@/components/ui/label";
@@ -142,7 +143,7 @@ export default function Schedule() {
end_hour: "10", end_min: "00",
});
- const { data: events = [] } = useQuery({
+ const { data: events = [], isLoading: eventsLoading, isError: eventsError, refetch: refetchEvents } = useQuery({
queryKey: ["events", user?.id],
queryFn: async () => {
const { data, error } = await supabase.from("events").select("*, courses(name, color)").order("start_time");
@@ -152,7 +153,7 @@ export default function Schedule() {
enabled: !!user,
});
- const { data: courses = [] } = useQuery({
+ const { data: courses = [], isLoading: coursesLoading, isError: coursesError, refetch: refetchCourses } = useQuery({
queryKey: ["courses", user?.id],
queryFn: async () => {
const { data, error } = await supabase.from("courses").select("id, name, code, color").order("name");
@@ -162,7 +163,7 @@ export default function Schedule() {
enabled: !!user,
});
- const { data: assignments = [] } = useQuery({
+ const { data: assignments = [], isLoading: assignmentsLoading, isError: assignmentsError, refetch: refetchAssignments } = useQuery({
queryKey: ["assignments-schedule", user?.id],
queryFn: async () => {
const { data, error } = await supabase.from("assignments").select("*, courses(name)").eq("status", "pending").order("due_date");
@@ -172,7 +173,7 @@ export default function Schedule() {
enabled: !!user,
});
- const { data: academicDates = [] } = useQuery({
+ const { data: academicDates = [], isLoading: academicDatesLoading, isError: academicDatesError, refetch: refetchAcademicDates } = useQuery({
queryKey: ["academic-dates-schedule", user?.id],
queryFn: async () => {
const { data, error } = await supabase
@@ -493,18 +494,49 @@ export default function Schedule() {
? `Busy day ahead with ${todayEvents.length} events. Prioritize your most demanding tasks first.`
: `You have ${todayEvents.length} event${todayEvents.length > 1 ? "s" : ""} today. Plan focused study blocks around them.`;
+ const scheduleLoading = eventsLoading || coursesLoading || assignmentsLoading || academicDatesLoading;
+ const scheduleError = eventsError || coursesError || assignmentsError || academicDatesError;
+
+ if (scheduleLoading) {
+ return (
+
+
+
+
+ Loading schedule…
+
+ );
+ }
+
+ if (scheduleError) {
+ return (
+
+
+
+ Your schedule could not be loaded
+ Check your connection and try loading your calendar again.
+
+
+
+ );
+ }
+
return (
{/* Hero Header */}
-
+
Schedule
Your academic calendar & time management
-
+
{events.length > 0 && (