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

(Issue #3 resolved ) Redirected user to the orgpage #4

Open
wants to merge 1 commit 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
20 changes: 10 additions & 10 deletions src/components/Organization/Orgsocial/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ const Orgsocial = props => {
console.log(props.toOpen);
const classes = useStyles();

const CurrentOrg = useSelector(
({
profile: {
data: { organizations }
},
org: {
general: { current }
}
}) => organizations.find(element => element.org_handle === current)
);
const CurrentOrg = useSelector((state) => {
const {
profile: { data: { organizations } = {} },
org: { general: { current } = {} }
} = state;

return organizations && Array.isArray(organizations)
? organizations.find(element => element.org_handle === current)
: null;
});

const [OrgData, setOrgData] = useState(CurrentOrg);

Expand Down
6 changes: 3 additions & 3 deletions src/store/actions/authActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const signInWithGoogle = () => async (firebase, dispatch) => {
provider: "google",
type: "popup"
});
window.location.href = "/dashboard";
dispatch({ type: actions.SIGN_IN_SUCCESS });
} catch (e) {
dispatch({ type: actions.SIGN_IN_FAIL, payload: e });
Expand All @@ -49,6 +50,7 @@ export const signInWithProviderID =
provider: providerID,
type: "popup"
});
window.location.href = "/dashboard";
dispatch({ type: actions.SIGN_IN_SUCCESS });
} catch (e) {
if (e.code === "auth/account-exists-with-different-credential") {
Expand Down Expand Up @@ -194,9 +196,7 @@ export const checkOrgHandleExists = orgHandle => async firebase => {
.collection("cl_org_general")
.doc(orgHandle)
.get();

console.log(organizationHandle);
return organizationHandle.exists;
return organizationHandle.exists
} catch (e) {
throw e.message;
}
Expand Down
10 changes: 5 additions & 5 deletions src/store/actions/orgActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,15 @@ export const getOrgData =
(org_handle, organizations) => async (firebase, firestore, dispatch) => {
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
.collection("cl_org_general")
.doc(org_handle)
.get();
const isPublished =
organizations.includes(org_handle) || doc.get("org_published");
const isPublished = organizations.includes(org_handle) || doc.get("org_published");

if (isPublished) {
dispatch({
Expand All @@ -251,6 +250,7 @@ export const getOrgData =
)
}
});

} else {
dispatch({ type: actions.GET_ORG_DATA_SUCCESS, payload: false });
}
Expand Down
175 changes: 175 additions & 0 deletions src/store2/actions/actionTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
export const CLEAR_AUTH_PROFILE_STATE = 'CLEAR_AUTH_PROFILE_STATE';
export const CLEAR_AUTH_VERIFY_EMAIL_STATE = 'CLEAR_AUTH_VERIFY_EMAIL_STATE';
export const CLEAR_AUTH_RECOVER_PASSWORD_STATE ='CLEAR_AUTH_RECOVER_PASSWORD_STATE';
export const CLEAR_PROFILE_EDIT_STATE = 'CLEAR_PROFILE_EDIT_STATE';
export const CLEAR_ORG_GENERAL_STATE = 'CLEAR_ORG_GENERAL_STATE';
export const CLEAR_PROFILE_DATA_STATE = 'CLEAR_PROFILE_DATA_STATE';
export const CLEAR_ORG_USER_STATE = 'CLEAR_ORG_USER_STATE';
export const CLEAR_USER_PROFILE_DATA_STATE = 'CLEAR_USER_PROFILE_DATA_STATE';
export const CLEAR_ORG_DATA_STATE = 'CLEAR_ORG_DATA_STATE';
export const CLEAR_EDITOR_STATE = 'CLEAR_EDITOR_STATE';
export const CLEAR_TUTORIALS_BASIC_STATE = 'CLEAR_TUTORIALS_BASIC_STATE';
export const CLEAR_CREATE_TUTORIALS_STATE = 'CLEAR_CREATE_TUTORIALS_STATE';
export const CLEAR_CURRENT_TUTORIAL_STATE = 'CLEAR_CURRENT_TUTORIAL_STATE';
export const CLEAR_TUTORIAL_IMAGES_STATE = 'CLEAR_TUTORIAL_IMAGES_STATE';

export const SIGN_UP_START = 'SIGN_UP_START';
export const SIGN_UP_SUCCESS = 'SIGN_UP_SUCCESS';
export const SIGN_UP_FAIL = 'SIGN_UP_FAIL';

export const SIGN_IN_START = 'SIGN_IN_START';
export const SIGN_IN_SUCCESS = 'SIGN_IN_SUCCESS';
export const SIGN_IN_FAIL = 'SIGN_IN_FAIL';

export const SET_VERIFY_EMAIL_FAIL = 'SET_VERIFY_EMAIL_FAIL';

export const EMAIL_VERIFY_START = 'EMAIL_VERIFY_START';
export const EMAIL_VERIFY_SUCCESS = 'EMAIL_VERIFY_SUCCESS';
export const EMAIL_VERIFY_FAIL = 'EMAIL_VERIFY_FAIL';

export const SEND_RESET_EMAIL_START = 'SEND_RESET_EMAIL_START';
export const SEND_RESET_EMAIL_SUCCESS = 'SEND_RESET_EMAIL_SUCCESS';
export const SEND_RESET_EMAIL_FAIL = 'SEND_RESET_EMAIL_FAIL';

export const PASSWORD_RECOVERY_START = 'PASSWORD_RECOVERY_START';
export const PASSWORD_RECOVERY_SUCCESS = 'PASSWORD_RECOVERY_SUCCESS';
export const PASSWORD_RECOVERY_FAIL = 'PASSWORD_RECOVERY_FAIL';

export const VERIFY_USER_HANDLE_EXISTS_START = 'VERIFY_USER_HANDLE_EXISTS_START';
export const VERIFY_USER_HANDLE_EXISTS_SUCCESS = 'VERIFY_USER_HANDLE_EXISTS_SUCCESS';
export const VERIFY_USER_HANDLE_EXISTS_FAIL = 'VERIFY_USER_HANDLE_EXISTS_FAIL';

export const VERIFY_ADMIN_HANDLE_EXISTS_START = 'VERIFY_ADMIN_HANDLE_EXISTS_START';
export const VERIFY_ADMIN_HANDLE_EXISTS_SUCCESS = 'VERIFY_ADMIN_HANDLE_EXISTS_SUCCESS';
export const VERIFY_ADMIN_HANDLE_EXISTS_FAIL = 'VERIFY_ADMIN_HANDLE_EXISTS_FAIL';

export const VERIFY_ROLES_ARE_MUTUALLY_EXCLUSIVE_START = 'VERIFY_ROLES_ARE_MUTUALLY_EXCLUSIVE_START';
export const VERIFY_ROLES_ARE_MUTUALLY_EXCLUSIVE_SUCCESS = 'VERIFY_ROLES_ARE_MUTUALLY_EXCLUSIVE_SUCCESS';
export const VERIFY_ROLES_ARE_MUTUALLY_EXCLUSIVE_END = 'VERIFY_ROLES_ARE_MUTUALLY_EXCLUSIVE_END';

export const VERIFY_CONTRIBUTOR_HANDLE_EXISTS_START = 'VERIFY_CONTRIBUTOR_HANDLE_EXISTS_START';
export const VERIFY_CONTRIBUTOR_HANDLE_EXISTS_SUCCESS = 'VERIFY_CONTRIBUTOR_HANDLE_EXISTS_SUCCESS';
export const VERIFY_CONTRIBUTOR_HANDLE_EXISTS_FAIL = 'VERIFY_CONTRIBUTOR_HANDLE_EXISTS_FAIL';

export const CHECK_ADMIN_EMAIL_START = 'VERIFY_ADMIN_EMAIL_START';
export const CHECK_ADMIN_EMAIL_SUCCESS = 'VERIFY_ADMIN_EMAIL_SUCCESS';
export const CHECK_ADMIN_EMAIL_FAIL = 'VERIFY_ADMIN_EMAIL_FAIL';

export const CHECK_CONTRIBUTOR_EMAIL_START = 'VERIFY_CONTRIBUTOR_EMAIL_START';
export const CHECK_CONTRIBUTOR_EMAIL_SUCCESS = 'VERIFY_CONTRIBUTOR_EMAIL_SUCCESS';
export const CHECK_CONTRIBUTOR_EMAIL_FAIL = 'VERIFY_CONTRIBUTOR_EMAIL_FAIL';

export const FETCH_ADMIN_DETAILS_START = 'FETCH_ADMIN_DETAILS_START';
export const FETCH_ADMIN_DETAILS_SUCCESS = 'FETCH_ADMIN_DETAILS_SUCCESS';
export const FETCH_ADMIN_DETAILS_FAIL = 'FETCH_ADMIN_DETAILS_FAIL';

export const FETCH_CONTRIBUTOR_DETAILS_START = 'FETCH_CONTRIBUTOR_DETAILS_START';
export const FETCH_CONTRIBUTOR_DETAILS_SUCCESS = 'FETCH_CONTRIBUTOR_DETAILS_SUCCESS';
export const FETCH_CONTRIBUTOR_DETAILS_FAIL = 'FETCH_CONTRIBUTOR_DETAILS_FAIL';

export const REMOVE_ORG_USER_START="REMOVE_ORG_USER_START"
export const REMOVE_ORG_USER_SUCCESS="REMOVE_ORG_USER_SUCCESS"
export const REMOVE_ORG_USER_FAIL="REMOVE_ORG_USER_FAIL"

export const VERIFY_RESET_CODE_START = 'VERIFY_RESET_CODE_START';
export const VERIFY_RESET_CODE_SUCCESS = 'VERIFY_RESET_CODE_SUCCESS';
export const VERIFY_RESET_CODE_FAIL = 'VERIFY_RESET_CODE_FAIL';

export const RESEND_VERIFY_EMAIL_START = 'RESEND_VERIFY_EMAIL_START';
export const RESEND_VERIFY_EMAIL_SUCCESS = 'RESEND_VERIFY_EMAIL_SUCCESS';
export const RESEND_VERIFY_EMAIL_FAIL = 'RESEND_VERIFY_EMAIL_FAIL';

export const PROFILE_EDIT_START = 'PROFILE_EDIT_START';
export const PROFILE_EDIT_SUCCESS = 'PROFILE_EDIT_SUCCESS';
export const PROFILE_EDIT_FAIL = 'PROFILE_EDIT_FAIL';

export const INITIAL_SETUP_START = 'INITIAL_SETUP_START';
export const INITIAL_SETUP_SUCCESS = 'INITIAL_SETUP_SUCCESS';
export const INITIAL_SETUP_FAIL = 'INITIAL_SETUP_FAIL';

export const GET_PROFILE_DATA_START = 'GET_PROFILE_DATA_START';
export const GET_PROFILE_DATA_SUCCESS = 'GET_PROFILE_DATA_SUCCESS';
export const GET_PROFILE_DATA_FAIL = 'GET_PROFILE_DATA_FAIL';
export const GET_PROFILE_DATA_END = 'GET_PROFILE_DATA_END';

export const SET_CURRENT_ORG_PERMISSIONS_START =
'SET_CURRENT_ORG_PERMISSIONS_START';
export const SET_CURRENT_ORG_PERMISSIONS_SUCCESS =
'SET_CURRENT_ORG_PERMISSIONS_SUCCESS';
export const SET_CURRENT_ORG_PERMISSIONS_FAIL =
'SET_CURRENT_ORG_PERMISSIONS_FAIL';

export const GET_ORG_USER_DATA_START = 'GET_ORG_USER_DATA_START';
export const GET_ORG_USER_DATA_SUCCESS = 'GET_ORG_USER_DATA_SUCCESS';
export const GET_ORG_USER_DATA_FAIL = 'GET_ORG_USER_DATA_FAIL';

export const ADD_ORG_USER_START = 'ADD_ORG_USER_START';
export const ADD_ORG_USER_SUCCESS = 'ADD_ORG_USER_SUCCESS';
export const ADD_ORG_USER_FAIL = 'ADD_ORG_USER_FAIL';

export const ADD_ORG_ADMIN_START = 'ADD_ORG_ADMIN_START';
export const ADD_ORG_ADMIN_SUCCESS = 'ADD_ORG_ADMIN_SUCCESS';
export const ADD_ORG_ADMIN_FAIL = 'ADD_ORG_ADMIN_FAIL';

export const ADD_ORG_CONTRIBUTOR_START = 'ADD_ORG_CONTRIBUTOR_START';
export const ADD_ORG_CONTRIBUTOR_SUCCESS = 'ADD_ORG_CONTRIBUTOR_SUCCESS';
export const ADD_ORG_CONTRIBUTOR_FAIL = 'ADD_ORG_CONTRIBUTOR_FAIL';

export const DELETE_ORG_START = 'DELETE_ORG_START';
export const DELETE_ORG_SUCCESS = 'DELETE_ORG_SUCCESS';
export const DELETE_ORG_FAIL = 'DELETE_ORG_FAIL';

export const GET_ORG_GENERAL_START = 'GET_ORG_GENERAL_START';
export const GET_ORG_GENERAL_SUCCESS = 'GET_ORG_GENERAL_SUCCESS';
export const GET_ORG_GENERAL_FAIL = 'GET_ORG_GENERAL_FAIL';

export const EDIT_ORG_GENERAL_START = 'EDIT_ORG_GENERAL_START';
export const EDIT_ORG_GENERAL_SUCCESS = 'EDIT_ORG_GENERAL_SUCCESS';
export const EDIT_ORG_GENERAL_FAIL = 'EDIT_ORG_GENERAL_FAIL';
export const CLEAR_EDIT_ORG_GENERAL = 'CLEAR_EDIT_ORG_GENERAL';

export const GET_USER_DATA_START = 'GET_USER_DATA_START';
export const GET_USER_DATA_SUCCESS = 'GET_USER_DATA_SUCCESS';
export const GET_USER_DATA_FAIL = 'GET_USER_DATA_FAIL';

export const GET_ORG_DATA_START = 'GET_ORG_DATA_START';
export const GET_ORG_DATA_SUCCESS = 'GET_ORG_DATA_SUCCESS';
export const GET_ORG_DATA_FAIL = 'GET_ORG_DATA_FAIL';

export const SET_EDITOR_DATA = 'SET_EDITOR_DATA';

export const GET_USER_TUTORIALS_BASIC_START = 'GET_USER_TUTORIALS_BASIC_START';
export const GET_USER_TUTORIALS_BASIC_SUCCESS =
'GET_USER_TUTORIALS_BASIC_SUCCESS';
export const GET_USER_TUTORIALS_BASIC_FAIL = 'GET_USER_TUTORIALS_BASIC_FAIL';

export const GET_ORG_TUTORIALS_BASIC_START = 'GET_ORG_TUTORIALS_BASIC_START';
export const GET_ORG_TUTORIALS_BASIC_SUCCESS =
'GET_ORG_TUTORIALS_BASIC_SUCCESS';
export const GET_ORG_TUTORIALS_BASIC_FAIL = 'GET_ORG_TUTORIALS_BASIC_FAIL';

export const CREATE_TUTORIAL_START = 'CREATE_TUTORIAL_START';
export const CREATE_TUTORIAL_SUCCESS = 'CREATE_TUTORIAL_SUCCESS';
export const CREATE_TUTORIAL_FAIL = 'CREATE_TUTORIAL_FAIL';

export const CREATE_TUTORIAL_STEP_START = 'CREATE_TUTORIAL_STEP_START';
export const CREATE_TUTORIAL_STEP_SUCCESS = 'CREATE_TUTORIAL_STEP_SUCCESS';
export const CREATE_TUTORIAL_STEP_FAIL = 'CREATE_TUTORIAL_STEP_FAIL';

export const GET_CURRENT_TUTORIAL_START = 'GET_CURRENT_TUTORIAL_START';
export const GET_CURRENT_TUTORIAL_SUCCESS = 'GET_CURRENT_TUTORIAL_SUCCESS';
export const GET_CURRENT_TUTORIAL_FAIL = 'GET_CURRENT_TUTORIAL_FAIL';

export const SET_CURRENT_STEP_NO = 'SET_CURRENT_STEP_NO';

export const TUTORIAL_IMAGE_UPLOAD_START = 'TUTORIAL_IMAGE_UPLOAD_START';
export const TUTORIAL_IMAGE_UPLOAD_SUCCESS = 'TUTORIAL_IMAGE_UPLOAD_SUCCESS';
export const TUTORIAL_IMAGE_UPLOAD_FAIL = 'TUTORIAL_IMAGE_UPLOAD_FAIL';

export const TUTORIAL_IMAGE_DELETE_START = 'TUTORIAL_IMAGE_DELETE_START';
export const TUTORIAL_IMAGE_DELETE_SUCCESS = 'TUTORIAL_IMAGE_DELETE_SUCCESS';
export const TUTORIAL_IMAGE_DELETE_FAIL = 'TUTORIAL_IMAGE_DELETE_FAIL';

export const GET_LAUNCHED_ORGS_START = 'GET_LAUNCHED_ORGS_START';
export const GET_LAUNCHED_ORGS_SUCCESS = 'GET_LAUNCHED_ORGS_SUCCESS';
export const GET_LAUNCHED_ORGS_FAIL = 'GET_LAUNCHED_ORGS_FAIL';
Loading