Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions registration-form/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default [
'warn',
{ allowConstantExport: true },
],
'react/prop-types': 0,
},
},
]
39 changes: 38 additions & 1 deletion registration-form/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion registration-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
"preview": "vite preview"
},
"dependencies": {
"@hookform/resolvers": "^3.9.1",
"react": "^18.3.1",
"react-dom": "^18.3.1"
"react-dom": "^18.3.1",
"react-hook-form": "^7.53.2",
"zod": "^3.23.8"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
Expand Down
42 changes: 0 additions & 42 deletions registration-form/src/App.css

This file was deleted.

40 changes: 29 additions & 11 deletions registration-form/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
import { useState } from 'react'
import './App.css'
import style from "./App.module.css";
import { useState } from "react";
import { FormMain } from "./components/FormMain/FormMain";
import { FormResume } from "./components/FormResume/FormResume";

function App() {
const [isFormSubmitted, setIsFormSubmitted] = useState(false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, this form is unnecessary because this information is stored in the formData state.

const [formData, setFormData] = useState(null);

return (
<>
<div>
Registration form
</div>

</>
)
return (
<>
{!isFormSubmitted ? (
<>
<h1 className={style.title}>
Formularz zgłoszeniowy na kurs programowania
</h1>
<div className={style.container}>
<FormMain
setIsFormSubmitted={setIsFormSubmitted}
setFormData={setFormData}
/>
</div>
</>
) : (
<>
<h1 className={style.title}>Dane z formularza</h1>
<FormResume formData={formData} />
</>
)}
</>
);
}

export default App
export default App;
23 changes: 23 additions & 0 deletions registration-form/src/App.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.container {
/* display: inline-block; */
outline: 1px solid black;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
background-color: white;
padding: 20px;
border-radius: 10px;
width: 50vw;
}

.title {
color: white;
min-width: 800px;
text-align: center;
font-size: 2rem;
font-weight: 700;
padding: 1rem;
}


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion registration-form/src/assets/react.svg

This file was deleted.

10 changes: 10 additions & 0 deletions registration-form/src/components/FormButton/FormButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import style from "./FormButton.module.css";

export function FormButton({ type, children, onClick}) {

return (
<button type={type} onClick={onClick} className={style.button} >
{children}
</button>
);
}
15 changes: 15 additions & 0 deletions registration-form/src/components/FormButton/FormButton.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.button {
color: var(--color-main);
background-color: transparent;
border: 1px solid currentColor;
border-radius: 5px;
padding: 2px 4px;
cursor: pointer;
transition: all 0.3s;
width: 99%;
}

.button:hover {
color: white;
background-color: var(--color-main);
}
71 changes: 71 additions & 0 deletions registration-form/src/components/FormExperience/FormExperience.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { useFieldArray } from "react-hook-form";
import style from "./FormExperience.module.css"

export function FormExperience({
control,
register,
setValue,
errors,
classError
}) {
const skills = ["JavaScript", "Python", "Java", "other"];
const level = [1, 2, 3, 4, 5];

const { fields, append, remove } = useFieldArray({
control,
name: "experience",
});

return (
<div className={style.exp}>
<button className={style.expButton}
type="button"
onClick={(e) => {
e.preventDefault();
append({
skills: "JavaScript",
level: "1",
});
}}>
Dodaj doświadczenie
</button>
{errors.experience && <p className={classError}>{errors.experience.message}</p>}

{fields.map((field, index) => {
setValue(`experience.${index}.id`, field.id);
return (
<div className={style.exp} key={index}>
<select
className={style.expSelect}
{...register(`experience.${index}.skills`)}
id={`skills-${index}`}>
{skills.map((item) => (
<option className={style.expSelect} key={item} value={item}>
{item}
</option>
))}
</select>
<select
className={style.expSelect}
{...register(`experience.${index}.level`)}
id={`level-${index}`}>
{level.map((item) => (
<option key={item} value={item}>
{item}
</option>
))}
</select>
<button
className={style.expButtonDelete}
onClick={(e) => {
e.preventDefault();
remove(index);
}}>
Usuń
</button>
</div>
);
})}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.exp {
color: var(--color-main);
padding: 5px 2px;
}

button {
cursor: pointer;
}

.expButton {
background-color: forestgreen;
color: white;
width: 99%;
min-height: 20px;
padding: 2px 10px;
border-radius: 6px;

}

.expSelect {
color: var(--color-main);
border-radius: 6px;
border: 0.5px solid;
width: 33%;
text-align: center;

}

.expButtonDelete {
background-color: crimson;
color: white;
min-height: 25px;
width: 33%;
border-radius: 6px;
border: none;

}
17 changes: 17 additions & 0 deletions registration-form/src/components/FormInput/FormInput.jsx
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems to be oddly formatted. Please verify the functionality of Prettier.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function FormInput({ register, type, name, placeholder, error, className, classError }) {

return (
<>
<input
id={name}
name={name}
{...register(name)}
type={type}
placeholder={placeholder}
className={className}

/>
{error && <p className={classError}>{error.message}</p>}
</>
);
}
Loading