Skip to content

Commit 4ac232d

Browse files
committed
feat: fetch
1 parent 9b01919 commit 4ac232d

File tree

10 files changed

+162
-85
lines changed

10 files changed

+162
-85
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12+
"@tanstack/vue-query": "^5.28.7",
1213
"@vueuse/core": "^10.7.2",
14+
"axios": "^1.6.8",
1315
"gsap": "^3.12.5",
1416
"pinia": "^2.1.7",
1517
"vue": "^3.4.15",
16-
"vue-router": "^4.2.5",
1718
"vue-recaptcha": "2.0.3",
19+
"vue-router": "^4.2.5",
1820
"vue3-lottie": "^3.2.0"
1921
},
2022
"devDependencies": {

pnpm-lock.yaml

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/faucet/FaucetCard.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<template>
22
<Card :tracker="tracker">
3-
<FaucetAvailability :available="faucet.availability" class="self-end" />
3+
<FaucetAvailability :available="availability" class="self-end" />
44
<div class="mt-28">
5-
<span class="mb-2 text-grey-100 text-50 uppercase">{{ faucet.network }}</span>
6-
<h2 class="text-500 text-grey-50">{{ faucet.name }}</h2>
5+
<span class="mb-2 text-grey-100 text-50 uppercase" v-if="faucet.Network">{{ faucet.Network }}</span>
6+
<h2 class="text-500 text-grey-50">{{ faucet.Name }}</h2>
77
</div>
88
</Card>
99
</template>
1010

1111
<script setup lang="ts">
12-
import { computed } from 'vue'
12+
import { computed, ref } from 'vue'
1313
1414
import Card from '@/components/ui/Card.vue'
1515
import FaucetAvailability from './FaucetAvailability.vue'
@@ -26,6 +26,9 @@ interface Props {
2626
2727
const props = defineProps<Props>()
2828
29+
//TODO: request to get availibility (or from props - parent req)
30+
const availability = ref(true)
31+
2932
const tracker = computed(() => {
3033
return {
3134
x: props.motion?.value?.x ?? 0,

src/components/faucet/FaucetDetail.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class="popup fixed flex flex-col items-center rounded w-[90vw] max-w-[36rem] bg-grey-300 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[1000] justify-center text-grey-50 before:absolute before:top-0 before:bottom-0 before:left-0 before:right-0 before:rounded before:bg-500 before:z-min after:absolute after:top-px after:left-px after:bottom-px after:right-px after:bg-grey-500 after:rounded after:z-min"
77
>
88
<div ref="DOMFaucetRequest" class="p-12">
9-
<FaucetContentForm :name="store.selectedFaucet.name ?? 'Faucet'" :options="store.faucetAmount" v-show="store.contentStep === 0" class="js-faucetform opacity-100" :error="error" @requestFaucet="requestFaucet" />
9+
<FaucetContentForm :name="store.selectedFaucet.Name ?? 'Faucet'" :options="store.faucetAmount" v-show="store.contentStep === 0" class="js-faucetform opacity-100" :error="error" @requestFaucet="requestFaucet" />
1010
<div>
1111
<div ref="gnoRequestLogo" v-show="store.contentStep >= 1" class="opacity-0">
1212
<Vue3Lottie :animationData="GnoJSON" :loop="true" :height="200" :width="200" :autoPlay="true" />
@@ -22,6 +22,7 @@
2222
import { onMounted, ref, reactive, watch, nextTick } from 'vue'
2323
import { gsap } from 'gsap'
2424
import { Vue3Lottie } from 'vue3-lottie'
25+
import axios from 'axios'
2526
2627
import FaucetContentForm from './content/FaucetContentForm.vue'
2728
import FaucetContentRequest from './content/FaucetContentRequest.vue'
@@ -30,8 +31,8 @@ import GnoJSON from '@/assets/lottie/logo.json'
3031
3132
import { useFaucetDetail } from '@/stores/faucetDetail'
3233
33-
import { req } from '@/data/mockedRequest'
34-
import { Status } from '@/types'
34+
// import { req } from '@/data/mockedRequest'
35+
import { Status, Request } from '@/types'
3536
3637
const txLink = ref('')
3738
@@ -59,11 +60,18 @@ const requestFaucet = async (address: string, amount: number, secret: string) =>
5960
})
6061
gsap.to(gnoRequestLogo.value, { autoAlpha: 1, delay: 0.5 })
6162
62-
//TODO: Request - replace fake request
63+
const data: Request = {
64+
To: address,
65+
Amount: amount.toString(),
66+
Captcha: secret,
67+
}
68+
6369
console.log(address)
6470
console.log(amount)
6571
console.log(secret)
6672
73+
await axios.get(store.selectedFaucet.URL, { data })
74+
6775
const res = await req('success')
6876
store.status = res.code
6977

src/components/faucet/FaucetsList.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313
<script setup lang="ts">
1414
import { ref, onMounted } from 'vue'
15+
import { useWindowSize } from '@vueuse/core'
1516
1617
import Carousel from '@/components/ui/Carousel.vue'
1718
import FaucetCard from '@/components/faucet/FaucetCard.vue'
1819
1920
import { useMouseDelegation } from '@/composables/useMouseDelegation'
2021
import { useFaucetDetail } from '@/stores/faucetDetail'
2122
22-
import { useWindowSize } from '@vueuse/core'
23-
2423
import { Faucet } from '@/types'
2524
26-
// TODO: Top replace with real data
27-
import { faucets } from '@/data/faucets.json'
25+
import { faucets as faucetJson } from '@/data/faucets.json'
26+
27+
const faucets = ref(faucetJson as Faucet[])
2828
2929
// slider & cards
3030
const projectCarouselEL = ref<HTMLElement | null>(null)
@@ -35,7 +35,7 @@ let isLoading = false
3535
3636
const { width } = useWindowSize()
3737
38-
const { motions } = useMouseDelegation(projectCarouselEL, faucets, 'ref')
38+
const { motions } = useMouseDelegation(projectCarouselEL, faucets.value, 'ref')
3939
4040
const store = useFaucetDetail()
4141
@@ -46,7 +46,6 @@ const openFaucet = (faucet: Faucet) => {
4646
4747
onMounted(() => {
4848
window.addEventListener('load', () => {
49-
// TODO: To custom with async data
5049
if (cards.value && cards.value?.length > 0) {
5150
store.DOM.cards = cards.value
5251
store.cardDisplay()

src/components/faucet/content/FaucetContentForm.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h2 class="text-600 mb-12">{{ name }}</h2>
44
<form class="w-full space-y-12" @submit.prevent="requestFaucet">
55
<Input :label="'Enter your wallet address'" :placeholder="'e.g. g1juwee0ynsdvaukvxk3j5s4cl6nn24uxwlydxrl'" v-model="bindAddress" />
6-
<Select v-if="store.selectedFaucet.amounts" :label="'Select faucet amount'" :options="options" @update="(option) => SelectAmount(option)" />
6+
<Select v-if="store.selectedFaucet.Amounts" :label="'Select faucet amount'" :options="options" @update="(option) => SelectAmount(option)" />
77
<Recaptcha @validation="captchaValidation" />
88
<div>
99
<div class="flex gap-4">
@@ -19,8 +19,6 @@
1919
<script setup lang="ts">
2020
import { ref } from 'vue'
2121
22-
import VueRecaptcha from 'vue-recaptcha'
23-
2422
import Input from '@/components/ui/Input.vue'
2523
import Select from '@/components/ui/Select.vue'
2624
import Button from '@/components/ui/Button.vue'
@@ -29,14 +27,14 @@ import Recaptcha from '@/components/ui/Recaptcha.vue'
2927
import { useFaucetDetail } from '@/stores/faucetDetail'
3028
3129
import { SelectOption } from '@/components/ui/Select.vue'
32-
import { Status } from '@/types'
30+
import { Status, Faucet } from '@/types'
3331
3432
type Props = {
35-
name: string
33+
name: Faucet['Name']
3634
options: SelectOption[]
3735
error?: Status | null
3836
}
39-
defineProps<Props>()
37+
const props = defineProps<Props>()
4038
const store = useFaucetDetail()
4139
4240
const bindAddress = ref('')
@@ -65,6 +63,6 @@ const errorDetail = {
6563
6664
const requestFaucet = () => {
6765
if (captchaValid.value === false) return
68-
emit('requestFaucet', bindAddress.value, store.selectedFaucet.amounts && amount.value?.value, captchaSecret.value)
66+
emit('requestFaucet', bindAddress.value, store.selectedFaucet.Amounts && amount.value?.value, captchaSecret.value)
6967
}
7068
</script>

0 commit comments

Comments
 (0)