Skip to content

Commit

Permalink
Refactor: Remove unused dispatch parameter and ensure correct usage o…
Browse files Browse the repository at this point in the history
…f firebase and firestore parameters
  • Loading branch information
lokeshwar777 committed Aug 24, 2024
1 parent 7bb38fe commit 0ab17e3
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 168 deletions.
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
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 = checkUserHandleExists(handle)(firestore);
const isUserExists = checkUserHandleExists(handle)(firebase);
if (isUserExists) {
const docs = await firestore
.collection("cl_user")
Expand Down
Loading

0 comments on commit 0ab17e3

Please sign in to comment.