mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
fix(cli): Add conditional rendering for private data based on API type
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
const {$authClient} = useNuxtApp()
|
||||
|
||||
definePageMeta({
|
||||
middleware: ['auth']
|
||||
})
|
||||
|
||||
const { $orpc } = useNuxtApp()
|
||||
|
||||
const session = $authClient.useSession()
|
||||
|
||||
const privateData = useQuery($orpc.privateData.queryOptions())
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container mx-auto p-4">
|
||||
<h1 class="text-2xl font-bold mb-4">Dashboard</h1>
|
||||
<div v-if="session?.data?.user">
|
||||
<p class="mb-2">Welcome {{ session.data.user.name }}</p>
|
||||
</div>
|
||||
<div v-if="privateData.status.value === 'pending'">Loading private data...</div>
|
||||
<div v-else-if="privateData.status.value === 'error'">Error loading private data: {{ privateData.error.value?.message }}</div>
|
||||
<p v-else-if="privateData.data.value">Private Data: {{ privateData.data.value.message }}</p>
|
||||
</div>
|
||||
</template>
|
||||
33
apps/cli/templates/auth/web/nuxt/app/pages/dashboard.vue.hbs
Normal file
33
apps/cli/templates/auth/web/nuxt/app/pages/dashboard.vue.hbs
Normal file
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
{{#if (eq api "orpc")}}
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
{{/if}}
|
||||
const {$authClient} = useNuxtApp()
|
||||
|
||||
definePageMeta({
|
||||
middleware: ['auth']
|
||||
})
|
||||
|
||||
const { $orpc } = useNuxtApp()
|
||||
|
||||
const session = $authClient.useSession()
|
||||
|
||||
{{#if (eq api "orpc")}}
|
||||
const privateData = useQuery($orpc.privateData.queryOptions())
|
||||
{{/if}}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container mx-auto p-4">
|
||||
<h1 class="text-2xl font-bold mb-4">Dashboard</h1>
|
||||
<div v-if="session?.data?.user">
|
||||
<p class="mb-2">Welcome \{{ session.data.user.name }}</p>
|
||||
</div>
|
||||
{{#if (eq api "orpc")}}
|
||||
<div v-if="privateData.status.value === 'pending'">Loading private data...</div>
|
||||
<div v-else-if="privateData.status.value === 'error'">Error loading private data: \{{ privateData.error.value?.message }}</div>
|
||||
<p v-else-if="privateData.data.value">Private Data: \{{ privateData.data.value.message }}</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user