import React from 'react'; import PropTypes from 'prop-types'; import { useIntl } from 'react-intl'; import { Pencil } from '@buffetjs/icons'; import { Text, IconLinks } from '@buffetjs/core'; import { CustomRow } from '@buffetjs/styles'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { getTrad } from '../../utils'; const LocaleSettingsPage = ({ locale, onDelete, onEdit }) => { const { formatMessage } = useIntl(); const links = []; if (onEdit) { links.push({ icon: ( ), onClick: () => onEdit(locale), }); } if (onDelete && !locale.isDefault) { links.push({ icon: !locale.isDefault ? ( ) : null, onClick: e => { e.stopPropagation(); onDelete(locale); }, }); } return ( onEdit(locale)}> {locale.code} {locale.name} {locale.isDefault ? formatMessage({ id: getTrad('Settings.locales.row.default-locale') }) : null} ); }; LocaleSettingsPage.defaultProps = { onDelete: undefined, onEdit: undefined, }; LocaleSettingsPage.propTypes = { locale: PropTypes.shape({ isDefault: PropTypes.bool, name: PropTypes.string, code: PropTypes.string.isRequired, }).isRequired, onDelete: PropTypes.func, onEdit: PropTypes.func, }; export default LocaleSettingsPage;