mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: navbar
This commit is contained in:
1 parent
502dcf4e54
commit
6b4dc4ca8d
10 files changed
+375
-409
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { getAccountInfo, idToRegion } from '@blitzkit/core';
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { Text } from '@radix-ui/themes';
|
||||
import { useMemo } from 'react';
|
||||
import usePromise from 'react-promise-suspense';
|
||||
import { $wargamingLogin } from '../stores/wargamingLogin';
|
||||
|
||||
export function WargamingAccountName() {
|
||||
const wargamingLogin = useStore($wargamingLogin);
|
||||
const promise = useMemo(async () => {
|
||||
if (!wargamingLogin.token) return null;
|
||||
|
||||
const data = await getAccountInfo(
|
||||
idToRegion(Number(wargamingLogin.id)),
|
||||
Number(wargamingLogin.id),
|
||||
[],
|
||||
{
|
||||
access_token: wargamingLogin.token,
|
||||
},
|
||||
);
|
||||
|
||||
return data?.nickname as string | undefined;
|
||||
}, [wargamingLogin.token]);
|
||||
const nickname = usePromise(() => promise, []);
|
||||
|
||||
return nickname ?? <Text color="gray">Unknown Account</Text>;
|
||||
}
|
||||
Reference in new issue
Block a user