mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
Ajout zones en pavage + fix dockefiles
This commit is contained in:
@@ -1,26 +1,29 @@
|
||||
import { useSocketListener } from "@/hook/useSocketListener";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function Notification({ socket }) {
|
||||
export default function Notification({ socket }) {
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [timeoutId, setTimeoutId] = useState(null);
|
||||
|
||||
const [notification, setNotification] = useState(null);
|
||||
|
||||
useSocketListener(socket, "error", (notification) => {
|
||||
console.log("error", notification);
|
||||
setNotification({ type: "error", text: notification });
|
||||
setVisible(true);
|
||||
});
|
||||
|
||||
useSocketListener(socket, "success", (notification) => {
|
||||
console.log("success", notification);
|
||||
setNotification({ type: "success", text: notification });
|
||||
setVisible(true);
|
||||
});
|
||||
|
||||
useSocketListener(socket, "warning", (notification) => {
|
||||
console.log("warning", notification);
|
||||
setNotification({ type: "warning", text: notification });
|
||||
setVisible(true);
|
||||
});
|
||||
|
||||
// Hide the notification after 5 seconds
|
||||
useEffect(() => {
|
||||
console.log({ visible });
|
||||
@@ -34,12 +37,14 @@ export function Notification({ socket }) {
|
||||
}
|
||||
}, [visible]);
|
||||
|
||||
let bgColorMap = {
|
||||
const bgColorMap = {
|
||||
error: "bg-red-500 text-white",
|
||||
success: "bg-green-500",
|
||||
warning: "bg-yellow-500"
|
||||
}
|
||||
|
||||
const classNames = 'fixed relative w-11/12 p-5 z-30 mx-auto inset-x-0 flex justify-center rounded-xl transition-all shadow-xl ' + (visible ? "top-5 " : "-translate-y-full ");
|
||||
|
||||
return (
|
||||
Object.keys(bgColorMap).map((key) =>
|
||||
notification?.type == key &&
|
||||
@@ -47,5 +52,5 @@ export function Notification({ socket }) {
|
||||
<p className="absolute top-2 right-2 p-2 rounded-l text-3xl bg-white">x</p>
|
||||
<p className='text-center text-xl'>{notification?.text}</p>
|
||||
</div>
|
||||
));
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user