import { useEffect } from "react"; import { observer } from "mobx-react-lite"; // hooks import { useApplication, useEventTracker, useDashboard, useProject, useUser } from "hooks/store"; // components import { DashboardWidgets } from "components/dashboard"; import { EmptyState } from "components/empty-state"; import { IssuePeekOverview } from "components/issues"; import { TourRoot } from "components/onboarding"; import { UserGreetingsView } from "components/user"; // ui import { Spinner } from "@plane/ui"; // constants import { PRODUCT_TOUR_COMPLETED } from "constants/event-tracker"; import { EmptyStateType } from "constants/empty-state"; export const WorkspaceDashboardView = observer(() => { // store hooks const { captureEvent, setTrackElement } = useEventTracker(); const { commandPalette: { toggleCreateProjectModal }, router: { workspaceSlug }, } = useApplication(); const { currentUser, updateTourCompleted } = useUser(); const { homeDashboardId, fetchHomeDashboardWidgets } = useDashboard(); const { joinedProjectIds } = useProject(); const handleTourCompleted = () => { updateTourCompleted() .then(() => { captureEvent(PRODUCT_TOUR_COMPLETED, { user_id: currentUser?.id, state: "SUCCESS", }); }) .catch((error) => { console.error(error); }); }; // fetch home dashboard widgets on workspace change useEffect(() => { if (!workspaceSlug) return; fetchHomeDashboardWidgets(workspaceSlug); }, [fetchHomeDashboardWidgets, workspaceSlug]); return ( <> {currentUser && !currentUser.is_tour_completed && (
)} {homeDashboardId && joinedProjectIds ? ( <> {joinedProjectIds.length > 0 ? ( <>
{currentUser && }
) : ( { setTrackElement("Dashboard empty state"); toggleCreateProjectModal(true); }} /> )} ) : (
)} ); });