mirror of
https://github.com/tmdinosaurcenter/gas-form.git
synced 2025-04-04 03:11:22 -06:00
15 lines
485 B
TypeScript
15 lines
485 B
TypeScript
import { useState } from "react";
|
|
|
|
export function useToast() {
|
|
const [message, setMessage] = useState<string | null>(null);
|
|
|
|
const toast = ({ title, description, variant }: { title: string; description: string; variant?: "default" | "destructive" }) => {
|
|
console.log(`${variant === "destructive" ? "[ERROR]" : "[INFO]"} ${title}: ${description}`);
|
|
setMessage(`${title}: ${description}`);
|
|
setTimeout(() => setMessage(null), 3000);
|
|
};
|
|
|
|
return { toast, message };
|
|
}
|
|
|