From ed55c696cd083bfaa5429082a9c5edd4ebde0cd8 Mon Sep 17 00:00:00 2001
From: Sebastien Castiel <sebastien@castiel.me>
Date: Tue, 5 Dec 2023 17:39:05 -0500
Subject: First version

---
 src/app/groups/create/page.tsx | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 src/app/groups/create/page.tsx

(limited to 'src/app/groups/create/page.tsx')

diff --git a/src/app/groups/create/page.tsx b/src/app/groups/create/page.tsx
new file mode 100644
index 0000000..4f220d2
--- /dev/null
+++ b/src/app/groups/create/page.tsx
@@ -0,0 +1,29 @@
+import { GroupForm } from '@/components/group-form'
+import { Button } from '@/components/ui/button'
+import { createGroup } from '@/lib/api'
+import { groupFormSchema } from '@/lib/schemas'
+import { ChevronLeft } from 'lucide-react'
+import Link from 'next/link'
+import { redirect } from 'next/navigation'
+
+export default function CreateGroupPage() {
+  async function createGroupAction(values: unknown) {
+    'use server'
+    const groupFormValues = groupFormSchema.parse(values)
+    const group = await createGroup(groupFormValues)
+    redirect(`/groups/${group.id}`)
+  }
+
+  return (
+    <main>
+      <div className="mb-4">
+        <Button variant="ghost" asChild>
+          <Link href="/groups">
+            <ChevronLeft className="w-4 h-4 mr-2" /> Back to recent groups
+          </Link>
+        </Button>
+      </div>
+      <GroupForm onSubmit={createGroupAction} />
+    </main>
+  )
+}
-- 
cgit v1.3

