Skip to content

Commit

Permalink
Merge pull request #625 from pennlabs/aag/frontend-fixes
Browse files Browse the repository at this point in the history
Frontend fixes
  • Loading branch information
AaDalal authored Apr 8, 2024
2 parents d668040 + 62acb4b commit 9816982
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions backend/degree/static/pdp/degree-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ const LayoutFlow = () => {
const [edges, setEdges, onEdgesChange] = useEdgesState([]);

const onConnect = useCallback((params) => {
console.log("onConnect", params);
if (params.source === params.target) return;
const [sourceIsDegree, sourceId] = pkOfNodeId(params.source);
const [targetIsDegree, targetId] = pkOfNodeId(params.target);
if (sourceIsDegree || targetIsDegree) return;
console.log("HERE");
const redirect = `/admin/degree/doublecountrestriction/add/?rule=${sourceId}&other_rule=${targetId}`;
window.location.href = redirect;
}, []);
Expand Down
5 changes: 2 additions & 3 deletions frontend/degree-plan/components/FourYearPlan/Semesters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Select from "react-select";
import { ModalKey } from "./DegreeModal";

const getNextSemester = (semester: string) => {
console.log("GET NEXT SEMESTER");
const year = parseInt(semester.slice(0, 4));
const season = semester.slice(4);
if (season === "A") {
Expand Down Expand Up @@ -238,10 +237,10 @@ const Semesters = ({
let parsed;
try {
parsed = JSON.parse(stickyValue)
setSemesters(parsed)
} catch {
setSemesters(getDefaultSemesters());
}
setSemesters(parsed);
}, [activeDegreeplan, currentSemester]);

/** Update semesters to local storage */
Expand All @@ -250,7 +249,7 @@ const Semesters = ({
// if finish loading and no semesters, we go to edit mode for the user to add new semesters
else setEditMode(false);
if (!activeDegreeplan) return;
if (typeof window !== undefined) {
if (typeof window !== "undefined" && Object.keys(semesters).length) {
localStorage.setItem(
getLocalSemestersKey(activeDegreeplan.id),
JSON.stringify(semesters)
Expand Down
1 change: 0 additions & 1 deletion frontend/degree-plan/components/FourYearPlanPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ const FourYearPlanPage = ({
if (!isLoadingDegreeplans && !degreeplans?.length) {
setShowOnboardingModal(true);
}
console.log(activeDegreeplan)
if (!degreeplans?.length) {
setActiveDegreeplan(null);
} else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const CourseInReq = (props : CourseInReqProps) => {
/** If the current rule about to be removed is the only rule
* the course satisfied, then we delete the fulfillment */
if (updated_rules && updated_rules.length == 0) {
console.log('hwere')
removeFulfillment(full_code);
} else {
updateFulfillment({rules: updated_rules}, full_code);
Expand Down
3 changes: 0 additions & 3 deletions frontend/degree-plan/components/Requirements/QObject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ const QObject = ({ q, fulfillments, rule, satisfied, activeDegreePlanId }: QObje
case "COURSE":
const [fulfillment] = fulfillments.filter(fulfillment => fulfillment.full_code == q.full_code && (!q.semester || q.semester === fulfillment.semester))
return <CourseInReq course={{...q, rules: fulfillment ? fulfillment.rules : []}} fulfillment={fulfillment} isDisabled={satisfied && !fulfillment} isUsed={!!fulfillment} rule_id={rule.id} activeDegreePlanId={activeDegreePlanId}/>;
// onClick={() => { console.log("fired"); createOrUpdate({ rules: [rule.id] }, q.full_code)}}
}
}

Expand Down Expand Up @@ -351,8 +350,6 @@ const RuleLeaf = ({ q_json, fulfillmentsForRule, rule, satisfied, activeDegreePl
const t3 = transformSearchConditions(t2)
q_json = t3 as TransformedQObject;

// console.log(q_json)

return (
<RuleLeafWrapper $wrap>
<QObject q={q_json} fulfillments={fulfillmentsForRule} rule={rule} satisfied={satisfied} activeDegreePlanId={activeDegreePlanId} />
Expand Down
8 changes: 7 additions & 1 deletion frontend/degree-plan/pages/OnboardingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ const OnboardingPage = ({
/** Filter major options based on selected schools/degrees */
const majorOptions =
degrees
?.filter((d) => d.year == startingYear?.value && schools.map((s) => s.value).includes(d.degree))
?.filter((d) => schools.map((s) => s.value).includes(d.degree))
.sort((d) => Math.abs((startingYear ? startingYear.value : d.year) - d.year))
.map((degree) => ({
value: degree,
label: createMajorLabel(degree),
Expand All @@ -268,6 +269,11 @@ const OnboardingPage = ({
getLocalSemestersKey(res.id),
JSON.stringify(interpolateSemesters(startingYear.value, graduationYear.value))
);
console.log(
"****",
getLocalSemestersKey(res.id),
JSON.stringify(interpolateSemesters(startingYear.value, graduationYear.value))
);
}
setActiveDegreeplan(res);
const updated = postFetcher(
Expand Down

0 comments on commit 9816982

Please sign in to comment.