Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"snet-sdk-web": "5.0.4",
"utf8": "^3.0.0",
"validate.js": "^0.13.1",
"waf-captcha-frontend": "0.0.7",
"web3": "^4.11.1"
},
"resolutions": {
Expand Down Expand Up @@ -126,4 +127,4 @@
"ts-protoc-gen": "^0.15.0",
"url": "^0.11.4"
}
}
}
29 changes: 0 additions & 29 deletions src/components/Captcha/WAFScriptLoad.js

This file was deleted.

34 changes: 0 additions & 34 deletions src/components/Captcha/captchaFetchHandler.js

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/Captcha/modal/CaptchaModal.css

This file was deleted.

13 changes: 0 additions & 13 deletions src/components/Captcha/modal/CaptchaModal.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/FeedbackFormModal/FeedbackForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ const FeedbackForm = ({ closeForm, sendFeedbackAPI }) => {
} catch (error) {
setAlert({ type: alertTypes.ERROR, message: error?.message });
} finally {
dispatch(loaderActions.stopAppLoader());
await new Promise((resolve) => setTimeout(resolve, 3000));
resetForm();
setIsRequestHandling(false);
dispatch(loaderActions.stopAppLoader());
closeForm();
}
};
Expand Down
14 changes: 2 additions & 12 deletions src/components/FeedbackFormModal/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
import { Fragment, useEffect, useState } from "react";
import { Fragment, useState } from "react";
import OpenFormButton from "./OpenFormButton";
import "./styles.css";
import FeedbackFormModal from "./FeedbackFormModal";
import { sendFeedbackSnetAPI } from "../../config/SupportAPI";
import CaptchaModal from "../Captcha/modal/CaptchaModal";
import { loadCaptchaScript } from "../Captcha/WAFScriptLoad";

const FeedbackForm = () => {
const [isModalVisible, setIsModalVisible] = useState(false);

useEffect(() => {
try {
loadCaptchaScript();
} catch (err) {
console.error("CAPTCHA script error: ", err);
}
}, []);

return (
<Fragment>
<CaptchaModal />
<div id="captchaContainer" />
<FeedbackFormModal
sendFeedbackAPI={sendFeedbackSnetAPI}
isModalVisible={isModalVisible}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import React, { useEffect, useState } from "react";
import React, { useState } from "react";
import { withStyles } from "@mui/styles";

import AlertBox from "../../../../../../../../common/AlertBox";
import StyledButton from "../../../../../../../../common/StyledButton";
import { useStyles } from "./styles";
import { sendFeedbackSnetAPI } from "../../../../../../../../../config/SupportAPI";
import FeedbackFormModal from "../../../../../../../../FeedbackFormModal/FeedbackFormModal";
import { loadCaptchaScript } from "../../../../../../../../Captcha/WAFScriptLoad";

const PurchaseAlert = ({ classes, alert, handleCancel }) => {
const [isModalVisible, setIsModalVisible] = useState(false);

useEffect(() => {
try {
loadCaptchaScript();
} catch (err) {
console.error("CAPTCHA script error: ", err);
}
}, []);

return (
<div className={classes.purchaseErrorContainer}>
<AlertBox type={alert.type} message={alert.message} />
Expand Down
8 changes: 5 additions & 3 deletions src/config/SupportAPI.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import axios from "axios";
import { captchaFetch } from "../components/Captcha/captchaFetchHandler";
import { getCaptchaFetch } from "../utility/captchaFetch";

const source = "MARKETPLACE";

export const sendFeedbackSnetAPI = ({ name, email, category, feedback, attachmentUrls }) => {
const captchaFetch = getCaptchaFetch();

export const sendFeedbackSnetAPI = async ({ name, email, category, feedback, attachmentUrls }) => {
const options = {
method: "POST",
headers: {
Expand All @@ -27,7 +29,7 @@ export const sendFeedbackSnetAPI = ({ name, email, category, feedback, attachmen
if (!feedbackUrl) {
throw new Error("Cannot start the application! process.env.REACT_APP_FEEDBACK_ENDPOINT is undefined");
}
captchaFetch(feedbackUrl + "/user/message", options);
await captchaFetch(feedbackUrl + "/user/message", options);
};

const ENTER_CODE = "%0D%0A";
Expand Down
20 changes: 20 additions & 0 deletions src/utility/captchaFetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createCaptchaFetchHandler } from "waf-captcha-frontend";

export const getCaptchaFetch = () => {
const keys = {
JSAPI_URL: process.env.REACT_APP_JSAPI_URL,
CAPTCHA_TOKEN: process.env.REACT_APP_CAPTCHA_TOKEN,
};

if (!keys.CAPTCHA_TOKEN || !keys.JSAPI_URL) {
throw new Error("Tokens undefined");
}

const captchaFetch = createCaptchaFetchHandler({
API_KEY: keys.CAPTCHA_TOKEN,
JSAPI_URL: keys.JSAPI_URL,
captchaContainerId: "captchaContainer",
});

return captchaFetch;
};
Loading