mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 23:49:15 +00:00
imrprovement: debounce delete
This commit is contained in:
@@ -1,15 +1,25 @@
|
|||||||
import { IconButton } from '@chakra-ui/button';
|
import { IconButton } from '@chakra-ui/button';
|
||||||
|
import { useState } from 'react';
|
||||||
import { FiMinus } from 'react-icons/fi';
|
import { FiMinus } from 'react-icons/fi';
|
||||||
|
|
||||||
export default function DeleteIconBtn(props) {
|
export default function DeleteIconBtn(props) {
|
||||||
const { actionHandler, ...rest } = props;
|
const { actionHandler, ...rest } = props;
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
setLoading(true);
|
||||||
|
actionHandler('delete');
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
size={props.size || 'xs'}
|
size={props.size || 'xs'}
|
||||||
icon={<FiMinus />}
|
icon={<FiMinus />}
|
||||||
colorScheme='red'
|
colorScheme='red'
|
||||||
onClick={() => actionHandler('delete')}
|
onClick={handleClick}
|
||||||
_focus={{ boxShadow: 'none' }}
|
_focus={{ boxShadow: 'none' }}
|
||||||
|
disabled={loading}
|
||||||
|
isLoading={loading}
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user