|
1 | | -<template> |
2 | | - <div> |
3 | | - Nuxt EdgeDB playground! |
| 1 | +<script setup lang="ts"> |
| 2 | +const { isLoggedIn } = useEdgeDbIdentity() |
4 | 3 |
|
5 | | - <div> |
6 | | - Blogposts: |
7 | | - {{ data }} |
8 | | - </div> |
| 4 | +const links = computed(() => { |
| 5 | + const links = [ |
| 6 | + { |
| 7 | + label: 'Home', |
| 8 | + icon: 'i-heroicons-home', |
| 9 | + to: '/' |
| 10 | + }, |
| 11 | + ] |
9 | 12 |
|
10 | | - <div> |
11 | | - Add a new client: |
12 | | - <input placeholder="thecompaniesapi.com"> |
13 | | - <button @click="submit"> |
14 | | - {{ loading ? 'Loading...' : 'Submit' }} |
15 | | - </button> |
16 | | - </div> |
| 13 | + if (isLoggedIn.value) { |
| 14 | + links.push( |
| 15 | + { |
| 16 | + label: 'New blogpost', |
| 17 | + icon: 'i-heroicons-newspaper-20-solid', |
| 18 | + to: '/new' |
| 19 | + }, |
| 20 | + { |
| 21 | + label: 'Logout', |
| 22 | + icon: 'i-heroicons-newspaper-20-solid', |
| 23 | + to: '/auth/logout' |
| 24 | + } |
| 25 | + ) |
| 26 | + } else { |
| 27 | + links.push( |
| 28 | + { |
| 29 | + label: 'Register', |
| 30 | + icon: 'i-heroicons-key-20-solid', |
| 31 | + to: '/auth/signup' |
| 32 | + }, |
| 33 | + { |
| 34 | + label: 'Login', |
| 35 | + icon: 'i-heroicons-lock-open-20-solid', |
| 36 | + to: '/auth/login' |
| 37 | + }, |
| 38 | + { |
| 39 | + label: 'Forgot my password', |
| 40 | + icon: 'i-heroicons-sparkles-20-solid', |
| 41 | + to: '/auth/forgot-password' |
| 42 | + }, |
| 43 | + ) |
| 44 | + } |
17 | 45 |
|
18 | | - <div v-if="error"> |
19 | | - {{ error }} |
20 | | - </div> |
21 | | - </div> |
22 | | -</template> |
| 46 | + return links |
| 47 | +}) |
23 | 48 |
|
24 | | -<script lang="ts" setup> |
25 | | -const loading = ref(false); |
26 | | -const error = ref(""); |
27 | | -const clientInput = ref(); |
| 49 | +</script> |
28 | 50 |
|
29 | | -const { data, refresh } = await useAsyncData( |
30 | | - 'blogpost-index', |
31 | | - () => $fetch('/api/blogpost') |
32 | | -) |
| 51 | +<template> |
| 52 | + <UContainer class="p-8 flex flex-col gap-4"> |
| 53 | + <UVerticalNavigation :links="links" /> |
33 | 54 |
|
34 | | -const submit = async () => { |
35 | | - loading.value = true |
36 | | - error.value = "" |
37 | | - try { |
38 | | - await $fetch('/api/client/create', { |
39 | | - query: { |
40 | | - domain: clientInput.value |
41 | | - } |
42 | | - }) |
43 | | - await refresh() |
44 | | - } catch (e: any) { |
45 | | - console.log(e); |
46 | | - error.value = e; |
47 | | - } |
48 | | - loading.value = false |
49 | | -} |
50 | | -</script> |
| 55 | + <div> |
| 56 | + <NuxtPage /> |
| 57 | + </div> |
| 58 | + </UContainer> |
| 59 | +</template> |
0 commit comments