first commit
This commit is contained in:
21
ui/hooks/use-toast.ts
Normal file
21
ui/hooks/use-toast.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { toast as sonnerToast } from "sonner";
|
||||
|
||||
export interface Toast {
|
||||
title: string;
|
||||
description?: string;
|
||||
variant?: "default" | "destructive";
|
||||
}
|
||||
|
||||
export function useToast() {
|
||||
const toast = ({ title, description, variant }: Toast) => {
|
||||
const message = description ? `${title}: ${description}` : title;
|
||||
|
||||
if (variant === "destructive") {
|
||||
sonnerToast.error(message);
|
||||
} else {
|
||||
sonnerToast.success(message);
|
||||
}
|
||||
};
|
||||
|
||||
return { toast };
|
||||
}
|
||||
Reference in New Issue
Block a user