Commit 4ca29017 authored by Imane Misrar's avatar Imane Misrar
Browse files

feat(PageUniversity) : create lastVisitedUniversity when you click on a new university

Relates to #149
parent e120ff47
import React from "react";
import React, { useEffect } from "react";
import PropTypes from "prop-types";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
......@@ -11,6 +11,7 @@ import { withErrorBoundary } from "../common/ErrorBoundary";
import APP_ROUTES from "../../config/appRoutes";
import CustomNavLink from "../common/CustomNavLink";
import UniversityService from "../../services/data/UniversityService";
import { useApiCreate } from "../../hooks/wrappers/api";
function UniversityNotFound() {
return (
......@@ -34,13 +35,25 @@ function UniversityNotFound() {
);
}
let lastVisitedUniv = -1;
/**
* Component holding the page with the university details
*/
function PageUniversity({ match }) {
const { univId, tabName } = match.params;
const createLastVisited = useApiCreate("lastVisitedUniversities");
useEffect(() => {
if (lastVisitedUniv !== univId)
createLastVisited({ university: univId }, () => {
lastVisitedUniv = univId;
});
}, [univId]);
const parsedUnivId = parseInt(univId, 10);
if (UniversityService.hasUniversity(parsedUnivId)) {
return (
<UnivInfoProvider univId={parsedUnivId}>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment