diff --git a/src/components/Card/CardWithPicture.jsx b/src/components/Card/CardWithPicture.jsx index e8cd65c2..e96144e6 100644 --- a/src/components/Card/CardWithPicture.jsx +++ b/src/components/Card/CardWithPicture.jsx @@ -23,6 +23,7 @@ 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", @@ -75,6 +76,8 @@ export default function CardWithPicture({ tutorial }) { const classes = useStyles(); const [alignment, setAlignment] = React.useState("left"); const [count, setCount] = useState(1); + const [tags, setTags] = useState([]) + const dispatch = useDispatch(); const firebase = useFirebase(); const firestore = useFirestore(); @@ -106,24 +109,44 @@ export default function CardWithPicture({ tutorial }) { return timestamp.toDate().toDateString(); }; + useEffect(() => { + if (tutorial.tags) { + const tagsArray = tutorial.tags.split(' '); + setTags(tagsArray) + } + console.log(tutorial) + },[]) + + + return ( - - - + {tutorial.featured_image ? + + + + : ""} - {user?.photoURL && user?.photoURL.length > 0 ? ( - - ) : ( - user?.displayName[0] - )} + {tutorial.profilePic ? + + + : + user?.photoURL && user?.photoURL.length > 0 ? ( + + ) : ( + user?.displayName[0] + ) + } + + + } title={ @@ -135,7 +158,7 @@ export default function CardWithPicture({ tutorial }) { color="textPrimary" data-testId="UserName" > - {user?.displayName} + {tutorial.name ? tutorial.name : user?.displayName} {tutorial?.owner && ( <> @@ -153,9 +176,25 @@ export default function CardWithPicture({ tutorial }) { )} } - subheader={tutorial?.createdAt ? getTime(tutorial?.createdAt) : ""} + subheader={tutorial?.createdAt ? getTime(tutorial?.createdAt) : tutorial.date} /> - + {tutorial.tutorial_id ? + + + + {tutorial?.title} + + + {tutorial?.summary} + + + : {tutorial?.title} @@ -167,26 +206,41 @@ export default function CardWithPicture({ tutorial }) { paragraph data-testId="Description" > - {tutorial?.summary} + {tutorial?.description} - + } + - + {tutorial.tags ? + tags.map((tag) => ( + + )) + : + + } + - {"10 min"} + {tutorial.time ? tutorial.time : "10 min"}
data ); + useEffect(() => { + console.log(tutorial, user) + }, []) + const getTime = timestamp => { return timestamp.toDate().toDateString(); }; + useEffect(() => { + if (tutorial.tags) { + const tagsArray = tutorial.tags.split(' '); + setTags(tagsArray) + } + console.log(tutorial) + }, []) + + return ( - {user?.photoURL && user?.photoURL.length > 0 ? ( - - ) : ( - user?.displayName[0] - )} + {tutorial?.profilePic ? + + + : + user?.photoURL && user?.photoURL.length > 0 ? ( + + ) : ( + user?.displayName[0] + ) + } + } title={ @@ -121,7 +141,7 @@ export default function CardWithoutPicture({ tutorial }) { color="textPrimary" data-testId="UserName" > - {user?.displayName} + {tutorial?.name ? tutorial.name : user?.displayName} {tutorial?.owner && ( <> @@ -139,9 +159,29 @@ export default function CardWithoutPicture({ tutorial }) { )} } - subheader={tutorial?.createdAt ? getTime(tutorial?.createdAt) : ""} + subheader={tutorial?.createdAt ? getTime(tutorial?.createdAt) : tutorial.date} /> - + {tutorial?.tutorial_id ? + + + + {tutorial?.title} + + + {tutorial?.summary} + + + + : - {tutorial?.summary} + {tutorial?.description} - + } + - + {tutorial.tags ? + tags.map((tag) => ( + + )) + : + + } - {"10 min"} + {tutorial.time ? tutorial.time : "10 min"}
))} diff --git a/src/components/User/UserProfile/UserProfile.jsx b/src/components/User/UserProfile/UserProfile.jsx index c0e31882..a2fabb1e 100644 --- a/src/components/User/UserProfile/UserProfile.jsx +++ b/src/components/User/UserProfile/UserProfile.jsx @@ -106,9 +106,9 @@ function UserProfile(props) { {userList.persons.map(person => { return person.Heading == "CardWithoutPicture" ? ( - + ) : ( - + ); })} diff --git a/src/store/actions/orgActions.js b/src/store/actions/orgActions.js index c73b05d4..27fd8dca 100644 --- a/src/store/actions/orgActions.js +++ b/src/store/actions/orgActions.js @@ -229,7 +229,7 @@ export const getOrgData = try { dispatch({ type: actions.GET_ORG_DATA_START }); - const isOrgExists = await checkOrgHandleExists(org_handle)(firestore); + const isOrgExists = await checkOrgHandleExists(org_handle)(firebase); if (isOrgExists) { const doc = await firestore