Skip to content

Commit

Permalink
front end edits
Browse files Browse the repository at this point in the history
  • Loading branch information
olegliubimov committed Jun 29, 2021
1 parent 0cff3a1 commit 63e6c2d
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const App = () => {
async function handleLogOut() {
await logOut();
history.push("/");
await getStatus(setLogged, setAuthType);
getStatus(setLogged, setAuthType);
}

const routes = (
Expand Down
22 changes: 17 additions & 5 deletions src/api/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { handleResponse, handleError } from "./apiHelper";
import { handleError } from "./apiHelper";
import history from "./history";
import axios from './interceptors';

Expand All @@ -21,6 +21,9 @@ export async function callback() {
process.env.REACT_APP_API_BASE_URL + "/callback",
{
code: code
},
{
withCredentials: true
}
);
return response.data.message
Expand All @@ -34,6 +37,9 @@ export async function logOut() {
try {
await axios.post(
process.env.REACT_APP_API_BASE_URL + "/logout",
{

},
{
withCredentials: true
}
Expand All @@ -47,7 +53,10 @@ export async function logOut() {
export async function getStatus(setStatus, setAuthType) {
try {
let response = await axios.get(
process.env.REACT_APP_API_BASE_URL + "/get_status"
process.env.REACT_APP_API_BASE_URL + "/get_status",
{
withCredentials: true
}
);
setStatus(response.data.logged);
setAuthType(response.data.auth_type);
Expand All @@ -58,7 +67,7 @@ export async function getStatus(setStatus, setAuthType) {

export async function jwtAuth() {
try {
await axios.post(
await axios.get(
process.env.REACT_APP_API_BASE_URL + "/jwt_auth",
{
withCredentials: true
Expand All @@ -82,7 +91,7 @@ export async function completeCallback(setShowAlert, setStatus, setAuthType, set
const message = await callback();
const redirectUrl = localStorage.getItem("redirectUrl")

await getStatus(setStatus, setAuthType);
getStatus(setStatus, setAuthType);
if (message === "Logged in with JWT") {
setShowAlert(true);
}
Expand All @@ -98,7 +107,10 @@ export async function completeCallback(setShowAlert, setStatus, setAuthType, set
export async function checkPayment(setShowJWTModal) {
try {
const response = await axios.get(
process.env.REACT_APP_API_BASE_URL + "/check_payment"
process.env.REACT_APP_API_BASE_URL + "/check_payment",
{
withCredentials: true
}
);
return response;
} catch (error){
Expand Down
2 changes: 1 addition & 1 deletion src/components/Callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const Callback = () => {
const { setLogged, setAuthType, setShowAlert, setShowJWTModal } = useContext(LoggedUserContext);
useEffect(() => {
completeCallback(setShowAlert, setLogged, setAuthType, setShowJWTModal);
}, []);
});

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Frame.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

export const Frame = ({ src }) => (
<iframe
<iframe title="Unique iframe title"
src={src}
style={{
position: "fixed",
Expand Down
3 changes: 1 addition & 2 deletions src/components/JWTModal.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useState, useContext } from "react";
import { Modal, Container, Button } from "react-bootstrap";
import { useTranslation } from "react-i18next";
import { jwtAuth, getStatus, logOut } from "../api/auth";
import history from "../api/history";
import { jwtAuth, logOut, getStatus } from "../api/auth";
import parse from "html-react-parser";
import LoggedUserContext from "../contexts/logged-user/logged-user.context";

Expand Down
6 changes: 0 additions & 6 deletions src/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const initialState = {
export const Login = (props) => {
const [request, setRequestData] = useState({ ...initialState.request });
const [errors, setErrors] = useState({});
const [showWarning, setShowWarning] = useState(false);
const [submitted, setSubmitted] = useState(false);
const { redirectUrl, setLogged, setAuthType } = useContext(LoggedUserContext);
const { t } = useTranslation("Modal");
Expand All @@ -28,15 +27,11 @@ export const Login = (props) => {
const { name, value } = event.target;
const { [name]: removed, ...updatedErrors } = errors;
setSubmitted(false);
setShowWarning(false);
setErrors(updatedErrors);
setRequestData(request => ({
...request,
[name]: loginOptions[value]
}));
if (value === "0") {
setShowWarning(true);
}
}

async function handleClick(event) {
Expand Down Expand Up @@ -78,7 +73,6 @@ export const Login = (props) => {

function handleClose() {
props.onHide();
setShowWarning(false);
setSubmitted(false);
setRequestData(request => ({
...request,
Expand Down
6 changes: 3 additions & 3 deletions src/features/History/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ListItem = ({ item, onClick }) => {
className="dropdown-menu dropdown-menu-right"
aria-labelledby="options3"
>
<a
<a href="#/"
className="dropdown-item"
onClick={() =>
onClick({
Expand All @@ -39,7 +39,7 @@ export const ListItem = ({ item, onClick }) => {
>
{t("HTMLOptionButton")}
</a>
<a
<a href="#/"
className="dropdown-item"
onClick={() =>
onClick({
Expand All @@ -52,7 +52,7 @@ export const ListItem = ({ item, onClick }) => {
>
{t("SummaryOptionButton")}
</a>
<a
<a href="#/"
className="dropdown-item"
onClick={() =>
onClick({
Expand Down
2 changes: 1 addition & 1 deletion src/features/RequestExtracurricularActivity/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const RequestExtracurricularActivityPage = () => {

useEffect(() => {
checkUnlogged(logged, setLogged, setAuthType);
}, []);
});

async function handleSave(event) {
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion src/features/RequestMajorMinorChange/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const RequestMajorMinorChangePage = () => {

useEffect(() => {
checkUnlogged(logged, setLogged, setAuthType);
}, [])
})

async function handleSave(event) {
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion src/features/RequestTranscript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const RequestTranscriptPage = () => {

useEffect(() => {
checkUnlogged(logged, setLogged, setAuthType);
}, [])
})

async function handleSave(event) {
event.preventDefault();
Expand Down

0 comments on commit 63e6c2d

Please sign in to comment.