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, name: string,
description: string, description: string,
theme: string, theme: string,
theme_description: string,
date_start: string, date_start: string,
date_end: string date_end: string
}}) { }}) {
@ -93,6 +94,18 @@ export function Form({jamID, preset}:{jamID:string, preset:{
<p><small>Error: {formik.errors.theme}</small></p> <p><small>Error: {formik.errors.theme}</small></p>
</ConditionalNull> </ConditionalNull>
</div> </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> <div>
<p><label htmlFor="date_start">Date Start</label></p> <p><label htmlFor="date_start">Date Start</label></p>
<input <input

View file

@ -11,6 +11,7 @@ export function Form() {
name: '', name: '',
description: '', description: '',
theme: '', theme: '',
theme_description: '',
date_start: '', date_start: '',
date_end: '', date_end: '',
}, },
@ -90,6 +91,18 @@ export function Form() {
<p><small>Error: {formik.errors.theme}</small></p> <p><small>Error: {formik.errors.theme}</small></p>
</ConditionalNull> </ConditionalNull>
</div> </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> <div>
<p><label htmlFor="date_start">Date Start</label></p> <p><label htmlFor="date_start">Date Start</label></p>
<input <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); 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); 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.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.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 != 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_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; 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) => { jams.forEach((jam) => {
const started = Date.now() >= parseInt(jam.date_start); 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); return Response.json(jams);
@ -96,7 +99,8 @@ export async function POST(request: NextRequest) {
if (body.author_id != null) te.push("author_id"); 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.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.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_start !== 'number') te.push("date_start");
if (typeof body.date_end !== 'number') te.push("date_end"); if (typeof body.date_end !== 'number') te.push("date_end");
if (body.created != null) te.push("created"); if (body.created != null) te.push("created");
@ -114,6 +118,7 @@ export async function POST(request: NextRequest) {
name: newBody.name, name: newBody.name,
description: newBody.description, description: newBody.description,
theme: newBody.theme, theme: newBody.theme,
theme_description: newBody.theme_description,
date_start: newBody.date_start, date_start: newBody.date_start,
date_end: newBody.date_end, date_end: newBody.date_end,
created: Date.now() created: Date.now()

View file

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

View file

@ -47,7 +47,10 @@ export default async function Home({
jams.forEach((jam) => { jams.forEach((jam) => {
const started = Date.now() >= parseInt(jam.date_start); 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 ( return (

View file

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

View file

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