Download packages/console/app/src/routes/user-menu.tsx from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/console/app/src/routes/user-menu.tsx
- Command line
-
hf download hf://SaylorTwift/opencode/packages/console/app/src/routes/user-menu.tsx
-
curl -L -o user-menu.tsx https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/console/app/src/routes/user-menu.tsx
1.09 kB
| import { action } from "@solidjs/router" | |
| import { getRequestEvent } from "solid-js/web" | |
| import { useAuthSession } from "~/context/auth" | |
| import { Dropdown } from "~/component/dropdown" | |
| import { useI18n } from "~/context/i18n" | |
| import { useLanguage } from "~/context/language" | |
| import "./user-menu.css" | |
| const _logout = action(async () => { | |
| "use server" | |
| const auth = await useAuthSession() | |
| const event = getRequestEvent() | |
| const current = auth.data.current | |
| if (current) | |
| await auth.update((val) => { | |
| delete val.account?.[current] | |
| const first = Object.keys(val.account ?? {})[0] | |
| val.current = first | |
| event!.locals.actor = undefined | |
| return val | |
| }) | |
| }, "auth.logout") | |
| export function UserMenu(props: { email: string | null | undefined }) { | |
| const i18n = useI18n() | |
| const language = useLanguage() | |
| return ( | |
| <div data-component="user-menu"> | |
| <Dropdown trigger={props.email ?? ""} align="right"> | |
| <a href={language.route("/auth/logout")} data-slot="item"> | |
| {i18n.t("user.logout")} | |
| </a> | |
| </Dropdown> | |
| </div> | |
| ) | |
| } | |