diff --git a/client/src/components/characterCard.js b/client/src/components/characterCard.js
index f78d866..b9db9a8 100644
--- a/client/src/components/characterCard.js
+++ b/client/src/components/characterCard.js
@@ -17,34 +17,30 @@ export default function CharacterCard(props) {
{characterName}
-
-
-
-
-
-
-
-
- | First Episode: |
-
- {firstEpisode} |
-
-
-
-
-
- | Last Episode: |
-
- {lastEpisode} |
-
-
-
-
+
+
+
+
+
+ | First Episode: |
+
+ {firstEpisode} |
+
+
+
+
+
+ | Last Episode: |
+
+ {lastEpisode} |
+
+
+
+
-
+
diff --git a/client/src/components/loadingError.js b/client/src/components/loadingError.js
new file mode 100644
index 0000000..0f612c9
--- /dev/null
+++ b/client/src/components/loadingError.js
@@ -0,0 +1,30 @@
+import React from 'react';
+
+import Container from 'react-bootstrap/Container';
+import Row from 'react-bootstrap/Row';
+import Col from 'react-bootstrap/Col';
+
+export default function LoadingError(props) {
+ return (
+
+
+
+
+
+
+ {props.message}
+
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
diff --git a/client/src/pages/home.js b/client/src/pages/home.js
index 1c46759..3cd59be 100644
--- a/client/src/pages/home.js
+++ b/client/src/pages/home.js
@@ -4,6 +4,7 @@ import Greeting from '../components/greeting';
import CardHolder from '../components/cardHolder';
import CharacterCard from '../components/characterCard';
import Loading from '../components/loading';
+import LoadingError from '../components/loadingError';
import CharacterService from '../services/characterService';
const characterService = new CharacterService();
@@ -11,13 +12,17 @@ const characterService = new CharacterService();
export default function Home() {
const [characters, setCharacters] = useState([]);
+ const [errorMessage, setErrorMessage] = useState(null);
const getCharacters = async () => {
const res = await characterService.getCharacters();
- // TODO: Handle a failed request.
- if (!res.ok) return;
+ if (!res.ok) {
+
+ return setErrorMessage('Failed to load characters.');
+
+ }
const characters = await res.json();
@@ -26,7 +31,9 @@ export default function Home() {
}
useEffect(() => {
+
getCharacters();
+
}, []);
const getCharacterCards = () => {
@@ -37,6 +44,7 @@ export default function Home() {
);
@@ -45,6 +53,12 @@ export default function Home() {
}
+ const handleTryAgain = async () => {
+
+ if (errorMessage === 'Failed to load characters.') return await getCharacters();
+
+ }
+
return (
<>
@@ -57,6 +71,13 @@ export default function Home() {
+ : errorMessage ?
+
+
+
: }
>
);
diff --git a/client/src/styles/app.css b/client/src/styles/app.css
index 37b08c9..9a41ea5 100644
--- a/client/src/styles/app.css
+++ b/client/src/styles/app.css
@@ -14,4 +14,14 @@
.highlight {
color: #912718;
+}
+
+.btn-cta,
+.btn-cta:hover,
+.btn-cta:focus,
+.btn-cta:active:focus {
+ color: white;
+ background-color: #912718;
+ border-color: #912718;
+ box-shadow: none;
}
\ No newline at end of file