diff --git a/fission/src/ui/ToastContext.tsx b/fission/src/ui/ToastContext.tsx index 41dcd6c05..91dc1a4f3 100644 --- a/fission/src/ui/ToastContext.tsx +++ b/fission/src/ui/ToastContext.tsx @@ -1,4 +1,4 @@ -import React, { createContext, useState, useContext, useCallback, ReactNode } from "react" +import React, { createContext, ReactNode, useCallback, useContext, useState } from "react" import Toast from "@/components/Toast" import { AnimatePresence, motion } from "framer-motion" @@ -6,7 +6,7 @@ export type ToastType = "info" | "warning" | "error" export type ToastData = { id: string - type: ToastType + toastType: ToastType title: string description: string } @@ -28,12 +28,12 @@ export const useToastContext = () => { export const ToastProvider: React.FC<{ children: ReactNode }> = ({ children }) => { const [toasts, setToasts] = useState([]) - const addToast = useCallback((type: ToastType, title: string, description: string) => { + const addToast = useCallback((toastType: ToastType, title: string, description: string) => { // divide by 10 so that it's harder to have duplicates? could make smaller or remove const id = "toast-" + Math.floor(Date.now() / 10).toString() const newToast: ToastData = { id, - type, + toastType, title, description, } @@ -80,7 +80,13 @@ export const ToastContainer: React.FC = () => { key={t.id} className="w-fit" > - + ))} diff --git a/fission/src/ui/components/Toast.tsx b/fission/src/ui/components/Toast.tsx index 3ec55dd1b..f87c7cd57 100644 --- a/fission/src/ui/components/Toast.tsx +++ b/fission/src/ui/components/Toast.tsx @@ -6,7 +6,7 @@ import { BiSolidErrorCircle } from "react-icons/bi" const TOAST_TIMEOUT: number = 5_000 -const Toast: React.FC = ({ id, type, title, description }) => { +const Toast: React.FC = ({ id, toastType, title, description }) => { const { removeToast } = useToastContext() useEffect(() => { @@ -22,7 +22,7 @@ const Toast: React.FC = ({ id, type, title, description }) => { let icon: ReactElement let className: string - switch (type) { + switch (toastType) { case "info": icon = className = "bg-toast-info" @@ -39,7 +39,7 @@ const Toast: React.FC = ({ id, type, title, description }) => { return (
{icon}