Skip to content

Commit

Permalink
Feat/transfer model (#1039)
Browse files Browse the repository at this point in the history
* initial transfer model to track transfers of bounties

* adding one more attribute to the transfer model

* transfer basic tests

* tests and basic api for async transfers

* adding transfer section and refactoring payments section to functional component

* getting a basic transfer list

* getting the basic transfer list and transfer cases starting by a simple order

* transfer needs now more attributes

* finishing up with the transfer webhook updating transfer

* update transfer webhook

* fixing wrong bank codes

* fixing lint transfers
  • Loading branch information
alexanmtz authored Jan 16, 2024
1 parent 2b6d04f commit 29b716e
Show file tree
Hide file tree
Showing 39 changed files with 1,802 additions and 620 deletions.
56 changes: 55 additions & 1 deletion frontend/src/actions/taskActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const CLAIM_TASK_REQUESTED = 'CLAIM_TASK_REQUESTED'
const CLAIM_TASK_SUCCESS = 'CLAIM_TASK_SUCCESS'
const CLAIM_TASK_ERROR = 'CLAIM_TASK_ERROR'

const TRANSFER_TASK_REQUESTED = 'TRANSFER_TASK_REQUESTED'
const TRANSFER_TASK_SUCCESS = 'TRANSFER_TASK_SUCCESS'
const TRANSFER_TASK_ERROR = 'TRANSFER_TASK_ERROR'

const VALIDATION_ERRORS = {
'url must be unique': 'actions.task.create.validation.url',
'Not Found': 'actions.task.create.validation.invalid'
Expand Down Expand Up @@ -446,6 +450,55 @@ const fetchTask = taskId => {
}
}

/* Transfer Task */

const transferTaskRequested = () => {
return { type: TRANSFER_TASK_REQUESTED, completed: false }
}

const transferTaskSuccess = task => {
return { type: TRANSFER_TASK_SUCCESS, completed: true, data: task.data }
}

const transferTaskError = error => {
return { type: TRANSFER_TASK_ERROR, completed: true, error: error }
}

const transferTask = (taskId) => {
return dispatch => {
dispatch(transferTaskRequested())
axios
.post(api.API_URL + `/transfers/create`, {
taskId
})
.then(transfer => {
if (transfer.data) {
if(transfer.data.error) {
return dispatch(
addNotification(task.data.error)
)
}
dispatch(addNotification('actions.task.transfer.success'))
dispatch(transferTaskSuccess(transfer))
return dispatch(fetchTask(taskId))
}
return dispatch(
transferTaskError({ message: 'actions.task.transfer.unavailable' })
)
})
.catch(e => {
dispatch(
addNotification('actions.task.transfer.other.error')
)
dispatch(transferTaskError(e))
// eslint-disable-next-line no-console
console.log('not possible to transfer issue')
// eslint-disable-next-line no-console
console.log(e)
})
}
}

const paymentTask = (taskId, value) => {
return (dispatch, getState) => {
dispatch(paymentTaskRequested())
Expand Down Expand Up @@ -776,5 +829,6 @@ export {
fundingInviteTask,
changeTaskTab,
reportTask,
requestClaimTask
requestClaimTask,
transferTask
}
53 changes: 53 additions & 0 deletions frontend/src/actions/transferActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import axios from 'axios'
import api from '../consts'

const SEARCH_TRANSFER_REQUESTED = 'SEARCH_TRANSFER_REQUESTED'
const SEARCH_TRANSFER_SUCCESS = 'SEARCH_TRANSFER_SUCCESS'
const SEARCH_TRANSFER_FAILED = 'SEARCH_TRANSFER_FAILED'

const searchTransferRequested = () => {
return {
type: SEARCH_TRANSFER_REQUESTED,
completed: false

}
}

const searchTransferSuccess = (data) => {
return {
type: SEARCH_TRANSFER_SUCCESS,
data: data,
completed: true
}
}

const searchTransferFailed = (error) => {
return {
type: SEARCH_TRANSFER_FAILED,
error: error,
completed: true
}
}

const searchTransfer = (params) => (dispatch) => {
dispatch(searchTransferRequested())
return axios.get(api.API_URL + '/transfers/search', { params }).then(
transfer => {
if (transfer.data) {
return dispatch(searchTransferSuccess(transfer.data))
}
if (transfer.error) {
return dispatch(searchTransferFailed(transfer.error))
}
}
).catch(e => {
return dispatch(searchTransferFailed(e))
})
}

export {
SEARCH_TRANSFER_REQUESTED,
SEARCH_TRANSFER_SUCCESS,
SEARCH_TRANSFER_FAILED,
searchTransfer
}
87 changes: 43 additions & 44 deletions frontend/src/bank-codes-br.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
export default BANK_CODES: {
'110': 'BANCO PARA TESTE STRIPE',
'260': 'NUBANK',
'001': 'BANCO DO BRASIL S.A. (Banco do Brasil)',
'237': 'BANCO BRADESCO S.A. (Bradesco)',
'341': 'BANCO ITAU S.A. (Itaú)',
'033': 'BANCO SANTANDER (BRASIL) S.A.',
'409': 'UNIBANCO UNIAO DE BANCOS BRASILEIROS S.A. (Unibanco)',
'041': 'BANCO DO ESTADO DO RIO GRANDE DO SUL S.A. (Banrisul)',
'104': 'CAIXA ECONOMICA FEDERAL (Caixa Econômica Federal)',
'399': 'HSBC BANK BRASIL S.A.BANCO MULTIPLO (HSBC)',
'745': 'BANCO CITIBANK S.A.',
'151': 'BANCO NOSSA CAIXA S.A (Nossa Caixa)',
'389': 'BANCO MERCANTIL DO BRASIL S.A. (Mercantil do Brasil)',
'004': 'BANCO DO NORDESTE DO BRASIL S.A (Banco do Nordeste (BNB) )',
'021': 'BANESTES S.A BANCO DO ESTADO DO ESPIRITO SANTO (Banestes)',
'422': 'BANCO SAFRA S.A. (Safra)',
'003': 'BANCO DA AMAZONIA S.A. (Banco da Amazônia (Basa))',
'047': 'Banco do Estado de Sergipe S.A (Banese)',
'070': 'Banco de Brasília S.A. (BRB)',
'655': 'Banco Votorantim S.A (Votorantim)',
'107': 'Banco BBM S.A (BBM)',
'025': 'Banco Alfa S.A (Alfa)',
'263': 'Banco Cacique S. A. (Cacique)',
'229': 'BANCO CRUZEIRO DO SUL S.A. (Cruzeiro do Sul)',
'252': 'BANCO FININVEST S.A. (Fininvest)',
'063': 'BANCO IBI S.A - BANCO MULTIPLO (Banco IBI)',
'623': 'BANCO PANAMERICANO S.A. (PanAmericano)',
'633': 'BANCO RENDIMENTO S.A. (Banco Rendimento)',
'749': 'BANCO SIMPLES S.A. (Banco Simples)',
'215': 'BANCO ACOMERCIAL E DE INVESTIMENTO SUDAMERIS S.A. (Sudameris)',
'756': 'BANCO COOPERATIVO DO BRASIL S.A. - (BANCOOB)',
'748': 'BANCO COOPERATIVO SICREDI S.A. (SICREDI)',
'065': 'LEMON BANK BANCO MÚLTIPLO S..A (Lemon Bank)',
'069': 'BPN BRASIL BANCO MÚLTIPLO S.A. (BPN)',
'719': 'BANIF - BANCO INTERNACIONAL DO FUNCHAL (BRASIL), S.A. (Banif)',
'318': 'BANCO BMG S.A. (BMG)',
'027': 'BANCO DO ESTADO DE SANTA CATARINA S.A.',
'208': 'BANCO UBS PACTUAL S.A.',
'479': 'BANCO ITAUBANK S.A.',
'077': 'BANCO INTERMEDIUM S.A.',
'212': 'BANCO ORIGINAL',
'085': 'CECRED-COOPERATIVA CENTRAL DE CREDITO URBANO'
}
export default BANK_CODES = {
'110': 'BANCO PARA TESTE STRIPE',
'260': 'NUBANK',
'001': 'BANCO DO BRASIL S.A. (Banco do Brasil)',
'237': 'BANCO BRADESCO S.A. (Bradesco)',
'341': 'BANCO ITAU S.A. (Itaú)',
'033': 'BANCO SANTANDER (BRASIL) S.A.',
'409': 'UNIBANCO UNIAO DE BANCOS BRASILEIROS S.A. (Unibanco)',
'041': 'BANCO DO ESTADO DO RIO GRANDE DO SUL S.A. (Banrisul)',
'104': 'CAIXA ECONOMICA FEDERAL (Caixa Econômica Federal)',
'399': 'HSBC BANK BRASIL S.A.BANCO MULTIPLO (HSBC)',
'745': 'BANCO CITIBANK S.A.',
'151': 'BANCO NOSSA CAIXA S.A (Nossa Caixa)',
'389': 'BANCO MERCANTIL DO BRASIL S.A. (Mercantil do Brasil)',
'004': 'BANCO DO NORDESTE DO BRASIL S.A (Banco do Nordeste (BNB) )',
'021': 'BANESTES S.A BANCO DO ESTADO DO ESPIRITO SANTO (Banestes)',
'422': 'BANCO SAFRA S.A. (Safra)',
'003': 'BANCO DA AMAZONIA S.A. (Banco da Amazônia (Basa))',
'047': 'Banco do Estado de Sergipe S.A (Banese)',
'070': 'Banco de Brasília S.A. (BRB)',
'655': 'Banco Votorantim S.A (Votorantim)',
'107': 'Banco BBM S.A (BBM)',
'025': 'Banco Alfa S.A (Alfa)',
'263': 'Banco Cacique S. A. (Cacique)',
'229': 'BANCO CRUZEIRO DO SUL S.A. (Cruzeiro do Sul)',
'252': 'BANCO FININVEST S.A. (Fininvest)',
'063': 'BANCO IBI S.A - BANCO MULTIPLO (Banco IBI)',
'623': 'BANCO PANAMERICANO S.A. (PanAmericano)',
'633': 'BANCO RENDIMENTO S.A. (Banco Rendimento)',
'749': 'BANCO SIMPLES S.A. (Banco Simples)',
'215': 'BANCO ACOMERCIAL E DE INVESTIMENTO SUDAMERIS S.A. (Sudameris)',
'756': 'BANCO COOPERATIVO DO BRASIL S.A. - (BANCOOB)',
'748': 'BANCO COOPERATIVO SICREDI S.A. (SICREDI)',
'065': 'LEMON BANK BANCO MÚLTIPLO S..A (Lemon Bank)',
'069': 'BPN BRASIL BANCO MÚLTIPLO S.A. (BPN)',
'719': 'BANIF - BANCO INTERNACIONAL DO FUNCHAL (BRASIL), S.A. (Banif)',
'318': 'BANCO BMG S.A. (BMG)',
'027': 'BANCO DO ESTADO DE SANTA CATARINA S.A.',
'208': 'BANCO UBS PACTUAL S.A.',
'479': 'BANCO ITAUBANK S.A.',
'077': 'BANCO INTERMEDIUM S.A.',
'212': 'BANCO ORIGINAL',
'085': 'CECRED-COOPERATIVA CENTRAL DE CREDITO URBANO'
}
Loading

0 comments on commit 29b716e

Please sign in to comment.