ERP-node/frontend/hooks/use-toast.ts

27 lines
612 B
TypeScript
Raw Normal View History

2025-09-19 12:15:14 +09:00
import { toast as sonnerToast } from "sonner";
interface ToastOptions {
title?: string;
description?: string;
variant?: "default" | "destructive";
duration?: number;
}
export const useToast = () => {
const toast = ({ title, description, variant = "default", duration }: ToastOptions) => {
if (variant === "destructive") {
sonnerToast.error(title || "오류", {
description,
duration: duration || 4000,
});
} else {
sonnerToast.success(title || "성공", {
description,
duration: duration || 4000,
});
}
};
return { toast };
};