From 9b5f9688090780240a769d40579482114a133ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Von=C3=A1=C5=A1ek?= Date: Tue, 15 Oct 2024 12:21:38 +0200 Subject: [PATCH] Improve DCA interval tooltip --- packages/apps/src/app/dca/Form.ts | 27 +++++++++---------- packages/apps/src/app/dca/translation.en.json | 2 +- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/apps/src/app/dca/Form.ts b/packages/apps/src/app/dca/Form.ts index 2b5c181b1b..d7dac473b4 100644 --- a/packages/apps/src/app/dca/Form.ts +++ b/packages/apps/src/app/dca/Form.ts @@ -374,21 +374,6 @@ export class DcaForm extends BaseElement { const max = this.maxFrequency; const value = this.frequency ?? max; - const valueMsec = value * 60 * 1000; - const blockTime = 12_000; - const blockCount = Math.floor(valueMsec / blockTime); - const blockHint = - blockCount > 0 - ? i18n.t('form.advanced.intervalBlocks', { - minutes: value, - blocks: blockCount, - }) - : undefined; - - const range = max - min; - const rangeInHours = Math.floor(range / HOUR_MIN); - const rangeInDays = Math.floor(range / DAY_MIN); - const minValues: Record = { min: min, hour: Math.ceil(min / HOUR_MIN), @@ -413,6 +398,18 @@ export class DcaForm extends BaseElement { this.frequencyRanges.day > 0 && 'day', ].filter((u): u is FrequencyUnit => !!u); + const valueMsec = value * 60 * 1000; + const blockTime = 12_000; + const blockCount = Math.floor(valueMsec / blockTime); + const blockHint = + blockCount > 0 + ? i18n.t('form.advanced.intervalBlocks', { + unit: i18n.t(`form.frequency.${this.frequencyUnit}`), + value: values[this.frequencyUnit], + blocks: blockCount, + }) + : undefined; + return html` {{amountIn}} {{assetIn}} for <1>{{assetOut}} every <1>~{{frequency}} with a total budget of <1>{{amountInBudget}} {{assetIn}} over the period of <1>~{{time}}",