Skip to content

Commit 255cfdc

Browse files
Merge pull request #87 from Rahulagg13/feat/add-random-anime-quote
Feat: Add Random Anime Quote
2 parents cbe9a11 + 19834ae commit 255cfdc

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "acm-fun",
33
"version": "0.1.0",
44
"private": true,
5+
"proxy": "https://animechan.io",
56
"dependencies": {
67
"@testing-library/jest-dom": "^5.17.0",
78
"@testing-library/react": "^13.4.0",

src/data/content.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {SearchWord} from "../pages/activities/getDefinition";
88
import {Jitter} from "../pages/games/Jitter";
99
import {RandomMeme} from "../pages/activities/RandomMemes";
1010
import { RandomJoke } from "../pages/activities/RandomJoke";
11+
import { RandomAnimeQuote } from "../pages/activities/RandomAnimeQuote";
1112
import meme from "../assets/activities/meme.jpg"
1213
import numberblocs from "../assets/numberblocks.png"
1314
import wordleicon from "../assets/games/Wordle/wordlejpg.png"
@@ -22,6 +23,13 @@ export const activities = [
2223
urlTerm: "random-quotes",
2324
element: <RandomQuote />
2425
},
26+
{
27+
title: "Random Anime Quotes",
28+
description: "Get random anime quotes",
29+
icon: "https://64.media.tumblr.com/7b526ba246f48e294ebc87fe2cbd8e1b/1a4bdb8275a18adc-c7/s250x400/94d6c7e70601111ba79b8801cd939694d0000018.jpg", // Add the path to the anime icon image
30+
urlTerm: "random-anime-quotes",
31+
element: <RandomAnimeQuote />, // Assuming you have a RandomQuote component for anime quotes
32+
},
2533
{
2634
title: "Random memes",
2735
description: "Get random meme",
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { useEffect, useState } from "react";
2+
import axios from "axios";
3+
import "../../styles/pages/activities/RandomQuote.css";
4+
5+
export const RandomAnimeQuote = () => {
6+
const [quote, setQuote] = useState(null);
7+
const [error, setError] = useState(null);
8+
9+
const generateQuote = async () => {
10+
try {
11+
setQuote(null);
12+
const res = await axios.get("/api/v1/quotes/random");
13+
setQuote(res.data.data);
14+
} catch (error) {
15+
console.log(error);
16+
setError(error);
17+
}
18+
};
19+
20+
useEffect(() => {
21+
generateQuote();
22+
}, []);
23+
24+
return (
25+
<div className="rquote-root">
26+
<h1 className="header">Random Anime Quote Generator</h1>
27+
<div className="description">
28+
Generate any random anime quote to get some inspiration!
29+
</div>
30+
{quote && (
31+
<div className="rquote-content">
32+
<div className="rquote-quote">{quote.content}</div>
33+
<div className="rquote-author">
34+
- {quote.character.name} ({quote.anime.name})
35+
</div>
36+
</div>
37+
)}
38+
{error && (
39+
<div className="rquote-content error">
40+
Too many requests have been sent to the API. Please try again after an
41+
hour.
42+
</div>
43+
)}
44+
{!quote && !error && (
45+
<div className="spinner-wrapper">
46+
<div className="spinner"></div>
47+
</div>
48+
)}
49+
<button className="rquote-button" onClick={() => generateQuote()}>
50+
Generate Quote
51+
</button>
52+
</div>
53+
);
54+
};

0 commit comments

Comments
 (0)