29 lines
532 B
TypeScript
29 lines
532 B
TypeScript
|
import { useToast } from '@chakra-ui/react';
|
||
|
import { useCallback } from 'react';
|
||
|
|
||
|
const useShowToast = () => {
|
||
|
const toast = useToast();
|
||
|
|
||
|
const showToast = useCallback(
|
||
|
(
|
||
|
title: string,
|
||
|
status: 'info' | 'warning' | 'success' | 'error',
|
||
|
description?: string,
|
||
|
) => {
|
||
|
toast({
|
||
|
title,
|
||
|
description,
|
||
|
status,
|
||
|
duration: 5000,
|
||
|
isClosable: true,
|
||
|
position: 'top-right',
|
||
|
});
|
||
|
},
|
||
|
[toast],
|
||
|
);
|
||
|
|
||
|
return showToast;
|
||
|
};
|
||
|
|
||
|
export default useShowToast;
|