Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
form-creator-ui
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
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simmctic
form-creator
form-creator-ui
Commits
d415962a
Commit
d415962a
authored
5 years ago
by
Richard Fernando Heise Ferreira
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#6
:Add login screen
Signed-off-by:
RichardHeise
<
rfhf19@inf.ufpr.br
>
parent
632c3519
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/App.js
+2
-0
2 additions, 0 deletions
src/App.js
src/pages/SignIn.js
+189
-0
189 additions, 0 deletions
src/pages/SignIn.js
with
191 additions
and
0 deletions
src/App.js
+
2
−
0
View file @
d415962a
...
...
@@ -6,6 +6,7 @@ import AnswerForm from "./pages/AnswerForm";
import
Header
from
"
./components/header/header
"
;
import
Footer
from
"
./components/footer/footer
"
;
import
SignUp
from
"
./pages/SignUp
"
;
import
SignIn
from
"
./pages/SignIn
"
;
function
App
()
{
return
(
...
...
@@ -14,6 +15,7 @@ function App() {
<
Route
path
=
"
/create
"
component
=
{
CreateForm
}
/
>
<
Route
path
=
"
/answer/:id
"
component
=
{
AnswerForm
}
/
>
<
Route
path
=
"
/SignUp
"
component
=
{
SignUp
}
/
>
<
Route
path
=
"
/SignIn
"
component
=
{
SignIn
}
/
>
<
/HashRouter
>
);
}
...
...
This diff is collapsed.
Click to expand it.
src/pages/SignIn.js
0 → 100644
+
189
−
0
View file @
d415962a
import
React
from
"
react
"
;
import
Grid
from
"
@material-ui/core/Grid
"
;
import
{
createMuiTheme
,
MuiThemeProvider
}
from
"
@material-ui/core
"
;
import
IconButton
from
"
@material-ui/core/IconButton
"
;
import
{
makeStyles
}
from
"
@material-ui/core/styles
"
;
import
KeyboardArrowRightIcon
from
"
@material-ui/icons/KeyboardArrowRight
"
;
import
FormInput
from
"
../components/fieldsSignUp/FormInput
"
;
import
Paper
from
"
@material-ui/core/Paper
"
;
import
api
from
"
../api
"
;
const
useStyles
=
makeStyles
(
theme
=>
({
register
:
{
maxWidth
:
"
1000px
"
,
background
:
"
#ffffff
"
,
borderRadius
:
"
2px
"
,
padding
:
"
2% 1%
"
,
margin
:
"
0 auto
"
,
marginTop
:
"
9%
"
,
width
:
"
95%
"
},
custom_strong
:
{
fontSize
:
"
25px
"
,
textAlign
:
"
center
"
,
display
:
"
block
"
,
color
:
"
#46525d
"
},
strong_description
:
{
fontSize
:
"
14px
"
,
color
:
"
#c2c6ca
"
},
form
:
{
marginTop
:
"
3%
"
,
alignItems
:
"
center
"
,
textAlign
:
"
center
"
},
button
:
{
type
:
"
submit
"
,
width
:
"
30%
"
,
marginTop
:
"
4%
"
,
background
:
"
#6ec46c
"
,
borderRadius
:
"
2px
"
,
padding
:
"
10px 20px
"
,
fontSize
:
"
18px
"
,
"
&:hover
"
:
{
backgroundColor
:
"
rgb(25, 109, 23)
"
},
[
"
@media (max-width:550px)
"
]:
{
width
:
"
55%
"
}
}
}));
export
default
function
SignUp
()
{
const
classes
=
useStyles
();
const
[
values
,
setValues
]
=
React
.
useState
({
email
:
""
,
password
:
""
,
emailError
:
false
});
async
function
update
(
prop
,
event
)
{
await
setValues
({
...
values
,
[
prop
]:
event
.
target
.
value
});
}
const
handleChange
=
prop
=>
event
=>
{
if
(
!
checkEmail
())
{
values
.
emailError
=
true
;
}
else
{
values
.
emailError
=
false
;
}
update
(
prop
,
event
);
};
function
checkEmail
()
{
if
(
/^
[
a-zA-Z0-9._-
]
+@
[
a-zA-Z0-9
]
+
\.[
A-Za-z
]
+$/
.
test
(
values
.
email
))
{
return
true
;
}
return
false
;
}
function
verifyValues
()
{
if
(
values
.
email
&&
values
.
password
)
{
return
true
;
}
return
false
;
}
function
verifyValuesContent
()
{
if
(
!
checkEmail
())
{
alert
(
"
email invalido
"
);
}
return
false
;
}
async
function
handleSubmit
()
{
const
response
=
await
api
.
post
(
`/user/signUp`
,
{
email
:
values
.
email
,
hash
:
values
.
password
})
.
then
(
function
(
error
)
{
if
(
!
error
.
response
)
{
alert
(
"
Usuário criado com sucesso
"
);
// redirecionar para a main page
}
})
.
catch
(
function
(
error
)
{
if
(
error
.
response
)
{
switch
(
error
.
response
.
data
.
error
)
{
case
'
duplicate key value violates unique constraint "form_user_name_key"
'
:
alert
(
"
Você já tem uma conta.
"
);
break
;
case
"
Email exists on the database.
"
:
alert
(
"
Email já cadastrado
"
);
break
;
case
"
data and salt arguments required
"
:
alert
(
"
Ocorreu um erro com sua senha. Tente novamente em alguns minutos ou tente mudá-la
"
);
default
:
alert
(
"
Um erro ocorreu. Tente novamente mais tarde.
"
);
}
return
;
// console.log(error.response.data);
}
});
}
function
submit
()
{
if
(
verifyValues
())
{
if
(
verifyValuesContent
())
{
handleSubmit
();
}
}
}
const
theme
=
createMuiTheme
({
overrides
:
{
root
:
{
color
:
"
white
"
},
MuiInput
:
{
underline
:
{
"
&:before
"
:
{
borderBottom
:
"
1px solid #35c7fc
"
},
"
&:after
"
:
{
borderBottom
:
"
1px solid #3f51b5
"
}
}
},
}
});
return
(
<
MuiThemeProvider
theme
=
{
theme
}
>
<
Paper
className
=
{
classes
.
register
}
justify
=
"
center
"
>
<
strong
className
=
{
classes
.
custom_strong
}
>
Login
de
Usuário
<
p
className
=
{
classes
.
strong_description
}
>
Insira
as
informações
abaixo
<
/p
>
<
/strong
>
<
form
className
=
{
classes
.
form
}
autocomplete
=
"
off
"
>
<
Grid
>
<
FormInput
label
=
"
E-mail
"
param
=
"
email
"
onUpdate
=
{
handleChange
}
verify
=
{
checkEmail
}
error
=
{
values
.
emailError
}
/
>
<
/Grid
>
<
Grid
>
<
FormInput
label
=
"
Senha
"
param
=
"
password
"
onUpdate
=
{
handleChange
}
/
>
<
/Grid
>
<
Grid
>
<
IconButton
type
=
"
submit
"
size
=
"
medium
"
className
=
{
classes
.
button
}
id
=
"
whiteTextedButton
"
onClick
=
{()
=>
submit
()}
>
<
KeyboardArrowRightIcon
/>
Conecte
-
se
<
/IconButton
>
<
/Grid
>
<
/form
>
<
/Paper
>
<
/MuiThemeProvider
>
);
}
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