+
+
+<<<<<<< HEAD
{adviserName || `Adviser Group: ${adviserGroup}`}
@@ -213,6 +238,9 @@ const AdviserGroupSection = ({ adviserGroup, teams, adviserName }) => {
tasks • {groupStats.completionRate}% overall completion
+=======
+
{adviserName || `Adviser Group: ${adviserGroup}`}
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
@@ -220,74 +248,6 @@ const AdviserGroupSection = ({ adviserGroup, teams, adviserName }) => {
);
};
-// SVG-based Circular Progress Bar (kept)
-const ProgressCircle = ({ percentage }) => {
- const radius = 54;
- const circumference = 2 * Math.PI * radius;
- const strokeDashoffset = circumference - (percentage / 100) * circumference;
- const isFilled = percentage > 0;
-
- return (
-
-
- {isFilled && (
-
- )}
-
- {percentage}%
-
-
- );
-};
-
-const TeamCard = ({ adviser, teams }) => {
- return (
-
-
-
- {adviser}
-
-
- {teams.map((team, index) => (
-
- ))}
-
-
- );
-};
-
const InstructorDashboard = () => {
useAuthGuard();
const [activePage, setActivePage] = useState("Dashboard");
@@ -328,7 +288,7 @@ const InstructorDashboard = () => {
const [hour, minute] = timeString.split(":");
let h = parseInt(hour, 10);
const ampm = h >= 12 ? "PM" : "AM";
- h = h % 12 || 12; // Convert to 12-hour format
+ h = h % 12 || 12;
return `${h}:${minute} ${ampm}`;
};
@@ -339,7 +299,6 @@ const InstructorDashboard = () => {
setIsLoading(true);
setDebugInfo("Fetching instructor dashboard data...");
- // Fetch all adviser tasks (oral and final defense)
const [oralTasksResult, finalTasksResult] = await Promise.all([
supabase.from("adviser_oral_def").select("*"),
supabase.from("adviser_final_def").select("*"),
@@ -361,11 +320,9 @@ const InstructorDashboard = () => {
})),
];
- console.log("📊 All Adviser Tasks Found:", allAdviserTasks.length);
-
const today = new Date();
- // 1. Upcoming Tasks with manager names
+ // 1. Upcoming Tasks
const upcoming = allAdviserTasks
.filter(
(task) =>
@@ -410,37 +367,43 @@ const InstructorDashboard = () => {
.select("first_name, last_name")
.eq("id", task.manager_id)
.single();
+<<<<<<< HEAD
return {
...task,
managerName: manager
? `${manager.first_name} ${manager.last_name}`
: "Unknown Manager",
+=======
+ return {
+ ...task,
+ managerName: manager ? `${manager.first_name} ${manager.last_name}` : "Unknown Manager"
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
};
})
);
setRecentTasks(recentWithNames);
+<<<<<<< HEAD
// 3. Teams' Progress - Fetch ALL project managers with ALL their tasks
console.log("👥 Fetching all project managers...");
+=======
+ // 3. Teams' Progress
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
const { data: teams, error: teamsError } = await supabase
.from("user_credentials")
.select("id, group_name, first_name, last_name, adviser_group")
- .eq("user_roles", 1); // All project managers (user_roles = 1)
-
- console.log("👥 All Project Managers Found:", teams?.length);
+ .eq("user_roles", 1);
if (teamsError) {
console.error("❌ Error fetching teams:", teamsError);
- setDebugInfo(`Error fetching teams: ${teamsError.message}`);
setTeamsProgress([]);
setAdviserGroups([]);
} else if (!teams || teams.length === 0) {
- console.warn("⚠️ No project managers found");
- setDebugInfo("No project managers found in the system");
setTeamsProgress([]);
setAdviserGroups([]);
} else {
+<<<<<<< HEAD
setDebugInfo(`Found ${teams.length} project manager(s)`);
// Fetch comprehensive task progress for each project manager
@@ -472,13 +435,21 @@ const InstructorDashboard = () => {
.from("adviser_final_def")
.select("status, task, due_date")
.eq("manager_id", team.id),
+=======
+ const teamsProgressData = await Promise.all(
+ teams.map(async (team) => {
+ try {
+ const [managerTasksResult, adviserOralTasksResult, adviserFinalTasksResult] = await Promise.all([
+ supabase.from("manager_title_task").select("status, task_name, due_date").eq("manager_id", team.id),
+ supabase.from("adviser_oral_def").select("status, task, due_date").eq("manager_id", team.id),
+ supabase.from("adviser_final_def").select("status, task, due_date").eq("manager_id", team.id)
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
]);
const managerTasks = managerTasksResult.data || [];
const adviserOralTasks = adviserOralTasksResult.data || [];
const adviserFinalTasks = adviserFinalTasksResult.data || [];
- // Combine ALL tasks for this team
const allTeamTasks = [
...managerTasks.map((t) => ({ ...t, source: "manager" })),
...adviserOralTasks.map((t) => ({
@@ -491,6 +462,7 @@ const InstructorDashboard = () => {
})),
];
+<<<<<<< HEAD
console.log(`📋 Team ${team.group_name} tasks:`, {
managerTasks: managerTasks.length,
adviserOralTasks: adviserOralTasks.length,
@@ -513,18 +485,29 @@ const InstructorDashboard = () => {
"To Review": 0,
Completed: 0,
Missed: 0,
+=======
+ if (allTeamTasks.length === 0) {
+ return null;
+ }
+
+ const counts = {
+ "To Do": 0,
+ "In Progress": 0,
+ "To Review": 0,
+ "Completed": 0,
+ "Missed": 0
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
};
allTeamTasks.forEach((task) => {
if (counts[task.status] !== undefined) {
counts[task.status]++;
} else {
- // Handle unknown statuses
counts["To Do"]++;
}
});
- const teamProgress = {
+ return {
group_name: team.group_name,
manager_id: team.id,
manager_name: `${team.first_name} ${team.last_name}`,
@@ -537,12 +520,15 @@ const InstructorDashboard = () => {
adviser_final_tasks: adviserFinalTasks.length,
},
};
+<<<<<<< HEAD
console.log(
`✅ Team ${team.group_name} progress:`,
teamProgress
);
return teamProgress;
+=======
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
} catch (error) {
console.error(
`❌ Error processing team ${team.group_name}:`,
@@ -552,11 +538,15 @@ const InstructorDashboard = () => {
}
})
);
+<<<<<<< HEAD
// Filter out null values (teams with no tasks or errors)
+=======
+
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
const filteredTeamsProgress = teamsProgressData.filter(Boolean);
- console.log("🎯 Final teams progress data:", filteredTeamsProgress);
setTeamsProgress(filteredTeamsProgress);
+<<<<<<< HEAD
// Group teams by adviser_group
const groupedByAdviser = filteredTeamsProgress.reduce(
@@ -570,11 +560,20 @@ const InstructorDashboard = () => {
},
{}
);
+=======
+
+ const groupedByAdviser = filteredTeamsProgress.reduce((groups, team) => {
+ const adviserGroup = team.adviser_group || 'Ungrouped';
+ if (!groups[adviserGroup]) {
+ groups[adviserGroup] = [];
+ }
+ groups[adviserGroup].push(team);
+ return groups;
+ }, {});
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
- console.log("👨🏫 Teams grouped by adviser:", groupedByAdviser);
-
- // Get adviser names for each group (user_roles = 3 for advisers)
const adviserGroupsWithNames = await Promise.all(
+<<<<<<< HEAD
Object.entries(groupedByAdviser).map(
async ([adviserGroup, teams]) => {
// Try to get adviser name from user_credentials
@@ -598,6 +597,21 @@ const InstructorDashboard = () => {
`❌ No adviser found for group: ${adviserGroup} with user_roles = 3`
);
}
+=======
+ Object.entries(groupedByAdviser).map(async ([adviserGroup, teams]) => {
+ let adviserName = `Adviser Group: ${adviserGroup}`;
+
+ if (adviserGroup && adviserGroup !== 'Ungrouped') {
+ const { data: adviser } = await supabase
+ .from("user_credentials")
+ .select("first_name, last_name")
+ .eq("adviser_group", adviserGroup)
+ .eq("user_roles", 3)
+ .single();
+
+ if (adviser) {
+ adviserName = `${adviser.first_name} ${adviser.last_name}`;
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
}
return {
@@ -610,6 +624,7 @@ const InstructorDashboard = () => {
);
setAdviserGroups(adviserGroupsWithNames);
+<<<<<<< HEAD
if (filteredTeamsProgress.length === 0) {
setDebugInfo((prev) => prev + " - But no teams have tasks yet");
@@ -620,23 +635,16 @@ const InstructorDashboard = () => {
` - ${filteredTeamsProgress.length} team(s) across ${adviserGroupsWithNames.length} adviser group(s)`
);
}
+=======
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
}
- // 4. Calendar Events
+ // 4. Calendar Events - with uniform color
const events = allAdviserTasks.map((task) => ({
id: task.id,
title: `${task.task} (${task.status})`,
start: task.due_date,
- color:
- task.status === "Completed"
- ? "#4BC0C0"
- : task.status === "Missed"
- ? "#FF6384"
- : task.status === "In Progress"
- ? "#809D3C"
- : task.status === "To Review"
- ? "#578FCA"
- : "#FABC3F",
+ color: TASKSPHERE_PRIMARY,
}));
setCalendarEvents(events);
@@ -690,31 +698,33 @@ const InstructorDashboard = () => {
return
;
default:
return (
-
+
{isLoading ? (
-
+
Loading...
Loading dashboard data...
) : (
<>
- {/* Section 1: INSTRUCTOR UPCOMING ACTIVITY */}
-
-
INSTRUCTOR UPCOMING ACTIVITY
-
+ {/* Section 1: UPCOMING ACTIVITY */}
+
+
UPCOMING ACTIVITY
+
{upcomingTasks.length === 0 ? (
No upcoming tasks.
) : (
upcomingTasks.map((t, i) => (
-
-
-
+
+
Title Defense
+
+
{t.managerName}
+<<<<<<< HEAD
{t.task}
@@ -737,6 +747,17 @@ const InstructorDashboard = () => {
>
{t.status}
+=======
+
+
+
+ {new Date(t.due_date).toLocaleDateString()}
+
+
+
+ {formatTime(t.time) || "No Time"}
+
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
))
@@ -744,6 +765,7 @@ const InstructorDashboard = () => {
+<<<<<<< HEAD
{/* Section 2: TEAMS' PROGRESS GROUPED BY ADVISER */}
@@ -754,8 +776,14 @@ const InstructorDashboard = () => {
+=======
+ {/* Section 2: TEAMS' PROGRESS */}
+
+
TEAMS' PROGRESS
+
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
{adviserGroups.length > 0 ? (
-
+
{adviserGroups.map((group, index) => (
{
{/* Section 3: RECENT ACTIVITY CREATED */}
-
-
RECENT ACTIVITY CREATED
+
+
RECENT ACTIVITY CREATED
{recentTasks.length === 0 ? (
No recent activities.
) : (
-
+
NO
- TASK
- DATE CREATED
- DUE DATE
- TIME
- STATUS
- TYPE
- MANAGER
+ Team
+ Date Created
+ Date
+ Time
+ Status
{recentTasks.map((t, i) => (
{i + 1}.
+<<<<<<< HEAD
{t.task}
{new Date(
@@ -821,9 +848,15 @@ const InstructorDashboard = () => {
>
{t.status}
-
- {t.type}
+=======
{t.managerName || "—"}
+ {new Date(t.date_created || t.created_at).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}
+ {t.due_date ? new Date(t.due_date).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }) : "—"}
+ {formatTime(t.time) || "—"}
+
+ {t.status}
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
+
))}
@@ -832,10 +865,10 @@ const InstructorDashboard = () => {
)}
- {/* Section 4: INSTRUCTOR CALENDAR */}
-
-
INSTRUCTOR CALENDAR
-
+ {/* Section 4: CALENDAR */}
+
+
CALENDAR
+
{
headerToolbar={{
left: "prev,next today",
center: "title",
+<<<<<<< HEAD
right: "dayGridMonth,timeGridWeek,timeGridDay",
+=======
+ right: "dayGridMonth"
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
}}
events={calendarEvents}
- height="400px"
+ height="auto"
+ eventDisplay="block"
/>
@@ -858,10 +896,14 @@ const InstructorDashboard = () => {
{/* CSS Styles */}
@@ -1191,12 +1562,16 @@ const InstructorDashboard = () => {
};
return (
+<<<<<<< HEAD
+=======
+
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
-
+
{
flexGrow: 1,
marginLeft: `${sidebarWidth}px`,
transition: "margin-left 0.3s",
+ background: "#ffffff"
}}
id="main-content-wrapper"
>
+<<<<<<< HEAD
+=======
+
+>>>>>>> 5b15d1d0e9f31e5eab7c8102b1a1dfffbaa33113
{renderContent()}
diff --git a/src/components/Instructor/RolesTransfer.jsx b/src/components/Instructor/RolesTransfer.jsx
index 74c4e02..36a2285 100644
--- a/src/components/Instructor/RolesTransfer.jsx
+++ b/src/components/Instructor/RolesTransfer.jsx
@@ -1,9 +1,8 @@
// src/components/Instructor/RoleTransfer.jsx
import React, { useState, useEffect } from "react";
-import { FaUserCircle } from "react-icons/fa";
+import { FaUserCircle, FaUserTie, FaUserPlus } from "react-icons/fa";
import Swal from "sweetalert2";
import { supabase } from "../../supabaseClient";
-import "bootstrap/dist/css/bootstrap.min.css";
const RoleTransfer = () => {
const [formData, setFormData] = useState({
@@ -55,268 +54,296 @@ const RoleTransfer = () => {
};
// ✅ Handle submit with SweetAlert2 confirmation
- // ✅ Handle submit with SweetAlert2 confirmation
-const handleSubmit = async (e) => {
- e.preventDefault();
-
- if (!validateFields()) {
- Swal.fire({
- icon: "error",
- title: "Missing Fields",
- text: "Please fill out all fields before enrolling.",
- });
- return;
- }
-
- const confirm = await Swal.fire({
- title: "Confirm Role Transfer?",
- text: "Are you sure you want to enroll this new instructor?",
- icon: "warning",
- showCancelButton: true,
- confirmButtonColor: "#5a0d0e",
- cancelButtonColor: "#6c757d",
- confirmButtonText: "Yes, Enroll",
- });
-
- if (confirm.isConfirmed) {
- // ✅ Step 1: Insert new instructor
- const { data, error } = await supabase
- .from("user_credentials")
- .insert([
- {
- user_id: formData.idNo,
- password: formData.password,
- first_name: formData.firstName,
- last_name: formData.lastName,
- middle_name: formData.middleName,
- user_roles: 3, // Adviser / New Instructor
- email: formData.email,
- },
- ])
- .select()
- .single();
+ const handleSubmit = async (e) => {
+ e.preventDefault();
- if (error) {
- console.error("Error inserting new instructor:", error);
+ if (!validateFields()) {
Swal.fire({
icon: "error",
- title: "Enrollment Failed",
- text: "An error occurred while enrolling the new instructor.",
+ title: "Missing Fields",
+ text: "Please fill out all fields before enrolling.",
});
return;
}
- // ✅ Step 2: Add notification for this newly created instructor
- try {
- const { error: notifError } = await supabase.from("notification").insert([
- {
- user_id: data.id, // 👈 uuid of the newly created account
- title: "You Have Been Assigned as the New Capstone Instructor",
- description: "The current instructor has officially transferred the Capstone advising role to you. You are now designated as the new Capstone Instructor for the group.",
- date: new Date().toISOString(), // timestamp
- },
- ]);
+ const confirm = await Swal.fire({
+ title: "Confirm Role Transfer?",
+ text: "Are you sure you want to enroll this new instructor?",
+ icon: "warning",
+ showCancelButton: true,
+ confirmButtonColor: "#5a0d0e",
+ cancelButtonColor: "#6c757d",
+ confirmButtonText: "Yes, Enroll",
+ });
- if (notifError) {
- console.error("Error adding notification:", notifError);
- } else {
- console.log("✅ Notification successfully added!");
+ if (confirm.isConfirmed) {
+ // ✅ Step 1: Insert new instructor
+ const { data, error } = await supabase
+ .from("user_credentials")
+ .insert([
+ {
+ user_id: formData.idNo,
+ password: formData.password,
+ first_name: formData.firstName,
+ last_name: formData.lastName,
+ middle_name: formData.middleName,
+ user_roles: 3, // Adviser / New Instructor
+ email: formData.email,
+ },
+ ])
+ .select()
+ .single();
+
+ if (error) {
+ console.error("Error inserting new instructor:", error);
+ Swal.fire({
+ icon: "error",
+ title: "Enrollment Failed",
+ text: "An error occurred while enrolling the new instructor.",
+ });
+ return;
}
- } catch (notifErr) {
- console.error("Notification insert failed:", notifErr);
- }
- // ✅ Step 3: Success alert and reset form
- Swal.fire({
- icon: "success",
- title: "Enrolled Successfully!",
- text: "The new instructor has been added successfully.",
- });
+ // ✅ Step 2: Add notification for this newly created instructor
+ try {
+ const { error: notifError } = await supabase.from("notification").insert([
+ {
+ user_id: data.id, // 👈 uuid of the newly created account
+ title: "You Have Been Assigned as the New Capstone Instructor",
+ description: "The current instructor has officially transferred the Capstone advising role to you. You are now designated as the new Capstone Instructor for the group.",
+ date: new Date().toISOString(), // timestamp
+ },
+ ]);
- setFormData({
- lastName: "",
- firstName: "",
- middleName: "",
- idNo: "",
- password: "",
- email: "",
- });
- }
-};
- return (
-
-
+ if (notifError) {
+ console.error("Error adding notification:", notifError);
+ } else {
+ console.log("✅ Notification successfully added!");
+ }
+ } catch (notifErr) {
+ console.error("Notification insert failed:", notifErr);
+ }
-
- {/* Header */}
-
-
- Role Transfer
-
+ // ✅ Step 3: Success alert and reset form
+ Swal.fire({
+ icon: "success",
+ title: "Enrolled Successfully!",
+ text: "The new instructor has been added successfully.",
+ });
- {/* Current Instructor */}
-
-
Current Capstone Instructor
- {currentInstructor ? (
- <>
-
- Name: {" "}
- {`${currentInstructor.first_name} ${currentInstructor.middle_name || ""} ${currentInstructor.last_name}`}
-
-
- ID No: {currentInstructor.user_id}
-
- >
- ) : (
-
Loading current instructor...
- )}
-
+ setFormData({
+ lastName: "",
+ firstName: "",
+ middleName: "",
+ idNo: "",
+ password: "",
+ email: "",
+ });
+ }
+ };
- {/* New Instructor */}
-
-
New Capstone Instructor
-