Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dora Noda
committed
Jun 18, 2023
1 parent
9cfdff9
commit a2317db
Showing
6 changed files
with
208 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { gql } from "@apollo/client/core"; | ||
|
||
export const queryUserProfile = gql` | ||
query UserProfile($userId: String!) { | ||
userProfile(userId: $userId) { | ||
} | ||
} | ||
`; |
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,6 @@ | ||
import { useSelector } from "react-redux"; | ||
|
||
export const useRoutePrefix = () => | ||
useSelector( | ||
(state: { base: { routePrefix: string } }) => state.base.routePrefix | ||
); |
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,4 @@ | ||
import { useSelector } from "react-redux"; | ||
|
||
export const useUserId = () => | ||
useSelector((state: { base: { userId: string } }) => state.base.userId); |
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,19 @@ | ||
import { useQuery } from "@apollo/client"; | ||
import { queryUserProfile } from "@/shared/common/data/query-user-profile"; | ||
import { useUserId } from "@/shared/common/hooks/use-user-id"; | ||
import { UserProfile } from "../data/__generated__/UserProfile"; | ||
|
||
export const useUserProfile = () => { | ||
const userId = useUserId(); | ||
const { data, loading, error } = useQuery<UserProfile>(queryUserProfile, { | ||
ssr: false, | ||
variables: { | ||
userId, | ||
}, | ||
}); | ||
return { | ||
email: data?.userProfile?.email, | ||
loading, | ||
error, | ||
}; | ||
}; |
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
Oops, something went wrong.