META-INF.resources.js.components.EditedTimestamp.es.js Maven / Gradle / Ivy
/**
* 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 {ClayTooltipProvider} from '@clayui/tooltip';
import React from 'react';
import {fromNow} from '../utils/time.es';
import {dateToInternationalHuman} from '../utils/utils.es';
const BCP47LanguageId = Liferay.ThemeDisplay.getBCP47LanguageId();
const getTextDelimeted = (text, date) => {
const delimeter = ' - ';
return `${text} ${delimeter} ${date}`;
};
const EditedTimestamp = ({
creator,
dateCreated,
dateModified,
operationText,
showSignature = false,
styledTimeStamp = false,
}) => {
if (!dateCreated || !dateModified) {
return null;
}
const selectedText = getTextDelimeted(
operationText,
dateToInternationalHuman(dateCreated, BCP47LanguageId)
);
const elapsedTime = fromNow(dateCreated);
return (
{styledTimeStamp && (
{creator}
{elapsedTime}
)}
{!styledTimeStamp && !showSignature && (
{selectedText}
)}
);
};
export default EditedTimestamp;