umami/components/pages/settings/account/ApiKeyDeleteForm.js

30 lines
831 B
JavaScript
Raw Normal View History

2023-01-10 08:59:26 +01:00
import useApi from 'hooks/useApi';
import { Button, Form, FormButtons, SubmitButton } from 'react-basics';
export default function ApiKeyDeleteForm({ apiKeyId, onSave, onClose }) {
const { del, useMutation } = useApi();
const { mutate, error, isLoading } = useMutation(data => del(`/api-key/${apiKeyId}`, data));
const handleSubmit = async data => {
mutate(data, {
onSuccess: async () => {
onSave();
},
});
};
return (
<Form onSubmit={handleSubmit} error={error}>
<div>Are you sure you want to delete this API KEY?</div>
<FormButtons flex>
<SubmitButton variant="primary" disabled={isLoading}>
Delete
</SubmitButton>
<Button disabled={isLoading} onClick={onClose}>
Cancel
</Button>
</FormButtons>
</Form>
);
}