Skip to content

Commit 33165b5

Browse files
committed
[SM-254] add WAF captcha package
1 parent 3f3f8ad commit 33165b5

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"snet-sdk-web": "5.0.4",
5252
"utf8": "^3.0.0",
5353
"validate.js": "^0.13.1",
54+
"waf-captcha-frontend": "0.0.7",
5455
"web3": "^4.11.1"
5556
},
5657
"resolutions": {
@@ -126,4 +127,4 @@
126127
"ts-protoc-gen": "^0.15.0",
127128
"url": "^0.11.4"
128129
}
129-
}
130+
}

src/components/FeedbackFormModal/FeedbackForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ const FeedbackForm = ({ closeForm, sendFeedbackAPI }) => {
3838
} catch (error) {
3939
setAlert({ type: alertTypes.ERROR, message: error?.message });
4040
} finally {
41+
dispatch(loaderActions.stopAppLoader());
4142
await new Promise((resolve) => setTimeout(resolve, 3000));
4243
resetForm();
4344
setIsRequestHandling(false);
44-
dispatch(loaderActions.stopAppLoader());
4545
closeForm();
4646
}
4747
};

src/config/SupportAPI.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import axios from "axios";
2-
import { captchaFetch } from "../components/Captcha/captchaFetchHandler";
2+
import { getCaptchaFetch } from "../utility/captchaFetch";
33

44
const source = "MARKETPLACE";
55

6-
export const sendFeedbackSnetAPI = ({ name, email, category, feedback, attachmentUrls }) => {
6+
const captchaFetch = getCaptchaFetch();
7+
8+
export const sendFeedbackSnetAPI = async ({ name, email, category, feedback, attachmentUrls }) => {
79
const options = {
810
method: "POST",
911
headers: {
@@ -27,7 +29,7 @@ export const sendFeedbackSnetAPI = ({ name, email, category, feedback, attachmen
2729
if (!feedbackUrl) {
2830
throw new Error("Cannot start the application! process.env.REACT_APP_FEEDBACK_ENDPOINT is undefined");
2931
}
30-
captchaFetch(feedbackUrl + "/user/message", options);
32+
await captchaFetch(feedbackUrl + "/user/message", options);
3133
};
3234

3335
const ENTER_CODE = "%0D%0A";

src/utility/captchaFetch.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { createCaptchaFetchHandler } from "waf-captcha-frontend";
2+
3+
export const getCaptchaFetch = () => {
4+
const keys = {
5+
JSAPI_URL: process.env.REACT_APP_JSAPI_URL,
6+
CAPTCHA_TOKEN: process.env.REACT_APP_CAPTCHA_TOKEN,
7+
};
8+
9+
if (!keys.CAPTCHA_TOKEN || !keys.JSAPI_URL) {
10+
throw new Error("Tokens undefined");
11+
}
12+
13+
const captchaFetch = createCaptchaFetchHandler({
14+
API_KEY: keys.CAPTCHA_TOKEN,
15+
JSAPI_URL: keys.JSAPI_URL,
16+
captchaContainerId: "captchaContainer",
17+
});
18+
19+
return captchaFetch;
20+
};

0 commit comments

Comments
 (0)