-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #563 from Concordium/ui-update/validation-transaction
UI update/validation transaction
- Loading branch information
Showing
42 changed files
with
1,661 additions
and
341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...owser-wallet/src/popup/popupX/pages/EarningRewards/Validator/Commissions/Commissions.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.validator-commissions { | ||
.page__top { | ||
margin-bottom: 0 !important; | ||
} | ||
|
||
&, | ||
&__form { | ||
gap: rem(16px); | ||
} | ||
|
||
&__form { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
...rowser-wallet/src/popup/popupX/pages/EarningRewards/Validator/Commissions/Commissions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import React, { useCallback, useMemo } from 'react'; | ||
import Page from '@popup/popupX/shared/Page'; | ||
import { useTranslation } from 'react-i18next'; | ||
import Text from '@popup/popupX/shared/Text'; | ||
import Button from '@popup/popupX/shared/Button'; | ||
import { ChainParameters, ChainParametersV0, CommissionRange, CommissionRates } from '@concordium/web-sdk'; | ||
import Form, { useForm } from '@popup/popupX/shared/Form'; | ||
import FormSlider from '@popup/popupX/shared/Form/Slider/Slider'; | ||
import { PropsOf } from 'wallet-common-helpers'; | ||
import { isRange } from '../util'; | ||
|
||
const COMMISSION_STEP = 0.001; | ||
|
||
type Props = { | ||
initial?: CommissionRates; | ||
onSubmit(values: CommissionRates): void; | ||
chainParams: Exclude<ChainParameters, ChainParametersV0>; | ||
}; | ||
|
||
export default function Commissions({ initial, onSubmit, chainParams }: Props) { | ||
const { t } = useTranslation('x', { keyPrefix: 'earn.validator.commissions' }); | ||
const { bakingCommissionRange, finalizationCommissionRange, transactionCommissionRange } = chainParams; | ||
const defaultValues: CommissionRates = useMemo( | ||
() => ({ | ||
bakingCommission: (initial?.bakingCommission ?? bakingCommissionRange.min) * 100, | ||
transactionCommission: (initial?.transactionCommission ?? transactionCommissionRange.min) * 100, | ||
finalizationCommission: (initial?.finalizationCommission ?? finalizationCommissionRange.min) * 100, | ||
}), | ||
[initial, chainParams] | ||
); | ||
const form = useForm({ defaultValues }); | ||
|
||
const commissionRules = useCallback( | ||
(range: CommissionRange): PropsOf<typeof FormSlider>['rules'] => { | ||
const min = range.min * 100; | ||
const max = range.max * 100; | ||
return { | ||
min: { value: min, message: t('error.min', { min }) }, | ||
max: { value: max, message: t('error.max', { max }) }, | ||
required: t('error.required'), | ||
}; | ||
}, | ||
[t] | ||
); | ||
|
||
const handleSubmit = useCallback( | ||
(values: CommissionRates) => { | ||
const fractions: CommissionRates = { | ||
transactionCommission: values.transactionCommission / 100, | ||
bakingCommission: values.bakingCommission / 100, | ||
finalizationCommission: values.finalizationCommission / 100, | ||
}; | ||
|
||
onSubmit(fractions); | ||
}, | ||
[onSubmit] | ||
); | ||
|
||
return ( | ||
<Page className="validator-commissions"> | ||
<Page.Top heading={t('title')} /> | ||
<Text.Capture>{t('desciption')}</Text.Capture> | ||
<Form formMethods={form} onSubmit={handleSubmit} className="validator-commissions__form"> | ||
{(f) => ( | ||
<> | ||
{isRange(transactionCommissionRange) && ( | ||
<FormSlider | ||
control={f.control} | ||
name="transactionCommission" | ||
label={t('fieldTransactionFee.label')} | ||
min={transactionCommissionRange.min * 100} | ||
max={transactionCommissionRange.max * 100} | ||
rules={commissionRules(transactionCommissionRange)} | ||
step={COMMISSION_STEP} | ||
unit="%" | ||
/> | ||
)} | ||
{isRange(bakingCommissionRange) && ( | ||
<FormSlider | ||
control={f.control} | ||
name="bakingCommission" | ||
label={t('fieldBlockReward.label')} | ||
min={bakingCommissionRange.min * 100} | ||
max={bakingCommissionRange.max * 100} | ||
rules={commissionRules(bakingCommissionRange)} | ||
step={COMMISSION_STEP} | ||
unit="%" | ||
/> | ||
)} | ||
{isRange(finalizationCommissionRange) && ( | ||
<FormSlider | ||
control={f.control} | ||
name="finalizationCommission" | ||
label={t('fieldFinalizationReward.label')} | ||
min={finalizationCommissionRange.min * 100} | ||
max={finalizationCommissionRange.max * 100} | ||
rules={commissionRules(finalizationCommissionRange)} | ||
step={COMMISSION_STEP} | ||
unit="%" | ||
/> | ||
)} | ||
</> | ||
)} | ||
</Form> | ||
<Page.Footer> | ||
<Button.Main label={t('buttonContinue')} onClick={form.handleSubmit(handleSubmit)} /> | ||
</Page.Footer> | ||
</Page> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
packages/browser-wallet/src/popup/popupX/pages/EarningRewards/Validator/Commissions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './Commissions'; |
58 changes: 20 additions & 38 deletions
58
...es/browser-wallet/src/popup/popupX/pages/EarningRewards/Validator/Keys/ValidatorKeys.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,29 @@ | ||
.validator-keys-container { | ||
.capture__main_small { | ||
color: $color-white; | ||
word-wrap: break-word; | ||
.validator-keys { | ||
gap: rem(16px); | ||
|
||
.page__top { | ||
margin-bottom: 0 !important; | ||
} | ||
|
||
.validator-keys { | ||
&__title { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: flex-end; | ||
margin-bottom: rem(12px); | ||
&--expanded { | ||
.validator-keys__expand svg { | ||
transform: rotate(-90deg); | ||
} | ||
} | ||
|
||
&__card { | ||
display: flex; | ||
flex-direction: column; | ||
border-radius: rem(12px); | ||
padding: rem(16px); | ||
margin-top: rem(16px); | ||
background-color: rgba($color-grey-3, 0.3); | ||
|
||
&_row:not(:last-child) { | ||
padding-bottom: rem(8px); | ||
margin-bottom: rem(8px); | ||
border-bottom: 1px solid $color-grey-3; | ||
} | ||
|
||
&_row { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
.capture__main_small:first-child { | ||
color: rgba($color-mineral-3, 0.5); | ||
margin-bottom: rem(6px); | ||
} | ||
} | ||
&:not(.validator-keys--expanded) { | ||
.card-x .details .capture__main_small { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
} | ||
|
||
&__expand { | ||
margin-bottom: rem(8px); | ||
|
||
&__export { | ||
display: flex; | ||
align-items: center; | ||
gap: rem(8px); | ||
margin-top: rem(16px); | ||
svg { | ||
transform: rotate(90deg); | ||
} | ||
} | ||
} |
Oops, something went wrong.