Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend-MECRED
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MECRED
Frontend-MECRED
Commits
181f8885
Commit
181f8885
authored
Mar 6, 2024
by
lumb19
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#26
: CONNECT signup modal to api
parent
f8bab04d
Branches
Branches containing commit
No related tags found
1 merge request
!18
Issue #26: CONNECT signup modal to api
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/login/components/LoginForm.js
+2
-2
2 additions, 2 deletions
src/app/login/components/LoginForm.js
src/app/login/components/SignupModal.js
+54
-12
54 additions, 12 deletions
src/app/login/components/SignupModal.js
src/axiosConfig.js
+1
-1
1 addition, 1 deletion
src/axiosConfig.js
with
57 additions
and
15 deletions
src/app/login/components/LoginForm.js
+
2
−
2
View file @
181f8885
...
@@ -47,7 +47,7 @@ export default function LoginForm({
...
@@ -47,7 +47,7 @@ export default function LoginForm({
label
=
"
E-mail
"
label
=
"
E-mail
"
className
=
"
m-5
"
className
=
"
m-5
"
onChange
=
{
handleEmailChange
}
onChange
=
{
handleEmailChange
}
error
=
{
errorMessage
!=
""
}
error
=
{
errorMessage
.
length
>
0
}
/
>
/
>
<
TextField
<
TextField
fullWidth
fullWidth
...
@@ -55,7 +55,7 @@ export default function LoginForm({
...
@@ -55,7 +55,7 @@ export default function LoginForm({
label
=
"
Senha
"
label
=
"
Senha
"
className
=
"
mb-5
"
className
=
"
mb-5
"
onChange
=
{
handlePasswordChange
}
onChange
=
{
handlePasswordChange
}
error
=
{
errorMessage
!=
""
}
error
=
{
errorMessage
!=
errorMessage
.
length
>
0
}
/
>
/
>
<
Button
<
Button
fullWidth
fullWidth
...
...
This diff is collapsed.
Click to expand it.
src/app/login/components/SignupModal.js
+
54
−
12
View file @
181f8885
...
@@ -4,21 +4,56 @@ import Button from "@mui/material/Button";
...
@@ -4,21 +4,56 @@ import Button from "@mui/material/Button";
import
Modal
from
"
@mui/material/Modal
"
;
import
Modal
from
"
@mui/material/Modal
"
;
import
{
TextField
,
Divider
,
Alert
}
from
"
@mui/material
"
;
import
{
TextField
,
Divider
,
Alert
}
from
"
@mui/material
"
;
import
{
useState
}
from
"
react
"
;
import
{
useState
}
from
"
react
"
;
import
mecredApi
from
"
@/axiosConfig
"
;
export
default
function
SignupModal
({
open
,
handleClose
})
{
export
default
function
SignupModal
({
open
,
handleClose
})
{
const
[
userName
,
setUserName
]
=
useState
(
""
);
const
[
userName
,
setUserName
]
=
useState
(
""
);
const
[
userEmail
,
setUserEmail
]
=
useState
(
""
);
const
[
userEmail
,
setUserEmail
]
=
useState
(
""
);
const
[
userPassword
,
setUserPassword
]
=
useState
(
""
);
const
[
userPassword
,
setUserPassword
]
=
useState
(
""
);
const
[
userPasswordConfirmation
,
setUserPasswordConfirmation
]
=
useState
(
""
);
const
[
userPasswordConfirmation
,
setUserPasswordConfirmation
]
=
useState
(
""
);
const
[
errorMessage
,
setErrorMessage
]
=
useState
(
""
);
const
[
feedbackMessage
,
setfeedbackMessage
]
=
useState
(
""
);
const
[
error
,
setError
]
=
useState
(
false
);
const
helperText
=
"
As senhas devem ser iguais!
"
;
const
userSignup
=
async
()
=>
{
mecredApi
.
post
(
"
/auth
"
,
{
name
:
userName
,
email
:
userEmail
,
password
:
userPassword
,
password_confirmation
:
userPasswordConfirmation
,
})
.
then
((
response
)
=>
{
setfeedbackMessage
(
"
Usuário cadastrado com sucesso! Por favor confirme seu e-mail.
"
);
setError
(
false
);
})
.
catch
(
e
=>
{
setfeedbackMessage
(
e
[
'
response
'
][
'
data
'
][
'
errors
'
][
'
full_messages
'
][
0
]);
setError
(
true
);
})
};
const
resetForm
=
()
=>
{
setUserName
(
""
);
setUserEmail
(
""
);
setUserPassword
(
""
);
setUserPasswordConfirmation
(
""
);
}
const
handleSubmit
=
(
event
)
=>
{
const
handleSubmit
=
(
event
)
=>
{
event
.
preventDefault
();
event
.
preventDefault
();
if
(
!
userName
||
!
userEmail
||
!
userPassword
||
!
userPasswordConfirmation
)
if
(
!
userName
||
!
userEmail
||
!
userPassword
||
!
userPasswordConfirmation
)
{
setErrorMessage
(
"
Todos os campos marcados com * são obrigatórios!
"
)
setfeedbackMessage
(
"
Todos os campos marcados com * são obrigatórios!
"
);
else
if
(
userPassword
!=
userPasswordConfirmation
)
setError
(
true
);
setErrorMessage
(
"
As senhas devem ser iguais!
"
);
}
else
if
(
userPassword
!=
userPasswordConfirmation
)
{
setfeedbackMessage
(
"
As senhas devem ser iguais!
"
);
setError
(
true
);
}
else
userSignup
();
resetForm
();
};
};
return
(
return
(
...
@@ -30,14 +65,14 @@ export default function SignupModal({ open, handleClose }) {
...
@@ -30,14 +65,14 @@ export default function SignupModal({ open, handleClose }) {
<
Box
className
=
"
bg-white sm:w-1/2 xl:w-1/4 p-5 flex flex-col items-center border-none rounded-xl
"
>
<
Box
className
=
"
bg-white sm:w-1/2 xl:w-1/4 p-5 flex flex-col items-center border-none rounded-xl
"
>
<
h1
className
=
"
text-secondary text-2xl font-bold m-5
"
>
Cadastre
-
se
<
/h1
>
<
h1
className
=
"
text-secondary text-2xl font-bold m-5
"
>
Cadastre
-
se
<
/h1
>
<
form
onSubmit
=
{
handleSubmit
}
>
<
form
onSubmit
=
{
handleSubmit
}
>
{
error
Message
?
<
Alert
severity
=
"
error
"
>
{
errorMessage
}
<
/Alert> : null
}
{
feedback
Message
?
<
Alert
severity
=
{
error
?
"
error
"
:
"
success
"
}
>
{
feedback
Message
}
<
/Alert> : null
}
<
TextField
<
TextField
fullWidth
fullWidth
onChange
=
{(
e
)
=>
setUserName
(
e
.
target
.
value
)}
onChange
=
{(
e
)
=>
setUserName
(
e
.
target
.
value
)}
label
=
"
Nome Completo *
"
label
=
"
Nome Completo *
"
className
=
"
my-5
"
className
=
"
my-5
"
value
=
{
userName
}
value
=
{
userName
}
error
=
{
!
userName
&&
error
Message
}
error
=
{
!
userName
&&
error
}
/
>
/
>
<
TextField
<
TextField
fullWidth
fullWidth
...
@@ -46,7 +81,7 @@ export default function SignupModal({ open, handleClose }) {
...
@@ -46,7 +81,7 @@ export default function SignupModal({ open, handleClose }) {
type
=
"
email
"
type
=
"
email
"
className
=
"
mb-5
"
className
=
"
mb-5
"
value
=
{
userEmail
}
value
=
{
userEmail
}
error
=
{
!
userEmail
&&
error
Message
}
error
=
{
!
userEmail
&&
error
}
/
>
/
>
<
TextField
<
TextField
fullWidth
fullWidth
...
@@ -55,7 +90,7 @@ export default function SignupModal({ open, handleClose }) {
...
@@ -55,7 +90,7 @@ export default function SignupModal({ open, handleClose }) {
label
=
"
Senha *
"
label
=
"
Senha *
"
className
=
"
mb-5
"
className
=
"
mb-5
"
value
=
{
userPassword
}
value
=
{
userPassword
}
error
=
{
!
userPassword
&&
error
Message
}
error
=
{
!
userPassword
&&
error
}
/
>
/
>
<
TextField
<
TextField
fullWidth
fullWidth
...
@@ -64,8 +99,15 @@ export default function SignupModal({ open, handleClose }) {
...
@@ -64,8 +99,15 @@ export default function SignupModal({ open, handleClose }) {
label
=
"
Confirmar senha *
"
label
=
"
Confirmar senha *
"
className
=
"
mb-5
"
className
=
"
mb-5
"
value
=
{
userPasswordConfirmation
}
value
=
{
userPasswordConfirmation
}
error
=
{
userPasswordConfirmation
!=
userPassword
&&
userPasswordConfirmation
!=
""
}
error
=
{
helperText
=
{
userPasswordConfirmation
&&
userPasswordConfirmation
!=
userPassword
&&
<
p
>
As
senhas
devem
ser
iguais
!<
/p>
}
userPasswordConfirmation
!=
userPassword
&&
userPasswordConfirmation
!=
""
}
helperText
=
{
userPasswordConfirmation
.
length
>
0
&&
userPasswordConfirmation
!=
userPassword
&&
helperText
}
/
>
/
>
<
Button
<
Button
fullWidth
fullWidth
...
...
This diff is collapsed.
Click to expand it.
src/axiosConfig.js
+
1
−
1
View file @
181f8885
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
const
mecredApi
=
axios
.
create
({
const
mecredApi
=
axios
.
create
({
baseURL
:
'
https://api.portalmec.c3sl.ufpr.br/v1
'
,
baseURL
:
'
https://api.portalmec
homologa
.c3sl.ufpr.br/v1
'
,
timeout
:
1000
timeout
:
1000
})
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment