Monetization: Fix monetization withdraw flow (#4995)
This commit is contained in:
parent
6b6591e10d
commit
9ddad6924f
@ -265,10 +265,12 @@ function buildChannelMonetizationBalances({
|
|||||||
currentBalance,
|
currentBalance,
|
||||||
availableBalance,
|
availableBalance,
|
||||||
overallRevenue,
|
overallRevenue,
|
||||||
|
withdrawalEnabled,
|
||||||
}: GramJs.BroadcastRevenueBalances): ChannelMonetizationBalances {
|
}: GramJs.BroadcastRevenueBalances): ChannelMonetizationBalances {
|
||||||
return {
|
return {
|
||||||
currentBalance: Number(currentBalance) / DECIMALS,
|
currentBalance: Number(currentBalance) / DECIMALS,
|
||||||
availableBalance: Number(availableBalance) / DECIMALS,
|
availableBalance: Number(availableBalance) / DECIMALS,
|
||||||
overallRevenue: Number(overallRevenue) / DECIMALS,
|
overallRevenue: Number(overallRevenue) / DECIMALS,
|
||||||
|
isWithdrawalEnabled: withdrawalEnabled,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,4 +139,5 @@ export interface ChannelMonetizationBalances {
|
|||||||
currentBalance: number;
|
currentBalance: number;
|
||||||
availableBalance: number;
|
availableBalance: number;
|
||||||
overallRevenue: number;
|
overallRevenue: number;
|
||||||
|
isWithdrawalEnabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,6 +71,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.textBottom {
|
.textBottom {
|
||||||
|
margin-top: 0.5rem;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
color: var(--color-text-secondary);
|
color: var(--color-text-secondary);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,7 +84,9 @@ const MonetizationStatistics = ({
|
|||||||
] = useFlag(false);
|
] = useFlag(false);
|
||||||
const [isConfirmPasswordDialogOpen, openConfirmPasswordDialogOpen, closeConfirmPasswordDialogOpen] = useFlag();
|
const [isConfirmPasswordDialogOpen, openConfirmPasswordDialogOpen, closeConfirmPasswordDialogOpen] = useFlag();
|
||||||
const availableBalance = statistics?.balances?.availableBalance;
|
const availableBalance = statistics?.balances?.availableBalance;
|
||||||
const canWithdraw = isCreator && isChannelRevenueWithdrawalEnabled && Boolean(availableBalance);
|
const isWithdrawalEnabled = statistics?.balances?.isWithdrawalEnabled;
|
||||||
|
const canWithdraw = isCreator && isChannelRevenueWithdrawalEnabled && Boolean(availableBalance)
|
||||||
|
&& isWithdrawalEnabled;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (chatId) {
|
if (chatId) {
|
||||||
@ -144,12 +146,14 @@ const MonetizationStatistics = ({
|
|||||||
<div className={styles.toncoin}>
|
<div className={styles.toncoin}>
|
||||||
<Icon className={styles.toncoinIcon} name="toncoin" />
|
<Icon className={styles.toncoinIcon} name="toncoin" />
|
||||||
<b className={styles.rewardValue}>
|
<b className={styles.rewardValue}>
|
||||||
{integerTonPart}<span className={styles.decimalPart}>.{decimalTonPart}</span>
|
{integerTonPart}
|
||||||
|
{decimalTonPart ? <span className={styles.decimalPart}>.{decimalTonPart}</span> : undefined}
|
||||||
</b>
|
</b>
|
||||||
</div>
|
</div>
|
||||||
{' '}
|
{' '}
|
||||||
<span className={styles.integer}>
|
<span className={styles.integer}>
|
||||||
≈ ${integerUsdPart}<span className={styles.decimalUsdPart}>.{decimalUsdPart}</span>
|
≈ ${integerUsdPart}
|
||||||
|
{decimalUsdPart ? <span className={styles.decimalUsdPart}>.{decimalUsdPart}</span> : undefined}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -212,6 +216,9 @@ const MonetizationStatistics = ({
|
|||||||
isToncoin
|
isToncoin
|
||||||
type="monetization"
|
type="monetization"
|
||||||
title={oldLang('MonetizationOverview')}
|
title={oldLang('MonetizationOverview')}
|
||||||
|
subtitle={
|
||||||
|
<div className={styles.textBottom}>{oldLang('MonetizationProceedsTONInfo')}</div>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{!loadedCharts.current.length && <Loading />}
|
{!loadedCharts.current.length && <Loading />}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
import type { FC } from '../../../lib/teact/teact';
|
import type { FC } from '../../../lib/teact/teact';
|
||||||
import React, { memo } from '../../../lib/teact/teact';
|
import React, { memo } from '../../../lib/teact/teact';
|
||||||
|
|
||||||
@ -109,6 +110,7 @@ export type OwnProps = {
|
|||||||
ApiPostStatistics |
|
ApiPostStatistics |
|
||||||
ApiBoostStatistics |
|
ApiBoostStatistics |
|
||||||
ApiChannelMonetizationStatistics;
|
ApiChannelMonetizationStatistics;
|
||||||
|
subtitle?: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
const StatisticsOverview: FC<OwnProps> = ({
|
const StatisticsOverview: FC<OwnProps> = ({
|
||||||
@ -117,6 +119,7 @@ const StatisticsOverview: FC<OwnProps> = ({
|
|||||||
statistics,
|
statistics,
|
||||||
isToncoin,
|
isToncoin,
|
||||||
className,
|
className,
|
||||||
|
subtitle,
|
||||||
}) => {
|
}) => {
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
|
|
||||||
@ -234,6 +237,8 @@ const StatisticsOverview: FC<OwnProps> = ({
|
|||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
{subtitle}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user