Get parts on profile to update when user saves a new part
This commit is contained in:
22
web/src/helpers/hooks/useUser.js
Normal file
22
web/src/helpers/hooks/useUser.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useQuery } from '@redwoodjs/web'
|
||||
import { useAuth } from '@redwoodjs/auth'
|
||||
|
||||
const QUERY = gql`
|
||||
query FIND_USER_BY_ID($id: String!) {
|
||||
user: user(id: $id) {
|
||||
id
|
||||
image
|
||||
userName
|
||||
name
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default function () {
|
||||
const { currentUser } = useAuth()
|
||||
const { data, loading } = useQuery(QUERY, {
|
||||
skip: !currentUser?.sub,
|
||||
variables: { id: currentUser?.sub },
|
||||
})
|
||||
return { user: data?.user, loading }
|
||||
}
|
||||
Reference in New Issue
Block a user