Jam theme description

This commit is contained in:
MeowcaTheoRange 2024-04-25 13:17:32 -05:00
parent 7685cff9ee
commit aa6b18e95c
8 changed files with 49 additions and 5 deletions

View file

@ -9,6 +9,7 @@ export function Form({jamID, preset}:{jamID:string, preset:{
name: string,
description: string,
theme: string,
theme_description: string,
date_start: string,
date_end: string
}}) {
@ -93,6 +94,18 @@ export function Form({jamID, preset}:{jamID:string, preset:{
<p><small>Error: {formik.errors.theme}</small></p>
</ConditionalNull>
</div>
<div>
<p><label htmlFor="theme_description">Theme Description</label></p>
<textarea
id="theme_description"
name="theme_description"
onChange={formik.handleChange}
value={formik.values.theme_description}
/>
<ConditionalNull condition={formik.touched.theme_description != null && formik.errors.theme_description != null}>
<p><small>Error: {formik.errors.theme_description}</small></p>
</ConditionalNull>
</div>
<div>
<p><label htmlFor="date_start">Date Start</label></p>
<input

View file

@ -11,6 +11,7 @@ export function Form() {
name: '',
description: '',
theme: '',
theme_description: '',
date_start: '',
date_end: '',
},
@ -90,6 +91,18 @@ export function Form() {
<p><small>Error: {formik.errors.theme}</small></p>
</ConditionalNull>
</div>
<div>
<p><label htmlFor="theme_description">Theme Description</label></p>
<textarea
id="theme_description"
name="theme_description"
onChange={formik.handleChange}
value={formik.values.theme_description}
/>
<ConditionalNull condition={formik.touched.theme_description != null && formik.errors.theme_description != null}>
<p><small>Error: {formik.errors.theme_description}</small></p>
</ConditionalNull>
</div>
<div>
<p><label htmlFor="date_start">Date Start</label></p>
<input

View file

@ -39,7 +39,10 @@ export async function GET(request: NextRequest, {params}: {params: {jam:string}}
const started = Date.now() >= parseInt(jam.date_start);
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) jam.theme = "";
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) {
jam.theme = "";
jam.theme_description = "";
}
return Response.json(jam);
}
@ -113,6 +116,7 @@ export async function PATCH(request: NextRequest, {params}: {params: {jam:string
if (body.name != null && typeof body.name === 'string' && body.name.length >= 10 && body.name.length <= 2048) newBody.name = body.name;
if (body.description != null && typeof body.description === 'string' && body.description.length >= 10 && body.description.length <= 10000) newBody.description = body.description;
if (body.theme != null && typeof body.theme === 'string' && body.theme.length >= 2 && body.theme.length <= 255) newBody.theme = body.theme;
if (body.theme_description != null && typeof body.theme_description === 'string' && body.theme_description.length >= 10 && body.theme_description.length <= 10000) newBody.theme_description = body.theme_description;
if (body.date_start != null && typeof body.date_start === 'number') newBody.date_start = body.date_start;
if (body.date_end != null && typeof body.date_end === 'number') newBody.date_end = body.date_end;

View file

@ -39,7 +39,10 @@ export async function GET(request: NextRequest) {
jams.forEach((jam) => {
const started = Date.now() >= parseInt(jam.date_start);
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) jam.theme = "";
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) {
jam.theme = "";
jam.theme_description = "";
}
})
return Response.json(jams);
@ -96,7 +99,8 @@ export async function POST(request: NextRequest) {
if (body.author_id != null) te.push("author_id");
if (typeof body.name !== 'string' || body.name.length < 10 || body.name.length > 2048) te.push("name");
if (typeof body.description !== 'string' || body.description.length < 10 || body.description.length > 10000) te.push("description");
if (typeof body.theme !== 'string' || body.theme.length < 2 || body.theme.length > 10000) te.push("theme");
if (typeof body.theme !== 'string' || body.theme.length < 2 || body.theme.length > 255) te.push("theme");
if (typeof body.theme_description !== 'string' || body.theme_description.length < 10 || body.theme_description.length > 10000) te.push("theme_description");
if (typeof body.date_start !== 'number') te.push("date_start");
if (typeof body.date_end !== 'number') te.push("date_end");
if (body.created != null) te.push("created");
@ -114,6 +118,7 @@ export async function POST(request: NextRequest) {
name: newBody.name,
description: newBody.description,
theme: newBody.theme,
theme_description: newBody.theme_description,
date_start: newBody.date_start,
date_end: newBody.date_end,
created: Date.now()

View file

@ -64,7 +64,10 @@ export default async function Home({
.selectAll()
.executeTakeFirst() as unknown as JSONUserTable;
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) jam.theme = "";
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) {
jam.theme = "";
jam.theme_description = "";
}
let content = await db
.selectFrom('content')
@ -104,6 +107,7 @@ export default async function Home({
<div style={{textAlign: 'center'}}>
<p>The theme is:</p>
<h1>{jam.theme}</h1>
<p>{jam.theme_description}</p>
<ConditionalNull condition={existingUser != null && started && !ended}><p><a href={`/jams/new/content/${jam.id}`}>Submit something</a></p></ConditionalNull>
</div>
</ConditionalNull>

View file

@ -47,7 +47,10 @@ export default async function Home({
jams.forEach((jam) => {
const started = Date.now() >= parseInt(jam.date_start);
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) jam.theme = "";
if (!started && !existingUser?.admin && jam.author_id != existingUser?.id) {
jam.theme = "";
jam.theme_description = "";
}
})
return (

View file

@ -44,6 +44,7 @@ export interface JamTable {
date_end: number;
created: number;
theme: string;
theme_description: string;
}
export interface ContentTable {

View file

@ -26,6 +26,7 @@ export interface JSONJamTable {
date_end: string;
created: string;
theme: string;
theme_description: string;
}
export interface JSONContentTable {