import { EntityTable } from "@repo/rdx-ui/components/entity-list"; import { EntityListStatus } from "@repo/rdx-ui/components/entity-list-status"; import { FormDialog } from "@repo/rdx-ui/components/form-dialog"; import { entityListLabels } from "@repo/rdx-ui/lib/entity-list"; import { Button } from "@repo/shadcn-ui/components/button"; import { useRef } from "react"; import { useTranslation } from "react-i18next"; import { CompanyIdentity } from "../../../companies/shared/ui/company-identity"; import { DashboardNavigationButton } from "../../shared"; import { useDashboardDetailsDialogController } from "../controllers"; import { detailsTitle } from "../helpers"; import type { DashboardDetailsDialogProps } from "../types"; import { DashboardRecordsTable } from "./dashboard-records-table"; export function DashboardDetailsDialog(props: DashboardDetailsDialogProps) { const { details, onClose, onNavigate } = props; const { page, setPage, total, state, available, onRetry, companyItems, entries, paginationDisabled, } = useDashboardDetailsDialogController(props); const { t, i18n } = useTranslation("companies"); const title = t(detailsTitle(details)); const labels = entityListLabels(i18n.language); const rootRef = useRef(null); const range = labels.range( total ? (page - 1) * 10 + 1 : 0, Math.min(page * 10, total), total, t("dashboard.records") ); return ( { if (!open) { onClose(); } }} open title={title} wide >
{details.companies ? ( item.name, render: (item) => ( onNavigate({ area: "company", id: item.id, section: "inventory" }) } > ), }, { id: "assets", label: t("dashboard.registeredAssets"), value: (item) => item.assets, render: (item) => item.assets, }, { id: "people", label: t("people"), value: (item) => item.people, render: (item) => item.people, }, ]} emptyMessage={t("noCompanies")} entityLabel={t("title")} items={companyItems} locale={i18n.language} onRetry={onRetry} state={state} title={title} /> ) : ( <> rootRef.current} retryLabel={t("retry")} state={state} > {available ? range : null} {!details.activity && ( )} )}
); }