Skip to content

Commit

Permalink
feat: Display tutorials on Profile Page
Browse files Browse the repository at this point in the history
  • Loading branch information
lokeshwar777 committed Aug 24, 2024
1 parent f2bbb51 commit fda7b73
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions src/components/User/UserProfile/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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([
{
Expand Down Expand Up @@ -104,11 +136,14 @@ function UserProfile(props) {
</Grid>

<Grid>
{userList.persons.map(person => {
return person.Heading == "CardWithoutPicture" ? (
<CardWithoutPicture {...person} className={classes.card} />
{tutorials.map(tutorial => {
return !tutorial?.featured_image ? (
<CardWithoutPicture
tutorial={tutorial}
className={classes.card}
/>
) : (
<CardWithPicture {...person} className={classes.card} />
<CardWithPicture tutorial={tutorial} className={classes.card} />
);
})}
</Grid>
Expand Down

0 comments on commit fda7b73

Please sign in to comment.