Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Resolve Author Data Visibility and Follow Button Functionality on Tutorial Page #156

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/Dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ const Dashboard = ({ background = "white", textColor = "black" }) => {
validateHandle(
checkUserHandleExists,
firebase,
dispatch,
handle,
setHandleValidateError,
setHandleValidateErrorMessage,
Expand Down
5 changes: 1 addition & 4 deletions src/components/Organization/OrgUsersCard/addOrgUserModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ const AddOrgUserModal = ({ currentOrgHandle }) => {
}, [userProps]);

const onFinish = async () => {
const handleExists = await checkUserHandleExists(handle)(
firebase,
dispatch
);
const handleExists = await checkUserHandleExists(handle)(firebase);

if (handle.length < 1) {
setHandleValidateError(true);
Expand Down
6 changes: 1 addition & 5 deletions src/components/TutorialPage/components/PostDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,7 @@ const PostDetails = ({ details }) => {
</Box>
<Box sx={{ width: "100%", marginTop: "10px" }}>
<Grid container justifyContent="space-between" alignItems="end">
<User
id={details?.user}
timestamp={details?.published_on}
showFollowButton={true}
/>
<User id={details?.user} timestamp={details?.published_on} />

<Grid item sx={{ width: "fit-content" }}>
<CardActions className={classes.settings} disableSpacing>
Expand Down
13 changes: 9 additions & 4 deletions src/components/TutorialPage/components/UserDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useFirebase, useFirestore } from "react-redux-firebase";
import { getUserProfileData } from "../../../store/actions";
import { isUserFollower } from "../../../store/actions/profileActions";
import { addUserFollower } from "../../../store/actions";

const useStyles = makeStyles(() => ({
container: {
padding: "20px",
Expand All @@ -19,7 +20,8 @@ const useStyles = makeStyles(() => ({
fontWeight: "600"
}
}));
const User = ({ id, timestamp, showFollowButton, size }) => {

const User = ({ id, timestamp, size }) => {
const classes = useStyles();
const dispatch = useDispatch();
const firebase = useFirebase();
Expand Down Expand Up @@ -55,13 +57,16 @@ const User = ({ id, timestamp, showFollowButton, size }) => {
return () => {};
}, [profileData, user]);

const followUser = () => {
addUserFollower(profileData, user, firestore);
const followUser = async () => {
await addUserFollower(profileData, user, firestore);
};

const getTime = timestamp => {
return timestamp.toDate().toDateString();
};

const showFollowButton = profileData?.uid !== user?.uid;

return (
<>
<Grid
Expand Down Expand Up @@ -117,7 +122,7 @@ const User = ({ id, timestamp, showFollowButton, size }) => {
padding: "1px 10px"
}}
>
Follow +
{isFollowed ? "Following" : "Follow +"}
</Button>
)}
</Grid>
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/validations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const validateName = (
export const validateHandle = async (
checkUserHandleExists,
firebase,
dispatch,
handle,
setHandleValidateError,
setHandleValidateErrorMessage,
Expand All @@ -34,7 +33,7 @@ export const validateHandle = async (
lengthMsg,
takenMsg
) => {
const handleExists = await checkUserHandleExists(handle)(firebase, dispatch);
const handleExists = await checkUserHandleExists(handle)(firebase);
if (validator.isEmpty(handle)) {
setHandleValidateError(true);
setHandleValidateErrorMessage(emptyMsg);
Expand Down
10 changes: 4 additions & 6 deletions src/store/actions/authActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ export const checkUserHandleExists = userHandle => async firebase => {
}
};

export const checkOrgHandleExists = orgHandle => async firebase => {
export const checkOrgHandleExists = orgHandle => async firestore => {
try {
const organizationHandle = await firebase
.firestore()
const organizationHandle = await firestore
.collection("cl_org_general")
.doc(orgHandle)
.get();
Expand Down Expand Up @@ -229,9 +228,8 @@ export const setUpInitialData =
}

if (orgData) {
const isOrgHandleExists = await checkOrgHandleExists(org_handle)(
firebase
);
const isOrgHandleExists =
await checkOrgHandleExists(org_handle)(firestore);

if (isOrgHandleExists) {
dispatch({
Expand Down
7 changes: 3 additions & 4 deletions src/store/actions/profileActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ export const createOrganization =
dispatch({ type: actions.PROFILE_EDIT_START });
const userData = firebase.auth().currentUser;
const { org_name, org_handle, org_country, org_website } = orgData;
const isOrgHandleExists = await checkOrgHandleExists(org_handle)(
firebase
);
const isOrgHandleExists =
await checkOrgHandleExists(org_handle)(firestore);

if (isOrgHandleExists) {
dispatch({
Expand Down Expand Up @@ -161,7 +160,7 @@ export const getUserProfileData =
handle => async (firebase, firestore, dispatch) => {
try {
dispatch({ type: actions.GET_USER_DATA_START });
const isUserExists = await checkUserHandleExists(handle)(firestore);
const isUserExists = checkUserHandleExists(handle)(firebase);
if (isUserExists) {
const docs = await firestore
.collection("cl_user")
Expand Down
Loading
Loading