diff --git a/sports-matcher/client/src/components/SportInfoCard.js b/sports-matcher/client/src/components/SportInfoCard.js index 5995d4d..14477e9 100644 --- a/sports-matcher/client/src/components/SportInfoCard.js +++ b/sports-matcher/client/src/components/SportInfoCard.js @@ -13,7 +13,7 @@ export default class SportInfoCard extends React.Component { {this.props.sport.name} {this.props.sport.minPlayers.toString()} -

{this.props.sport.description}

+ {this.props.sport.description}
diff --git a/sports-matcher/client/src/pages/Dashboard.js b/sports-matcher/client/src/pages/Dashboard.js index e400a1b..a8370a0 100644 --- a/sports-matcher/client/src/pages/Dashboard.js +++ b/sports-matcher/client/src/pages/Dashboard.js @@ -4,6 +4,9 @@ import "../styles/Dashboard.css"; import { apiClient } from "../utils/httpClients.js"; import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay"; import SportInfoCardDisplay from "../components/SportInfoCardDisplay"; +import { globalContext } from "../context"; +import { needUser } from "../utils/routing"; + export default class Dashboard extends React.Component { constructor(props) { super(props); @@ -15,7 +18,10 @@ export default class Dashboard extends React.Component { }; } + static contextType = globalContext; + async componentDidMount() { + await needUser(this.context.navigate); await this.latestMatches(); await this.availableSports(); } diff --git a/sports-matcher/client/src/utils/httpClients.js b/sports-matcher/client/src/utils/httpClients.js index 95af7d7..6cff00c 100644 --- a/sports-matcher/client/src/utils/httpClients.js +++ b/sports-matcher/client/src/utils/httpClients.js @@ -1,7 +1,10 @@ import axios from "axios"; export const apiClient = axios.create({ - baseURL: process.env.REACT_APP_API_HOST + "/api/", + baseURL: process.env.REACT_APP_API_HOST || "" + "/api/", timeout: 5000, withCredentials: process.env.NODE_ENV === "development", + validateStatus: function (status) { + return status === 401 || status == 200; + } }); \ No newline at end of file