import { useEffect } from "react"; import { observer } from "mobx-react"; import Link from "next/link"; import useSWR from "swr"; // icons import { History, MessageSquare } from "lucide-react"; // hooks import { ActivityIcon, ActivityMessage, IssueLink } from "@/components/core"; import { RichTextReadOnlyEditor } from "@/components/editor/rich-text-editor/rich-text-read-only-editor"; import { ActivitySettingsLoader } from "@/components/ui"; // constants import { USER_ACTIVITY } from "@/constants/fetch-keys"; // helpers import { calculateTimeAgo } from "@/helpers/date-time.helper"; // hooks import { useUser } from "@/hooks/store"; // services import { UserService } from "@/services/user.service"; const userService = new UserService(); type Props = { cursor: string; perPage: number; updateResultsCount: (count: number) => void; updateTotalPages: (count: number) => void; updateEmptyState: (state: boolean) => void; }; export const ProfileActivityListPage: React.FC = observer((props) => { const { cursor, perPage, updateResultsCount, updateTotalPages, updateEmptyState } = props; // store hooks const { data: currentUser } = useUser(); const { data: userProfileActivity } = useSWR( USER_ACTIVITY({ cursor, }), () => userService.getUserActivity({ cursor, per_page: perPage, }) ); useEffect(() => { if (!userProfileActivity) return; // if no results found then show empty state if (userProfileActivity.total_results === 0) updateEmptyState(true); updateTotalPages(userProfileActivity.total_pages); updateResultsCount(userProfileActivity.results.length); }, [updateResultsCount, updateTotalPages, userProfileActivity, updateEmptyState]); // TODO: refactor this component return ( <> {userProfileActivity ? ( ) : ( )} ); });