/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import { useTranslation } from "@plane/i18n"; import type { IUser, TActivityEntityData, TProjectAnalyticsCount } from "@plane/types"; import { useCurrentTime } from "@/hooks/use-current-time"; import { getActivityProjectId, getCompletionRate, type THomeProjectData } from "@/components/home/home.utils"; type HomePageHeaderProps = { currentUser?: IUser; selectedProject?: THomeProjectData; selectedProjectAnalytics?: TProjectAnalyticsCount; recents?: TActivityEntityData[]; }; export function HomePageHeader(props: HomePageHeaderProps) { const { currentUser, selectedProject, selectedProjectAnalytics, recents } = props; const { currentLocale } = useTranslation(); const { currentTime } = useCurrentTime(); const timeString = new Intl.DateTimeFormat(currentLocale, { timeZone: currentUser?.user_timezone, hour12: false, hour: "2-digit", minute: "2-digit", }).format(currentTime); const dateString = new Intl.DateTimeFormat(currentLocale, { weekday: "long", day: "numeric", month: "long", }).format(currentTime); const heroDateLabel = dateString.toLocaleUpperCase(currentLocale || "ru-RU"); const totalIssues = selectedProjectAnalytics?.total_issues ?? 0; const completedIssues = selectedProjectAnalytics?.completed_issues ?? 0; const openIssues = Math.max(totalIssues - completedIssues, 0); const completionRate = getCompletionRate(selectedProjectAnalytics); const recentTouchpoints = (recents ?? []).filter((activity) => { if (!selectedProject) return true; return getActivityProjectId(activity) === selectedProject.id; }).length; const marketMetrics = [ { label: "Готовность", value: `${completionRate}%`, caption: `${completedIssues}/${totalIssues || 0}` }, { label: "Открытые задачи", value: openIssues.toString(), caption: "в работе" }, { label: "Касания 7 дней", value: recentTouchpoints.toString(), caption: "recent" }, ]; return (
{heroDateLabel}
{timeString}

WORKSPACE HOME

{selectedProject ? `${selectedProject.identifier} в фокусе домашней сводки.` : "Выберите проект для фокуса, Ганта и рабочей аналитики."}

Фокус
{selectedProject?.name ?? "Workspace"}
{selectedProject?.description || selectedProject?.identifier || "Координационный обзор"}
{marketMetrics.map((metric) => (
{metric.label}
{metric.value}
{metric.caption}
))}
); }