2021-01-29 17:22:32 +01:00
|
|
|
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-02 16:08:16 +01:00
|
|
|
const LocaleSettingsPage = ({ locale, onDelete, onEdit }) => {
|
2021-01-29 17:22:32 +01:00
|
|
|
const { formatMessage } = useIntl();
|
|
|
|
|
|
|
|
|
|
return (
|
2021-02-02 17:20:04 +01:00
|
|
|
<CustomRow>
|
2021-01-29 17:22:32 +01:00
|
|
|
<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,
|
2021-02-02 16:08:16 +01:00
|
|
|
onClick: onEdit,
|
2021-01-29 17:22:32 +01:00
|
|
|
},
|
|
|
|
|
{
|
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,
|
2021-01-29 17:22:32 +01:00
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
/>
|
|
|
|
|
</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,
|
2021-02-02 16:08:16 +01:00
|
|
|
onEdit: PropTypes.func.isRequired,
|
2021-01-29 17:22:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default LocaleSettingsPage;
|