Skip to content

Commit

Permalink
Merge pull request #30 from swat-sccs/dcrepublic-dev
Browse files Browse the repository at this point in the history
Fix cookie error
  • Loading branch information
DCRepublic authored Dec 2, 2024
2 parents 5cba8c8 + 0096f6d commit 677eea0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/CreatePlan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export default function CreatePlan(props: any) {
}
async function updateLocalPlan() {
const planCourses: any = await getPlanCourses1();
setCourses(planCourses.courses);
if (planCourses) {
setCourses(planCourses?.courses);
}
if (scrollRef.current) {
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
}
Expand Down Expand Up @@ -119,15 +121,17 @@ export default function CreatePlan(props: any) {

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

const CoursesList = () => {
const output: any = [];

if (courses) {
if (courses && courses != undefined) {
return courses.map((course: any) => (
<Card
key={course.id}
Expand Down

0 comments on commit 677eea0

Please sign in to comment.