File size: 1,629 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | import { SubscriptionManager } from '@automattic/data-stores';
import { useTranslate } from 'i18n-calypso';
import { Notice, NoticeType } from 'calypso/landing/subscriptions/components/notice';
import { PendingPostList, PendingSiteList } from '../../pending-list';
import TabView from '../tab-view';
const Pending = () => {
const translate = useTranslate();
const {
data: { pendingSites, totalCount: totalPendingSitesCount = 0 },
isLoading: isLoadingPendingSites,
error: errorPendingSites,
} = SubscriptionManager.usePendingSiteSubscriptionsQuery();
const {
data: { pendingPosts, totalCount: totalPendingPostsCount = 0 },
isLoading: isLoadingPendingPosts,
error: errorPendingPosts,
} = SubscriptionManager.usePendingPostSubscriptionsQuery();
let errorMessage;
if ( errorPendingSites ) {
errorMessage = translate( 'An error occurred while fetching your site subscriptions.' );
} else if ( errorPendingPosts ) {
errorMessage = translate( 'An error occurred while fetching your post subscriptions.' );
}
if (
! isLoadingPendingSites &&
! isLoadingPendingPosts &&
! totalPendingSitesCount &&
! totalPendingPostsCount
) {
return (
<Notice type={ NoticeType.Success }>
{ translate( 'All set! No pending subscriptions.' ) }
</Notice>
);
}
return (
<TabView
errorMessage={ errorMessage }
isLoading={ isLoadingPendingSites || isLoadingPendingPosts }
>
{ totalPendingSitesCount > 0 && <PendingSiteList pendingSites={ pendingSites } /> }
{ totalPendingPostsCount > 0 && <PendingPostList pendingPosts={ pendingPosts } /> }
</TabView>
);
};
export default Pending;
|