Last active
December 7, 2023 01:22
-
-
Save nickcherry/93ebe3cd64bc8497603457b5930302cc to your computer and use it in GitHub Desktop.
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
const userController = pageController<UserSchema>(async (props) => { | |
const user = await client | |
.selectFrom('User') | |
.selectAll() | |
.where('id', '=', props.params.id) | |
.executeTakeFirstOrThrow(); | |
return clientRoot(UserPage, decoratePageProps(props, { user })); | |
}); | |
export { userController }; |
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
function UserPage({ currentUser, user }: PageProps<{ user: User }>) { | |
return ( | |
<Page title={user.name}> | |
<div className="flex flex-row items-center gap-2"> | |
<Avatar url={user.avatarUrl} /> | |
<span className="font-bold">{user.name}</span> | |
{user.id === currentUser?.id && ( | |
<a href={`/users/${user.id}/edit`}>Edit</a> | |
)} | |
</div> | |
</Page> | |
); | |
} | |
export { UserPage }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment