diff --git a/src/components/Card/CardWithVideo.jsx b/src/components/Card/CardWithVideo.jsx
new file mode 100644
index 00000000..ec713909
--- /dev/null
+++ b/src/components/Card/CardWithVideo.jsx
@@ -0,0 +1,235 @@
+import React, { useState, useEffect } from "react";
+import { makeStyles } from "@mui/styles";
+import Card from "@mui/material/Card";
+import CardHeader from "@mui/material/CardHeader";
+import CardMedia from "@mui/material/CardMedia";
+import CardContent from "@mui/material/CardContent";
+import CardActions from "@mui/material/CardActions";
+import Avatar from "@mui/material/Avatar";
+import IconButton from "@mui/material/IconButton";
+import Typography from "@mui/material/Typography";
+import { red } from "@mui/material/colors";
+import cardImage from "./card.png";
+import Chip from "@mui/material/Chip";
+import ShareOutlinedIcon from "@mui/icons-material/ShareOutlined";
+import ChatOutlinedIcon from "@mui/icons-material/ChatOutlined";
+import TurnedInNotOutlinedIcon from "@mui/icons-material/TurnedInNotOutlined";
+import MoreVertOutlinedIcon from "@mui/icons-material/MoreVertOutlined";
+import { ToggleButton, ToggleButtonGroup } from "@mui/material";
+import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
+import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
+import { Link } from "react-router-dom";
+import { useDispatch, useSelector } from "react-redux";
+import { useFirebase, useFirestore } from "react-redux-firebase";
+import { getUserProfileData } from "../../store/actions";
+
+const useStyles = makeStyles(theme => ({
+ root: {
+ margin: "0.5rem",
+ borderRadius: "10px",
+ boxSizing: "border-box",
+ [theme.breakpoints.down("md")]: {
+ width: "auto"
+ },
+ [theme.breakpoints.down("xs")]: {
+ width: "auto"
+ }
+ },
+ grow: {
+ flexGrow: 1
+ },
+ media: {
+ height: 0,
+ paddingTop: "56.25%" // 16:9
+ },
+ margin: {
+ marginRight: "5px"
+ },
+ expandOpen: {
+ transform: "rotate(180deg)"
+ },
+ avatar: {
+ backgroundColor: red[500]
+ },
+ inline: {
+ fontWeight: 600
+ },
+ contentPadding: {
+ padding: "0 16px"
+ },
+ icon: {
+ padding: "5px"
+ },
+ time: {
+ lineHeight: "1"
+ },
+ small: {
+ padding: "4px"
+ },
+ settings: {
+ flexWrap: "wrap"
+ }
+}));
+
+export default function CardWithVideo({ tutorial }) {
+ const classes = useStyles();
+ const [alignment, setAlignment] = React.useState("left");
+ const [count, setCount] = useState(1);
+ const dispatch = useDispatch();
+ const firebase = useFirebase();
+ const firestore = useFirestore();
+ console.log("Tutorial Card with video",tutorial)
+ const handleIncrement = () => {
+ setCount(count + 1);
+ };
+
+ const handleDecrement = () => {
+ setCount(count - 1);
+ };
+
+ const handleAlignment = (event, newAlignment) => {
+ setAlignment(newAlignment);
+ };
+
+ useEffect(() => {
+ getUserProfileData(tutorial?.created_by)(firebase, firestore, dispatch);
+ }, [tutorial]);
+
+ const user = useSelector(
+ ({
+ profile: {
+ user: { data }
+ }
+ }) => data
+ );
+
+ const getTime = timestamp => {
+ return timestamp.toDate().toDateString();
+ };
+
+ return (
+
+ ) : (
+ user?.displayName[0]
+ )}
+
+ }
+ title={
+
- Click or drag images to here to upload + Click or drag images here to upload
> )} diff --git a/src/store/actions/authActions.js b/src/store/actions/authActions.js index 04b2f6a0..9bc064c6 100644 --- a/src/store/actions/authActions.js +++ b/src/store/actions/authActions.js @@ -195,22 +195,26 @@ export const resendVerifyEmail = email => async dispatch => { export const checkUserHandleExists = userHandle => async firebase => { try { const handle = await firebase - .ref(`/cl_user_handle/${userHandle}`) - .once("value"); - return handle.exists(); + .firestore() + .collection("cl_user") + .doc(userHandle) + .get(); + console.log("User Handle",handle) + return handle.exists; } catch (e) { throw e.message; } }; -export const checkOrgHandleExists = orgHandle => async firestore => { +export const checkOrgHandleExists = orgHandle => async firebase => { try { - const organizationHandle = await firestore + const organizationHandle = await firebase + .firestore() .collection("cl_org_general") .doc(orgHandle) .get(); - console.log(organizationHandle); + console.log("Organization Handle",organizationHandle); return organizationHandle.exists; } catch (e) { throw e.message; diff --git a/src/store/actions/tutorialPageActions.js b/src/store/actions/tutorialPageActions.js index d35e774d..9ed20f9c 100644 --- a/src/store/actions/tutorialPageActions.js +++ b/src/store/actions/tutorialPageActions.js @@ -101,6 +101,7 @@ export const getTutorialFeedData = created_by: tutorial?.created_by, createdAt: tutorial?.createdAt, featured_image: tutorial?.featured_image, + featured_video: tutorial?.featured_video, tut_tags: tutorial?.tut_tags, upVotes: tutorial?.upVotes || 0, downVotes: tutorial?.downVotes || 0, diff --git a/src/store/actions/tutorialsActions.js b/src/store/actions/tutorialsActions.js index 25e45b41..5e1a95a5 100644 --- a/src/store/actions/tutorialsActions.js +++ b/src/store/actions/tutorialsActions.js @@ -144,7 +144,7 @@ export const createTutorial = tutorialData => async (firebase, firestore, dispatch, history) => { try { dispatch({ type: actions.CREATE_TUTORIAL_START }); - const { title, summary, owner, created_by, is_org, tags } = tutorialData; + const { title, summary, owner, created_by, is_org, tags, featured_video } = tutorialData; const setData = async () => { const document = firestore.collection("tutorials").doc(); @@ -152,6 +152,18 @@ export const createTutorial = const documentID = document.id; const step_id = `${documentID}_${new Date().getTime()}`; + let videoUrl = ""; + if(featured_video){ + try { + const storageRef = firebase.storage().ref(); + const videoRef = storageRef.child(`tutorial_videos/${documentID}_${featured_video.name}`); + await videoRef.put(featured_video); + videoUrl = await videoRef.getDownloadURL(); + } catch (e) { + console.error("Error uploading video to firebase storage", e); + } + } + await document.set({ created_by, editors: [created_by], @@ -161,6 +173,7 @@ export const createTutorial = title, tutorial_id: documentID, featured_image: "", + featured_video: videoUrl, icon: "", tut_tags: tags, url: "", @@ -232,7 +245,7 @@ export const getTutorialsByTopTags = (limit = 10) => async (firebase, firestore) export const checkUserOrOrgHandle = handle => async (firebase, firestore) => { const userHandleExists = await checkUserHandleExists(handle)(firebase); - const orgHandleExists = await checkOrgHandleExists(handle)(firestore); + const orgHandleExists = await checkOrgHandleExists(handle)(firebase); if (userHandleExists && !orgHandleExists) { return "user";