-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathpage.tsx
More file actions
57 lines (51 loc) · 1.62 KB
/
page.tsx
File metadata and controls
57 lines (51 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use client";
import React, { useContext } from "react";
import { UserContext } from "../../components/user-data-wrapper";
import styles from "./styles.module.css";
// we don't export a metadata object here because react client
// components aren't allowed to do that, and we need to be a client
// component to get access to the user context
/**
* A React Client Component that renders the /whoami page
*/
export default function WhoAmI(): React.ReactElement {
const { user, groupMemberships } = useContext(UserContext);
return user ? (
<div className={styles.userContainer}>
You’re logged in as <strong>{user.username}</strong>.
<p className={styles.subText}>
You are a member of the following Nextstrain groups, which each contain
a collection of datasets and/or narratives:
</p>
Public:
<ul className={styles.userGroupList}>
{groupMemberships
.filter((group) => group.isPublic)
.map((group) => (
<li key={group.name}>
<a href={`/groups/${group.name}`}>{group.name}</a>
</li>
))}
</ul>
Private:
<ul className={styles.userGroupList}>
{groupMemberships
.filter((group) => !group.isPublic)
.map((group) => (
<li key={group.name}>
<a href={`/groups/${group.name}`}>{group.name}</a>
</li>
))}
</ul>
<a href="/logout">Logout</a>
</div>
) : (
<div className={styles.userContainer}>
<p>
You are not logged in.
<br />
<a href="/login">Login</a>
</p>
</div>
);
}