From cc3352d44d031307aff25ed0d9838c1a4924e4be Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Fri, 18 Aug 2023 17:37:45 +0000 Subject: [PATCH] HF29 - UI for payment subscriptions --- app/components/cards/TransferHistoryRow.jsx | 44 +++++++++++++++++++++ app/components/modules/TopRightMenu.jsx | 4 +- app/locales/en.json | 6 +++ app/locales/ru-RU.json | 7 ++++ app/redux/FetchDataSaga.js | 4 +- 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/app/components/cards/TransferHistoryRow.jsx b/app/components/cards/TransferHistoryRow.jsx index 626f8a8..302ab55 100644 --- a/app/components/cards/TransferHistoryRow.jsx +++ b/app/components/cards/TransferHistoryRow.jsx @@ -2,6 +2,7 @@ import React from 'react'; import {connect} from 'react-redux' import { Link } from 'react-router'; import { PrivateKey } from 'golos-lib-js/lib/auth/ecc' +import { Asset } from 'golos-lib-js/lib/utils' import tt from 'counterpart' import TimeAgoWrapper from 'app/components/elements/TimeAgoWrapper'; @@ -269,6 +270,49 @@ class TransferHistoryRow extends React.Component { description_end += tt('transferhistoryrow_jsx.with_unlimit') } } + else if (type === 'subscription_payment') { + const iAmSponsor = data.subscriber === this.props.context + const total = Asset(data.amount).plus(data.rest).floatString + if (data.payment_type === 'first') { + if (iAmSponsor) { + description_start += tt('transferhistoryrow_jsx.i_become_sponsor') + link = data.author + description_end += tt('transferhistoryrow_jsx.for') + description_end += total + } else { + link = data.subscriber + description_end += tt('transferhistoryrow_jsx.their_become_sponsor') + description_end += tt('transferhistoryrow_jsx.for') + description_end += total + } + } else if (data.payment_type === 'prolong') { + if (iAmSponsor) { + description_start += tt('transferhistoryrow_jsx.i_prolong_sponsor') + link = data.author + description_end += tt('transferhistoryrow_jsx.for') + description_end += total + } else { + link = data.subscriber + description_end += tt('transferhistoryrow_jsx.their_prolong_sponsor') + description_end += tt('transferhistoryrow_jsx.for') + description_end += total + } + } else if (data.payment_type === 'regular') { + if (iAmSponsor) { + description_start += tt('transferhistoryrow_jsx.payment_for_sponsorship') + link = data.author + description_end += ' - ' + total + description_end += tt('transferhistoryrow_jsx.per_month') + } else { + description_start += tt('transferhistoryrow_jsx.payment_from_sponsor') + link = data.subscriber + description_end += ' - ' + total + description_end += tt('transferhistoryrow_jsx.per_month') + } + } else { + code_key = JSON.stringify({type, ...data}, null, 2); + } + } else { code_key = JSON.stringify({type, ...data}, null, 2); diff --git a/app/components/modules/TopRightMenu.jsx b/app/components/modules/TopRightMenu.jsx index 3051ae4..4e020b0 100644 --- a/app/components/modules/TopRightMenu.jsx +++ b/app/components/modules/TopRightMenu.jsx @@ -154,7 +154,7 @@ function TopRightMenu({account, savings_withdraws, price_per_golos, globalprops, {link: uiaLink, icon: 'editor/coin', value: tt('g.assets')}, {link: ordersLink, icon: 'trade', value: tt('navigation.market2'), addon: }, {link: inviteLink, icon: 'hf/hf19', value: tt('g.invites')}, - {link: blogLink, target: blogsTarget(), icon: 'new/blogging', value: tt('g.blog'), addon: }, + {link: blogLink, target: blogsTarget(), icon: 'new/blogging', value: tt('g.blog'), addon: }, {link: donatesLink, icon: 'hf/hf8', value: tt('g.rewards'), addon: }, (messagesLink ? {link: messagesLink, icon: 'new/envelope', value: tt('g.messages'), target: '_blank', addon: } : @@ -196,7 +196,7 @@ function TopRightMenu({account, savings_withdraws, price_per_golos, globalprops, -
+
} {navAdditional} diff --git a/app/locales/en.json b/app/locales/en.json index 8f69c90..d0d9054 100644 --- a/app/locales/en.json +++ b/app/locales/en.json @@ -851,6 +851,12 @@ "transferred": "Transfer ", "percen_referral": " - you get a percentage of the referral fee ", "funded_workers": "Funded by the community ", + "i_become_sponsor": "Became a sponsor of ", + "their_become_sponsor": " became a sponsor of ", + "i_prolong_sponsor": "Prolonged sponsorship of ", + "their_prolong_sponsor": " prolonged sponsorship of ", + "payment_for_sponsorship": "Payment for sponsorship of ", + "payment_from_sponsor": "Payment from sponsor ", "to_golos_power": " for Golos Power", "to_tip": " to TIP balance ", "from_tip": " with TIP balance ", diff --git a/app/locales/ru-RU.json b/app/locales/ru-RU.json index 0a7b649..d4a29b1 100644 --- a/app/locales/ru-RU.json +++ b/app/locales/ru-RU.json @@ -884,6 +884,13 @@ "transferred": "Передано ", "percen_referral": " - процент от награды в адрес вашего реферала ", "funded_workers": "Профинансировано ", + "i_become_sponsor": "Стал спонсором ", + "their_become_sponsor": " стал спонсором", + "i_prolong_sponsor": "Продлил спонсорство ", + "their_prolong_sponsor": " продлил спонсорство ", + "payment_for_sponsorship": "Платеж за спонсорство ", + "payment_from_sponsor": "Платеж от спонсора ", + "per_month": " в месяц", "to_golos_power": " в Силу Голоса", "to_golos_liquid": " на основной баланс", "to_tip": " на TIP-баланс ", diff --git a/app/redux/FetchDataSaga.js b/app/redux/FetchDataSaga.js index 845a53a..6c48c16 100644 --- a/app/redux/FetchDataSaga.js +++ b/app/redux/FetchDataSaga.js @@ -143,7 +143,7 @@ export function* fetchState(location_change_action) { break case 'transfers': default: - const history = yield call([api, api.getAccountHistoryAsync], uname, -1, 1000, {select_ops: ['donate', 'transfer', 'author_reward', 'curation_reward', 'transfer_to_tip', 'transfer_from_tip', 'transfer_to_vesting', 'withdraw_vesting', 'asset_issue', 'invite', 'transfer_to_savings', 'transfer_from_savings', 'convert_sbd_debt', 'convert', 'fill_convert_request', 'interest', 'worker_reward', 'account_freeze', 'unwanted_cost', 'unlimit_cost']}) + const history = yield call([api, api.getAccountHistoryAsync], uname, -1, 1000, {select_ops: ['donate', 'transfer', 'author_reward', 'curation_reward', 'transfer_to_tip', 'transfer_from_tip', 'transfer_to_vesting', 'withdraw_vesting', 'asset_issue', 'invite', 'transfer_to_savings', 'transfer_from_savings', 'convert_sbd_debt', 'convert', 'fill_convert_request', 'interest', 'worker_reward', 'account_freeze', 'unwanted_cost', 'unlimit_cost', 'subscription_payment'/*, 'subscription_prepaid_return'*/]}) account.transfer_history = [] account.other_history = [] @@ -170,6 +170,8 @@ export function* fetchState(location_change_action) { case 'account_freeze': case 'unwanted_cost': case 'unlimit_cost': + case 'subscription_payment': + //case 'subscription_prepaid_return': state.accounts[uname].transfer_history.push(operation) break