diff --git a/src/common/contributor-dashboard/ContributorPlay.jsx b/src/common/contributor-dashboard/ContributorPlay.jsx new file mode 100644 index 0000000000..8ae8525f54 --- /dev/null +++ b/src/common/contributor-dashboard/ContributorPlay.jsx @@ -0,0 +1,83 @@ +import { useState, useEffect } from 'react'; +import { Link } from 'react-router-dom'; +import { BsPlayCircleFill } from 'react-icons/bs'; +import thumbPlay from 'images/thumb-play.png'; +import Shimmer from 'react-shimmer-effect'; +import userImage from 'images/user.png'; +import Like from 'common/components/Like/Like'; +import { useUserId, useAuthenticated } from '@nhost/react'; +import countByProp from 'common/utils/commonUtils'; + +const PlayThumbnail = ({ play }) => { + const [cover, setCover] = useState(null); + const isAuthenticated = useAuthenticated(); + const userId = useUserId(); + + const likeObject = () => { + const { play_like } = play; + const number = countByProp(play_like, 'liked', true); + if (isAuthenticated) { + const liked = play_like.find((i) => i.user_id === userId)?.liked; + + return { liked, number }; + } + + return { liked: false, number }; + }; + + useEffect(() => { + // Set the cover image + // if it is passed as a meta data + if (play.cover) { + setCover(play.cover); + } else { + // if it is not passed as a meta data + // check in the play folder for a cover image + // with the name cover.png + import(`plays/${play.slug}/cover.png`) + .then((Cover) => { + setCover(Cover.default); + }) + .catch((err) => { + // if there is no cover image, set a default image + setCover(thumbPlay); + + return { + success: false, + error: err, + message: `Cover image not found for the play ${play.name}. Setting the default cover image...` + }; + }); + } + }, [play]); + + return ( +
+ {userInfo.users_user_profile_map && userInfo.users_user_profile_map.email} +
*/} ++ {userInfo.users_user_profile_map && + userInfo.users_user_profile_map.plays[0].github} +
+{data.followers} Followers
{' '} +{data.following} Followings
+{data.bio}
+{data.company}
+ +handleTabSelect(tab)} + > + {tab} ( + {tab === TabList[0] + ? allBadges.length + : tab === TabList[1] + ? plays.length + : ''} + ) +
+Contribution
+User not found
+ )} +