Skip to content

Commit 8f80dbd

Browse files
committed
fixed equity subroutes
1 parent 9b1a07e commit 8f80dbd

File tree

15 files changed

+186
-165
lines changed

15 files changed

+186
-165
lines changed

frontend/app/(dashboardLayout)/equity/cap_table/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22
import { CircleCheck } from "lucide-react";
3-
import { useSearchParams } from "next/navigation";
3+
import { usePathname, useSearchParams } from "next/navigation";
44
import React, { useMemo } from "react";
55
import CopyButton from "@/components/CopyButton";
66
import DataTable, { createColumnHelper, useTable } from "@/components/DataTable";
@@ -18,12 +18,15 @@ import {
1818
import type { RouterOutput } from "@/trpc";
1919
import { trpc } from "@/trpc/client";
2020
import { formatOwnershipPercentage } from "@/utils/numbers";
21+
import { PageHeader } from "@/components/layouts/PageHeader";
22+
import { navLinks } from "@/app/(dashboardLayout)/equity";
2123

2224
type Data = RouterOutput["capTable"]["show"];
2325

2426
export default function CapTable() {
2527
const company = useCurrentCompany();
2628
const searchParams = useSearchParams();
29+
const pathname = usePathname();
2730
const newSchema = searchParams.get("new_schema") !== null;
2831
const [data] = trpc.capTable.show.useSuspenseQuery({ companyId: company.id, newSchema });
2932
const user = useCurrentUser();
@@ -156,9 +159,10 @@ export default function CapTable() {
156159
);
157160

158161
const shareClassesTable = useTable({ data: shareClassesData, columns: shareClassesColumns });
159-
162+
const currentLink = navLinks(user, company).find((link) => link.route === pathname);
160163
return (
161164
<>
165+
{currentLink && <PageHeader currentLink={currentLink} />}
162166
{selectedInvestors.length > 0 && (
163167
<Alert className="mb-4">
164168
<AlertDescription className="flex items-center justify-between">

frontend/app/(dashboardLayout)/equity/convertibles/page.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import type { RouterOutput } from "@/trpc";
88
import { trpc } from "@/trpc/client";
99
import { formatMoney, formatMoneyFromCents } from "@/utils/formatMoney";
1010
import { formatDate } from "@/utils/time";
11+
import { navLinks } from "@/app/(dashboardLayout)/equity";
12+
import { usePathname } from "next/navigation";
13+
import { PageHeader } from "@/components/layouts/PageHeader";
1114

1215
const columnHelper =
1316
createColumnHelper<RouterOutput["convertibleSecurities"]["list"]["convertibleSecurities"][number]>();
@@ -21,15 +24,18 @@ const columns = [
2124
export default function Convertibles() {
2225
const company = useCurrentCompany();
2326
const user = useCurrentUser();
27+
const pathname = usePathname();
2428
const [data] = trpc.convertibleSecurities.list.useSuspenseQuery({
2529
companyId: company.id,
2630
investorId: user.roles.investor?.id ?? "",
2731
});
2832

2933
const table = useTable({ columns, data: data.convertibleSecurities });
34+
const currentLink = navLinks(user, company).find((link) => link.route === pathname);
3035

3136
return (
3237
<>
38+
{currentLink && <PageHeader currentLink={currentLink} />}
3339
{data.convertibleSecurities.length > 0 ? (
3440
<DataTable table={table} />
3541
) : (

frontend/app/(dashboardLayout)/equity/dividend_rounds/[id]/layout.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

frontend/app/(dashboardLayout)/equity/dividend_rounds/[id]/page.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"use client";
22
import Link from "next/link";
33
import { useParams, useRouter } from "next/navigation";
4-
import React, { useEffect } from "react";
4+
import React from "react";
55
import DividendStatusIndicator from "@/app/(dashboardLayout)/equity/DividendStatusIndicator";
66
import DataTable, { createColumnHelper, useTable } from "@/components/DataTable";
77
import { useCurrentCompany } from "@/global";
88
import type { RouterOutput } from "@/trpc";
99
import { trpc } from "@/trpc/client";
1010
import { formatMoneyFromCents } from "@/utils/formatMoney";
11-
import { useLayoutStore } from "@/components/layouts/LayoutStore";
11+
import { PageHeader } from "@/components/layouts/PageHeader";
1212

1313
type Dividend = RouterOutput["dividends"]["list"][number];
1414
const rowLink = (row: Dividend) => `/people/${row.investor.user.id}?tab=dividends` as const;
@@ -41,12 +41,10 @@ export default function DividendRound() {
4141

4242
const table = useTable({ columns, data });
4343

44-
const setTitle = useLayoutStore((state) => state.setTitle);
45-
const setHeaderActions = useLayoutStore((state) => state.setHeaderActions);
46-
useEffect(() => {
47-
setTitle("Dividend");
48-
setHeaderActions(null);
49-
}, []);
50-
51-
return <DataTable table={table} onRowClicked={(row) => router.push(rowLink(row))} />;
44+
return (
45+
<>
46+
<PageHeader title={"Dividend"} />
47+
<DataTable table={table} onRowClicked={(row) => router.push(rowLink(row))} />
48+
</>
49+
);
5250
}

frontend/app/(dashboardLayout)/equity/dividend_rounds/page.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
"use client";
22
import { CircleCheck } from "lucide-react";
33
import Link from "next/link";
4-
import { useRouter } from "next/navigation";
4+
import { usePathname, useRouter } from "next/navigation";
55
import React from "react";
66
import DataTable, { createColumnHelper, useTable } from "@/components/DataTable";
77
import Placeholder from "@/components/Placeholder";
8-
import { useCurrentCompany } from "@/global";
8+
import { useCurrentCompany, useCurrentUser } from "@/global";
99
import type { RouterOutput } from "@/trpc";
1010
import { trpc } from "@/trpc/client";
1111
import { formatMoneyFromCents } from "@/utils/formatMoney";
1212
import { formatDate } from "@/utils/time";
13+
import { navLinks } from "@/app/(dashboardLayout)/equity";
14+
import { PageHeader } from "@/components/layouts/PageHeader";
1315

1416
type DividendRound = RouterOutput["dividendRounds"]["list"][number];
1517
const columnHelper = createColumnHelper<DividendRound>();
@@ -29,12 +31,15 @@ const columns = [
2931
export default function DividendRounds() {
3032
const company = useCurrentCompany();
3133
const router = useRouter();
34+
const user = useCurrentUser();
35+
const pathname = usePathname();
3236
const [dividendRounds] = trpc.dividendRounds.list.useSuspenseQuery({ companyId: company.id });
33-
3437
const table = useTable({ columns, data: dividendRounds });
38+
const currentLink = navLinks(user, company).find((link) => link.route === pathname);
3539

3640
return (
3741
<>
42+
{currentLink && <PageHeader currentLink={currentLink} />}
3843
{dividendRounds.length > 0 ? (
3944
<DataTable table={table} onRowClicked={(row) => router.push(`/equity/dividend_rounds/${row.id}`)} />
4045
) : (

frontend/app/(dashboardLayout)/equity/dividends/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ import { Separator } from "@/components/ui/separator";
3030
import { Avatar, AvatarImage } from "@/components/ui/avatar";
3131
import RichText from "@/components/RichText";
3232
import MutationButton from "@/components/MutationButton";
33+
import { navLinks } from "@/app/(dashboardLayout)/equity";
34+
import { usePathname } from "next/navigation";
35+
import { PageHeader } from "@/components/layouts/PageHeader";
3336

3437
type Dividend = RouterOutput["dividends"]["list"][number];
3538
const columnHelper = createColumnHelper<Dividend>();
3639
export default function Dividends() {
3740
const company = useCurrentCompany();
41+
const pathname = usePathname();
3842
const user = useCurrentUser();
3943
const [data, { refetch }] = trpc.dividends.list.useSuspenseQuery({
4044
companyId: company.id,
@@ -114,9 +118,10 @@ export default function Dividends() {
114118
[],
115119
);
116120
const table = useTable({ columns, data });
117-
121+
const currentLink = navLinks(user, company).find((link) => link.route === pathname);
118122
return (
119123
<>
124+
{currentLink && <PageHeader currentLink={currentLink} />}
120125
{!user.legalName ? (
121126
<Alert>
122127
<Info />

frontend/app/(dashboardLayout)/equity/grants/page.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"use client";
22
import { CircleCheck, CircleAlert, Pencil, Info } from "lucide-react";
33
import Link from "next/link";
4-
import { useRouter } from "next/navigation";
4+
import { usePathname, useRouter } from "next/navigation";
55
import DataTable, { createColumnHelper, useTable } from "@/components/DataTable";
66
import { linkClasses } from "@/components/Link";
77
import Placeholder from "@/components/Placeholder";
88
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
99
import { Button } from "@/components/ui/button";
1010
import { DocumentTemplateType } from "@/db/enums";
11-
import { useCurrentCompany } from "@/global";
11+
import { useCurrentCompany, useCurrentUser } from "@/global";
1212
import type { RouterOutput } from "@/trpc";
1313
import { trpc } from "@/trpc/client";
1414
import { formatMoney } from "@/utils/formatMoney";
@@ -23,12 +23,15 @@ import {
2323
DialogTitle,
2424
} from "@/components/ui/dialog";
2525
import MutationButton from "@/components/MutationButton";
26-
import { useLayoutStore } from "@/components/layouts/LayoutStore";
26+
import { navLinks } from "@/app/(dashboardLayout)/equity";
27+
import { PageHeader } from "@/components/layouts/PageHeader";
2728
type EquityGrant = RouterOutput["equityGrants"]["list"][number];
2829

2930
export default function GrantsPage() {
3031
const router = useRouter();
3132
const company = useCurrentCompany();
33+
const user = useCurrentUser();
34+
const pathname = usePathname();
3235
const [data, { refetch }] = trpc.equityGrants.list.useSuspenseQuery({ companyId: company.id });
3336
const [cancellingGrantId, setCancellingGrantId] = useState<string | null>(null);
3437
const cancellingGrant = data.find((grant) => grant.id === cancellingGrantId);
@@ -76,7 +79,7 @@ export default function GrantsPage() {
7679
type: DocumentTemplateType.EquityPlanContract,
7780
signable: true,
7881
});
79-
const setHeaderActions = useLayoutStore((state) => state.setHeaderActions);
82+
const [headerActions, setHeaderActions] = useState<React.ReactNode>(null);
8083
useEffect(() => {
8184
setHeaderActions(
8285
equityPlanContractTemplates.length > 0 ? (
@@ -86,14 +89,14 @@ export default function GrantsPage() {
8689
New option grant
8790
</Link>
8891
</Button>
89-
) : (
90-
<Button>jjj</Button>
91-
),
92+
) : null,
9293
);
9394
}, [equityPlanContractTemplates.length]);
95+
const currentLink = navLinks(user, company).find((link) => link.route === pathname);
9496

9597
return (
9698
<>
99+
{currentLink && <PageHeader currentLink={currentLink} headerActions={headerActions} />}
97100
{equityPlanContractTemplates.length === 0 ? (
98101
<Alert>
99102
<Info />

frontend/app/(dashboardLayout)/equity/layout.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

frontend/app/(dashboardLayout)/equity/option_pools/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import React from "react";
44
import DataTable, { createColumnHelper, useTable } from "@/components/DataTable";
55
import Placeholder from "@/components/Placeholder";
66
import { Progress } from "@/components/ui/progress";
7-
import { useCurrentCompany } from "@/global";
7+
import { useCurrentCompany, useCurrentUser } from "@/global";
88
import type { RouterOutput } from "@/trpc";
99
import { trpc } from "@/trpc/client";
10+
import { usePathname } from "next/navigation";
11+
import { navLinks } from "@/app/(dashboardLayout)/equity";
12+
import { PageHeader } from "@/components/layouts/PageHeader";
1013

1114
type OptionPool = RouterOutput["optionPools"]["list"][number];
1215

@@ -26,12 +29,16 @@ const columns = [
2629

2730
export default function OptionPools() {
2831
const company = useCurrentCompany();
32+
const user = useCurrentUser();
33+
const pathname = usePathname();
2934
const [data] = trpc.optionPools.list.useSuspenseQuery({ companyId: company.id });
3035

3136
const table = useTable({ columns, data });
37+
const currentLink = navLinks(user, company).find((link) => link.route === pathname);
3238

3339
return (
3440
<>
41+
{currentLink && <PageHeader currentLink={currentLink} />}
3542
{data.length > 0 ? (
3643
<DataTable table={table} />
3744
) : (

frontend/app/(dashboardLayout)/equity/options/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import DetailsModal from "@/app/(dashboardLayout)/equity/grants/DetailsModal";
1717
import ExerciseModal from "@/app/(dashboardLayout)/equity/grants/ExerciseModal";
1818
import type { RouterOutput } from "@/trpc";
1919
import { resend_company_equity_grant_exercise_path } from "@/utils/routes";
20-
import { forbidden } from "next/navigation";
20+
import { forbidden, usePathname } from "next/navigation";
2121
import { CircleCheck, Info } from "lucide-react";
22+
import { navLinks } from "@/app/(dashboardLayout)/equity";
23+
import { PageHeader } from "@/components/layouts/PageHeader";
2224
const pluralizeGrants = (number: number) => `${number} ${pluralize("stock option grant", number)}`;
2325

2426
type EquityGrant = RouterOutput["equityGrants"]["list"][number];
@@ -39,6 +41,7 @@ const investorGrantColumns = [
3941
export default function OptionsPage() {
4042
const company = useCurrentCompany();
4143
const user = useCurrentUser();
44+
const pathname = usePathname();
4245
if (!user.roles.investor) forbidden();
4346
const [data] = trpc.equityGrants.list.useSuspenseQuery({
4447
companyId: company.id,
@@ -91,9 +94,11 @@ export default function OptionsPage() {
9194
},
9295
onSuccess: () => setTimeout(() => resendPaymentInstructions.reset(), 5000),
9396
});
97+
const currentLink = navLinks(user, company).find((link) => link.route === pathname);
9498

9599
return (
96100
<>
101+
{currentLink && <PageHeader currentLink={currentLink} />}
97102
{data.length === 0 ? (
98103
<Placeholder icon={CircleCheck}>You don't have any option grants right now.</Placeholder>
99104
) : (

0 commit comments

Comments
 (0)