Skip to content

Commit 662fd90

Browse files
authored
refresh when a new year is added
1 parent 5e6bfd7 commit 662fd90

File tree

1 file changed

+8
-4
lines changed
  • client/src/screens/browse/components/year-info

1 file changed

+8
-4
lines changed

client/src/screens/browse/components/year-info/index.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { useState } from "react";
44
import { addYear,deleteYear } from "../../../../api/Year";
55
import { getCourse } from "../../../../api/Course";
66
import { useDispatch } from "react-redux";
7-
import { ChangeCurrentYearData,ChangeFolder,RefreshCurrentFolder } from "../../../../actions/filebrowser_actions";
7+
import { ChangeCurrentYearData,ChangeFolder,LoadCourses,RefreshCurrentFolder} from "../../../../actions/filebrowser_actions";
88

99
import {ConfirmDialog} from "./confirmDialog";
1010
import {ConfirmDelDialog} from "./confirmDelDialog";
1111

1212
const YearInfo = ({
1313
isBR,
1414
courseCode,
15-
course,
15+
course, // years list
1616
currYear,
1717
}) => {
1818
const dispatch = useDispatch();
@@ -40,12 +40,16 @@ const YearInfo = ({
4040
toast.error("Course not found. Cannot add year.");
4141
return;
4242
}
43-
44-
await addYear({
43+
const newYear=await addYear({
4544
name: yearName.trim(),
4645
course: courseCode,
4746
});
4847

48+
course.push(newYear);
49+
dispatch(LoadCourses(newYear));
50+
dispatch(ChangeCurrentYearData(course.length-1, []));
51+
dispatch(ChangeFolder(newYear));
52+
4953
toast.success(`Year "${yearName}" added`);
5054
} catch (error) {
5155
console.log(error);

0 commit comments

Comments
 (0)