Skip to content

Commit

Permalink
feat(auth): rudamentary viewer context and profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking committed Sep 3, 2024
1 parent de69a70 commit 1befa5e
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 10 deletions.
6 changes: 5 additions & 1 deletion app/src/contexts/ViewerContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ export function ViewerProvider({
}>) {
const [data] = useRefetchableFragment(
graphql`
fragment ViewerContext_viewer on Query {
fragment ViewerContext_viewer on Query
@refetchable(queryName: "ViewerContextRefetchQuery") {
viewer {
id
username
email
role {
name
}
}
}
`,
Expand Down
108 changes: 108 additions & 0 deletions app/src/contexts/__generated__/ViewerContextRefetchQuery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 33 additions & 4 deletions app/src/contexts/__generated__/ViewerContext_viewer.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions app/src/pages/profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react";
import { css } from "@emotion/react";

import { Card } from "@arizeai/components";
import { Card, Form, TextField } from "@arizeai/components";

import { useViewer } from "@phoenix/contexts/ViewerContext";

import { LogoutButton } from "./LogoutButton";

Expand All @@ -20,11 +22,23 @@ const profilePageInnerCSS = css`
`;

export function ProfilePage() {
const { viewer } = useViewer();
if (!viewer) {
return null;
}
return (
<main css={profilePageCSS}>
<div css={profilePageInnerCSS}>
<Card title="Profile" extra={<LogoutButton />} variant="compact">
Profile goes here
<Form>
<TextField label="email" value={viewer.email} isReadOnly />
<TextField
label="username"
value={viewer.username || ""}
isReadOnly
/>
<TextField label="role" value={viewer.role.name || ""} isReadOnly />
</Form>
</Card>
</div>
</main>
Expand Down

0 comments on commit 1befa5e

Please sign in to comment.