Skip to content

Commit

Permalink
Merge pull request #36 from amagovpt/fix-api-endpoint
Browse files Browse the repository at this point in the history
Fix url in form
  • Loading branch information
eadafonso authored Sep 3, 2024
2 parents 105d25a + 5fbe11c commit 43dcb86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
7 changes: 2 additions & 5 deletions src/pages/Details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export default function Details({ allData, setAllData }) {
},
];

const removeProtocol = (url) => {
return url.replace(/^(https?:\/\/)?(www\.)?/, "");
};

function getDetailsData(data, tt) {
const response = getTestResults(details, data, tt);
setDataTable(response);
Expand All @@ -79,7 +75,8 @@ export default function Details({ allData, setAllData }) {
const storedUrl = localStorage.getItem("evaluationUrl");
const test = location.pathname.split("/")
let url = test[test.length-2]
const currentUrl = removeProtocol(url.split("%2F")[2]) +"/"

const currentUrl = decodeURIComponent(url)

if (storedData && storedUrl === currentUrl) {
const parsedStoredData = JSON.parse(storedData);
Expand Down
6 changes: 1 addition & 5 deletions src/pages/PageCode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export default function Resume() {
navigate(`${pathURL}results/${test[test.length-2]}`);
};

const removeProtocol = (url) => {
return url.replace(/^(https?:\/\/)?(www\.)?/, "");
};

useEffect(() => {
const fetchData = async () => {
setLoadingProgress(true);
Expand All @@ -58,7 +54,7 @@ export default function Resume() {
const storedUrl = localStorage.getItem("evaluationUrl");
const test = location.pathname.split("/")
let url = test[test.length-2]
const currentUrl = removeProtocol(url.split("%2F")[2]) +"/"
const currentUrl = decodeURIComponent(url)
if (storedData && storedUrl === currentUrl) {
const parsedStoredData = JSON.parse(storedData);
setOriginalData(parsedStoredData);
Expand Down
12 changes: 3 additions & 9 deletions src/pages/Resume/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export default function Resume({ setAllData, setEle }) {
const { theme } = useContext(ThemeContext);
const themeClass = theme === "light" ? "" : "dark_mode-resume";

const removeProtocol = (url) => {
return url.replace(/^(https?:\/\/)?(www\.)?/, "");
};

const decodedUrl = removeProtocol(content);

useEffect(() => {
const fetchData = async () => {
setLoadingProgress(true);
Expand All @@ -47,7 +41,7 @@ export default function Resume({ setAllData, setEle }) {
const storedData = localStorage.getItem("evaluation");
const storedUrl = localStorage.getItem("evaluationUrl");

const currentUrl = content === "html" ? contentHtml : decodedUrl;
const currentUrl = content === "html" ? contentHtml : content;

if (storedData && storedUrl === currentUrl) {
const parsedStoredData = JSON.parse(storedData);
Expand All @@ -60,7 +54,7 @@ export default function Resume({ setAllData, setEle }) {

return;
}

const response = await getEvalData(content, currentUrl);


Expand All @@ -83,7 +77,7 @@ export default function Resume({ setAllData, setEle }) {
};

fetchData();
}, [content, contentHtml, decodedUrl]);
}, [content, contentHtml]);

const reRequest = () => {
if (content === "html") {
Expand Down

0 comments on commit 43dcb86

Please sign in to comment.