Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
2cae922c9f
commit
7de0827070
@@ -1,4 +1,4 @@
|
||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||
import { createFileRoute, useNavigate, Outlet, useMatches } from "@tanstack/react-router";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { ProtectedLayout } from "@/components/protected-layout";
|
||||
import { PageContainer, PageHeader } from "@/components/app-shell";
|
||||
@@ -11,12 +11,20 @@ import { Search, ArrowLeft } from "lucide-react";
|
||||
import { formatCurrency } from "@/lib/format";
|
||||
|
||||
export const Route = createFileRoute("/invoices/new")({
|
||||
component: () => (
|
||||
component: NewInvoiceLayout,
|
||||
});
|
||||
|
||||
function NewInvoiceLayout() {
|
||||
// If a child route (e.g. /invoices/new/$clientId) is matched, render only it.
|
||||
const matches = useMatches();
|
||||
const hasChild = matches.some((m) => m.routeId !== "/invoices/new" && m.routeId.startsWith("/invoices/new/"));
|
||||
if (hasChild) return <Outlet />;
|
||||
return (
|
||||
<ProtectedLayout>
|
||||
<NewInvoicePickClient />
|
||||
</ProtectedLayout>
|
||||
),
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
interface ClientLite {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user