diff --git a/client/pages/profile/index.js b/client/pages/profile/index.js index 6e88ad5..197ac4b 100644 --- a/client/pages/profile/index.js +++ b/client/pages/profile/index.js @@ -5,7 +5,7 @@ import RHeader from "@/components/header"; import UpdateUsername from "@/components/changeusername"; import { Button, Modal, ModalBody, ModalFooter, Form, FormGroup, Label, Input } from "reactstrap"; import ChangePassword from "@/components/changepassword"; - +import FilesApi from "@/Api/FilesApi"; const ProfileCard = () => { @@ -15,6 +15,8 @@ const ProfileCard = () => { const [showUpdateUsername, setShowUpdateUsername] = useState(false); const [imagesExpanded, setImagesExpanded] = useState(false); const imagesContainerRef = useRef(null); + const [images, setImages] = useState([]); + const [loading, setLoading] = useState(true); const toggleImagesExpanded = () => { setImagesExpanded(!imagesExpanded); @@ -48,7 +50,41 @@ const ProfileCard = () => { fetchUsername(); }, []); -const toggleUpdateUsernameModal = () => { + + useEffect(() => { + const fetchImages = async () => { + const userId = sessionStorage.getItem('uid'); + const response = await FilesApi.get(`/user/${userId}`); + setImages(response.data); + setLoading(false); + }; + + fetchImages(); + }, []); + + const renderImages = () => { + if (loading) { + return
Loading...
; + } + + if (images.length === 0) { + // If no images found for the user, render default image + return ( +
+ No images found +
+ ); + } + + return images.map((image) => ( +
+ {`Image +
+ )); + }; + + + const toggleUpdateUsernameModal = () => { setModalOpen(!modalOpen); }; @@ -59,7 +95,19 @@ const toggleUpdateUsernameModal = () => {
-
+ +
+ +
+ + + +
+

+ {username} +

+ +
@@ -72,16 +120,6 @@ const toggleUpdateUsernameModal = () => {
-
- -
- - - -
-

- {username} -

Enjoy Stylizing your best Selfies

FaceStylizer is a Non-Profit Organization

@@ -97,16 +135,8 @@ const toggleUpdateUsernameModal = () => { {imagesExpanded && (
-
-
- Image 1 -
-
- Image 2 -
-
- Image 3 -
+
+ {renderImages()}
)} @@ -115,10 +145,10 @@ const toggleUpdateUsernameModal = () => {