diff --git a/src/App.scss b/src/App.scss
index 3a9cd21..c1e1e98 100644
--- a/src/App.scss
+++ b/src/App.scss
@@ -39,4 +39,10 @@ $default-font: "Segoe UI";
a {
text-decoration: none;
+}
+
+.home-content {
+ color: $text-color;
+ width: 100vw;
+ height: 100vh;
}
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index aa74936..4ddea8e 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -15,11 +15,11 @@ function App() {
}/>
+ element={} />
}/>
+ element={} />
-
+
);
diff --git a/src/Home/Home.tsx b/src/Home/Home.tsx
index 9549374..aa598b1 100644
--- a/src/Home/Home.tsx
+++ b/src/Home/Home.tsx
@@ -1,27 +1,35 @@
-import { useState } from "react";
+import React, { useState } from "react";
+import DisplayBackgroundImage from '../images/DisplayBackgroundImage';
function Home() {
- const [username, setUsername] = useState("");
- const [submitStatus, setSubmitStatus] = useState(false);
+ const [username, setUsername] = useState("");
+ const [submitStatus, setSubmitStatus] = useState(false);
const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();
setSubmitStatus(true);
}
+ const homeBackgroundImage = DisplayBackgroundImage();
+
return (
<>
-
+
+
+ {/* Other components and content */}
+
+
+
>
)
}
diff --git a/src/images/DisplayBackgroundImage.tsx b/src/images/DisplayBackgroundImage.tsx
new file mode 100644
index 0000000..e069e9f
--- /dev/null
+++ b/src/images/DisplayBackgroundImage.tsx
@@ -0,0 +1,50 @@
+import React, { useState, useEffect } from 'react';
+import { fetchAPI } from '../utils/fetchData';
+
+interface PictureOfDay {
+ date: string,
+ explanation: string,
+ hdurl: string,
+ title: string,
+ url: string
+}
+
+const DisplayBackgroundImage = () => {
+ const [myPictureData, setMyPictureData] = useState(null);
+ const [isLoading, setIsLoading] = useState(false);
+ const [error, setError] = useState(null);
+
+ const FetchPicture = async () => {
+
+ try {
+ setIsLoading(true);
+
+ const pictureData = await fetchAPI("https://api.nasa.gov/planetary/apod?api_key=");
+
+ setMyPictureData(pictureData);
+ setIsLoading(false);
+
+ } catch (err: unknown) {
+ if (err instanceof Error) {
+ setError(err); // Set the actual Error object
+ } else {
+ setError(new Error('An unknown error occurred')); // Provide a default Error object
+ }
+
+ setIsLoading(false);
+ }
+ }
+ useEffect(() => {
+ FetchPicture();
+ }, [])
+
+ if (isLoading) return (Is Loading...
);
+ if (error) return ({error.message}
);
+ if (!myPictureData) return (EMPTY
);
+
+
+ return myPictureData.hdurl;
+
+};
+
+export default DisplayBackgroundImage;
\ No newline at end of file
diff --git a/src/images/DisplayPicture.tsx b/src/images/DisplayPicture.tsx
index bc3d4d0..5b4f978 100644
--- a/src/images/DisplayPicture.tsx
+++ b/src/images/DisplayPicture.tsx
@@ -43,4 +43,5 @@ export const DisplayPictureOfDay = () => {
if (!myPictureData) return (EMPTY
);
return myPictureData;
+
};
\ No newline at end of file