"use client"; import { History, Pencil, Trash2 } from "lucide-react"; import { getEmployeeActionTone, } from "@/lib/users/userDetailUtils"; import type { EmployeeAction } from "@/types/api"; type EmployeeActionsTimelineProps = { actionLoading: string | null; canManageActions: boolean; canViewActions: boolean; latestActionId: number | null; onAddAction: () => void; onDeleteAction: (actionId: number) => void; onEditAction: (action: EmployeeAction) => void; sortedActions: EmployeeAction[]; }; function formatActionDate(value: string) { const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return date.toLocaleDateString("ru-RU", { day: "2-digit", month: "2-digit", year: "numeric", }); } export default function EmployeeActionsTimeline({ actionLoading, canManageActions, canViewActions, latestActionId, onAddAction, onDeleteAction, onEditAction, sortedActions, }: EmployeeActionsTimelineProps) { if (!canViewActions || sortedActions.length === 0) { return null; } return (

Кадровые события

{sortedActions.length}{" "} {sortedActions.length === 1 ? "событие" : sortedActions.length < 5 ? "события" : "событий"} {canManageActions ? ( ) : null}
{sortedActions.map((action) => { const isCurrent = latestActionId === action.id; const deleteKey = `delete-${action.id}`; const tone = getEmployeeActionTone(action.action); return (
{isCurrent ? ( ) : null}
{action.action_display || action.action} {isCurrent ? ( текущий ) : null}
{action.comment ? (

{action.comment}

) : null}
{canManageActions ? (
) : null}
); })}
); }