Skip to content

Commit

Permalink
feat: show forms and forms submissions on /forms/id page
Browse files Browse the repository at this point in the history
  • Loading branch information
ephraimduncan committed Feb 19, 2024
1 parent f0fa1c1 commit c0932ea
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/(main)/dashboard/_components/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function Posts({ promises }: PostsProps) {

<div className="flex flex-col space-y-2">
{forms.map((form) => (
<Link href={`/form/${form.id}`}>
<Link href={`/form/${form.id}`} key={form.id}>
{/* <pre>{JSON.stringify(form, null, 2)}</pre> */}
Name: {form.title}
</Link>
Expand Down
20 changes: 20 additions & 0 deletions src/app/(main)/form/[id]/layout.tsx
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>
);
}
18 changes: 18 additions & 0 deletions src/app/(main)/form/[id]/page.tsx
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>
);
}

0 comments on commit c0932ea

Please sign in to comment.