mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 03:43:28 +10:00
Merge pull request #829 from sharetribe/update-image-upload-endpoint
Update image upload endpoint
This commit is contained in:
commit
683fe6353c
7 changed files with 13 additions and 21 deletions
|
|
@ -48,7 +48,7 @@
|
|||
"redux-thunk": "^2.2.0",
|
||||
"sanitize.css": "^5.0.0",
|
||||
"sharetribe-scripts": "1.1.2",
|
||||
"sharetribe-sdk": "git+ssh://git@github.com/sharetribe/sharetribe-sdk-js#1c6a0d1c1a794bb2ee6de0e7b0bde1d2fd6f9388",
|
||||
"sharetribe-sdk": "git+ssh://git@github.com/sharetribe/sharetribe-sdk-js#b438be11d0f40f62e1a0388da745f6792420ddb1",
|
||||
"smoothscroll-polyfill": "^0.4.0",
|
||||
"source-map-support": "^0.5.4",
|
||||
"url": "^0.11.0"
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ export const showListings = requestAction(SHOW_LISTINGS_REQUEST);
|
|||
export const showListingsSuccess = successAction(SHOW_LISTINGS_SUCCESS);
|
||||
export const showListingsError = errorAction(SHOW_LISTINGS_ERROR);
|
||||
|
||||
// SDK method: images.uploadListingImage
|
||||
// SDK method: images.upload
|
||||
export const uploadImage = requestAction(UPLOAD_IMAGE_REQUEST);
|
||||
export const uploadImageSuccess = successAction(UPLOAD_IMAGE_SUCCESS);
|
||||
export const uploadImageError = errorAction(UPLOAD_IMAGE_ERROR);
|
||||
|
|
@ -304,7 +304,7 @@ export function requestImageUpload(actionPayload) {
|
|||
const id = actionPayload.id;
|
||||
dispatch(uploadImage(actionPayload));
|
||||
return sdk.images
|
||||
.uploadListingImage({ image: actionPayload.file })
|
||||
.upload({ image: actionPayload.file })
|
||||
.then(resp => dispatch(uploadImageSuccess({ data: { id, imageId: resp.data.data.id } })))
|
||||
.catch(e => dispatch(uploadImageError({ id, error: storableError(e) })));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export const clearUpdatedForm = () => ({
|
|||
type: CLEAR_UPDATED_FORM,
|
||||
});
|
||||
|
||||
// SDK method: images.uploadListingImage
|
||||
// SDK method: images.upload
|
||||
export const uploadImageRequest = params => ({ type: UPLOAD_IMAGE_REQUEST, payload: { params } });
|
||||
export const uploadImageSuccess = result => ({ type: UPLOAD_IMAGE_SUCCESS, payload: result.data });
|
||||
export const uploadImageError = error => ({
|
||||
|
|
@ -124,7 +124,7 @@ export function uploadImage(actionPayload) {
|
|||
};
|
||||
|
||||
return sdk.images
|
||||
.uploadProfileImage(bodyParams, queryParams)
|
||||
.upload(bodyParams, queryParams)
|
||||
.then(resp => {
|
||||
const uploadedImage = resp.data.data;
|
||||
dispatch(uploadImageSuccess({ data: { id, uploadedImage } }));
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { isEqual } from 'lodash';
|
|||
import classNames from 'classnames';
|
||||
import { propTypes } from '../../util/types';
|
||||
import { nonEmptyArray, composeValidators } from '../../util/validators';
|
||||
import { isUploadListingImageOverLimitError } from '../../util/errors';
|
||||
import { isUploadImageOverLimitError } from '../../util/errors';
|
||||
import { AddImages, Button, Form, ValidationError } from '../../components';
|
||||
|
||||
import css from './EditListingPhotosForm.css';
|
||||
|
|
@ -79,7 +79,7 @@ export class EditListingPhotosFormComponent extends Component {
|
|||
});
|
||||
|
||||
const { createListingsError, showListingsError, uploadImageError } = errors;
|
||||
const uploadOverLimit = isUploadListingImageOverLimitError(uploadImageError);
|
||||
const uploadOverLimit = isUploadImageOverLimitError(uploadImageError);
|
||||
|
||||
let uploadImageFailed = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import classNames from 'classnames';
|
|||
import { ensureCurrentUser } from '../../util/data';
|
||||
import { propTypes } from '../../util/types';
|
||||
import * as validators from '../../util/validators';
|
||||
import { isUploadProfileImageOverLimitError } from '../../util/errors';
|
||||
import { isUploadImageOverLimitError } from '../../util/errors';
|
||||
import { Form, Avatar, Button, ImageFromFile, IconSpinner, FieldTextInput } from '../../components';
|
||||
|
||||
import css from './ProfileSettingsForm.css';
|
||||
|
|
@ -220,7 +220,7 @@ class ProfileSettingsFormComponent extends Component {
|
|||
|
||||
let error = null;
|
||||
|
||||
if (isUploadProfileImageOverLimitError(uploadImageError)) {
|
||||
if (isUploadImageOverLimitError(uploadImageError)) {
|
||||
error = (
|
||||
<div className={css.error}>
|
||||
<FormattedMessage id="ProfileSettingsForm.imageUploadFailedFileTooLarge" />
|
||||
|
|
|
|||
|
|
@ -66,18 +66,10 @@ export const isTooManyEmailVerificationRequestsError = error =>
|
|||
|
||||
/**
|
||||
* Check if the given API error (from
|
||||
* `sdk.images.uploadListingImage()`) is due to the image being over
|
||||
* `sdk.images.upload()`) is due to the image being over
|
||||
* the size limit.
|
||||
*/
|
||||
export const isUploadListingImageOverLimitError = error =>
|
||||
hasErrorWithCode(error, ERROR_CODE_UPLOAD_OVER_LIMIT);
|
||||
|
||||
/**
|
||||
* Check if the given API error (from
|
||||
* `sdk.images.uploadProfileImage()`) is due to the image being over
|
||||
* the size limit.
|
||||
*/
|
||||
export const isUploadProfileImageOverLimitError = error =>
|
||||
export const isUploadImageOverLimitError = error =>
|
||||
hasErrorWithCode(error, ERROR_CODE_UPLOAD_OVER_LIMIT);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7599,9 +7599,9 @@ sharetribe-scripts@1.1.2:
|
|||
optionalDependencies:
|
||||
fsevents "^1.1.3"
|
||||
|
||||
"sharetribe-sdk@git+ssh://git@github.com/sharetribe/sharetribe-sdk-js#1c6a0d1c1a794bb2ee6de0e7b0bde1d2fd6f9388":
|
||||
"sharetribe-sdk@git+ssh://git@github.com/sharetribe/sharetribe-sdk-js#b438be11d0f40f62e1a0388da745f6792420ddb1":
|
||||
version "0.0.1"
|
||||
resolved "git+ssh://git@github.com/sharetribe/sharetribe-sdk-js#1c6a0d1c1a794bb2ee6de0e7b0bde1d2fd6f9388"
|
||||
resolved "git+ssh://git@github.com/sharetribe/sharetribe-sdk-js#b438be11d0f40f62e1a0388da745f6792420ddb1"
|
||||
dependencies:
|
||||
axios "^0.15.3"
|
||||
js-cookie "^2.1.3"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue