META-INF.resources.js.components.BasicInformation.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.analytics.reports.web
Show all versions of com.liferay.analytics.reports.web
Liferay Analytics Reports Web
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
import ClayIcon from '@clayui/icon';
import ClayLayout from '@clayui/layout';
import ClaySticker from '@clayui/sticker';
import classnames from 'classnames';
import {sub} from 'frontend-js-web';
import PropTypes from 'prop-types';
import React, {useContext} from 'react';
import {StoreStateContext} from '../context/StoreContext';
import Translation from './Translation';
function Author({author: {authorId, name, url}}) {
return (
{url ? (
) : (
)}
{sub(Liferay.Language.get('authored-by-x'), name)}
);
}
function BasicInformation({
author,
canonicalURL,
onSelectedLanguageClick,
publishDate,
title,
viewURLs,
}) {
const {languageTag} = useContext(StoreStateContext);
const formattedPublishDate = Intl.DateTimeFormat(languageTag, {
day: 'numeric',
month: 'long',
year: 'numeric',
}).format(new Date(publishDate));
return (
{title}
{canonicalURL}
{sub(
Liferay.Language.get('published-on-x'),
formattedPublishDate
)}
{author && (
)}
);
}
Author.propTypes = {
author: PropTypes.object.isRequired,
};
BasicInformation.propTypes = {
author: PropTypes.object,
canonicalURL: PropTypes.string.isRequired,
onSelectedLanguageClick: PropTypes.func.isRequired,
publishDate: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
viewURLs: PropTypes.arrayOf(
PropTypes.shape({
default: PropTypes.bool.isRequired,
languageId: PropTypes.string.isRequired,
selected: PropTypes.bool.isRequired,
viewURL: PropTypes.string.isRequired,
})
).isRequired,
};
export default BasicInformation;