-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show forms and forms submissions on /forms/id page
- Loading branch information
1 parent
f0fa1c1
commit c0932ea
Showing
3 changed files
with
39 additions
and
1 deletion.
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
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,20 @@ | ||
import { validateRequest } from "~/lib/auth/validate-request"; | ||
import { redirects } from "~/lib/constants"; | ||
import { redirect } from "next/navigation"; | ||
import * as React from "react"; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default async function FormLayout({ children }: Props) { | ||
const { user } = await validateRequest(); | ||
|
||
if (!user) redirect(redirects.toLogin); | ||
|
||
return ( | ||
<div className="container flex min-h-[calc(100vh-180px)] flex-col gap-6 px-2 pt-6 md:flex-row md:px-4 lg:gap-10"> | ||
<main className="w-full">{children}</main> | ||
</div> | ||
); | ||
} |
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,18 @@ | ||
import { api } from "@/trpc/server"; | ||
|
||
export default async function FormPage({ params }: { params: { id: string } }) { | ||
const formSubmissions = await api.formData.all.query({ formId: params.id }); | ||
|
||
return ( | ||
<div> | ||
<div>My Form Id: {params.id}</div> | ||
<div>My Submittions</div> | ||
|
||
<div> | ||
{formSubmissions.map((f) => { | ||
return <div key={f.id}>{JSON.stringify(f.data as string)}</div>; | ||
})} | ||
</div> | ||
</div> | ||
); | ||
} |