-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
814 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SafeSigningForm } from "@/components/safe/safe-signing-form"; | ||
import { SafeTemplateRenderer } from "@/components/safe/safe-template-render"; | ||
import { SigningFieldRenderer } from "@/components/signing-field/signing-field-renderer"; | ||
import { Button } from "@/components/ui/button"; | ||
import { SafeSigningFieldProvider } from "@/providers/safe-signing-field-provider"; | ||
import { api } from "@/trpc/server"; | ||
|
||
export default async function SafeSignPage({ | ||
params, | ||
}: { params: { token: string } }) { | ||
const fields = await api.safe.getSigningFields.query({ token: params.token }); | ||
|
||
return ( | ||
<SafeSigningFieldProvider safeId={fields.safeId} token={params.token}> | ||
<div className="flex min-h-screen bg-gray-50"> | ||
<div className="flex h-full flex-grow flex-col"> | ||
<div className="mx-auto min-h-full w-full px-5 py-10 lg:px-8 2xl:max-w-screen-xl"> | ||
<div className="grid grid-cols-12"> | ||
<div className="col-span-12 "> | ||
<SafeTemplateRenderer /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="sticky top-0 flex min-h-full w-80 flex-col lg:border-l"> | ||
<SafeSigningForm> | ||
<SigningFieldRenderer fields={fields.fields} /> | ||
<Button type="submit">Complete signing</Button> | ||
</SafeSigningForm> | ||
</div> | ||
</div> | ||
</SafeSigningFieldProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use client"; | ||
|
||
import type { SafeSigningFieldForm } from "@/providers/safe-signing-field-provider"; | ||
import { api } from "@/trpc/react"; | ||
import { useRouter } from "next/navigation"; | ||
import type { ReactNode } from "react"; | ||
import { useFormContext } from "react-hook-form"; | ||
import { toast } from "sonner"; | ||
|
||
interface SafeSigningFormProps { | ||
children: ReactNode; | ||
} | ||
|
||
export function SafeSigningForm({ children }: SafeSigningFormProps) { | ||
const { handleSubmit } = useFormContext<SafeSigningFieldForm>(); | ||
const router = useRouter(); | ||
const { mutate } = api.safe.sign.useMutation({ | ||
onSuccess() { | ||
toast.success("🎉 Great job, you are done signing this document."); | ||
router.push("/"); | ||
}, | ||
}); | ||
|
||
const onSubmit = (values: SafeSigningFieldForm) => { | ||
mutate({ | ||
data: values.fieldValues, | ||
safeId: values.safeId, | ||
token: values.token, | ||
}); | ||
}; | ||
|
||
return ( | ||
<form | ||
onSubmit={handleSubmit(onSubmit)} | ||
className="flex flex-col gap-y-4 px-2 py-10" | ||
> | ||
{children} | ||
</form> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use client"; | ||
|
||
import { PDFViewer } from "@react-pdf/renderer"; | ||
import { PostMoneyDiscount } from "./templates"; | ||
|
||
export function SafeTemplateRenderer() { | ||
return ( | ||
<PDFViewer | ||
className="w-full h-screen border-none rounded-md" | ||
showToolbar={false} | ||
> | ||
<PostMoneyDiscount | ||
options={{ | ||
author: "Y Combinator", | ||
creator: "Captable, Inc.", | ||
producer: "Captable, Inc.", | ||
title: "YC SAFE - Post Money Discount", | ||
subject: "YC SAFE - Post Money Discount", | ||
keywords: "YC, SAFE, Post Money, Discount", | ||
}} | ||
investor={{ | ||
name: "Puru Dahal", | ||
email: "", | ||
}} | ||
investment={100000} | ||
discountRate={10} | ||
date={new Date().toISOString()} | ||
company={{ | ||
name: "Company Inc.", | ||
state: "CA", | ||
}} | ||
/> | ||
</PDFViewer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.