Skip to content

Commit e57a8f4

Browse files
committed
Update some packages, move from history to navigate
1 parent 33819b1 commit e57a8f4

File tree

7 files changed

+186
-169
lines changed

7 files changed

+186
-169
lines changed

package-lock.json

Lines changed: 156 additions & 140 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@babel/core": "^7.24.3",
7-
"@testing-library/react": "^14.2.2",
6+
"@babel/core": "^7.24.4",
7+
"@testing-library/react": "^14.3.1",
88
"axios": "^1.6.8",
99
"bootstrap": "^4.6.2",
1010
"bootstrap-icons": "^1.11.3",
1111
"chokidar": "^3.6.0",
1212
"history": "^4.10.1",
1313
"html-react-parser": "^4.2.10",
14-
"i18next": "^23.10.1",
14+
"i18next": "^23.11.2",
1515
"i18next-xhr-backend": "^3.2.2",
1616
"jquery": "^3.7.1",
1717
"node-sass": "^9.0.0",

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ chardet==5.2.0
55
click==8.1.7
66
cryptography==42.0.5
77
docusign-esign==3.25.1
8-
Flask==3.0.2
8+
Flask==3.0.3
99
Flask-Cors==4.0.0
1010
Flask-Session==0.8.0
1111
Flask-WTF==1.2.1
12-
idna==3.6
13-
itsdangerous==2.1.2
12+
idna==3.7
13+
itsdangerous==2.2.0
1414
Jinja2==3.1.3
1515
MarkupSafe==2.1.5
1616
nose==1.3.7

src/api/auth.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { handleError } from "./apiHelper";
2-
import history from "./history";
32
import axios from './interceptors';
43

54
export async function codeGrantAuth(redirectUrl) {
@@ -13,7 +12,7 @@ export async function codeGrantAuth(redirectUrl) {
1312
}
1413
}
1514

16-
export async function callback() {
15+
export async function callback(navigate) {
1716
try {
1817
const urlParams = new URLSearchParams(window.location.search);
1918
const code = urlParams.get('code');
@@ -28,7 +27,7 @@ export async function callback() {
2827
);
2928
return response.data.message
3029
} catch (error) {
31-
history.push("/");
30+
navigate("/");
3231
handleError(error);
3332
}
3433
}
@@ -45,7 +44,6 @@ export async function logOut() {
4544
}
4645
);
4746
} catch (error) {
48-
history.push('/');
4947
handleError(error);
5048
}
5149
}
@@ -65,7 +63,7 @@ export async function getStatus(setStatus, setAuthType) {
6563
}
6664
}
6765

68-
export async function jwtAuth() {
66+
export async function jwtAuth(navigate) {
6967
try {
7068
await axios.get(
7169
process.env.REACT_APP_API_BASE_URL + "/jwt_auth",
@@ -74,37 +72,37 @@ export async function jwtAuth() {
7472
}
7573
);
7674
} catch (error){
77-
history.push('/');
75+
navigate('/');
7876
handleError(error);
7977
}
8078
}
8179

82-
export async function checkUnlogged(logged, setStatus, setAuthType) {
80+
export async function checkUnlogged(logged, setStatus, setAuthType, navigate) {
8381
if (!logged) {
84-
await jwtAuth();
82+
await jwtAuth(navigate);
8583
await getStatus(setStatus, setAuthType)
8684
}
8785
}
8886

89-
export async function completeCallback(setShowAlert, setStatus, setAuthType, setShowJWTModal) {
87+
export async function completeCallback(setShowAlert, setStatus, setAuthType, setShowJWTModal, navigate) {
9088
try {
91-
const message = await callback();
89+
const message = await callback(navigate);
9290
const redirectUrl = localStorage.getItem("redirectUrl")
9391

9492
await getStatus(setStatus, setAuthType);
9593
if (message === "Logged in with JWT") {
9694
setShowAlert(true);
9795
}
9896
else if (redirectUrl === '/byNewInsurance') {
99-
await checkPayment(setShowJWTModal);
97+
await checkPayment(setShowJWTModal, navigate);
10098
}
101-
history.push(redirectUrl);
99+
navigate(redirectUrl);
102100
} catch (error){
103101
handleError(error, setShowJWTModal)
104102
}
105103
}
106104

107-
export async function checkPayment(setShowJWTModal) {
105+
export async function checkPayment(setShowJWTModal, navigate) {
108106
try {
109107
const response = await axios.get(
110108
process.env.REACT_APP_API_BASE_URL + "/check_payment",
@@ -114,7 +112,7 @@ export async function checkPayment(setShowJWTModal) {
114112
);
115113
return response;
116114
} catch (error){
117-
history.push('/');
115+
navigate("/");
118116
handleError(error, setShowJWTModal);
119117
}
120118
}

src/components/Callback.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React, { useEffect, useContext } from "react";
22
import { completeCallback } from "../api/auth";
33
import LoggedUserContext from "../contexts/logged-user/logged-user.context";
4+
import { useNavigate } from "react-router-dom";
45

56
export const Callback = () => {
67
const { setShowAlert, setLogged, setAuthType, setShowJWTModal } = useContext(LoggedUserContext);
8+
const navigate = useNavigate();
79
useEffect(() => {
8-
completeCallback(setShowAlert, setLogged, setAuthType, setShowJWTModal);
10+
completeCallback(setShowAlert, setLogged, setAuthType, setShowJWTModal, navigate);
911
// eslint-disable-next-line react-hooks/exhaustive-deps
1012
}, []);
1113

src/components/Modal.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Modal, Container, Button } from "react-bootstrap";
33
import { InputRadio } from "./InputRadio";
44
import { useTranslation } from "react-i18next";
55
import { codeGrantAuth, jwtAuth, getStatus } from "../api/auth";
6-
import history from "../api/history";
76
import parse from "html-react-parser";
87
import LoggedUserContext from "../contexts/logged-user/logged-user.context";
8+
import { useNavigate } from "react-router-dom";
99

1010

1111
const initialState = {
@@ -22,6 +22,7 @@ export const Login = (props) => {
2222
const { redirectUrl, setLogged, setAuthType } = useContext(LoggedUserContext);
2323
const { t } = useTranslation("Modal");
2424
const loginOptions = t("LoginOptions", { returnObjects: true });
25+
const navigate = useNavigate();
2526

2627

2728
function handleChange(event) {
@@ -46,9 +47,9 @@ export const Login = (props) => {
4647
if (request.loginOption === loginOptions[0]) {
4748
await codeGrantAuth(redirectUrl);
4849
} else if (request.loginOption === loginOptions[1]){
49-
await jwtAuth();
50+
await jwtAuth(navigate);
5051
await getStatus(setLogged, setAuthType);
51-
history.push(redirectUrl);
52+
navigate(redirectUrl);
5253
handleClose();
5354
}
5455
} catch(error) {

src/pages/home/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useContext } from "react";
2-
import { Link } from "react-router-dom";
2+
import { Link, useNavigate } from "react-router-dom";
33
import image1 from "../../assets/img/img-01.svg";
44
import image2 from "../../assets/img/img-02.svg";
55
import image3 from "../../assets/img/img-03.svg";
@@ -9,12 +9,12 @@ import parse from "html-react-parser";
99
import LoggedUserContext from "../../contexts/logged-user/logged-user.context";
1010
import ModalContext from "../../contexts/modal/modal.context";
1111
import { checkPayment } from "../../api/auth";
12-
import history from "../../api/history";
1312

1413
export const Home = () => {
1514
const { t } = useTranslation("Home");
1615
const { logged, setRedirectUrl, setShowJWTModal, authType } = useContext(LoggedUserContext);
1716
const { setModalShow } = useContext(ModalContext);
17+
const navigate = useNavigate();
1818

1919
function handleClick(event, redirectUrl) {
2020
event.preventDefault();
@@ -25,12 +25,12 @@ export const Home = () => {
2525
async function handlePayment(event, redirectUrl) {
2626
event.preventDefault()
2727
if (authType === "code_grant"){
28-
const response = await checkPayment(setShowJWTModal)
28+
const response = await checkPayment(setShowJWTModal, navigate)
2929
if (response.status === 200) {
30-
history.push(redirectUrl);
30+
navigate(redirectUrl);
3131
}
3232
} else {
33-
history.push(redirectUrl);
33+
navigate(redirectUrl);
3434
}
3535
}
3636

0 commit comments

Comments
 (0)