Пересборка контактной формы, вынос полей в отдельный компонент

This commit is contained in:
Ifraim Solomonov committed 2024-02-28 14:20:44 +03:00
1 parent 87596e4411
commit 9e1c2c385a
8 files changed
+173 -96

No files matched your search

@@ -0,0 +1,59 @@
import { Form } from "react-router-dom";
import Field from "../Field";
import "./ContactForm.styles.scss";
import { fileUpload } from "../../assets/images";
const mock = [
{
id: 1,
type: "text",
name: "name",
placeholder: "Имя",
},
{
id: 2,
type: "email",
name: "email",
placeholder: "E-mail",
},
{
id: 3,
type: "textarea",
name: "text",
placeholder: "Опишите в этом поле свой проект и, по возможности, прикрепите файл с ТЗ",
},
{
id: 4,
type: "file",
name: "file",
icon: fileUpload,
},
{
id: 5,
type: "submit",
}
];
function ContactForm({ fields = mock }) {
return (
<Form method="post" className="half contact-form">
<h2>Свяжитесь с нами!</h2>
<div className="inputs">
{fields.map(item =>
<Field
key={item.id}
type={item.type}
name={item.name}
placeholder={item.placeholder}
icon={item.icon}
/>
)}
</div>
</Form>
);
}
export default ContactForm;