Skip to content

Commit

Permalink
fix deposit-form
Browse files Browse the repository at this point in the history
  • Loading branch information
Yehor Podporinov authored and Yehor Podporinov committed Jan 30, 2024
1 parent 1795630 commit 00e2ff3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/forms/DepositForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
/>
<app-button
class="deposit-form__btn"
:text="submitBtnText"
:text="submissionBtnText"
:disabled="isSubmitting || !isFieldsValid"
:is-loading="isInitializing"
@click="submit"
Expand All @@ -78,7 +78,7 @@ import { config } from '@config'
import { v4 as uuidv4 } from 'uuid'
import { computed, onMounted, reactive, ref } from 'vue'
enum SUBMIT_ACTIONS {
enum ACTIONS {
approve = 'approve',
stake = 'stake',
}
Expand Down Expand Up @@ -126,19 +126,19 @@ const { contractWithSigner: stEthWithSigner } = useContract(
const { $t } = useContext()
const web3ProvidersStore = useWeb3ProvidersStore()
const submitAction = computed<SUBMIT_ACTIONS>(() => {
const action = computed<ACTIONS>(() => {
if (isFieldsValid.value) {
const amountInDecimals = parseUnits(form.amount, 'ether')
const allowance = formAvailable.value
? allowances[formAvailable.value.value.currency]
: null
if (allowance && amountInDecimals.gt(allowance)) {
return SUBMIT_ACTIONS.approve
return ACTIONS.approve
}
}
return SUBMIT_ACTIONS.stake
return ACTIONS.stake
})
const availableOptions = computed<FieldOption<AvailableOptionValue>[]>(() => [
Expand Down Expand Up @@ -176,8 +176,8 @@ const { getFieldErrorMessage, isFieldsValid, isFormValid, touchField } =
},
})
const submitBtnText = computed<string>(() =>
submitAction.value === SUBMIT_ACTIONS.approve
const submissionBtnText = computed<string>(() =>
action.value === ACTIONS.approve
? $t('deposit-form.submit-btn.approve')
: $t('deposit-form.submit-btn.deposit'),
)
Expand Down Expand Up @@ -219,7 +219,7 @@ const submit = async (): Promise<void> => {
try {
let tx
if (submitAction.value === SUBMIT_ACTIONS.approve && formAvailable.value) {
if (action.value === ACTIONS.approve && formAvailable.value) {
tx = await approveByCurrency(formAvailable.value.value.currency)
} else {
const amountInDecimals = parseUnits(form.amount, 'ether')
Expand Down

0 comments on commit 00e2ff3

Please sign in to comment.