Skip to content

Commit 0a846a6

Browse files
committed
fix: error system
1 parent ecd36ba commit 0a846a6

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/components/faucet/FaucetDetail.vue

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ const requestFaucet = async (address: string, amount: number, secret: string) =>
6262
const minTimer = new Promise((resolve) => setTimeout(resolve, 2000))
6363
6464
const displayError = (e: string) => {
65-
store.status = 'error'
6665
error.value = e
67-
store.contentStep = 0
66+
store.status = 'error'
67+
6868
console.error(e)
6969
}
7070
try {
@@ -75,22 +75,22 @@ const requestFaucet = async (address: string, amount: number, secret: string) =>
7575
},
7676
body: JSON.stringify({
7777
to: address,
78-
amount: amount * 1000000 + 'ugnot',
78+
amount: amount * 1000000 + 'ugnot', //TODO: need to be dynamyc if different token
7979
captcha: secret,
8080
}),
8181
})
8282
8383
await minTimer
8484
const faucetResponse = await response.json()
8585
86-
store.status = !faucetResponse.result ? 'error' : 'success'
86+
store.status = response.status !== 200 || faucetResponse.error ? 'error' : 'success'
8787
8888
// Check the faucet response
89-
if (!response.ok || store.status === 'error') {
90-
displayError(faucetResponse.error.message)
91-
} else {
89+
if (response.status === 200 && store.status === 'success') {
9290
store.status = 'success'
9391
txLink.value = faucetResponse.result ?? '' //TODO: get tx link
92+
} else {
93+
displayError(faucetResponse.error)
9494
}
9595
} catch (e) {
9696
await minTimer
@@ -143,9 +143,20 @@ watch(
143143
toggleLoader(false)
144144
setPopupHeight()
145145
146-
gsap.to('.js-faucetform', {
147-
autoAlpha: 1,
148-
duration: 0.5,
146+
gsap.to('.js-faucetpending', {
147+
autoAlpha: 0,
148+
duration: 0.6,
149+
onComplete: () => {
150+
store.contentStep = 0
151+
popupHeight.from = popupHeight.to
152+
gsap.set(DOMpopup.value, { height: 'auto' })
153+
154+
gsap.to('.js-faucetform', {
155+
autoAlpha: 1,
156+
duration: 0.5,
157+
})
158+
gsap.set('.js-faucetpending', { autoAlpha: 1 })
159+
},
149160
})
150161
break
151162

src/components/faucet/content/FaucetContentForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<form class="w-full space-y-7 md:space-y-12" @submit.prevent="isAddressValid && captchaValid && requestFaucet()">
55
<Input :label="'Enter your wallet address'" :placeholder="'e.g. g1juwee0ynsdvaukvxk3j5s4cl6nn24uxwlydxrl'" v-model="bindAddress" required />
66
<Select v-if="store.selectedFaucet.amounts" :label="'Select faucet amount'" :options="options" @update="(option) => SelectAmount(option)" />
7-
<Recaptcha @validation="captchaValidation" :captchakey="store.selectedFaucet.recaptcha" />
7+
<Recaptcha :key="store.status" @validation="captchaValidation" :captchakey="store.selectedFaucet.recaptcha" />
88
<div>
99
<div class="flex flex-col md:flex-row gap-4">
1010
<Button text="Cancel" variant="outline" @click.prevent="() => closePopup()" class="w-full" />

0 commit comments

Comments
 (0)