diff --git a/src/app/semana/admin/palestra/page.tsx b/src/app/semana/admin/palestra/page.tsx index ff4c5d8..a9d61f3 100644 --- a/src/app/semana/admin/palestra/page.tsx +++ b/src/app/semana/admin/palestra/page.tsx @@ -1,3 +1,5 @@ +import PalestrasForms from '@/components/palestras/palestras_forms' + export default function PalestraPage() { - return <> + return } diff --git a/src/components/palestras/palestras_forms.tsx b/src/components/palestras/palestras_forms.tsx new file mode 100644 index 0000000..48647fc --- /dev/null +++ b/src/components/palestras/palestras_forms.tsx @@ -0,0 +1,137 @@ +'use client' + +import React from 'react' +import { useState, MouseEventHandler } from 'react' +import PalestrasLabel from './palestras_label' + +export default function PalestrasForms() { + const [numPalestrantes, setNumPalestrantes] = useState(1) // Por Default + + /* + const [erroPalestrantes, setErroPalestrantes] = useState('') + async function cadastrar_palestra(formData: FormData) { + //const formData = new FormData(event.currentTarget) + const title = formData.get('title') + const day = formData.get('data') + + const name: string[] = [] + for (let i = 0; i < numPalestrantes; i++) { + const nome = formData.get(`name-${i}`) + if (nome) { + name.push(nome.toString()) + } + } + + const response = await fetch('/api/atividade/', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + title: title, + name: name, + day: day, + }), + }) + + const res = await response.json() + } + */ + + function handleNumPalestrantes() { + setNumPalestrantes(numPalestrantes + 1); + } + + function removePalestrantes() { + setNumPalestrantes(numPalestrantes - 1); + } + + return ( + <> +
+
+

Adicionar Palestra

+ + + + {[...Array(numPalestrantes)].map((_, index) => ( + + + ))} + + {numPalestrantes < 20 && ( +
+ +
)} + + {numPalestrantes > 1 && ( +
+ +
+ )} + +
+ + + +
+ +
+ +
+
+
+ + ) +} diff --git a/src/components/palestras/palestras_label.tsx b/src/components/palestras/palestras_label.tsx new file mode 100644 index 0000000..cdc4b26 --- /dev/null +++ b/src/components/palestras/palestras_label.tsx @@ -0,0 +1,24 @@ +interface PalestrasLabelProps { + value : string; + label : string; + type : string; +} + +export default function PalestrasLabel({ value, label, type} : PalestrasLabelProps) { + return ( +
+ + + +
+ ); +} \ No newline at end of file diff --git a/src/lib/submit.ts b/src/lib/submit.ts new file mode 100644 index 0000000..0750cb5 --- /dev/null +++ b/src/lib/submit.ts @@ -0,0 +1,7 @@ +import type { NextApiRequest, NextApiResponse } from 'next' + +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + const data = req.body + const id = await createItem(data) + res.status(200).json({ id }) +}