Skip to content

Commit

Permalink
Resolve Conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
MuntazirHaider committed Aug 27, 2023
2 parents 46c5676 + 3225631 commit b4dddc9
Show file tree
Hide file tree
Showing 46 changed files with 2,059 additions and 636 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ First of all make sure that your are using version 14 of node. If the problem st

This problem generally arises when you have not setuped/started the Firebase emulators.

1. [Setup firebase emulator](#install-configure-and-integrate-firebase-emulator-suite).
2. [Start the Emulators](#to-start-the-emulators-)
1. [Setup firebase emulator](https://github.com/scorelab/Codelabz/blob/master/CONTRIBUTING.md#firebase-setup).
2. [Start the Emulators]( https://github.com/scorelab/Codelabz/blob/master/CONTRIBUTING.md#run-firebase-emulator)
3. Run the app using `npm run dev`.

> 📝**NOTE** : Remember to start the emulators before running the app.
Expand Down
16 changes: 7 additions & 9 deletions functions/cloud_functions/onCreateFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,17 @@ exports.createOrganizationHandler = async (snapshot, context) => {
});

/**
* create org_users sub-collection => set user uid and respective permissions
* create org_users collection => set user uid and respective permissions
* @type {Promise<FirebaseFirestore.WriteResult>}
*/
const setOrgUsers = db
.collection("cl_org_general")
.doc(org_handle)
.collection("cl_org_users")
.doc("users")
.collection("org_users")
.doc(`${org_handle}_${user_uid}`)
.set({
[user_uid]: [3],
createdAt: admin.firestore.FieldValue.serverTimestamp(),
updatedAt: admin.firestore.FieldValue.serverTimestamp()
});
uid: user_uid,
org_handle,
permissions: [3]
})

await Promise.all([registerOrgHandle, setOrgMetrics, setOrgUsers]);
return console.log(
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"react-responsive": "^8.1.0",
"react-reveal": "^1.2.2",
"react-router-dom": "^5.2.0",
"react-router-hash-link": "^2.4.3",
"react-select": "^5.7.0",
"react-social-login-buttons": "^3.4.0",
"react-syntax-highlighter": "^15.4.3",
Expand All @@ -68,6 +69,7 @@
"redux-thunk": "^2.3.0",
"simple-peer": "^9.11.1",
"start-server-and-test": "^1.15.3",
"swiper": "^10.2.0",
"url": "^0.11.0",
"validator": "^13.6.0",
"y-quill": "^0.1.5",
Expand Down
31 changes: 16 additions & 15 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
import React, { useEffect } from "react";
import Routes from "./routes";
import "./App.less";
import { useFirebase } from "react-redux-firebase";
import { useFirebase, useFirestore } from "react-redux-firebase";
import { useDispatch, useSelector } from "react-redux";
import { getProfileData } from "./store/actions";

const App = () => {
const firebase = useFirebase();
const dispatch = useDispatch();
const organizations = useSelector(
({
firebase: {
profile: { organizations }
}
}) => organizations
);
const firebase = useFirebase();
const firestore = useFirestore();
const dispatch = useDispatch();
const organizations = useSelector(
({
firebase: {
profile: { organizations },
},
}) => organizations
);

useEffect(() => {
getProfileData(organizations)(firebase, dispatch);
}, [organizations, firebase, dispatch]);
return <Routes />;
useEffect(() => {
getProfileData(organizations)(firebase, firestore, dispatch);
}, [organizations, firebase, dispatch]);
return <Routes />;
};

export default App;
export default App;
4 changes: 2 additions & 2 deletions src/components/AuthPage/Login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ const Login = ({
/>
</FormGroup>
</Grid>
<Grid>
<Grid style={{fontFamily:"Arial, sans-serif",fontSize:"1.5vh"}}>
<Link
data-testId="forgotPassoword"
to="/forgotpassword"
className="login-form-forgot"
style={{ float: "right" }}
style={{ float: "right"}}
>
Forgot password
</Link>
Expand Down
93 changes: 60 additions & 33 deletions src/components/Card/CardWithPicture.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useEffect } from "react";
import { makeStyles } from "@mui/styles";
import Card from "@mui/material/Card";
import CardHeader from "@mui/material/CardHeader";
Expand All @@ -18,6 +18,10 @@ 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: {
Expand Down Expand Up @@ -67,10 +71,13 @@ const useStyles = makeStyles(theme => ({
}
}));

export default function CardWithPicture(props) {
export default function CardWithPicture({ tutorial }) {
const classes = useStyles();
const [alignment, setAlignment] = React.useState("left");
const [count, setCount] = useState(1);
const dispatch = useDispatch();
const firebase = useFirebase();
const firestore = useFirestore();
const handleIncrement = () => {
setCount(count + 1);
};
Expand All @@ -83,22 +90,40 @@ export default function CardWithPicture(props) {
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 (
<Card className={classes.root}>
<CardMedia
className={classes.media}
image={cardImage}
title="code"
data-testId="Image"
/>
<Link to={`/tutorial/${tutorial?.tutorial_id}`}>
<CardMedia
className={classes.media}
image={tutorial?.featured_image}
title="code"
data-testId="Image"
/>
</Link>
<CardHeader
avatar={
<Avatar
aria-label="recipe"
className={classes.avatar}
data-testId="UserAvatar"
>
S
<Avatar className={classes.avatar}>
{user?.photoURL && user?.photoURL.length > 0 ? (
<img src={user?.photoURL} />
) : (
user?.displayName[0]
)}
</Avatar>
}
title={
Expand All @@ -110,9 +135,9 @@ export default function CardWithPicture(props) {
color="textPrimary"
data-testId="UserName"
>
{props.name}
{user?.displayName}
</Typography>
{props.organizationName && (
{tutorial?.owner && (
<>
{" for "}
<Typography
Expand All @@ -122,28 +147,30 @@ export default function CardWithPicture(props) {
color="textPrimary"
data-testId="UserOrgName"
>
{props.organizationName}
{tutorial?.owner}
</Typography>
</>
)}
</React.Fragment>
}
subheader={props.date}
subheader={tutorial?.createdAt ? getTime(tutorial?.createdAt) : ""}
/>
<CardContent className={classes.contentPadding}>
<Typography variant="h5" color="text.primary" data-testId="Title">
{props.title}
</Typography>
<Typography
variant="body2"
color="textSecondary"
component="p"
paragraph
data-testId="Description"
>
{props.contentDescription}
</Typography>
</CardContent>
<Link to={`/tutorial/${tutorial?.tutorial_id}`}>
<CardContent className={classes.contentPadding}>
<Typography variant="h5" color="text.primary" data-testId="Title">
{tutorial?.title}
</Typography>
<Typography
variant="body2"
color="textSecondary"
component="p"
paragraph
data-testId="Description"
>
{tutorial?.summary}
</Typography>
</CardContent>
</Link>
<CardActions className={classes.settings} disableSpacing>
<Chip
label="HTML"
Expand All @@ -159,7 +186,7 @@ export default function CardWithPicture(props) {
className={classes.time}
data-testId="Time"
>
{props.time}
{"10 min"}
</Typography>
<div className={classes.grow} />
<ToggleButtonGroup
Expand Down
Loading

0 comments on commit b4dddc9

Please sign in to comment.