Skip to content

Instantly share code, notes, and snippets.

@fernandocamargo
Created January 5, 2018 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandocamargo/7ea557bac0f0d08f8a0caae6d55f21e4 to your computer and use it in GitHub Desktop.
Save fernandocamargo/7ea557bac0f0d08f8a0caae6d55f21e4 to your computer and use it in GitHub Desktop.
const selectActivationStatus = createSelector(
selectActivationInProgress,
selectResendActivationInProgress,
selectActivationError,
selectResendActivationError,
selectActivationSuccess,
selectResendActivationSuccess,
(
activateInProgress,
resendInProgress,
activateError,
resendError,
activateSuccess,
resendSuccess,
) => {
switch (true) {
case (resendInProgress || activateInProgress):
return PENDING;
case resendSuccess:
return RESEND_SUCCESS;
case activateSuccess:
return SUCCESS;
case resendError:
return errorConstantToUserActivationStatus(resendError);
case activateError:
return errorConstantToUserActivationStatus(activateError);
default:
return;
}
},
);
const selectActivationStatus = createSelector(
selectActivationInProgress,
selectResendActivationInProgress,
selectActivationError,
selectResendActivationError,
selectActivationSuccess,
selectResendActivationSuccess,
(
activateInProgress,
resendInProgress,
activateError,
resendError,
activateSuccess,
resendSuccess,
) => {
if (resendInProgress || activateInProgress) return PENDING;
if (resendSuccess) return RESEND_SUCCESS;
if (activateSuccess) return SUCCESS;
if (resendError) {
return errorConstantToUserActivationStatus(resendError);
}
if (activateError) {
return errorConstantToUserActivationStatus(activateError);
}
return undefined;
},
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment