Remove Stripe account creation from listing creation

This commit is contained in:
Kimmo Puputti 2017-05-15 16:52:15 +03:00
parent 05bd75d26b
commit 05962e70e5
2 changed files with 4 additions and 15 deletions

View file

@ -1,6 +1,6 @@
import { omitBy, isUndefined } from 'lodash';
import { addMarketplaceEntities } from '../../ducks/marketplaceData.duck';
import { createStripeAccount, fetchCurrentUserHasListingsSuccess } from '../../ducks/user.duck';
import { fetchCurrentUserHasListingsSuccess } from '../../ducks/user.duck';
const requestAction = actionType => params => ({ type: actionType, payload: { params } });
@ -176,17 +176,10 @@ export function requestShowListing(actionPayload) {
export function requestCreateListing(data) {
return (dispatch, getState, sdk) => {
const { bankAccountToken, country, ...actionPayload } = data;
dispatch(createListing(actionPayload));
dispatch(createListing(data));
const shouldCreateStripeAccount = bankAccountToken && country;
const stripeAccountAddress = { country };
const accountCreated = shouldCreateStripeAccount
? dispatch(createStripeAccount(bankAccountToken, stripeAccountAddress))
: Promise.resolve('already created');
return accountCreated
.then(() => sdk.listings.create(actionPayload))
return sdk.listings
.create(data)
.then(response => {
const id = response.data.data.id.uuid;
// Modify store to understand that we have created listing and can redirect away

View file

@ -21,13 +21,11 @@ import {
const formatRequestData = values => {
const {
address,
country,
description,
images,
geolocation,
price,
title,
bankAccountToken,
} = values;
return {
@ -37,8 +35,6 @@ const formatRequestData = values => {
images: images.map(i => i.imageId),
price,
title,
country,
bankAccountToken,
};
};