@@ -23,11 +23,7 @@ const validationSchema = () => Yup.object().shape({
2323 . string ( )
2424 . email ( "E-mail inválido" )
2525 . required ( "Preenchimento do email obrigatório" ) ,
26- githubUser : Yup . string ( ) . required ( "Preenchimento do usuário Github obrigatório" ) ,
27- cpf : Yup
28- . string ( )
29- . matches ( / ^ \d { 3 } \. \d { 3 } \. \d { 3 } - \d { 2 } $ / , "CPF inválido" )
30- . required ( "Preenchimento do CPF obrigatório" ) ,
26+ githubUser : Yup . string ( ) . required ( "Preenchimento do usuário Github obrigatório" )
3127} )
3228
3329const useStyles = makeStyles ( ( theme : Theme ) => ( {
@@ -45,23 +41,6 @@ const useStyles = makeStyles((theme: Theme) => ({
4541 }
4642} ) )
4743
48- const formatCPF = ( value : string ) : string => {
49- // Remove tudo que não é dígito
50- const numbers = value . replace ( / \D / g, '' )
51-
52- // Aplica a máscara: 000.000.000-00
53- if ( numbers . length <= 3 ) {
54- return numbers
55- } else if ( numbers . length <= 6 ) {
56- return numbers . replace ( / ( \d { 3 } ) ( \d { 1 , 3 } ) / , '$1.$2' )
57- } else if ( numbers . length <= 9 ) {
58- return numbers . replace ( / ( \d { 3 } ) ( \d { 3 } ) ( \d { 1 , 3 } ) / , '$1.$2.$3' )
59- } else {
60- return numbers . replace ( / ( \d { 3 } ) ( \d { 3 } ) ( \d { 3 } ) ( \d { 1 , 2 } ) / , '$1.$2.$3-$4' )
61- }
62- }
63-
64-
6544const PersonalDataForm = ( props : PersonalDataFormProps ) => {
6645 const classes = useStyles ( ) ;
6746 const { user, onSuccess, showOnlyEmailField = false } = props
@@ -72,9 +51,7 @@ const PersonalDataForm = (props: PersonalDataFormProps) => {
7251 name : user . name ,
7352 email : user . email ,
7453 githubUser : user . githubUser ,
75- githubID : user . githubID ,
76- linkedin : user . linkedin ,
77- cpf : user . cpf ,
54+ githubID : user . githubID
7855 }
7956
8057 const onSubmit = async ( values : any ) => {
@@ -94,11 +71,6 @@ const PersonalDataForm = (props: PersonalDataFormProps) => {
9471
9572 const formik = useFormik ( { initialValues, validationSchema, onSubmit } ) ;
9673
97- const handleCPFChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
98- const formatted = formatCPF ( event . target . value )
99- formik . setFieldValue ( 'cpf' , formatted )
100- }
101-
10274 return (
10375 < React . Fragment >
10476 < form onSubmit = { formik . handleSubmit } >
@@ -110,7 +82,7 @@ const PersonalDataForm = (props: PersonalDataFormProps) => {
11082 >
11183 { ! showOnlyEmailField && < >
11284 < HeaderTitle title = { "Minha Área" } description = 'Dados pessoais' />
113- < Grid item xs = { 12 } md = { 4 } >
85+ < Grid item xs = { 12 } md = { 6 } >
11486 < HacktoberfestTextInput
11587 fullWidth
11688 onChange = { formik . handleChange }
@@ -128,7 +100,7 @@ const PersonalDataForm = (props: PersonalDataFormProps) => {
128100 } }
129101 />
130102 </ Grid >
131- < Grid item xs = { 12 } md = { 4 } >
103+ < Grid item xs = { 12 } md = { 6 } >
132104 < HacktoberfestTextInput
133105 color = "primary"
134106 value = { formik . values . githubID }
@@ -140,21 +112,9 @@ const PersonalDataForm = (props: PersonalDataFormProps) => {
140112 } }
141113 />
142114 </ Grid >
143- < Grid item xs = { 12 } md = { 4 } >
144- < HacktoberfestTextInput
145- color = "primary"
146- value = { formik . values . linkedin }
147- fullWidth
148- variant = "outlined"
149- label = "LinkedIn"
150- InputProps = { {
151- disabled : true
152- } }
153- />
154- </ Grid >
155115 </ >
156116 }
157- < Grid item xs = { 12 } md = { 7 } >
117+ < Grid item xs = { 12 } >
158118 < HacktoberfestTextInput
159119 onChange = { formik . handleChange }
160120 name = "email"
@@ -171,19 +131,6 @@ const PersonalDataForm = (props: PersonalDataFormProps) => {
171131 } }
172132 />
173133 </ Grid >
174- < Grid item xs = { 12 } md = { 5 } >
175- < HacktoberfestTextInput
176- onChange = { handleCPFChange }
177- name = "cpf"
178- value = { formik . values . cpf }
179- fullWidth
180- variant = "outlined"
181- error = { formik . touched . cpf && Boolean ( formik . errors . cpf ) }
182- helperText = { formik . touched . cpf && formik . errors . cpf }
183- label = "CPF"
184- inputProps = { { maxLength : 14 } }
185- />
186- </ Grid >
187134 < Grid container alignItems = "flex-start" justifyContent = "flex-start" item xs = { 12 } lg = { 12 } >
188135 < LoadingButton fullWidth isLoading = { isLoading } >
189136 SALVAR
0 commit comments