diff --git a/src/app/jams/(manip)/new/content/[jamid]/components/form.tsx b/src/app/jams/(manip)/new/content/[jamid]/components/form.tsx new file mode 100644 index 0000000..0750f30 --- /dev/null +++ b/src/app/jams/(manip)/new/content/[jamid]/components/form.tsx @@ -0,0 +1,36 @@ +'use client'; +import React from "react"; +import { useFormik } from "formik"; + +export function Form() { + const formik = useFormik({ + initialValues: { + email: '', + }, + onSubmit: values => { + alert(JSON.stringify(values, null, 2)); + }, + }); + + return ( +
+ ); +} \ No newline at end of file diff --git a/src/app/jams/(manip)/new/content/[jamid]/page.tsx b/src/app/jams/(manip)/new/content/[jamid]/page.tsx index 193afd5..02ea9f7 100644 --- a/src/app/jams/(manip)/new/content/[jamid]/page.tsx +++ b/src/app/jams/(manip)/new/content/[jamid]/page.tsx @@ -1,19 +1,79 @@ + +import { Conditional, ConditionalNull } from "@/components/utility/Conditional"; import { MainLayout } from "@/layout/MainLayout/MainLayout"; +import { db } from "@/lib/mastoauth/kysely"; +import { JSONJamTable } from "@/lib/mastoauth/realtypes"; +import { cookies } from "next/headers"; +import { notFound, redirect } from "next/navigation"; +import { Form } from "./components/form"; export default async function Home({ - params, - searchParams + params }: { params: { - content: string - }, - searchParams: { - until: string + jamid: string } }) { + const cookieStore = cookies(); + const token = cookieStore.get('token')?.value; + let existingUser; + if (token != null) { + let existingToken = await db + .selectFrom('tokens') + .where('tokens.id', '=', token) + .select('owner') + .executeTakeFirst(); + + if (existingToken != null) { + existingUser = await db + .selectFrom('users') + .where('users.id', '=', existingToken.owner) + .selectAll() + .executeTakeFirst(); + } + } + + const jamid = params.jamid; + + if (jamid == null) return notFound(); + + // It's a JSONJamTable. I don't know why TS hates `number` => `string` conversion. + let parentJam = await db + .selectFrom('jams') + .where('jams.id', '=', jamid) + .selectAll() + .executeTakeFirst() as unknown as JSONJamTable; + + // const started = Date.now() >= parseInt(parentJam.date_start); + // const ended = Date.now() >= parseInt(parentJam.date_end); + const started = true; + const ended = false; + + if (!started || ended) return ( +The jam starts at {new Date(parseInt(parentJam.date_start)).toLocaleString('en-us', { + timeZoneName: "long" + })}
+The jam ended at {new Date(parseInt(parentJam.date_start)).toLocaleString('en-us', { + timeZoneName: "long" + })}
+Submit something to {parentJam.name}
+Logged in as {existingUser?.username}@{existingUser?.instance}
+