@@ -19,7 +19,7 @@ import { ActionType } from 'typesafe-actions';
1919import { DividendModuleTypes } from '@polymathnetwork/sdk' ;
2020import { BigNumber } from 'bignumber.js' ;
2121import { Page } from '@polymathnetwork/new-ui' ;
22- import { range , padStart , flatten , map , every } from 'lodash' ;
22+ import { range , padStart , flatten , map , every , values } from 'lodash' ;
2323import { polyClient } from '~/lib/polyClient' ;
2424import { GetErc20BalanceByAddressAndWalletArgs } from '~/types' ;
2525import { push } from 'redux-little-router' ;
@@ -236,25 +236,21 @@ export class ContainerBase extends Component<Props, State> {
236236 render = { ( dividendsData : {
237237 [ key : string ] : types . DividendEntity [ ] ;
238238 } ) => {
239- const allDividendsCompleted = every (
240- flatten (
241- map ( dividendsData , dividends =>
242- map ( dividends , dividend => {
243- const { expiry, investors } = dividend ;
244-
245- const remainingPayments = investors . filter (
246- ( investor : any ) =>
247- ! investor . paymentReceived && ! investor . excluded
248- ) . length ;
239+ const dividends = flatten ( values ( dividendsData ) ) ;
240+ const isCompleted = map ( dividends , dividend => {
241+ const { expiry, investors } = dividend ;
242+ const remainingPayments = investors . filter (
243+ ( investor : any ) =>
244+ ! investor . paymentReceived && ! investor . excluded
245+ ) . length ;
249246
250- return (
251- expiry <= new Date ( ) || remainingPayments === 0
252- ) ;
253- } )
254- )
255- ) ,
247+ return expiry <= new Date ( ) || remainingPayments === 0 ;
248+ } ) ;
249+ const allDividendsCompleted = every (
250+ isCompleted ,
256251 ( complete : boolean ) => complete
257252 ) ;
253+
258254 if ( ! allDividendsCompleted ) {
259255 // There are dividends with pending distribution
260256 const { dispatch } = this . props ;
0 commit comments