mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
import { Button, Form, FormButtons, SubmitButton } from 'react-basics';
|
|
import useApi from 'hooks/useApi';
|
|
import useMessages from 'hooks/useMessages';
|
|
|
|
export default function TeamLeaveForm({ teamUserId, teamName, onSave, onClose }) {
|
|
const { formatMessage, labels, messages, FormattedMessage } = useMessages();
|
|
const { del, useMutation } = useApi();
|
|
const { mutate, error, isLoading } = useMutation(data => del(`/teamUsers/${teamUserId}`, data));
|
|
|
|
const handleSubmit = async data => {
|
|
mutate(data, {
|
|
onSuccess: async () => {
|
|
onSave();
|
|
onClose();
|
|
},
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Form onSubmit={handleSubmit} error={error}>
|
|
<p>
|
|
<FormattedMessage {...messages.confirmLeave} values={{ name: <b>{teamName}</b> }} />
|
|
</p>
|
|
<FormButtons flex>
|
|
<SubmitButton variant="danger" disabled={isLoading}>
|
|
{formatMessage(labels.leave)}
|
|
</SubmitButton>
|
|
<Button onClick={onClose}>{formatMessage(labels.cancel)}</Button>
|
|
</FormButtons>
|
|
</Form>
|
|
);
|
|
}
|