- Hey Buddy! Grab your special Hey NFT Here.
+ Hey! Grab your special Hey NFT here.
New or OG, this NFT's for our epic times together. Let's keep the vibe
diff --git a/apps/web/src/components/Staff/Sidebar.tsx b/apps/web/src/components/Staff/Sidebar.tsx
index 33fccf6bf07a..8f1a8e076edf 100644
--- a/apps/web/src/components/Staff/Sidebar.tsx
+++ b/apps/web/src/components/Staff/Sidebar.tsx
@@ -5,6 +5,7 @@ import {
AdjustmentsHorizontalIcon,
ClipboardIcon,
CurrencyDollarIcon,
+ PencilSquareIcon,
UserIcon
} from '@heroicons/react/24/outline';
@@ -28,6 +29,11 @@ const settingsSidebarItems = [
icon:
,
title: 'Feature flags',
url: '/staff/feature-flags'
+ },
+ {
+ icon:
,
+ title: 'Top Publications',
+ url: '/staff/top-publications'
}
];
diff --git a/apps/web/src/components/Staff/TopPublications/List.tsx b/apps/web/src/components/Staff/TopPublications/List.tsx
new file mode 100644
index 000000000000..4c903a09753f
--- /dev/null
+++ b/apps/web/src/components/Staff/TopPublications/List.tsx
@@ -0,0 +1,88 @@
+import type { AnyPublication } from '@hey/lens';
+import type { FC } from 'react';
+
+import SinglePublication from '@components/Publication/SinglePublication';
+import Loader from '@components/Shared/Loader';
+import { PencilIcon } from '@heroicons/react/24/outline';
+import { HEY_API_URL } from '@hey/data/constants';
+import { usePublicationsQuery } from '@hey/lens';
+import { Card, EmptyState, ErrorMessage } from '@hey/ui';
+import { useQuery } from '@tanstack/react-query';
+import axios from 'axios';
+import { useImpressionsStore } from 'src/store/non-persisted/useImpressionsStore';
+
+const List: FC = () => {
+ const fetchAndStoreViews = useImpressionsStore(
+ (state) => state.fetchAndStoreViews
+ );
+
+ const getTop50Publications = async (): Promise<
+ [] | [{ count: number; id: string }]
+ > => {
+ try {
+ const response = await axios.get(
+ `${HEY_API_URL}/internal/leafwatch/top50Publications`
+ );
+
+ return response.data.result;
+ } catch {
+ return [];
+ }
+ };
+
+ const { data: top50Publications } = useQuery({
+ queryFn: () => getTop50Publications(),
+ queryKey: ['getTop50Publications']
+ });
+
+ const publicationIds = top50Publications?.map((p) => p.id) || [];
+
+ const { data, error, loading } = usePublicationsQuery({
+ onCompleted: async ({ publications }) => {
+ const ids = publications?.items?.map((p) => p.id) || [];
+ await fetchAndStoreViews(ids);
+ },
+ skip: publicationIds.length === 0,
+ variables: { request: { where: { publicationIds } } }
+ });
+
+ const publications = data?.publications.items || [];
+
+ return (
+
+
+
+ Top Publications in the last 24h
+
+
+
+
+ {loading ? (
+
+ ) : error ? (
+
+ ) : !publications.length ? (
+
}
+ message={
No top publications found}
+ />
+ ) : (
+
+ {publications?.map((publication) => (
+
+
+
+ ))}
+
+ )}
+
+
+ );
+};
+
+export default List;
diff --git a/apps/web/src/components/Staff/TopPublications/index.tsx b/apps/web/src/components/Staff/TopPublications/index.tsx
new file mode 100644
index 000000000000..baadf98d3655
--- /dev/null
+++ b/apps/web/src/components/Staff/TopPublications/index.tsx
@@ -0,0 +1,44 @@
+import type { NextPage } from 'next';
+
+import MetaTags from '@components/Common/MetaTags';
+import { APP_NAME } from '@hey/data/constants';
+import { PAGEVIEW } from '@hey/data/tracking';
+import { GridItemEight, GridItemFour, GridLayout } from '@hey/ui';
+import { Leafwatch } from '@lib/leafwatch';
+import Custom404 from 'src/pages/404';
+import { useFeatureFlagsStore } from 'src/store/persisted/useFeatureFlagsStore';
+import useProfileStore from 'src/store/persisted/useProfileStore';
+import { useEffectOnce } from 'usehooks-ts';
+
+import StaffSidebar from '../Sidebar';
+import List from './List';
+
+const TopPublications: NextPage = () => {
+ const currentProfile = useProfileStore((state) => state.currentProfile);
+ const staffMode = useFeatureFlagsStore((state) => state.staffMode);
+
+ useEffectOnce(() => {
+ Leafwatch.track(PAGEVIEW, {
+ page: 'staff-tools',
+ subpage: 'feature-flags'
+ });
+ });
+
+ if (!currentProfile || !staffMode) {
+ return
;
+ }
+
+ return (
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default TopPublications;
diff --git a/apps/web/src/pages/staff/feature-flags.ts b/apps/web/src/pages/staff/feature-flags.tsx
similarity index 100%
rename from apps/web/src/pages/staff/feature-flags.ts
rename to apps/web/src/pages/staff/feature-flags.tsx
diff --git a/apps/web/src/pages/staff/index.ts b/apps/web/src/pages/staff/index.tsx
similarity index 100%
rename from apps/web/src/pages/staff/index.ts
rename to apps/web/src/pages/staff/index.tsx
diff --git a/apps/web/src/pages/staff/tokens.ts b/apps/web/src/pages/staff/tokens.tsx
similarity index 100%
rename from apps/web/src/pages/staff/tokens.ts
rename to apps/web/src/pages/staff/tokens.tsx
diff --git a/apps/web/src/pages/staff/top-publications..tsx b/apps/web/src/pages/staff/top-publications..tsx
new file mode 100644
index 000000000000..84d314515b99
--- /dev/null
+++ b/apps/web/src/pages/staff/top-publications..tsx
@@ -0,0 +1,3 @@
+import TopPublications from '@components/Staff/TopPublications';
+
+export default TopPublications;
diff --git a/apps/web/src/pages/staff/users/[id].ts b/apps/web/src/pages/staff/users/[id].tsx
similarity index 100%
rename from apps/web/src/pages/staff/users/[id].ts
rename to apps/web/src/pages/staff/users/[id].tsx
diff --git a/apps/web/src/pages/staff/users/index.ts b/apps/web/src/pages/staff/users/index.tsx
similarity index 100%
rename from apps/web/src/pages/staff/users/index.ts
rename to apps/web/src/pages/staff/users/index.tsx