-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mobile): create db user after sign up
- Loading branch information
Quốc Khánh
committed
Jun 9, 2024
1 parent
a0b34e3
commit 08251bc
Showing
8 changed files
with
64 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { getHonoClient } from '@/lib/client' | ||
import type { CreateUser } from '@6pm/api' | ||
import { useMutation } from '@tanstack/react-query' | ||
|
||
export function useCreateUserMutation() { | ||
return useMutation({ | ||
mutationFn: async (data: CreateUser) => { | ||
const hc = await getHonoClient() | ||
await hc.v1.users.$post({ | ||
json: data, | ||
}) | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { getHonoClient } from '@/lib/client' | ||
import { useQuery } from '@tanstack/react-query' | ||
|
||
export function useMeQuery() { | ||
return useQuery({ | ||
queryKey: ['me'], | ||
queryFn: async () => { | ||
const hc = await getHonoClient() | ||
const res = await hc.v1.auth.me.$get() | ||
if (!res.ok) { | ||
throw new Error(await res.text()) | ||
} | ||
return await res.json() | ||
}, | ||
}) | ||
} |