Skip to content

Commit ae27e18

Browse files
committed
chore(new-ui): resolve conflicts
2 parents ecc14f5 + 896f40f commit ae27e18

50 files changed

Lines changed: 729 additions & 272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/new-polymath-issuer/src/components/DividendCard/DividendCard.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
ButtonFluid,
1818
} from '@polymathnetwork/new-ui';
1919
import { DIVIDEND_PAYMENT_INVESTOR_BATCH_SIZE } from '~/constants';
20+
import * as sc from './styles';
2021

2122
interface Props {
2223
dividend: types.DividendEntity;
@@ -88,9 +89,9 @@ export const DividendCard: FC<Props> = ({
8889
{formatters.toTokens(dividend.amount)} {currencyLabel}
8990
</Paragraph>
9091
</CardPrimary>
91-
<Heading mt="m" mb={1}>
92+
<sc.DividendHeading mt="m" mb={1}>
9293
{dividend.name}
93-
</Heading>
94+
</sc.DividendHeading>
9495
<Label color={currencyColor} bg={currencyBgColor}>
9596
Issued in {currencyType}
9697
</Label>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { styled, Heading, ThemeInterface } from '@polymathnetwork/new-ui';
2+
import { StyledComponent } from 'styled-components';
3+
4+
export const DividendHeading: StyledComponent<
5+
typeof Heading,
6+
ThemeInterface,
7+
any,
8+
'variant'
9+
> = styled(Heading)`
10+
width: 100%;
11+
word-wrap: break-word;
12+
`;

packages/new-polymath-issuer/src/components/DividendList/Presenter.tsx

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,38 @@ export const DividendListPresenter: FC<Props> = ({
4040
/>
4141
</li>
4242
))}
43-
<sc.NewDividendButton
43+
<span>
44+
<sc.NewDividendButton
45+
as={allDividendsCompleted ? ButtonLink : Button}
46+
disabled={!allDividendsCompleted}
47+
href={newDividendUrl}
48+
variant="ghost"
49+
iconPosition="top"
50+
>
51+
<IconOutlined
52+
Asset={icons.SvgPlus}
53+
width={25}
54+
height={25}
55+
scale={0.8}
56+
/>
57+
Add new <br /> dividend <br /> distribution
58+
</sc.NewDividendButton>
59+
{!allDividendsCompleted && (
60+
<TooltipPrimary placement="top-start">
61+
You can add a new dividend distribution if the previous
62+
distribution has been completed/expired.
63+
</TooltipPrimary>
64+
)}
65+
</span>
66+
</Fragment>
67+
) : (
68+
<span>
69+
<sc.PlaceholderButton
4470
as={allDividendsCompleted ? ButtonLink : Button}
45-
disabled={!allDividendsCompleted}
4671
href={newDividendUrl}
4772
variant="ghost"
4873
iconPosition="top"
74+
disabled={!allDividendsCompleted}
4975
>
5076
<IconOutlined
5177
Asset={icons.SvgPlus}
@@ -54,28 +80,14 @@ export const DividendListPresenter: FC<Props> = ({
5480
scale={0.8}
5581
/>
5682
Add new <br /> dividend <br /> distribution
57-
{!allDividendsCompleted && (
58-
<TooltipPrimary placement="top-start">
59-
You can add a new dividend distribution if the previous
60-
distribution has been completed/expired.
61-
</TooltipPrimary>
62-
)}
63-
</sc.NewDividendButton>
64-
</Fragment>
65-
) : (
66-
<sc.PlaceholderButton
67-
href={newDividendUrl}
68-
variant="ghost"
69-
iconPosition="top"
70-
>
71-
<IconOutlined
72-
Asset={icons.SvgPlus}
73-
width={25}
74-
height={25}
75-
scale={0.8}
76-
/>
77-
Add new <br /> dividend <br /> distribution
78-
</sc.PlaceholderButton>
83+
</sc.PlaceholderButton>
84+
{!allDividendsCompleted && (
85+
<TooltipPrimary placement="top-start">
86+
You can add a new dividend distribution if the previous
87+
distribution has been completed/expired.
88+
</TooltipPrimary>
89+
)}
90+
</span>
7991
)}
8092
</List>
8193
);

packages/new-polymath-issuer/src/components/DividendList/styles.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ type NewDividendButtonType = StyledComponent<
1111
export const NewDividendButtonBase: NewDividendButtonType = styled(ButtonLink)`
1212
flex-direction: column;
1313
align-items: center;
14+
color: ${({ theme }) => theme.colors.primary};
15+
16+
&[disabled]:hover {
17+
color: ${({ theme }) => theme.colors.primary};
18+
}
1419
`;
1520

1621
export const NewDividendButton: NewDividendButtonType = Object.assign(
@@ -34,11 +39,13 @@ export const PlaceholderButtonBase: PlaceholderButtonType = styled(
3439
height: 370px;
3540
border: 1px dashed ${({ theme }) => theme.colors.primary};
3641
border-radius: 5px;
37-
color: ${({ theme }) => theme.colors.primary};
3842
3943
&:hover {
40-
background-color: transparent;
4144
color: ${({ theme }) => theme.colors.primary};
45+
}
46+
47+
&:not([disabled]):hover {
48+
background-color: transparent;
4249
border: 2px solid ${({ theme }) => theme.colors.primary};
4350
}
4451
`;

packages/new-polymath-issuer/src/pages/DividendDetails/Presenter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export const Presenter = ({
243243
<Box ml="m">
244244
<Text color="highlightText" fontSize={6} fontWeight={0}>
245245
{formatters.toPercent(
246-
1 - pendingTransactions / totalTransactions
246+
1 - pendingTransactions / (totalTransactions || 1)
247247
)}
248248
</Text>
249249
<Paragraph>Transactions are completed</Paragraph>

packages/new-polymath-issuer/src/pages/DividendsWizard/Container.tsx

Lines changed: 108 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { DataFetcher } from '~/components/enhancers/DataFetcher';
66
import {
77
createTaxWithholdingListBySymbolAndCheckpointFetcher,
88
createCheckpointBySymbolAndIdFetcher,
9+
createCheckpointsBySymbolFetcher,
10+
createDividendsByCheckpointFetcher,
911
} from '~/state/fetchers';
1012
import { types, formatters, utils } from '@polymathnetwork/new-shared';
1113
import { DateTime } from 'luxon';
@@ -17,13 +19,15 @@ import { ActionType } from 'typesafe-actions';
1719
import { DividendModuleTypes } from '@polymathnetwork/sdk';
1820
import { BigNumber } from 'bignumber.js';
1921
import { Page } from '@polymathnetwork/new-ui';
20-
import { range, padStart } from 'lodash';
22+
import { range, padStart, flatten, map, every, values } from 'lodash';
2123
import { polyClient } from '~/lib/polyClient';
2224
import { GetErc20BalanceByAddressAndWalletArgs } from '~/types';
25+
import { push } from 'redux-little-router';
2326

2427
const actions = {
2528
updateTaxWithholdingListStart,
2629
createErc20DividendDistributionStart,
30+
push,
2731
};
2832

2933
export interface Props {
@@ -203,48 +207,116 @@ export class ContainerBase extends Component<Props, State> {
203207

204208
public render() {
205209
const { securityTokenSymbol, checkpointIndex } = this.props;
210+
const fetcher = createCheckpointsBySymbolFetcher({
211+
securityTokenSymbol,
212+
});
213+
206214
const { step } = this.state;
207215
const parsedCheckpointIndex = parseInt(checkpointIndex, 10);
208216
return (
209217
<Page title="Create New Dividend Distribution">
210218
<DataFetcher
211219
watchProps={this.state}
212-
fetchers={[
213-
createTaxWithholdingListBySymbolAndCheckpointFetcher({
214-
securityTokenSymbol,
215-
checkpointIndex: parsedCheckpointIndex,
216-
dividendType: DividendModuleTypes.Erc20,
217-
}),
218-
createCheckpointBySymbolAndIdFetcher({
219-
securityTokenSymbol,
220-
checkpointIndex: parsedCheckpointIndex,
221-
}),
222-
]}
223-
render={(
224-
{
225-
taxWithholdings,
226-
checkpoints: [checkpoint],
227-
}: {
228-
taxWithholdings: types.TaxWithholdingEntity[];
229-
checkpoints: types.CheckpointEntity[];
230-
},
231-
loading: boolean
232-
) => {
220+
fetchers={[fetcher]}
221+
render={(data: { checkpoints: types.CheckpointEntity[] }) => {
222+
const { checkpoints } = data;
223+
const fetchers = checkpoints.map(({ index }) =>
224+
createDividendsByCheckpointFetcher(
225+
{
226+
securityTokenSymbol,
227+
checkpointIndex: index,
228+
},
229+
{ propKey: `${index}` }
230+
)
231+
);
233232
return (
234-
<Presenter
235-
createDividendDistribution={this.createDividendDistribution}
236-
updateTaxWithholdingList={this.updateTaxWithholdingList}
237-
stepIndex={step}
238-
securityTokenSymbol={securityTokenSymbol}
239-
checkpoint={checkpoint}
240-
onNextStep={this.nextStep}
241-
onPreviousStep={this.previousStep}
242-
taxWithholdings={taxWithholdings}
243-
downloadTaxWithholdingList={this.downloadTaxWithholdingList}
244-
downloadSampleExclusionList={this.downloadSampleExclusionList}
245-
fetchBalance={this.fetchBalance}
246-
fetchIsValidToken={this.fetchIsValidToken}
247-
isLoadingData={loading}
233+
<DataFetcher
234+
watchProps={this.state}
235+
fetchers={fetchers}
236+
render={(dividendsData: {
237+
[key: string]: types.DividendEntity[];
238+
}) => {
239+
const { dispatch } = this.props;
240+
const dividendsListUrl = `/securityTokens/${securityTokenSymbol}/dividends`;
241+
242+
const checkpointsList = values(dividendsData);
243+
if (checkpointsList.length === 0) {
244+
// No checkpoints exist
245+
dispatch(push(dividendsListUrl));
246+
}
247+
248+
const dividends = flatten(checkpointsList);
249+
const isCompleted = map(dividends, dividend => {
250+
const { expiry, investors } = dividend;
251+
const remainingPayments = investors.filter(
252+
(investor: any) =>
253+
!investor.paymentReceived && !investor.excluded
254+
).length;
255+
256+
return expiry <= new Date() || remainingPayments === 0;
257+
});
258+
const allDividendsCompleted = every(
259+
isCompleted,
260+
(complete: boolean) => complete
261+
);
262+
263+
if (!allDividendsCompleted) {
264+
// There are dividends with pending distribution
265+
dispatch(push(dividendsListUrl));
266+
}
267+
return (
268+
<DataFetcher
269+
watchProps={this.state}
270+
fetchers={[
271+
createTaxWithholdingListBySymbolAndCheckpointFetcher({
272+
securityTokenSymbol,
273+
checkpointIndex: parsedCheckpointIndex,
274+
dividendType: DividendModuleTypes.Erc20,
275+
}),
276+
createCheckpointBySymbolAndIdFetcher({
277+
securityTokenSymbol,
278+
checkpointIndex: parsedCheckpointIndex,
279+
}),
280+
]}
281+
render={(
282+
{
283+
taxWithholdings,
284+
checkpoints: [checkpoint],
285+
}: {
286+
taxWithholdings: types.TaxWithholdingEntity[];
287+
checkpoints: types.CheckpointEntity[];
288+
},
289+
loading: boolean
290+
) => {
291+
return (
292+
<Presenter
293+
createDividendDistribution={
294+
this.createDividendDistribution
295+
}
296+
updateTaxWithholdingList={
297+
this.updateTaxWithholdingList
298+
}
299+
stepIndex={step}
300+
securityTokenSymbol={securityTokenSymbol}
301+
checkpoint={checkpoint}
302+
onNextStep={this.nextStep}
303+
onPreviousStep={this.previousStep}
304+
taxWithholdings={taxWithholdings}
305+
downloadTaxWithholdingList={
306+
this.downloadTaxWithholdingList
307+
}
308+
downloadSampleExclusionList={
309+
this.downloadSampleExclusionList
310+
}
311+
fetchBalance={this.fetchBalance}
312+
fetchIsValidToken={this.fetchIsValidToken}
313+
isLoadingData={loading}
314+
/>
315+
);
316+
}}
317+
/>
318+
);
319+
}}
248320
/>
249321
);
250322
}}

0 commit comments

Comments
 (0)