Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

1.2 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.

import { useParams } from "react-router";
import { useRouteData } from "~/hooks";
import { ReimbursementSummary } from "~/modules/invoicing/ui";
import type { loader } from "~/routes/x+/reimbursements+/$reimbursementId";
import { path } from "~/utils/path";

/**
 * Read mode. The document is loaded once by the page
 * (`$reimbursementId.tsx`); its header owns Post, Pay expense and Void.
 */
export default function ReimbursementDetailRoute() {
  const { reimbursementId } = useParams();
  if (!reimbursementId) throw new Error("Could not find reimbursementId");

  const routeData = useRouteData<Awaited<ReturnType<typeof loader>>>(
    path.to.reimbursement(reimbursementId)
  );

  if (!routeData?.reimbursement) {
    throw new Error("Could not find reimbursement in routeData");
  }

  return (
    <ReimbursementSummary
      reimbursement={routeData.reimbursement}
      lines={routeData.lines}
      accountsById={routeData.accountsById}
      mapping={routeData.mapping}
      availableDimensions={routeData.dimensions}
    />
  );
}