rsnext/examples/authsignal/passwordless-login/components/dashboard.tsx
Balázs Orbán e875dded8b
chore(examples): add Authsignal passwordless example (#41079)
Lands #39048 with lint fixes. Needed to open a new PR, because GitHub
does not allow maintainers to edit organization forks.

https://github.com/orgs/community/discussions/5634

Closes #39048

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)

Co-authored-by: Chris Fisher <chris.i.fisher@gmail.com>
2022-10-01 06:39:38 +02:00

35 lines
758 B
TypeScript

import { useRouter } from 'next/router'
import { User } from '../lib'
import styles from './dashboard.module.css'
interface Props {
user: User
}
export const Dashboard = ({ user }: Props) => {
const router = useRouter()
const logout = async () => {
await fetch('/api/logout', {
method: 'POST',
credentials: 'same-origin',
})
router.push('/')
}
return (
<>
<header className={styles.header}>
<div className={styles.logo}>My Example App</div>
<button onClick={() => logout()}>Log out</button>
</header>
<div className={styles.user}>
<div>
<div className={styles.label}>Logged in as:</div>
<div>{user.email}</div>
</div>
</div>
</>
)
}