You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
1.9 KiB
91 lines
1.9 KiB
import { |
|
IS_SENDING_AUTH_REQUEST, |
|
SET_AUTH_REQUEST_ERROR, |
|
CLEAR_AUTH_REQUEST_ERROR, |
|
SET_AUTH_REQUEST_SUCCESS, |
|
CLEAR_AUTH_REQUEST_SUCCESS, |
|
SET_SELF_USER, |
|
SET_FORM_EMAIL, |
|
SET_FORM_PASSWORD, |
|
SET_FORM_PASSWORD_CONFIRMATION |
|
} from "../../constants/auth.constants"; |
|
import { parseError } from "../common.actions"; |
|
|
|
export function isSendingAuthRequest(sendingRequest) { |
|
return { |
|
type: IS_SENDING_AUTH_REQUEST, |
|
data: sendingRequest |
|
}; |
|
} |
|
|
|
export function setAuthRequestError(exception) { |
|
let rawError = parseError(exception); |
|
if (rawError.email) { |
|
rawError["Email"] = rawError.email; |
|
delete rawError["email"]; |
|
} |
|
if (rawError.password1) { |
|
rawError["Password"] = rawError.password1; |
|
delete rawError["password1"]; |
|
} |
|
if (rawError.password2) { |
|
rawError["Password Confirmation"] = rawError.password2; |
|
delete rawError["password2"]; |
|
} |
|
if (rawError.non_field_errors) { |
|
rawError["Non Field Errors"] = rawError.non_field_errors; |
|
delete rawError["non_field_errors"]; |
|
} |
|
|
|
return { |
|
type: SET_AUTH_REQUEST_ERROR, |
|
data: parseError(exception) |
|
}; |
|
} |
|
|
|
export function clearAuthRequestError() { |
|
return { |
|
type: CLEAR_AUTH_REQUEST_ERROR |
|
}; |
|
} |
|
|
|
export function setAuthRequestSuccess(response) { |
|
return { |
|
type: SET_AUTH_REQUEST_SUCCESS, |
|
data: response.detail || response |
|
} |
|
} |
|
|
|
export function clearAuthRequestSuccess() { |
|
return { |
|
type: CLEAR_AUTH_REQUEST_SUCCESS |
|
} |
|
} |
|
|
|
export function setSelfUser(selfUser) { |
|
return { |
|
type: SET_SELF_USER, |
|
data: selfUser |
|
}; |
|
} |
|
|
|
export function setFormEmail(email) { |
|
return { |
|
type: SET_FORM_EMAIL, |
|
data: email |
|
}; |
|
} |
|
|
|
export function setFormPassword(password) { |
|
return { |
|
type: SET_FORM_PASSWORD, |
|
data: password |
|
}; |
|
} |
|
|
|
export function setFormPasswordConfirmation(passwordConfirmation) { |
|
return { |
|
type: SET_FORM_PASSWORD_CONFIRMATION, |
|
data: passwordConfirmation |
|
}; |
|
}
|
|
|