Skip to content

Commit a281128

Browse files
committed
➕ Add: Quota exceeding message + Add blog link at the footer
1 parent 11fb1f4 commit a281128

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

src/components/Footer.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ const Footer = () => {
4747
>
4848
GitHub.{" "}
4949
</a>
50-
Hosted on{" "}
50+
Read the complete blog on{" "}
5151
<a
52-
href="https://vercel.com"
52+
href="https://www.freecodecamp.org/news/how-to-build-react-based-code-editor/"
5353
target="__blank"
5454
className="text-gray-700 hover:bg-red-500 hover:text-white font-medium"
5555
>
56-
Vercel
56+
FreeCodeCamp
5757
</a>
58+
.
5859
</span>
5960
</div>
6061
);

src/components/Landing.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,19 @@ const Landing = () => {
110110
})
111111
.catch((err) => {
112112
let error = err.response ? err.response.data : err;
113+
// get error status
114+
let status = err.response.status;
115+
console.log("status", status);
116+
if (status === 429) {
117+
console.log("too many requests", status);
118+
119+
showErrorToast(
120+
`Quota of 100 requests exceeded for the Day! Please read the blog on freeCodeCamp to learn how to setup your own RAPID API Judge0!`,
121+
10000
122+
);
123+
}
113124
setProcessing(false);
114-
console.log(error);
125+
console.log("catch block...", error);
115126
});
116127
};
117128

@@ -130,17 +141,18 @@ const Landing = () => {
130141
let statusId = response.data.status?.id;
131142

132143
// Processed - we have a result
133-
if (statusId !== 1 && statusId !== 2) {
134-
setProcessing(false);
135-
setOutputDetails(response.data);
136-
showSuccessToast();
137-
console.log("response.data", response.data);
138-
return;
139-
} else {
144+
if (statusId === 1 || statusId === 2) {
140145
// still processing
141146
setTimeout(() => {
142147
checkStatus(token);
143148
}, 2000);
149+
return;
150+
} else {
151+
setProcessing(false);
152+
setOutputDetails(response.data);
153+
showSuccessToast(`Compiled Successfully!`);
154+
console.log("response.data", response.data);
155+
return;
144156
}
145157
} catch (err) {
146158
console.log("err", err);
@@ -176,10 +188,10 @@ const Landing = () => {
176188
progress: undefined,
177189
});
178190
};
179-
const showErrorToast = (msg) => {
191+
const showErrorToast = (msg, timer) => {
180192
toast.error(msg || `Something went wrong! Please try again.`, {
181193
position: "top-right",
182-
autoClose: 1000,
194+
autoClose: timer ? timer : 1000,
183195
hideProgressBar: false,
184196
closeOnClick: true,
185197
pauseOnHover: true,

0 commit comments

Comments
 (0)