forked from M3-Academy/desafio-react-e-typescript
Merge pull request 'development' (#24) from development into main
Reviewed-on: #24
This commit is contained in:
commit
540d012305
@ -114,14 +114,6 @@
|
||||
text-transform: none;
|
||||
}
|
||||
}
|
||||
|
||||
&__socialMedia {
|
||||
height: 35px;
|
||||
|
||||
.socialMeida-site {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 2500px) {
|
||||
|
@ -110,10 +110,8 @@ const Contact = () => {
|
||||
</div>
|
||||
<div className={styles["form__input"]}>
|
||||
<label htmlFor="cpf">CPF</label>
|
||||
<Field
|
||||
id="cpf"
|
||||
name="cpf"
|
||||
render={({ field }: any) => (
|
||||
<Field id="cpf" name="cpf">
|
||||
{({ field }: any) => (
|
||||
<MaskedInput
|
||||
{...field}
|
||||
mask={cpfNumberMask}
|
||||
@ -122,7 +120,7 @@ const Contact = () => {
|
||||
type="text"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Field>
|
||||
<ErrorMessage
|
||||
component="span"
|
||||
name="cpf"
|
||||
@ -131,10 +129,8 @@ const Contact = () => {
|
||||
</div>
|
||||
<div className={styles["form__input"]}>
|
||||
<label htmlFor="birthDate">Data de Nascimento:</label>
|
||||
<Field
|
||||
id="birthDate"
|
||||
name="birthDate"
|
||||
render={({ field }: any) => (
|
||||
<Field id="birthDate" name="birthDate">
|
||||
{({ field }: any) => (
|
||||
<MaskedInput
|
||||
{...field}
|
||||
mask={bhirtDateMask}
|
||||
@ -143,7 +139,7 @@ const Contact = () => {
|
||||
type="text"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Field>
|
||||
<ErrorMessage
|
||||
component="span"
|
||||
name="birthDate"
|
||||
@ -152,10 +148,8 @@ const Contact = () => {
|
||||
</div>
|
||||
<div className={styles["form__input"]}>
|
||||
<label htmlFor="phone">Telefone:</label>
|
||||
<Field
|
||||
id="phone"
|
||||
name="phone"
|
||||
render={({ field }: any) => (
|
||||
<Field id="phone" name="phone">
|
||||
{({ field }: any) => (
|
||||
<MaskedInput
|
||||
{...field}
|
||||
mask={phoneNumberMask}
|
||||
@ -164,7 +158,7 @@ const Contact = () => {
|
||||
type="text"
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Field>
|
||||
<ErrorMessage
|
||||
component="span"
|
||||
name="phone"
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import styles from "./styles.module.scss";
|
||||
import { Formik, Form, Field, ErrorMessage, FormikHelpers } from "formik";
|
||||
import FormSchema from "../../schema/FormSchema";
|
||||
import { Formik, Form, Field, ErrorMessage } from "formik";
|
||||
import NewsletterSchema from "../../schema/NewsLetterSchema";
|
||||
|
||||
interface FormikValues {
|
||||
newsLetter: string;
|
||||
@ -12,8 +12,9 @@ const initialValues = {
|
||||
};
|
||||
|
||||
const NewsLetter = () => {
|
||||
const handleFormikSubmit = (values: FormikValues) => {
|
||||
const handleNewsletterSubmit = (values: FormikValues, { resetForm }: any) => {
|
||||
console.log(values);
|
||||
resetForm({ values: "" });
|
||||
};
|
||||
|
||||
return (
|
||||
@ -22,9 +23,9 @@ const NewsLetter = () => {
|
||||
<h1>Assine nossa Newsletter</h1>
|
||||
</div>
|
||||
<Formik
|
||||
onSubmit={handleFormikSubmit}
|
||||
onSubmit={handleNewsletterSubmit}
|
||||
initialValues={initialValues}
|
||||
validationSchema={FormSchema}
|
||||
validationSchema={NewsletterSchema}
|
||||
>
|
||||
<Form className={styles["newsLetter__container"]}>
|
||||
<Field
|
||||
@ -34,7 +35,7 @@ const NewsLetter = () => {
|
||||
placeholder="E-mail"
|
||||
/>
|
||||
<ErrorMessage component="span" name="newsLetter" />
|
||||
<button className={styles["newsLetter__button"]} type="submit">
|
||||
<button type="submit" className={styles["newsLetter__button"]}>
|
||||
Enviar
|
||||
</button>
|
||||
</Form>
|
||||
|
5
src/schema/NewsLetterSchema.ts
Normal file
5
src/schema/NewsLetterSchema.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import * as Yup from "yup";
|
||||
|
||||
export default Yup.object().shape({
|
||||
newsLetter: Yup.string().required("").email("e-Mail inválido"),
|
||||
});
|
Loading…
Reference in New Issue
Block a user