From be31f120e62d230640d42ce313fe7e67a34209a1 Mon Sep 17 00:00:00 2001 From: devartes Date: Sat, 14 Jan 2023 10:52:16 -0300 Subject: [PATCH] refactor: organizando arquivos do yup em uma pasta --- src/components/Footer/Newsletter.tsx | 8 ++++---- src/components/Main/Contato/Contato.tsx | 2 +- src/{components/Main/schema.tsx => schema/FormSchema.tsx} | 0 .../Footer/schema.tsx => schema/NewsletterSchema.tsx} | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename src/{components/Main/schema.tsx => schema/FormSchema.tsx} (100%) rename src/{components/Footer/schema.tsx => schema/NewsletterSchema.tsx} (67%) diff --git a/src/components/Footer/Newsletter.tsx b/src/components/Footer/Newsletter.tsx index caf5edf..2ecb9f7 100644 --- a/src/components/Footer/Newsletter.tsx +++ b/src/components/Footer/Newsletter.tsx @@ -1,13 +1,13 @@ import styles from "./styles/Footer.module.scss"; import { Formik, Field, Form } from "formik"; -import schema from "./schema"; +import schema from "../../schema/NewsletterSchema"; interface NewsletterArea { - email: string; + newsletteremail: string; } const initialValues = { - email: "", + newsletteremail: "", }; const Newsletter = () => { @@ -23,7 +23,7 @@ const Newsletter = () => { assine nossa newsletter
- +
diff --git a/src/components/Main/Contato/Contato.tsx b/src/components/Main/Contato/Contato.tsx index f5b57ef..ad0f791 100644 --- a/src/components/Main/Contato/Contato.tsx +++ b/src/components/Main/Contato/Contato.tsx @@ -1,5 +1,5 @@ import { Formik, Field, Form } from "formik"; -import schema from "../schema"; +import schema from "../../../schema/FormSchema"; import styles from "../styles/Main.module.scss"; import { FormField } from "../Contato/FormContentField/FormContentField"; import { useState } from "react"; diff --git a/src/components/Main/schema.tsx b/src/schema/FormSchema.tsx similarity index 100% rename from src/components/Main/schema.tsx rename to src/schema/FormSchema.tsx diff --git a/src/components/Footer/schema.tsx b/src/schema/NewsletterSchema.tsx similarity index 67% rename from src/components/Footer/schema.tsx rename to src/schema/NewsletterSchema.tsx index 39d985a..caa8e21 100644 --- a/src/components/Footer/schema.tsx +++ b/src/schema/NewsletterSchema.tsx @@ -1,8 +1,8 @@ import * as Yup from 'yup'; -const email = +const newsletteremail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; export default Yup.object().shape({ - email: Yup.string().email().matches(email).required(), + newsletteremail: Yup.string().email().matches(newsletteremail).required(), }); \ No newline at end of file