mirror of
https://github.com/wassname/talk.git
synced 2026-08-16 11:29:31 +08:00
Merge branch 'master' of github.com:coralproject/talk into passport
This commit is contained in:
@@ -106,27 +106,3 @@ export const logout = () => dispatch => {
|
||||
.catch(error => dispatch(logOutFailure(error)));
|
||||
};
|
||||
|
||||
// Availability Checks Actions
|
||||
|
||||
const availabilityRequest = () => ({type: actions.FETCH_AVAILABILITY_REQUEST});
|
||||
const availabilitySuccess = () => ({type: actions.FETCH_AVAILABILITY_SUCCESS});
|
||||
const availabilityFailure = () => ({type: actions.FETCH_AVAILABILITY_FAILURE});
|
||||
|
||||
const availableField = field => ({type: actions.AVAILABLE_FIELD, field});
|
||||
const unavailableField = field => ({type: actions.UNAVAILABLE_FIELD, field});
|
||||
|
||||
export const fetchCheckAvailability = formData => dispatch => {
|
||||
dispatch(availabilityRequest());
|
||||
fetch(`${base}/user/availability`, getInit('POST', formData))
|
||||
.then(handleResp)
|
||||
.then(({status}) => {
|
||||
const [field] = Object.keys(formData);
|
||||
dispatch(availabilitySuccess());
|
||||
if (status === 'available') {
|
||||
return dispatch(availableField(field));
|
||||
}
|
||||
return dispatch(unavailableField(field));
|
||||
})
|
||||
.catch((error) => availabilityFailure(error));
|
||||
};
|
||||
|
||||
|
||||
@@ -66,12 +66,6 @@ export default function auth (state = initialState, action) {
|
||||
return state
|
||||
.set('loggedIn', false)
|
||||
.set('user', null);
|
||||
case actions.AVAILABLE_FIELD:
|
||||
return state
|
||||
.set(`${action.field}Available`, true);
|
||||
case actions.UNAVAILABLE_FIELD:
|
||||
return state
|
||||
.set(`${action.field}Available`, false);
|
||||
default :
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user