import React from 'react';
import PropTypes from 'prop-types';
import DevidedPagePath from '@commons/models/devided-page-path';
const PagePathLabel = (props) => {
const dPagePath = new DevidedPagePath(props.page.path, false, true);
let classNames = ['page-path'];
classNames = classNames.concat(props.additionalClassNames);
if (props.isLatterOnly) {
return {dPagePath.latter};
}
const textElem = (dPagePath.former == null && dPagePath.latter == null)
? <>/>
: <>{dPagePath.former}/{dPagePath.latter}>;
return {textElem};
};
PagePathLabel.propTypes = {
page: PropTypes.object.isRequired,
isLatterOnly: PropTypes.bool,
additionalClassNames: PropTypes.array,
};
PagePathLabel.defaultProps = {
additionalClassNames: [],
};
export default PagePathLabel;