Skip to content

Commit 9b1a07e

Browse files
committed
initial version for migrationof mainLayout
1 parent ab2c8b5 commit 9b1a07e

File tree

54 files changed

+1300
-1186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1300
-1186
lines changed

frontend/app/document_templates/TemplateSelector.tsx renamed to frontend/app/(dashboardLayout)/document_templates/TemplateSelector.tsx

File renamed without changes.

frontend/app/document_templates/[id]/page.tsx renamed to frontend/app/(dashboardLayout)/document_templates/[id]/page.tsx

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { InformationCircleIcon } from "@heroicons/react/24/outline";
44
import { ArrowLeftIcon } from "lucide-react";
55
import Link from "next/link";
66
import { useParams, useRouter } from "next/navigation";
7-
import { useState } from "react";
7+
import { useEffect, useState } from "react";
88
import { z } from "zod";
9-
import MainLayout from "@/components/layouts/Main";
109
import MutationButton from "@/components/MutationButton";
1110
import { Alert, AlertDescription } from "@/components/ui/alert";
1211
import { Button } from "@/components/ui/button";
1312
import { useCurrentCompany } from "@/global";
1413
import { DocumentTemplateType, trpc } from "@/trpc/client";
14+
import { useLayoutStore } from "@/components/layouts/LayoutStore";
1515

1616
const templateSchema = z.object({
1717
name: z.string(),
@@ -144,66 +144,69 @@ export default function EditTemplatePage() {
144144
},
145145
);
146146
}
147+
const setTitle = useLayoutStore((state) => state.setTitle);
148+
const setHeaderActions = useLayoutStore((state) => state.setHeaderActions);
149+
useEffect(() => {
150+
setTitle(template.companyId !== null ? `${id ? "Edit" : "New"} ${template.name}` : `Default ${template.name}`);
151+
setHeaderActions(
152+
<Button variant="outline" asChild>
153+
<Link href="/documents">
154+
<ArrowLeftIcon className="size-4" />
155+
Back to documents
156+
</Link>
157+
</Button>,
158+
);
159+
}, [template.name, template.companyId, id]);
160+
147161
return (
148-
<MainLayout
149-
title={template.companyId !== null ? `${id ? "Edit" : "New"} ${template.name}` : `Default ${template.name}`}
150-
headerActions={
151-
<Button variant="outline" asChild>
152-
<Link href="/documents">
153-
<ArrowLeftIcon className="size-4" />
154-
Back to documents
155-
</Link>
156-
</Button>
157-
}
158-
>
159-
<div className="grid gap-6">
160-
{template.companyId === null ? (
161-
<Alert variant="destructive">
162-
<InformationCircleIcon />
163-
<AlertDescription>
164-
<div className="flex items-center justify-between gap-4">
165-
<p>This is our default template. Replace it with your own to fully customize it.</p>
166-
<MutationButton
167-
size="small"
168-
idleVariant="critical"
169-
mutation={trpc.documents.templates.create.useMutation({
170-
onSuccess: (id) => {
171-
router.push(`/document_templates/${id}`);
172-
},
173-
})}
174-
param={{
175-
companyId: company.id,
176-
name: template.name,
177-
type: template.type,
178-
}}
179-
>
180-
Replace default template
181-
</MutationButton>
182-
</div>
183-
</AlertDescription>
184-
</Alert>
185-
) : docusealTemplate?.documents.length && !isSignable(docusealTemplate) ? (
186-
<Alert>
187-
<InformationCircleIcon />
188-
<AlertDescription>
189-
To use this template, add at least the signature fields for both parties below.
190-
</AlertDescription>
191-
</Alert>
192-
) : null}
193-
<DocusealBuilder
194-
token={token}
195-
withSendButton={false}
196-
withSignYourselfButton={false}
197-
withTitle={false}
198-
roles={Array.from(new Set(requiredFields.map((field) => field.role)))}
199-
fieldTypes={["text", "date", "checkbox"]}
200-
fields={fields}
201-
requiredFields={requiredFields}
202-
onSave={(data) => save(templateSchema.parse(data))}
203-
onLoad={(data) => setDocusealTemplate(templateSchema.parse(data))}
204-
preview={template.companyId === null}
205-
autosave
206-
customCss={`
162+
<div className="grid gap-6">
163+
{template.companyId === null ? (
164+
<Alert variant="destructive">
165+
<InformationCircleIcon />
166+
<AlertDescription>
167+
<div className="flex items-center justify-between gap-4">
168+
<p>This is our default template. Replace it with your own to fully customize it.</p>
169+
<MutationButton
170+
size="small"
171+
idleVariant="critical"
172+
mutation={trpc.documents.templates.create.useMutation({
173+
onSuccess: (id) => {
174+
router.push(`/document_templates/${id}`);
175+
},
176+
})}
177+
param={{
178+
companyId: company.id,
179+
name: template.name,
180+
type: template.type,
181+
}}
182+
>
183+
Replace default template
184+
</MutationButton>
185+
</div>
186+
</AlertDescription>
187+
</Alert>
188+
) : docusealTemplate?.documents.length && !isSignable(docusealTemplate) ? (
189+
<Alert>
190+
<InformationCircleIcon />
191+
<AlertDescription>
192+
To use this template, add at least the signature fields for both parties below.
193+
</AlertDescription>
194+
</Alert>
195+
) : null}
196+
<DocusealBuilder
197+
token={token}
198+
withSendButton={false}
199+
withSignYourselfButton={false}
200+
withTitle={false}
201+
roles={Array.from(new Set(requiredFields.map((field) => field.role)))}
202+
fieldTypes={["text", "date", "checkbox"]}
203+
fields={fields}
204+
requiredFields={requiredFields}
205+
onSave={(data) => save(templateSchema.parse(data))}
206+
onLoad={(data) => setDocusealTemplate(templateSchema.parse(data))}
207+
preview={template.companyId === null}
208+
autosave
209+
customCss={`
207210
.mx-auto:has(> #main_container) {
208211
padding-left: 0px;
209212
}
@@ -342,8 +345,7 @@ export default function EditTemplatePage() {
342345
color: var(--accent-foreground, black) !important;
343346
}
344347
`}
345-
/>
346-
</div>
347-
</MainLayout>
348+
/>
349+
</div>
348350
);
349351
}

frontend/app/documents/DocusealForm.tsx renamed to frontend/app/(dashboardLayout)/documents/DocusealForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DocusealForm } from "@docuseal/react";
2-
import type React from "react";
2+
import React from "react";
33
import { useCurrentUser } from "@/global";
44

55
// Define and export the centralized custom CSS

frontend/app/documents/page.tsx renamed to frontend/app/(dashboardLayout)/documents/page.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ import Link from "next/link";
1616
import { useRouter } from "next/navigation";
1717
import { useQueryState } from "nuqs";
1818
import React, { useEffect, useMemo, useState } from "react";
19-
import DocusealForm, { customCss } from "@/app/documents/DocusealForm";
19+
import DocusealForm, { customCss } from "@/app/(dashboardLayout)/documents/DocusealForm";
2020
import DataTable, { createColumnHelper, filterValueSchema, useTable } from "@/components/DataTable";
2121
import { Input } from "@/components/ui/input";
22-
import MainLayout from "@/components/layouts/Main";
2322
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
2423
import MutationButton, { MutationStatusButton } from "@/components/MutationButton";
2524
import Placeholder from "@/components/Placeholder";
@@ -38,6 +37,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
3837
import { useForm } from "react-hook-form";
3938
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
4039
import { storageKeys } from "@/models/constants";
40+
import { useLayoutStore } from "@/components/layouts/LayoutStore";
4141

4242
type Document = RouterOutput["documents"]["list"][number];
4343
type SignableDocument = Document & { docusealSubmissionId: number };
@@ -338,22 +338,25 @@ export default function DocumentsPage() {
338338
});
339339

340340
const filingDueDateFor1099DIV = new Date(currentYear, 2, 31);
341+
const setTitle = useLayoutStore((state) => state.setTitle);
342+
const setHeaderActions = useLayoutStore((state) => state.setHeaderActions);
343+
useEffect(() => {
344+
setTitle("Documents");
345+
setHeaderActions(
346+
<>
347+
{isCompanyRepresentative && documents.length === 0 ? <EditTemplates /> : null}
348+
{user.roles.administrator && company.flags.includes("lawyers") ? (
349+
<Button onClick={() => setShowInviteModal(true)}>
350+
<BriefcaseBusiness className="size-4" />
351+
Invite lawyer
352+
</Button>
353+
) : null}
354+
</>,
355+
);
356+
}, [isCompanyRepresentative, documents.length, user.roles.administrator, company.flags]);
341357

342358
return (
343-
<MainLayout
344-
title="Documents"
345-
headerActions={
346-
<>
347-
{isCompanyRepresentative && documents.length === 0 ? <EditTemplates /> : null}
348-
{user.roles.administrator && company.flags.includes("lawyers") ? (
349-
<Button onClick={() => setShowInviteModal(true)}>
350-
<BriefcaseBusiness className="size-4" />
351-
Invite lawyer
352-
</Button>
353-
) : null}
354-
</>
355-
}
356-
>
359+
<>
357360
<div className="grid gap-4">
358361
{canSign ? null : (
359362
<Alert>
@@ -424,7 +427,7 @@ export default function DocumentsPage() {
424427
</Form>
425428
</DialogContent>
426429
</Dialog>
427-
</MainLayout>
430+
</>
428431
);
429432
}
430433

frontend/app/equity/DividendStatusIndicator.tsx renamed to frontend/app/(dashboardLayout)/equity/DividendStatusIndicator.tsx

File renamed without changes.

frontend/app/equity/EquityGrantExerciseStatusIndicator.tsx renamed to frontend/app/(dashboardLayout)/equity/EquityGrantExerciseStatusIndicator.tsx

File renamed without changes.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
import type { RouterOutput } from "@/trpc";
1919
import { trpc } from "@/trpc/client";
2020
import { formatOwnershipPercentage } from "@/utils/numbers";
21-
import EquityLayout from "../Layout";
2221

2322
type Data = RouterOutput["capTable"]["show"];
2423

@@ -159,7 +158,7 @@ export default function CapTable() {
159158
const shareClassesTable = useTable({ data: shareClassesData, columns: shareClassesColumns });
160159

161160
return (
162-
<EquityLayout>
161+
<>
163162
{selectedInvestors.length > 0 && (
164163
<Alert className="mb-4">
165164
<AlertDescription className="flex items-center justify-between">
@@ -184,6 +183,6 @@ export default function CapTable() {
184183
<DataTable table={shareClassesTable} caption="Share Classes" />
185184
</div>
186185
)}
187-
</EquityLayout>
186+
</>
188187
);
189188
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ 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 EquityLayout from "../Layout";
1211

1312
const columnHelper =
1413
createColumnHelper<RouterOutput["convertibleSecurities"]["list"]["convertibleSecurities"][number]>();
@@ -30,12 +29,12 @@ export default function Convertibles() {
3029
const table = useTable({ columns, data: data.convertibleSecurities });
3130

3231
return (
33-
<EquityLayout>
32+
<>
3433
{data.convertibleSecurities.length > 0 ? (
3534
<DataTable table={table} />
3635
) : (
3736
<Placeholder icon={CircleCheck}>You do not hold any convertible securities.</Placeholder>
3837
)}
39-
</EquityLayout>
38+
</>
4039
);
4140
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use client";
2+
import { useLayoutStore } from "@/components/layouts/LayoutStore";
3+
import React, { useEffect } from "react";
4+
5+
export default function Layout({ children }: { children: React.ReactNode }) {
6+
const setTitle = useLayoutStore((state) => state.setTitle);
7+
const setHeaderActions = useLayoutStore((state) => state.setHeaderActions);
8+
useEffect(() => {
9+
setTitle("Dividend");
10+
setHeaderActions(null);
11+
}, []);
12+
return children;
13+
}

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

Lines changed: 11 additions & 8 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 from "react";
5-
import DividendStatusIndicator from "@/app/equity/DividendStatusIndicator";
4+
import React, { useEffect } from "react";
5+
import DividendStatusIndicator from "@/app/(dashboardLayout)/equity/DividendStatusIndicator";
66
import DataTable, { createColumnHelper, useTable } from "@/components/DataTable";
7-
import MainLayout from "@/components/layouts/Main";
87
import { useCurrentCompany } from "@/global";
98
import type { RouterOutput } from "@/trpc";
109
import { trpc } from "@/trpc/client";
1110
import { formatMoneyFromCents } from "@/utils/formatMoney";
11+
import { useLayoutStore } from "@/components/layouts/LayoutStore";
1212

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

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

44-
return (
45-
<MainLayout title="Dividend">
46-
<DataTable table={table} onRowClicked={(row) => router.push(rowLink(row))} />
47-
</MainLayout>
48-
);
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))} />;
4952
}

0 commit comments

Comments
 (0)