Skip to content

Instantly share code, notes, and snippets.

@nickcherry
Last active December 7, 2023 01:22
Show Gist options
  • Save nickcherry/93ebe3cd64bc8497603457b5930302cc to your computer and use it in GitHub Desktop.
Save nickcherry/93ebe3cd64bc8497603457b5930302cc to your computer and use it in GitHub Desktop.
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 };
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