Boost Modal: Add text for non-premium users (#3925)
This commit is contained in:
parent
38e0e7a847
commit
eddbd476b6
@ -5,7 +5,7 @@ import type { ApiApplyBoostInfo, ApiChat } from '../../../api/types';
|
|||||||
import type { TabState } from '../../../global/types';
|
import type { TabState } from '../../../global/types';
|
||||||
|
|
||||||
import { getChatTitle } from '../../../global/helpers';
|
import { getChatTitle } from '../../../global/helpers';
|
||||||
import { selectChat } from '../../../global/selectors';
|
import { selectChat, selectIsCurrentUserPremium } from '../../../global/selectors';
|
||||||
import { formatDateInFuture } from '../../../util/dateFormat';
|
import { formatDateInFuture } from '../../../util/dateFormat';
|
||||||
import { getServerTime } from '../../../util/serverTime';
|
import { getServerTime } from '../../../util/serverTime';
|
||||||
import { getBoostProgressInfo } from '../../common/helpers/boostInfo';
|
import { getBoostProgressInfo } from '../../common/helpers/boostInfo';
|
||||||
@ -50,21 +50,25 @@ export type OwnProps = {
|
|||||||
type StateProps = {
|
type StateProps = {
|
||||||
chat?: ApiChat;
|
chat?: ApiChat;
|
||||||
boostedChat?: ApiChat;
|
boostedChat?: ApiChat;
|
||||||
|
isCurrentUserPremium?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const BoostModal = ({
|
const BoostModal = ({
|
||||||
info,
|
info,
|
||||||
chat,
|
chat,
|
||||||
boostedChat,
|
boostedChat,
|
||||||
|
isCurrentUserPremium,
|
||||||
}: OwnProps & StateProps) => {
|
}: OwnProps & StateProps) => {
|
||||||
const {
|
const {
|
||||||
applyBoost,
|
applyBoost,
|
||||||
closeBoostModal,
|
closeBoostModal,
|
||||||
requestConfetti,
|
requestConfetti,
|
||||||
|
openPremiumModal,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const [isReplaceModalOpen, openReplaceModal, closeReplaceModal] = useFlag();
|
const [isReplaceModalOpen, openReplaceModal, closeReplaceModal] = useFlag();
|
||||||
const [isWaitDialogOpen, openWaitDialog, closeWaitDialog] = useFlag();
|
const [isWaitDialogOpen, openWaitDialog, closeWaitDialog] = useFlag();
|
||||||
|
const [isPremiumDialogOpen, openPremiumDialog, closePremiumDialog] = useFlag();
|
||||||
|
|
||||||
const isOpen = Boolean(info);
|
const isOpen = Boolean(info);
|
||||||
|
|
||||||
@ -160,13 +164,26 @@ const BoostModal = ({
|
|||||||
};
|
};
|
||||||
}, [chat, chatTitle, info, lang]);
|
}, [chat, chatTitle, info, lang]);
|
||||||
|
|
||||||
|
const isBoostDisabled = !applyInfo && isCurrentUserPremium;
|
||||||
|
|
||||||
const handleApplyBoost = useLastCallback(() => {
|
const handleApplyBoost = useLastCallback(() => {
|
||||||
closeReplaceModal();
|
closeReplaceModal();
|
||||||
applyBoost({ chatId: chat!.id });
|
applyBoost({ chatId: chat!.id });
|
||||||
requestConfetti();
|
requestConfetti();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleProceedPremium = useLastCallback(() => {
|
||||||
|
openPremiumModal();
|
||||||
|
closePremiumDialog();
|
||||||
|
closeBoostModal();
|
||||||
|
});
|
||||||
|
|
||||||
const handleButtonClick = useLastCallback(() => {
|
const handleButtonClick = useLastCallback(() => {
|
||||||
|
if (!isCurrentUserPremium) {
|
||||||
|
openPremiumDialog();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isBoosted) {
|
if (isBoosted) {
|
||||||
closeBoostModal();
|
closeBoostModal();
|
||||||
return;
|
return;
|
||||||
@ -207,7 +224,7 @@ const BoostModal = ({
|
|||||||
{renderText(descriptionText, ['simple_markdown', 'emoji'])}
|
{renderText(descriptionText, ['simple_markdown', 'emoji'])}
|
||||||
</div>
|
</div>
|
||||||
<div className="dialog-buttons">
|
<div className="dialog-buttons">
|
||||||
<Button isText className="confirm-dialog-button" disabled={!applyInfo} onClick={handleButtonClick}>
|
<Button isText className="confirm-dialog-button" disabled={isBoostDisabled} onClick={handleButtonClick}>
|
||||||
{!isBoosted ? (
|
{!isBoosted ? (
|
||||||
<>
|
<>
|
||||||
<Icon name="boost" />
|
<Icon name="boost" />
|
||||||
@ -278,6 +295,17 @@ const BoostModal = ({
|
|||||||
)}
|
)}
|
||||||
</ConfirmDialog>
|
</ConfirmDialog>
|
||||||
)}
|
)}
|
||||||
|
{!isCurrentUserPremium && (
|
||||||
|
<ConfirmDialog
|
||||||
|
isOpen={isPremiumDialogOpen}
|
||||||
|
confirmLabel={lang('Common.Yes')}
|
||||||
|
title={lang('PremiumNeeded')}
|
||||||
|
onClose={closePremiumDialog}
|
||||||
|
confirmHandler={handleProceedPremium}
|
||||||
|
>
|
||||||
|
{renderText(lang('PremiumNeededForBoosting'), ['simple_markdown', 'emoji'])}
|
||||||
|
</ConfirmDialog>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -291,6 +319,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
return {
|
return {
|
||||||
chat,
|
chat,
|
||||||
boostedChat,
|
boostedChat,
|
||||||
|
isCurrentUserPremium: selectIsCurrentUserPremium(global),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
)(BoostModal));
|
)(BoostModal));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user