70 lines
1.8 KiB
JavaScript
Raw Normal View History

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';
// Fake permissions
const canUpdate = true;
const canDelete = true;
2021-02-01 16:02:47 +01:00
const LocaleSettingsPage = ({ locale, onDelete }) => {
const { formatMessage } = useIntl();
return (
<CustomRow onClick={() => console.log('open modal')}>
<td>
<Text>{locale.code}</Text>
</td>
<td>
<Text fontWeight="semiBold">{locale.displayName}</Text>
</td>
<td>
<Text>
{locale.isDefault
? formatMessage({ id: getTrad('Settings.locales.row.default-locale') })
: null}
</Text>
</td>
<td>
<IconLinks
links={[
{
2021-02-01 16:02:47 +01:00
icon: canUpdate ? (
<span aria-label="Edit locale">
<Pencil fill="#0e1622" />
</span>
) : null,
onClick: () => console.log('edit'),
},
{
2021-02-01 16:02:47 +01:00
icon:
canDelete && !locale.isDefault ? (
<span aria-label="Delete locale">
<FontAwesomeIcon icon="trash-alt" />
</span>
) : null,
onClick: onDelete,
},
]}
/>
</td>
</CustomRow>
);
};
LocaleSettingsPage.propTypes = {
locale: PropTypes.shape({
isDefault: PropTypes.bool,
displayName: PropTypes.string,
code: PropTypes.string.isRequired,
}).isRequired,
2021-02-01 16:02:47 +01:00
onDelete: PropTypes.func.isRequired,
};
export default LocaleSettingsPage;