Skip to content

Commit

Permalink
Merge pull request #29 from swat-sccs/dcrepublic-dev
Browse files Browse the repository at this point in the history
Fix broken calendar
  • Loading branch information
DCRepublic authored Dec 1, 2024
2 parents ae3c14c + 7eedba0 commit 5cba8c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/calendar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Calendar from "../../components/Calendar";
import prisma from "../../lib/prisma";
import { getPlanCookie } from "../actions/actions";
import { generateColorFromName } from "../../components/primitives";
import { getCoursePlans, getPlanCourses1 } from "app/actions/getCourses";

interface Event {
classNames: string;
Expand Down Expand Up @@ -104,6 +105,9 @@ async function getEvents(): Promise<Event[]> {

export default async function CalendarPage() {
const events: Event[] = await getEvents();
const planCourses: any = await getPlanCourses1();
const coursePlans: any = await getCoursePlans();

let endTime = "17:00";
let startTime = "09:00";

Expand All @@ -121,7 +125,7 @@ export default async function CalendarPage() {
<Calendar events={events} startTime={startTime} endTime={endTime} />
</div>
<div className="sm:h-[62vh] col-span-10 sm:col-span-3 sm:ml-[5vw]">
<CreatePlan />
<CreatePlan initialPlan={planCourses} coursePlans={coursePlans} />
</div>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions components/CreatePlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default function CreatePlan(props: any) {
}
}
async function updateLocalPlan() {
console.log("updating local plan");
const planCourses: any = await getPlanCourses1();
setCourses(planCourses.courses);
if (scrollRef.current) {
Expand Down Expand Up @@ -115,13 +114,14 @@ export default function CreatePlan(props: any) {
};

useEffect(() => {
console.log("RUNNING THE SCROll");
updateLocalPlan();
}, [props.initialPlan, props.coursePlans, cookies.get("selectedCourses")]);

useEffect(() => {
setSelectedCoursePlan([cookies.get("plan")]);
setCourses(props.initialPlan.courses);
if (props.initialPlan.courses) {
setCourses(props.initialPlan.courses);
}
}, [props.initialPlan, cookies.get("plan")]);

const CoursesList = () => {
Expand Down

0 comments on commit 5cba8c8

Please sign in to comment.