umami/components/pages/reports/funnel/UrlAddForm.js

41 lines
1.0 KiB
JavaScript
Raw Normal View History

import { useState } from 'react';
import { useMessages } from 'hooks';
import { Button, Form, FormButtons, FormRow, TextField } from 'react-basics';
2023-06-03 08:10:59 +02:00
import styles from './UrlAddForm.module.css';
2023-06-03 08:10:59 +02:00
export function UrlAddForm({ defaultValue = '', onSave, onClose }) {
const [url, setUrl] = useState(defaultValue);
const { formatMessage, labels } = useMessages();
const handleSave = () => {
onSave?.(url);
setUrl('');
onClose();
};
const handleChange = e => {
setUrl(e.target.value);
};
return (
2023-06-05 12:08:43 +02:00
<Form className={styles.form} onSubmit={handleSave}>
<FormRow label={formatMessage(labels.url)}>
<TextField
name="url"
value={url}
onChange={handleChange}
autoFocus={true}
autoComplete="off"
/>
</FormRow>
<FormButtons align="center" flex>
<Button variant="primary" onClick={handleSave}>
{formatMessage(labels.save)}
</Button>
</FormButtons>
</Form>
);
}
2023-06-03 08:10:59 +02:00
export default UrlAddForm;