diff --git a/frontend/src/components/profile/transfers.js b/frontend/src/components/profile/transfers.js index d2920d77..8e96dfd7 100644 --- a/frontend/src/components/profile/transfers.js +++ b/frontend/src/components/profile/transfers.js @@ -67,6 +67,53 @@ const Transfers = ({ searchTransfer, updateTransfer, transfers, user, intl, hist getTranfers().then(t => console.log('transfers:', t)) }, [user]) + const transferActions = (t) => { + if(!user.account_id && t.status !== 'pending') return null + switch(value) { + case 'from': + return (user.account_id && t.status === 'pending') ? + ( + ) : null + case 'to': + return ( user.account_id && t.status === 'pending') ? + + : + !user.account_id && + default: + return null + } + } + return (
@@ -126,33 +173,8 @@ const Transfers = ({ searchTransfer, updateTransfer, transfers, user, intl, hist { t.Task.title } , - value === 'to' && ( - (user.account_id && t.status === 'pending') ? - - : - !user.account_id && - )]) } || {} - } + transferActions(t) + ]) } || {}} />
diff --git a/modules/transfers/transferUpdate.js b/modules/transfers/transferUpdate.js index 4fae0f17..d658c7d5 100644 --- a/modules/transfers/transferUpdate.js +++ b/modules/transfers/transferUpdate.js @@ -48,14 +48,14 @@ module.exports = Promise.method(async function transferUpdate(params) { returning: true }) - const { Task: task, User: user } = existingTransfer + const { value, Task: task, User: user } = existingTransfer if (!updateTask || !updateTransfer) { TransferMail.error(user, task, task.value) return { error: 'update_task_reject' } } const taskOwner = await models.User.findByPk(task.userId) - TransferMail.notifyOwner(taskOwner.dataValues, task, task.value) - TransferMail.success(user, task, task.value) + TransferMail.notifyOwner(taskOwner.dataValues, task, value) + TransferMail.success(user, task, value) return updateTransfer[1][0].dataValues } } diff --git a/test/transfer.test.js b/test/transfer.test.js index 9d5b0f8e..ffdb43c3 100644 --- a/test/transfer.test.js +++ b/test/transfer.test.js @@ -168,6 +168,10 @@ describe("Transfer", () => { .persist() .post('/v1/transfers') .reply(200, transfer ); + nock('https://api.stripe.com') + .persist() + .get('/v1/transfers') + .reply(200, transfer ); const task = await createTask(agent); const taskData = task.dataValues; const order = await createOrder({userId: taskData.userId, TaskId: taskData.id, paid: true, provider: 'stripe'});