Upgrade axios to v0.27, fix EditProfile uploads
This commit is contained in:
@@ -46,11 +46,21 @@ export function fetchMe() {
|
||||
};
|
||||
}
|
||||
|
||||
export function patchMe(params) {
|
||||
export function patchMe(params, formData = false) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(patchMeRequest());
|
||||
|
||||
let options = {};
|
||||
if (formData) {
|
||||
options = {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return api(getState)
|
||||
.patch('/api/v1/accounts/update_credentials', params)
|
||||
.patch('/api/v1/accounts/update_credentials', params, options)
|
||||
.then(response => {
|
||||
dispatch(patchMeSuccess(response.data));
|
||||
}).catch(error => {
|
||||
|
||||
@@ -169,7 +169,7 @@ const EditProfile: React.FC = () => {
|
||||
};
|
||||
|
||||
const handleSubmit: React.FormEventHandler = (event) => {
|
||||
const credentials = dispatch(patchMe(data));
|
||||
const credentials = dispatch(patchMe(data, true));
|
||||
/* Bad API url, was causing errors in the promise call below blocking the success message after making edits. */
|
||||
/* const notifications = dispatch(updateNotificationSettings({
|
||||
block_from_strangers: this.state.stranger_notifications || false,
|
||||
|
||||
@@ -61,7 +61,7 @@ const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
||||
setSelectedFile(null);
|
||||
|
||||
if (error.response?.status === 422) {
|
||||
dispatch(snackbar.error(error.response.data.error.replace('Validation failed: ', '')));
|
||||
dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', '')));
|
||||
} else {
|
||||
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.'));
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ const BioStep = ({ onNext }: { onNext: () => void }) => {
|
||||
setSubmitting(false);
|
||||
|
||||
if (error.response?.status === 422) {
|
||||
setErrors([error.response.data.error.replace('Validation failed: ', '')]);
|
||||
setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]);
|
||||
} else {
|
||||
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.'));
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
||||
setSelectedFile(null);
|
||||
|
||||
if (error.response?.status === 422) {
|
||||
dispatch(snackbar.error(error.response.data.error.replace('Validation failed: ', '')));
|
||||
dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', '')));
|
||||
} else {
|
||||
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.'));
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
|
||||
setSubmitting(false);
|
||||
|
||||
if (error.response?.status === 422) {
|
||||
setErrors([error.response.data.error.replace('Validation failed: ', '')]);
|
||||
setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]);
|
||||
} else {
|
||||
dispatch(snackbar.error('An unexpected error occurred. Please try again or skip this step.'));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ const Header = () => {
|
||||
.catch((error: AxiosError) => {
|
||||
setLoading(false);
|
||||
|
||||
const data = error.response?.data;
|
||||
const data: any = error.response?.data;
|
||||
if (data?.error === 'mfa_required') {
|
||||
setMfaToken(data.mfa_token);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user