Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 32 additions & 23 deletions src/pegin/components/create/PegInForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,33 @@
<v-row no-gutters class="my-4">
<span class="text-body-sm">Select mode to see exact amounts</span>
</v-row>
<v-row no-gutters v-if="(!flyoverIsEnabled
|| peginQuotes.length === 0)
|| !enoughAmountFlyover">
<v-row no-gutters v-if="fastModeState !== 'available'">
<pegin-option-card :option-type="peginType.FLYOVER" flyover-not-available>
<template v-slot>
<h4 v-if="countdown === recaptchanNewTokenTime">
<h4 v-if="fastModeState === 'disabled' && countdown === recaptchaNewTokenTime">
<span class="text-orange">Fast Mode</span> is unavailable at this time.
</h4>
<h4 v-else>
<h4 v-else-if="fastModeState === 'disabled'">
Fast mode will be <br> available in
<span class="text-orange">{{ countdown }} seconds.</span>
</h4>
</template>
</pegin-option-card>
</v-row>
<v-row no-gutters v-if="flyoverIsEnabled
&& peginQuotes.length === 0 && enoughAmountFlyover">
<pegin-option-card :option-type="peginType.FLYOVER" flyover-not-available>
<template v-slot>
<h4 v-if="countdown === recaptchanNewTokenTime && enoughFlyoverLiquidity">
<span class="text-orange">Fast Mode</span> no quotes available for this amount.
</h4>
<h4 v-else-if="!enoughFlyoverLiquidity">
<h4 v-else-if="fastModeState === 'no-liquidity'">
<span class="text-orange">Fast Mode</span>
There is not enough liquidity for this amount.
<a href="mailto:flyover@rootstocklabs.com?subject=Insufficient Liquidity">
Contact support</a> if you want to use the fast mode.
</h4>
<h4 v-else-if="fastModeState === 'no-quotes'">
<span class="text-orange">Fast Mode</span> no quotes available for this amount.
</h4>
<h4 v-else-if="fastModeState === 'insufficient-funds'">
<span class="text-orange">Fast Mode</span>
You don't have enough funds to cover the amount including fees.
</h4>
</template>
</pegin-option-card>
</v-row>
<v-row no-gutters v-else-if="countdown === recaptchanNewTokenTime
&& peginQuotes.length > 0"
v-for="(quote, index) in peginQuotes" :key="index">
<v-row no-gutters v-else v-for="(quote, index) in peginQuotes" :key="index">
<pegin-option-card
:option-type="peginType.FLYOVER"
@selected-option="changeSelectedOption"
Expand Down Expand Up @@ -163,6 +156,13 @@ import { AcceptedQuote } from '@rsksmart/flyover-sdk';
import { EnvironmentAccessorService } from '@/common/services/enviroment-accessor.service';
import { useRouter } from 'vue-router';

type FlyoverDisplayState =
| 'disabled'
| 'no-liquidity'
| 'no-quotes'
| 'insufficient-funds'
| 'available';

export default defineComponent({
name: 'PegInForm',
props: {
Expand Down Expand Up @@ -208,7 +208,7 @@ export default defineComponent({
const loadingFee = useStateAttribute<boolean>('pegInTx', 'loadingFee');
const startCountdown = useAction('web3Session', constants.SESSION_COUNTDOWN_GRECAPTCHA_TIME);
const countdown = useStateAttribute<number>('web3Session', 'grecaptchaCountdown');
const recaptchanNewTokenTime = EnvironmentAccessorService.getEnvironmentVariables()
const recaptchaNewTokenTime = EnvironmentAccessorService.getEnvironmentVariables()
.grecaptchaTime;
const toQr = ref(false);
const router = useRouter();
Expand All @@ -231,7 +231,7 @@ export default defineComponent({
const flyoverIsEnabled = computed(() => {
if (props.isFlyoverAvailable) {
if (sendingPegin.value) return true;
return countdown.value === recaptchanNewTokenTime;
return countdown.value === recaptchaNewTokenTime;
}
return false;
});
Expand All @@ -245,6 +245,14 @@ export default defineComponent({
return selectedAccountBalance.value?.gte(fullAmount);
});

const fastModeState = computed<FlyoverDisplayState>(() => {
if (!flyoverIsEnabled.value) return 'disabled';
if (!enoughFlyoverLiquidity.value) return 'no-liquidity';
if (peginQuotes.value.length === 0) return 'no-quotes';
if (!enoughAmountFlyover.value) return 'insufficient-funds';
Comment thread
lserra-iov marked this conversation as resolved.
return 'available';
});

function back() {
pegInFormState.value.send('loading');
clearQuotes();
Expand Down Expand Up @@ -375,7 +383,7 @@ export default defineComponent({
&& !!flyoverPeginState.value.selectedQuoteHash
&& !!flyoverPeginState.value.rootstockRecipientAddress
&& flyoverPeginState.value.rootstockRecipientAddress !== '0x'
&& countdown.value === recaptchanNewTokenTime;
&& countdown.value === recaptchaNewTokenTime;
}

return false;
Expand Down Expand Up @@ -434,11 +442,12 @@ export default defineComponent({
sendTx,
flyoverIsEnabled,
countdown,
recaptchanNewTokenTime,
recaptchaNewTokenTime,
mdiQrcode,
toQr,
enoughFlyoverLiquidity,
enoughAmountFlyover,
fastModeState,
};
},
});
Expand Down
Loading