Added feedback to the user that their profile is loading

This commit is contained in:
2026-07-22 20:49:18 -04:00
parent c6b6d316cf
commit 852331f909

View File

@@ -1,8 +1,25 @@
import { Button, Avatar, Typography, Dropdown, Label, Separator } from "@heroui/react"; import {
Button,
Avatar,
Typography,
Dropdown,
Label,
Separator,
Spinner,
} from "@heroui/react";
import { useAuth } from "~/hooks/auth"; import { useAuth } from "~/hooks/auth";
export default function User() { export default function User() {
const {user, login, logout} = useAuth(); const { user, loading, login, logout } = useAuth();
if (loading) {
return (
<Button isPending={true}>
<Spinner color="current" size="md" />
Loading...
</Button>
);
}
if (user === null) { if (user === null) {
return <Button onClick={() => login()}>Login</Button>; return <Button onClick={() => login()}>Login</Button>;
@@ -17,12 +34,18 @@ export default function User() {
</Avatar> </Avatar>
</Button> </Button>
<Dropdown.Popover> <Dropdown.Popover>
<Dropdown.Menu onAction={(key) => handleAction(String(key), logout)}> <Dropdown.Menu
onAction={(key) => handleAction(String(key), logout)}
>
<Dropdown.Item id="settings" textValue="Settings"> <Dropdown.Item id="settings" textValue="Settings">
<Label>Settings</Label> <Label>Settings</Label>
</Dropdown.Item> </Dropdown.Item>
<Separator variant="tertiary" /> <Separator variant="tertiary" />
<Dropdown.Item id="logout" textValue="Logout" variant="danger"> <Dropdown.Item
id="logout"
textValue="Logout"
variant="danger"
>
<Label>Logout</Label> <Label>Logout</Label>
</Dropdown.Item> </Dropdown.Item>
</Dropdown.Menu> </Dropdown.Menu>