"use client" import { Check, X, Trash2 } from "lucide-react" import { createContext, ReactNode, useContext, useState } from "react" type BannerType = "success" | "deleted" | "failed" | "default" type Notification = { code: string message: string type?: BannerType } type NotificationContextType = { notification: Notification | null showNotification: (notification: Notification) => void } const NotificationContext = createContext({ notification: null, showNotification: () => {}, }) export function NotificationProvider({ children }: { children: ReactNode }) { const [notification, setNotification] = useState(null) const showNotification = (notification: Notification) => { setNotification(notification) if (notification.code === "global.banner") { setTimeout(() => setNotification(null), 2000) } } const getBannerStyles = (type: BannerType = "default") => { switch (type) { case "success": return "bg-green-500 text-teal-50" case "deleted": return "bg-black text-white" case "failed": return "bg-red-500 text-white" case "default": return "bg-white text-black" } } const getBannerIcon = (type: BannerType = "default") => { switch (type) { case "success": return case "deleted": return case "failed": return case "default": return null } } return ( {children} {notification?.code === "global.banner" && (
{getBannerIcon(notification.type)}

{notification.message}

)}
) } export const useNotification = () => useContext(NotificationContext)