53 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-02-02 16:08:16 +01:00
import React from 'react';
2021-02-08 13:47:43 +01:00
import PropTypes from 'prop-types';
2021-02-02 16:08:16 +01:00
import { Modal, ModalHeader, ModalSection, ModalFooter } from 'strapi-helper-plugin';
import { useIntl } from 'react-intl';
import { Button, Padded } from '@buffetjs/core';
import { Row } from 'reactstrap';
2021-02-08 13:47:43 +01:00
import useEditLocale from '../../hooks/useEditLocale';
2021-02-02 16:08:16 +01:00
import { getTrad } from '../../utils';
2021-02-08 13:47:43 +01:00
const ModalEdit = ({ localeToEdit, onClose }) => {
const { isEditing, editLocale } = useEditLocale();
2021-02-02 16:08:16 +01:00
const { formatMessage } = useIntl();
2021-02-08 13:47:43 +01:00
const isOpened = Boolean(localeToEdit);
const handleEdit = () => editLocale(localeToEdit).then(onClose);
2021-02-02 16:08:16 +01:00
return (
2021-02-08 13:47:43 +01:00
<Modal isOpen={isOpened} onToggle={onClose} onClosed={onClose}>
<ModalHeader
headerBreadcrumbs={[formatMessage({ id: getTrad('Settings.list.actions.edit') })]}
/>
2021-02-02 16:08:16 +01:00
<ModalSection>
<div>
<Padded top size="md">
<Row>Put the form here</Row>
</Padded>
</div>
</ModalSection>
<ModalFooter>
<section>
2021-02-08 13:47:43 +01:00
<Button type="button" color="cancel" onClick={onClose}>
2021-02-02 16:08:16 +01:00
{formatMessage({ id: 'app.components.Button.cancel' })}
</Button>
2021-02-08 13:47:43 +01:00
<Button color="success" type="button" onClick={handleEdit} isLoading={isEditing}>
2021-02-02 16:08:16 +01:00
{formatMessage({ id: getTrad('Settings.locales.modal.edit.confirmation') })}
</Button>
</section>
</ModalFooter>
</Modal>
);
};
2021-02-08 13:47:43 +01:00
ModalEdit.defaultProps = {
localeToEdit: undefined,
};
2021-02-02 16:08:16 +01:00
ModalEdit.propTypes = {
2021-02-08 13:47:43 +01:00
localeToEdit: PropTypes.shape({}),
onClose: PropTypes.func.isRequired,
2021-02-02 16:08:16 +01:00
};
export default ModalEdit;