Fixed backend issue, update course status working

This commit is contained in:
Harshitha Shetty
2025-01-04 23:50:59 +05:30
parent b4adca13c7
commit 7079591f84
7 changed files with 123 additions and 454 deletions

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react";
import { useLocation, useParams, useNavigate } from "react-router-dom";
import { fetchFaculties, saveAppointment } from "../api";
import { fetchFaculties, saveAppointment, updateCourseStatus } from "../api";
import "./CourseForm.css";
const CourseForm = () => {
@@ -85,7 +85,7 @@ const CourseForm = () => {
if (!groupedTasks[assignedFaculty.facultyId]) {
groupedTasks[assignedFaculty.facultyId] = {
facultyId: assignedFaculty.facultyId,
courseId: course?.id || id,
courseId: course?.courseId || id,
tasks: [],
};
}
@@ -96,6 +96,7 @@ const CourseForm = () => {
const payload = Object.values(groupedTasks); // Convert the grouped tasks into an array
console.log("Saving appointment with payload:", payload);
await saveAppointment(payload); // Save to backend
await updateCourseStatus(course?.courseId || id);
console.log("Form submitted successfully:", payload);
// Redirect to courses page after successful submission
@@ -119,7 +120,7 @@ const CourseForm = () => {
<form onSubmit={handleSubmit}>
<label>
Course ID:
<input type="text" value={course?.id || id} readOnly />
<input type="text" value={course?.courseId || id} readOnly />
</label>
<label>
Course Name: