Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const changePostAction = (post) => {
- return (dispatch) => {
- dispatch(blockEditButton(true));
- let formData = new FormData();
- formData.append('postId', post.details.data.postId.value);
- formData.append('title', post.details.data.title.value);
- // formData.append('categoryId', post.category.data.subcategory.value);
- formData.append('description', post.details.data.describe.value);
- formData.append('price', post.details.data.price.value);
- formData.append('latitude', post.details.data.location.info.latitude);
- formData.append('longtitude', post.details.data.location.info.longetude);
- formData.append('location', post.details.data.location.info.address);
- //formData.append('type', post.category.data.type.value);
- formData.append('availableUntil', post.details.data.date.value);
- post.images.data.images.new.forEach(file => {
- formData.append('image', file);
- });
- post.images.data.images.deleted.forEach(name => {
- formData.append('imagesToDelete', name);
- });
- PostApi.editPost(formData).then(response => {
- if(response.data.success === false){
- messageError('Data editing error');
- }
- else{
- dispatch(showPostWindowAction());
- dispatch(blockEditButton(false));
- dispatch(resetPostData());
- messageSuccess('Data edited successfully')
- }
- }).catch(error => {
- dispatch(blockEditButton(false));
- ErrorStatus(error,dispatch,
- {status:401,function: dispatch(showPostWindowAction())}
- );
- })
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement