-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move settings to ui package
- Loading branch information
Showing
25 changed files
with
1,703 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getSession } from "@/lib/auth"; | ||
import Settings from "@umamin/ui/app/settings/page"; | ||
import { CurrentUserResult, getCurrentUser } from "./queries"; | ||
import { redirect } from "next/navigation"; | ||
|
||
export default async function Page() { | ||
const { user, session } = await getSession(); | ||
const userData = await getCurrentUser(session?.id); | ||
|
||
if (!user) { | ||
redirect("/login"); | ||
} | ||
|
||
return <Settings user={user} userData={userData as CurrentUserResult} />; | ||
} |
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,39 @@ | ||
import { cache } from "react"; | ||
import getClient from "@/lib/gql/rsc"; | ||
import { graphql, ResultOf } from "gql.tada"; | ||
|
||
export const CURRENT_USER_QUERY = graphql(` | ||
query CurrentUser { | ||
user { | ||
__typename | ||
id | ||
bio | ||
username | ||
displayName | ||
question | ||
quietMode | ||
imageUrl | ||
createdAt | ||
accounts { | ||
__typename | ||
id | ||
picture | ||
createdAt | ||
} | ||
} | ||
} | ||
`); | ||
|
||
const currentUserPersisted = graphql.persisted( | ||
"3f2320bbe96bd7895f618b6cdedfdee5d2f40e3e0c1d75095ea0844a0ff107b4", | ||
CURRENT_USER_QUERY | ||
); | ||
|
||
export const getCurrentUser = cache(async (sessionId?: string) => { | ||
const result = await getClient(sessionId).query(currentUserPersisted, {}); | ||
|
||
return result?.data?.user; | ||
}); | ||
|
||
export type CurrentUserResult = ResultOf<typeof CURRENT_USER_QUERY>["user"]; |
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
Oops, something went wrong.