Files
mediacms/frontend/src/static/js/pages/ProfileHistoryPage.js
T
2026-05-11 12:47:09 +03:00

68 lines
2.2 KiB
JavaScript
Executable File

import React from 'react';
import PropTypes from 'prop-types';
import { ApiUrlConsumer } from '../utils/contexts/';
import { PageStore } from '../utils/stores/';
import { inEmbeddedApp } from '../utils/helpers/';
import { MediaListWrapper } from '../components/MediaListWrapper';
import ProfilePagesHeader from '../components/profile-page/ProfilePagesHeader';
import ProfilePagesContent from '../components/profile-page/ProfilePagesContent';
import { LazyLoadItemListAsync } from '../components/item-list/LazyLoadItemListAsync.jsx';
import { ProfileMediaPageBase } from './ProfileMediaPage';
export class ProfileHistoryPage extends ProfileMediaPageBase {
constructor(props) {
super(props, 'author-history');
this.state = {
resultsCount: null,
};
this.getCountFunc = this.getCountFunc.bind(this);
}
getCountFunc(resultsCount) {
this.setState({
resultsCount: resultsCount,
});
}
pageContent() {
return [
this.state.author ? (
<ProfilePagesHeader key="ProfilePagesHeader" author={this.state.author} type="history" hideChannelBanner={inEmbeddedApp()} />
) : null,
this.state.author ? (
<ProfilePagesContent key="ProfilePagesContent">
<ApiUrlConsumer>
{(apiUrl) => (
<MediaListWrapper
title={
this.props.title + (null !== this.state.resultsCount ? ' (' + this.state.resultsCount + ')' : '')
}
className="items-list-ver"
>
<LazyLoadItemListAsync
itemsCountCallback={this.getCountFunc}
requestUrl={apiUrl.user.history}
hideAuthor={!PageStore.get('config-media-item').displayAuthor}
hideViews={!PageStore.get('config-media-item').displayViews}
hideDate={!PageStore.get('config-media-item').displayPublishDate}
canEdit={false}
/>
</MediaListWrapper>
)}
</ApiUrlConsumer>
</ProfilePagesContent>
) : null,
];
}
}
ProfileHistoryPage.propTypes = {
title: PropTypes.string.isRequired,
};
ProfileHistoryPage.defaultProps = {
title: 'History',
};