import { useState } from "react"; import { IconChevronRight, IconFile } from "@tabler/icons-react"; import { useTranslation } from "react-i18next"; import { IPage } from "@/features/page/types/page.types"; import { PageChildren } from "./page-children"; import classes from "./destination-picker.module.css"; type PageRowProps = { page: Partial; depth: number; limit: number; selectedId: string | null; excludePageId?: string; onSelect: (page: Partial) => void; }; export function PageRow({ page, depth, limit, selectedId, excludePageId, onSelect, }: PageRowProps) { const { t } = useTranslation(); const [expanded, setExpanded] = useState(false); const isExcluded = page.id === excludePageId; const isSelected = page.id === selectedId; const rowClasses = [ classes.pageRow, isSelected && classes.selected, isExcluded && classes.disabled, ] .filter(Boolean) .join(" "); return ( <>
!isExcluded && onSelect(page)} > {page.hasChildren ? (
{ e.stopPropagation(); setExpanded(!expanded); }} >
) : (
)}
{page.icon ? ( page.icon ) : ( )}
{page.title || t("Untitled")}
{expanded && page.hasChildren && ( )} ); }