diff --git a/src/components/Card/CardWithoutPicture.jsx b/src/components/Card/CardWithoutPicture.jsx index abc4ecb0..5b4708cd 100644 --- a/src/components/Card/CardWithoutPicture.jsx +++ b/src/components/Card/CardWithoutPicture.jsx @@ -18,6 +18,7 @@ import ToggleButton from "@mui/lab/ToggleButton"; import ToggleButtonGroup from "@mui/lab/ToggleButtonGroup"; import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; +import ShareTutorial from "../Tutorials/ShareTutorial"; import { useDispatch, useSelector } from "react-redux"; import { useFirebase, useFirestore } from "react-redux-firebase"; import { getUserProfileData } from "../../store/actions"; @@ -65,8 +66,9 @@ const useStyles = makeStyles(theme => ({ } })); -export default function CardWithoutPicture({ tutorial }) { +export default function CardWithoutPicture({ tutorial,setOpenShare,openShare,onSidebarClick, }) { const classes = useStyles(); + console.log(tutorial) const [alignment, setAlignment] = React.useState("left"); const [count, setCount] = useState(1); const dispatch = useDispatch(); @@ -84,6 +86,10 @@ export default function CardWithoutPicture({ tutorial }) { setAlignment(newAlignment); }; + const handleShare = () => { + setOpenShare(!openShare); + } + useEffect(() => { getUserProfileData(tutorial?.created_by)(firebase, firestore, dispatch); }, [tutorial]); @@ -102,6 +108,14 @@ export default function CardWithoutPicture({ tutorial }) { return ( + + @@ -207,10 +221,11 @@ export default function CardWithoutPicture({ tutorial }) { - + - + + diff --git a/src/components/HomePage/index.jsx b/src/components/HomePage/index.jsx index e8190e6b..cabc8e1d 100644 --- a/src/components/HomePage/index.jsx +++ b/src/components/HomePage/index.jsx @@ -31,6 +31,7 @@ import CardWithoutPicture from "../Card/CardWithoutPicture"; import Activity from "../Topbar/Activity"; import useWindowSize from "../../helpers/customHooks/useWindowSize"; import NewTutorial from "../Tutorials/NewTutorial"; +import ShareTutorial from "../Tutorials/ShareTutorial"; import { useDispatch, useSelector } from "react-redux"; import { useFirebase, useFirestore } from "react-redux-firebase"; import { @@ -46,6 +47,7 @@ function HomePage({ background = "white", textColor = "black" }) { const [value, setValue] = useState(2); const [selectedTab, setSelectedTab] = useState("1"); const [visibleModal, setVisibleModal] = useState(false); + const [openShare, setOpenShare] = useState(false); const [footerContent, setFooterContent] = useState([ { name: "Help", link: "https://dev.codelabz.io/" }, { name: "About", link: "https://dev.codelabz.io/" }, @@ -194,6 +196,10 @@ function HomePage({ background = "white", textColor = "black" }) { const closeModal = () => { setVisibleModal(prev => !prev); }; + + const shareModel = () => { + setOpenShare(prev => !prev); + }; return ( closeModal(e)} /> + + + @@ -241,9 +250,9 @@ function HomePage({ background = "white", textColor = "black" }) { {tutorials.map(tutorial => { return !tutorial?.featured_image ? ( - + (shareModel(e))} /> ) : ( - + (shareModel(e))}/> ); })} ({ + root: { + display: "flex", + paddingTop: "8px", + paddingBottom: "10px" + }, + item: { + margin: "10px" + }, + purple: { + color: deepPurple[700], + backgroundColor: deepPurple[500] + } +})); + +const ShareTutorial = ({ tutorial, openShare, setOpenShare,onSidebarClick }) => { + + const [loading, setLoading] = useState(false); + console.log(tutorial) + const [error, setError] = useState(false); + + + const loadingProp = useSelector( + ({ + tutorials: { + create: { loading } + } + }) => loading + ); + const errorProp = useSelector( + ({ + tutorials: { + create: { error } + } + }) => error + ); + + useEffect(() => { + setLoading(loadingProp); + }, [loadingProp]); + + useEffect(() => { + setError(errorProp); + }, [errorProp]); + + + + + + + + + const classes = useStyles(); + return ( + +
+ {error && ( + + description={"Tutorial Creation Failed"}/ + + )} + Share a Tutorial + + +
+ {`http://localhost:5173/tutorial/` + tutorial?.tutorial_id} +
+
+
+
Close
+ +
+
+ ); +}; + +export default ShareTutorial;