mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Refactored intl messages.
This commit is contained in:
parent
fbccf4d3af
commit
7725b5c129
44 changed files with 558 additions and 485 deletions
|
|
@ -1,36 +1,29 @@
|
|||
import { useMutation } from '@tanstack/react-query';
|
||||
import useApi from 'hooks/useApi';
|
||||
import { Button, Form, FormButtons, SubmitButton } from 'react-basics';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { labels } from 'components/messages';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { labels, messages } from 'components/messages';
|
||||
|
||||
const messages = defineMessages({
|
||||
confirm: { id: 'label.confirm', defaultMessage: 'Confirm' },
|
||||
warning: {
|
||||
id: 'message.confirm-delete-user',
|
||||
defaultMessage: 'Are you sure you want to delete this user?',
|
||||
},
|
||||
});
|
||||
|
||||
export default function UserDeleteForm({ userId, onSave, onClose }) {
|
||||
export default function UserDeleteForm({ userId, username, onSave, onClose }) {
|
||||
const { formatMessage } = useIntl();
|
||||
const { del } = useApi();
|
||||
const { mutate, error, isLoading } = useMutation(data => del(`/users/${userId}`, data));
|
||||
const { mutate, error, isLoading } = useMutation(() => del(`/users/${userId}`));
|
||||
|
||||
const handleSubmit = async data => {
|
||||
mutate(data, {
|
||||
onSuccess: async () => {
|
||||
onSave();
|
||||
onClose();
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Form onSubmit={handleSubmit} error={error}>
|
||||
<p>{formatMessage(messages.warning)}</p>
|
||||
<p>{formatMessage(messages.deleteUserWarning, { username })}</p>
|
||||
<FormButtons flex>
|
||||
<SubmitButton variant="primary" disabled={isLoading}>
|
||||
{formatMessage(labels.save)}
|
||||
{formatMessage(labels.delete)}
|
||||
</SubmitButton>
|
||||
<Button disabled={isLoading} onClick={onClose}>
|
||||
{formatMessage(labels.cancel)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue