/
useDomainsForOwner.vue
55 lines (48 loc) · 1.43 KB
/
useDomainsForOwner.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script setup lang="ts">
import { ref } from 'vue';
import { refDebounced } from '@vueuse/core';
import { useDomainsForOwner } from '@bonfida/sns-vue';
import { useSolanaConnection } from '../../utils/solana';
import UsageExample from '../usage-example.vue';
const connection = useSolanaConnection();
const fileName = import.meta.url.match(/\/([^\/]+)\.vue/)?.[1] || '';
const formValue = ref('');
const debouncedFormValue = refDebounced(formValue, 500);
const { result: domains, isLoading } = useDomainsForOwner(
connection,
debouncedFormValue,
);
</script>
<template>
<UsageExample :name="fileName">
<label class="block mb-4">
Enter owner pubkey:
<input
v-model="formValue"
class="w-[500px] p-2 outline-none"
placeholder="Enter value"
/>
</label>
<div class="mb-4">Domains:</div>
<template v-if="!domains?.length && !isLoading"> No data </template>
<template v-else-if="isLoading">
<p>Loading...</p>
</template>
<template v-else>
<div class="max-h-[300px] overflow-auto">
<table>
<tr>
<td>Domain name</td>
<td>Pubkey</td>
</tr>
<template v-for="domain in domains" :key="domain.domain">
<tr>
<td>{{ domain.domain }}</td>
<td>{{ domain.pubkey }}</td>
</tr>
</template>
</table>
</div>
</template>
</UsageExample>
</template>