Compare commits
4 Commits
2438a07eb7
...
c50d203de4
| Author | SHA1 | Date | |
|---|---|---|---|
| c50d203de4 | |||
| c81fe28ba5 | |||
| d310837338 | |||
| 43c200e45e |
@@ -1,4 +1,4 @@
|
|||||||
import { Separator, Surface, Typography } from "@heroui/react";
|
import { ButtonGroup, Surface, Typography } from "@heroui/react";
|
||||||
import { Tabs } from "@heroui/react";
|
import { Tabs } from "@heroui/react";
|
||||||
import { Button } from "@heroui/react";
|
import { Button } from "@heroui/react";
|
||||||
import { useNavigate, useLocation } from "react-router";
|
import { useNavigate, useLocation } from "react-router";
|
||||||
@@ -43,7 +43,12 @@ export function Header() {
|
|||||||
<div className="absolute flex left-1/2 -translate-x-1/2">
|
<div className="absolute flex left-1/2 -translate-x-1/2">
|
||||||
<img className="h-12" src={porning} alt="Porning logo" />
|
<img className="h-12" src={porning} alt="Porning logo" />
|
||||||
</div>
|
</div>
|
||||||
<User />
|
<ButtonGroup >
|
||||||
|
<Button onClick={() => {window.open("steam://rungame/730//+connect cs.p0rning.com", "_blank")}}><Typography.Paragraph>Connect to server</Typography.Paragraph></Button>
|
||||||
|
<User>
|
||||||
|
<ButtonGroup.Separator />
|
||||||
|
</User>
|
||||||
|
</ButtonGroup>
|
||||||
</Surface>
|
</Surface>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ import {
|
|||||||
Separator,
|
Separator,
|
||||||
Spinner,
|
Spinner,
|
||||||
} from "@heroui/react";
|
} from "@heroui/react";
|
||||||
|
import type { PropsWithChildren } from "react";
|
||||||
import { useAuth } from "~/hooks/auth";
|
import { useAuth } from "~/hooks/auth";
|
||||||
|
|
||||||
export default function User() {
|
export default function User({ children }: PropsWithChildren) {
|
||||||
const { user, loading, login, logout } = useAuth();
|
const { user, loading, login, logout } = useAuth();
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
@@ -21,12 +22,17 @@ export default function User() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
return <Button onClick={() => login()}>Login</Button>;
|
return (
|
||||||
|
<Button onClick={() => login()}>
|
||||||
|
<Typography.Paragraph>{children}Login</Typography.Paragraph>
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown>
|
<Dropdown>
|
||||||
<Button className="pr-0">
|
<Button className="pr-0">
|
||||||
|
{children}
|
||||||
<Typography.Paragraph>{user.name}</Typography.Paragraph>
|
<Typography.Paragraph>{user.name}</Typography.Paragraph>
|
||||||
<Avatar>
|
<Avatar>
|
||||||
<Avatar.Image alt="Avatar" src={user.avatar}></Avatar.Image>
|
<Avatar.Image alt="Avatar" src={user.avatar}></Avatar.Image>
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ export function AuthProvider({ children }: PropsWithChildren) {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
setUser(null);
|
setUser(null);
|
||||||
|
notify({type: "success", loading: false, title: "Logout successful!", message: ""}, 2000)
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
notify(
|
notify(
|
||||||
|
|||||||
@@ -23,22 +23,19 @@ export function NotificationProvider({ children }: PropsWithChildren) {
|
|||||||
const [popupShowed, setPopupShowed] = useState(false);
|
const [popupShowed, setPopupShowed] = useState(false);
|
||||||
|
|
||||||
const notify = (newNotification: NotificationType, timeout: number) => {
|
const notify = (newNotification: NotificationType, timeout: number) => {
|
||||||
console.log("Changed notification");
|
|
||||||
setNotification(newNotification);
|
setNotification(newNotification);
|
||||||
setNotificationTimeout(timeout);
|
setNotificationTimeout(timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!popupShowed && notification !== null) {
|
if (notification === null) {
|
||||||
console.log("setting timeout")
|
setPopupShowed(false);
|
||||||
|
} else if (!popupShowed && notificationTimeout !== Infinity) {
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
console.log("timeout done")
|
|
||||||
setPopupShowed(true);
|
setPopupShowed(true);
|
||||||
setNotification(null);
|
setNotification(null);
|
||||||
}, notificationTimeout);
|
}, notificationTimeout);
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
} else {
|
|
||||||
setPopupShowed(false);
|
|
||||||
}
|
}
|
||||||
}, [notification, notificationTimeout]);
|
}, [notification, notificationTimeout]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user