Skip to content

Commit d48f3bd

Browse files
create ticket add vueuse
1 parent ae9f263 commit d48f3bd

File tree

5 files changed

+77
-162
lines changed

5 files changed

+77
-162
lines changed

app/src/composables/useApiFetch.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export function useApiFetch<P extends AllPaths<Paths>, M extends IgnoreCase<keyo
3535
body?: Paths[`/${P}`][Lowercase<M>]['requestBody']['content']['application/json'],
3636
): /* @ts-ignore */
3737
AsyncData<OpenApiResponse<Paths[`/${P}`][Lowercase<M>]> | undefined, FetchError<OpenApiError<Paths[`/${P}`][Lowercase<M>]>>> {
38+
if(!body){
39+
return useApiData(path, {
40+
...opts,
41+
cache: false,
42+
client: true,
43+
} as any)
44+
}
3845
return useApiData(path, {
3946
...opts,
4047
cache: false,
@@ -45,3 +52,4 @@ export function useApiFetch<P extends AllPaths<Paths>, M extends IgnoreCase<keyo
4552
}
4653
} as any)
4754
}
55+

app/src/pages/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
<template lang='pug'>
23
div
34
tk-hook(name="accueil" :data='{exemple: 1}' debug)
@@ -8,5 +9,7 @@ div
89
</template>
910

1011
<script lang='ts' setup>
12+
import { definePageMeta, useAuth } from '#imports'
1113
const { signIn, signOut, session, status, cookies, getProviders, user, sessionToken } = useAuth()
14+
1215
</script>

app/src/pages/login.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script lang="ts" setup>
22
import { ref } from 'vue'
33
import { definePageMeta, useAuth } from '#imports'
4-
4+
import { useMouse } from '@vueuse/core'
55
const { signIn, token, data, status, lastRefreshedAt } = useAuth()
6+
const { x, y } = useMouse()
67
78
const username = ref('')
89
const password = ref('')
@@ -21,6 +22,7 @@ definePageMeta({
2122
<template>
2223
<div>
2324
<h1>Login Page</h1>
25+
<pre>Mouse position: {{ x }}, {{ y }}</pre>
2426
<pre>Status: {{ status }}</pre>
2527
<pre>Data: {{ data || 'no session data present, are you logged in?' }}</pre>
2628
<pre>Last refreshed at: {{ lastRefreshedAt || 'no refresh happened' }}</pre>

app/src/pages/tickets.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
<template lang="pug">
3+
div
4+
q-btn(@click="refresh") refresh
5+
span Tickets
6+
div {{ data?.data }}
7+
div {{ pending }}
8+
div.text-error {{ error }}
9+
10+
</template>
11+
12+
<script lang="ts" setup>
13+
import { useApiFetch } from "../composables/useApiFetch";
14+
15+
const { data, pending, error, refresh } = useApiFetch('tickets/ticket')
16+
17+
</script>

0 commit comments

Comments
 (0)