mirror of
https://github.com/codeaashu/claude-code.git
synced 2026-04-08 22:28:48 +03:00
claude-code
This commit is contained in:
29
web/hooks/useToast.ts
Normal file
29
web/hooks/useToast.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback } from "react";
|
||||
import { useNotificationStore, DEFAULT_DURATIONS, type ToastVariant } from "@/lib/notifications";
|
||||
|
||||
export interface ToastOptions {
|
||||
variant: ToastVariant;
|
||||
title: string;
|
||||
description?: string;
|
||||
duration?: number;
|
||||
action?: { label: string; onClick: () => void };
|
||||
details?: string;
|
||||
}
|
||||
|
||||
export function useToast() {
|
||||
const addToast = useNotificationStore((s) => s.addToast);
|
||||
const dismissToast = useNotificationStore((s) => s.dismissToast);
|
||||
const dismissAllToasts = useNotificationStore((s) => s.dismissAllToasts);
|
||||
|
||||
const toast = useCallback(
|
||||
(options: ToastOptions): string => {
|
||||
const duration = options.duration ?? DEFAULT_DURATIONS[options.variant];
|
||||
return addToast({ ...options, duration });
|
||||
},
|
||||
[addToast]
|
||||
);
|
||||
|
||||
return { toast, dismiss: dismissToast, dismissAll: dismissAllToasts };
|
||||
}
|
||||
Reference in New Issue
Block a user