25 lines
585 B
TypeScript
25 lines
585 B
TypeScript
import { useState } from 'react';
|
||
import { Button } from 'ui/elements';
|
||
import { ReloadOutlined } from 'ui/elements/icons';
|
||
|
||
export function ReloadButton({ onClick }: { readonly onClick: () => Promise<unknown> }) {
|
||
const [pending, setPending] = useState(false);
|
||
|
||
return (
|
||
<Button
|
||
loading={pending}
|
||
onClick={() => {
|
||
setPending(true);
|
||
onClick().finally(() => {
|
||
setTimeout(() => {
|
||
setPending(false);
|
||
}, 1000);
|
||
});
|
||
}}
|
||
icon={<ReloadOutlined rev="" />}
|
||
>
|
||
Обновить
|
||
</Button>
|
||
);
|
||
}
|