changed the topic card, the form and .gitignore
Signed-off-by: Alex Stan <alex.stan.2010@proton.me>
This commit is contained in:
parent
b9ba572572
commit
4dbdf4835b
3 changed files with 13 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -34,3 +34,4 @@ yarn-error.log*
|
||||||
# typescript
|
# typescript
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
app/test/*
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
'use client';
|
'use client';
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
const Form = <T,>({ initialData, onSubmit }) => {
|
const Form = <T,>({ initialData, submitFunction }) => {
|
||||||
const [formData, setFormData] = useState( initialData );
|
const [formData, setFormData] = useState( initialData );
|
||||||
|
|
||||||
const handleSubmit = (event) => {
|
const handleSubmit = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
//q = formData;
|
//q = formData;
|
||||||
|
@ -13,7 +13,7 @@ const Form = <T,>({ initialData, onSubmit }) => {
|
||||||
|
|
||||||
//console.log( `Adding question ${JSON.stringify(q)}` );
|
//console.log( `Adding question ${JSON.stringify(q)}` );
|
||||||
|
|
||||||
onSubmit( formData );
|
await submitFunction( formData );
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
|
@ -27,13 +27,13 @@ const Form = <T,>({ initialData, onSubmit }) => {
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="flex">
|
<form onSubmit={handleSubmit} className="flex">
|
||||||
<div>
|
<div>
|
||||||
{Object.entries( initialData ).map( (key, val) => {
|
{Object.entries( initialData ).map( (elem) => {
|
||||||
return(
|
return(
|
||||||
<input
|
<input
|
||||||
type = { typeof( val ) == typeof( 0 ) ? "number" : "text" /* pretty hacky, we should change this */ }
|
type = { typeof( elem[1] ) == typeof( 0 ) ? "number" : "text" /* pretty hacky, we should change this */ }
|
||||||
id = {key[0]}
|
id = {elem[0]}
|
||||||
name = {key[0]}
|
name = {elem[0]}
|
||||||
value = {formData[key[0]]}
|
value = {formData[elem[0]]}
|
||||||
onChange = {handleChange}
|
onChange = {handleChange}
|
||||||
required
|
required
|
||||||
/>)})}
|
/>)})}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
const TopicCard = ({ title, children, link }) => {
|
const TopicCard = ({ title, children, link }) => {
|
||||||
return(
|
return(
|
||||||
<div className="mx-auto mt-16 max-w-2xl rounded-3xl sm:mt-20 lg:mx-0 lg:flex lg:max-w-none relative isolate overflow-hidden bg-gray-900 px-6 pt-16 shadow-2xl sm:rounded-3xl sm:px-16 md:pt-24 lg:flex lg:gap-x-20 lg:px-24 lg:pt-0">
|
<div className="mx-auto mt-16 max-w-2xl rounded-3xl sm:mt-20 lg:mx-0 lg:flex lg:max-w-none relative isolate overflow-hidden bg-gray-900 px-6 pt-16 shadow-2xl sm:rounded-3xl sm:px-16 md:pt-24 lg:flex lg:gap-x-20 lg:px-24 lg:pt-0" style={{marginTop: '20px', paddingTop: '0px', paddingBottom: '24px'}}>
|
||||||
<svg
|
<svg
|
||||||
viewBox="0 0 1024 1024"
|
viewBox="0 0 1024 1024"
|
||||||
className="absolute left-1/2 top-1/2 -z-10 h-[64rem] w-[64rem] -translate-y-1/2 [mask-image:radial-gradient(closest-side,white,transparent)] sm:left-full sm:-ml-80 lg:left-1/2 lg:ml-0 lg:-translate-x-1/2 lg:translate-y-0"
|
className="absolute left-1/2 top-1/2 -z-10 h-[64rem] w-[64rem] -translate-y-1/2 [mask-image:radial-gradient(closest-side,white,transparent)] sm:left-full sm:-ml-80 lg:left-1/2 lg:ml-0 lg:-translate-x-1/2 lg:translate-y-0"
|
||||||
|
@ -21,24 +20,16 @@ const TopicCard = ({ title, children, link }) => {
|
||||||
{children}
|
{children}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="-mt-2 p-2 lg:mt-0 lg:w-full lg:max-w-md lg:flex-shrink-0">
|
<div className="-mt-2 p-2 lg:mt-0 lg:w-full lg:max-w-md lg:flex-shrink-0 lg:flex lg:flex-col lg:justify-center">
|
||||||
<div className="rounded-2xl bg-gray-50 py-10 text-center ring-1 ring-inset ring-gray-900/5 lg:flex lg:flex-col lg:justify-center lg:py-16">
|
|
||||||
<div className="mx-auto max-w-xs px-8">
|
|
||||||
<p className="mt-6 flex items-baseline justify-center gap-x-2">
|
|
||||||
<span className="text-5xl font-bold tracking-tight text-gray-900">Start</span>
|
|
||||||
<span className="text-sm font-semibold leading-6 tracking-wide text-gray-900">now!</span>
|
|
||||||
</p>
|
|
||||||
<a
|
<a
|
||||||
href={link}
|
href={link}
|
||||||
className="mt-10 block w-full rounded-md bg-indigo-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
|
className="mt-10 block w-full rounded-md bg-blue-500 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
|
||||||
>
|
>
|
||||||
Begin
|
Begin
|
||||||
</a>
|
</a>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TopicCard;
|
export default TopicCard;
|
||||||
|
|
Loading…
Reference in a new issue