Add files via upload
This commit is contained in:
25
src/hooks/useNotification.ts
Normal file
25
src/hooks/useNotification.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useState, useCallback } from 'react';
|
||||
|
||||
export function useNotification() {
|
||||
const [isVisible, setIsVisible] = useState(false);
|
||||
const [message, setMessage] = useState('');
|
||||
const [type, setType] = useState<'success' | 'error'>('success');
|
||||
|
||||
const showNotification = useCallback((text: string, notificationType: 'success' | 'error' = 'success') => {
|
||||
setMessage(text);
|
||||
setType(notificationType);
|
||||
setIsVisible(true);
|
||||
}, []);
|
||||
|
||||
const hideNotification = useCallback(() => {
|
||||
setIsVisible(false);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
isVisible,
|
||||
message,
|
||||
type,
|
||||
showNotification,
|
||||
hideNotification
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user