From fda7b73b806678f53cb625c75ab62f9191172655 Mon Sep 17 00:00:00 2001 From: Mallepally Lokeshwar Reddy Date: Sat, 24 Aug 2024 16:44:49 +0530 Subject: [PATCH] feat: Display tutorials on Profile Page --- .../User/UserProfile/UserProfile.jsx | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/components/User/UserProfile/UserProfile.jsx b/src/components/User/UserProfile/UserProfile.jsx index c0e31882..b2b52aea 100644 --- a/src/components/User/UserProfile/UserProfile.jsx +++ b/src/components/User/UserProfile/UserProfile.jsx @@ -9,6 +9,12 @@ import OrgUser from "../../../assets/images/org-user.svg"; import { userList } from "../../HomePage/userList"; import Card from "@mui/material/Card"; import UserHighlights from "./UserHighlights"; +import { useDispatch, useSelector } from "react-redux"; +import { useFirebase, useFirestore } from "react-redux-firebase"; +import { + getTutorialFeedData, + getTutorialFeedIdArray +} from "../../../store/actions/tutorialPageActions"; const useStyles = makeStyles(theme => ({ parentBody: { @@ -50,6 +56,32 @@ const useStyles = makeStyles(theme => ({ function UserProfile(props) { const classes = useStyles(); + const firebase = useFirebase(); + const firestore = useFirestore(); + const dispatch = useDispatch(); + getTutorialFeedData; + + const profileData = useSelector(({ firebase: { profile } }) => profile); + + useEffect(() => { + const getFeed = async () => { + const tutorialIdArray = await getTutorialFeedIdArray(profileData.uid)( + firebase, + firestore, + dispatch + ); + getTutorialFeedData(tutorialIdArray)(firebase, firestore, dispatch); + }; + getFeed(); + }, []); + + const tutorials = useSelector( + ({ + tutorialPage: { + feed: { homepageFeedArray } + } + }) => homepageFeedArray + ); const [organizations, setUpOrganizations] = useState([ { @@ -104,11 +136,14 @@ function UserProfile(props) { - {userList.persons.map(person => { - return person.Heading == "CardWithoutPicture" ? ( - + {tutorials.map(tutorial => { + return !tutorial?.featured_image ? ( + ) : ( - + ); })}