Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
checkin_hrm
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
checkin_hrm
Commits
5096aa74
Commit
5096aa74
authored
Jan 16, 2021
by
Giang Tran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update code
parent
d0825019
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
212 additions
and
53 deletions
+212
-53
.eslintcache
.eslintcache
+0
-0
logo-DCV.png
public/logo-DCV.png
+0
-0
HomeContainer.js
src/View/Home/HomeContainer.js
+33
-1
HomeView.js
src/View/Home/HomeView.js
+8
-21
LoginScreen.js
src/View/Login/LoginScreen.js
+67
-31
api.js
src/api/api.js
+83
-0
user.js
src/api/user.js
+21
-0
No files found.
.eslintcache
View file @
5096aa74
This diff is collapsed.
Click to expand it.
public/logo-DCV.png
0 → 100644
View file @
5096aa74
10.1 KB
src/View/Home/HomeContainer.js
View file @
5096aa74
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
HomeView
from
"./HomeView"
;
import
HomeView
from
"./HomeView"
;
import
{
useLocation
}
from
"react-router-dom"
;
const
HomeContainer
=
(
props
)
=>
{
const
HomeContainer
=
(
props
)
=>
{
return
<
HomeView
/>
;
const
location
=
useLocation
();
const
[
state
,
setState
]
=
useState
({
latitude
:
null
,
longitude
:
null
,
});
useEffect
(()
=>
{
getPosition
();
},
[]);
const
[
user
,
setUser
]
=
useState
({
name
:
location
.
state
.
fullName
,
code
:
location
.
state
.
code
,
});
const
getPosition
=
async
()
=>
{
navigator
.
geolocation
.
getCurrentPosition
((
position
)
=>
{
if
(
position
.
coords
.
longitude
)
setState
({
latitude
:
position
.
coords
.
latitude
,
longitude
:
position
.
coords
.
longitude
,
});
});
};
const
onCheckIn
=
()
=>
{
console
.
log
(
state
);
};
return
<
HomeView
user
=
{
user
}
onCheckIn
=
{
onCheckIn
}
/>
;
};
};
export
default
HomeContainer
;
export
default
HomeContainer
;
src/View/Home/HomeView.js
View file @
5096aa74
...
@@ -12,38 +12,25 @@ import {
...
@@ -12,38 +12,25 @@ import {
import
ButtonCheckIn
from
"./ButtonCheckIn"
;
import
ButtonCheckIn
from
"./ButtonCheckIn"
;
const
HomeView
=
(
props
)
=>
{
const
HomeView
=
(
props
)
=>
{
const
[
state
,
setState
]
=
useState
({
const
{
user
,
onCheckIn
}
=
props
;
latitude
:
null
,
longitude
:
null
,
});
const
[
status
,
setStatus
]
=
useState
(
0
);
const
[
status
,
setStatus
]
=
useState
(
0
);
const
getPosition
=
()
=>
{
navigator
.
geolocation
.
getCurrentPosition
((
position
)
=>
{
console
.
log
(
position
.
coords
.
longitude
);
console
.
log
(
position
.
coords
.
latitude
);
});
if
(
status
==
0
)
{
setStatus
(
1
);
}
else
{
setStatus
(
0
);
}
};
useEffect
(()
=>
{
getPosition
();
},
[]);
return
(
return
(
<
Container
fixed
style
=
{{
height
:
"100vh"
}}
>
<
Container
fixed
style
=
{{
height
:
"100vh"
}}
>
<
div
style
=
{{
marginTop
:
50
}}
/
>
<
div
style
=
{{
marginTop
:
50
}}
/
>
<
div
style
=
{{
textAlign
:
"center"
,
fontSize
:
"35px"
}}
>
<
div
style
=
{{
textAlign
:
"center"
,
fontSize
:
"35px"
}}
>
T
ê
n
:
L
ê
Tr
ọ
ng
Tr
í
<
Typography
variant
=
{
"h4"
}
style
=
{{
color
:
" #3399ff"
}}
>
Ch
à
o
m
ừ
ng
{
user
?
user
.
name
:
""
}
<
/Typography
>
<
/div
>
<
/div
>
<
br
/>
<
br
/>
<
Grid
container
style
=
{{
height
:
"100vh"
,
justifyContent
:
"center"
}}
>
<
Grid
container
style
=
{{
height
:
"100vh"
,
justifyContent
:
"center"
}}
>
<
Fab
<
Fab
color
=
"secondary"
color
=
"secondary"
aria
-
label
=
"edit"
aria
-
label
=
"edit"
style
=
{{
width
:
"
20vw"
,
height
:
"2
0vw"
}}
style
=
{{
width
:
"
30vw"
,
height
:
"3
0vw"
}}
onClick
=
{
getPositio
n
}
onClick
=
{
onCheckI
n
}
>
>
<
span
style
=
{{
fontSize
:
"3vw"
}}
>
<
span
style
=
{{
fontSize
:
"3vw"
}}
>
{
status
==
0
?
"Checkin"
:
"Checkout"
}
{
status
==
0
?
"Checkin"
:
"Checkout"
}
...
...
src/View/Login/LoginScreen.js
View file @
5096aa74
import
React
from
"react"
;
import
React
,
{
useState
}
from
"react"
;
import
Avatar
from
"@material-ui/core/Avatar"
;
import
Avatar
from
"@material-ui/core/Avatar"
;
import
Button
from
"@material-ui/core/Button"
;
import
Button
from
"@material-ui/core/Button"
;
import
CssBaseline
from
"@material-ui/core/CssBaseline"
;
import
CssBaseline
from
"@material-ui/core/CssBaseline"
;
import
TextField
from
"@material-ui/core/TextField"
;
import
TextField
from
"@material-ui/core/TextField"
;
import
FormControlLabel
from
"@material-ui/core/FormControlLabel"
;
import
{
FormHelperText
,
Link
,
Grid
,
Box
,
Typography
}
from
"@material-ui/core"
;
import
Checkbox
from
"@material-ui/core/Checkbox"
;
import
{
useHistory
}
from
"react-router-dom"
;
import
Link
from
"@material-ui/core/Link"
;
import
Grid
from
"@material-ui/core/Grid"
;
import
Box
from
"@material-ui/core/Box"
;
import
LockOutlinedIcon
from
"@material-ui/icons/LockOutlined"
;
import
LockOutlinedIcon
from
"@material-ui/icons/LockOutlined"
;
import
Typography
from
"@material-ui/core/Typography"
;
import
{
makeStyles
}
from
"@material-ui/core/styles"
;
import
{
makeStyles
}
from
"@material-ui/core/styles"
;
import
Container
from
"@material-ui/core/Container"
;
import
Container
from
"@material-ui/core/Container"
;
import
{
loginApi
}
from
"../../api/user"
;
function
Copyright
()
{
function
Copyright
()
{
return
(
return
(
...
@@ -46,27 +43,63 @@ const useStyles = makeStyles((theme) => ({
...
@@ -46,27 +43,63 @@ const useStyles = makeStyles((theme) => ({
const
LoginScreen
=
()
=>
{
const
LoginScreen
=
()
=>
{
const
classes
=
useStyles
();
const
classes
=
useStyles
();
let
history
=
useHistory
();
const
[
state
,
setState
]
=
useState
({
appcode
:
"Dcv"
,
username
:
""
,
password
:
""
,
});
const
[
helperText
,
sethelperText
]
=
useState
(
""
);
const
onLogin
=
async
()
=>
{
console
.
log
(
"Abc"
);
if
(
state
.
username
===
""
||
state
.
password
===
""
)
{
sethelperText
(
""
);
sethelperText
(
"Cần phải điền đầy đủ email và password"
);
}
else
{
sethelperText
(
""
);
console
.
log
(
state
);
const
res
=
await
loginApi
(
state
);
console
.
log
(
res
.
data
);
if
(
res
.
data
&&
res
.
data
.
errorCode
===
0
)
{
localStorage
.
setItem
(
"TOKEN_KEY"
,
res
.
data
.
data
.
accessToken
);
history
.
push
({
pathname
:
"/home"
,
state
:
{
code
:
res
.
data
.
data
.
code
,
fullName
:
res
.
data
.
data
.
fullName
},
});
}
else
if
(
res
.
data
&&
res
.
data
.
errorCode
===
1
)
{
sethelperText
(
""
);
sethelperText
(
"Sai email hoặc mật khẩu"
);
}
}
};
return
(
return
(
<
div
style
=
{{
height
:
"100vh"
}}
>
<
div
style
=
{{
height
:
"100vh"
}}
>
<
Container
component
=
"main"
maxWidth
=
"xs"
>
<
Container
component
=
"main"
maxWidth
=
"xs"
>
<
CssBaseline
/>
<
CssBaseline
/>
<
div
className
=
{
classes
.
paper
}
>
<
div
className
=
{
classes
.
paper
}
>
<
Avatar
className
=
{
classes
.
avatar
}
>
<
img
<
LockOutlinedIcon
/>
style
=
{{
width
:
200
,
height
:
100
,
marginTop
:
10
,
marginBottom
:
10
}}
<
/Avatar
>
src
=
"/logo-DCV.png"
<
Typography
component
=
"h1"
variant
=
"h5"
>
/>
Sign
in
<
Typography
color
=
{
"primary"
}
component
=
"h1"
variant
=
"h5"
>
ĐĂ
NG
NH
Ậ
P
<
/Typography
>
<
/Typography
>
<
form
className
=
{
classes
.
form
}
noValidate
>
<
TextField
<
TextField
variant
=
"outlined"
variant
=
"outlined"
margin
=
"normal"
margin
=
"normal"
required
required
fullWidth
fullWidth
id
=
"email"
label
=
"email"
label
=
"Email Address"
name
=
"email"
autoComplete
=
"email"
autoComplete
=
"email"
onChange
=
{(
e
)
=>
{
setState
({
...
state
,
username
:
e
.
target
.
value
,
});
}}
autoFocus
autoFocus
/>
/>
<
TextField
<
TextField
...
@@ -74,38 +107,41 @@ const LoginScreen = () => {
...
@@ -74,38 +107,41 @@ const LoginScreen = () => {
margin
=
"normal"
margin
=
"normal"
required
required
fullWidth
fullWidth
name
=
"password"
label
=
"Mật khẩu"
label
=
"Password"
type
=
"password"
type
=
"password"
id
=
"password"
onChange
=
{(
e
)
=>
{
setState
({
...
state
,
password
:
e
.
target
.
value
,
});
}}
autoComplete
=
"current-password"
autoComplete
=
"current-password"
/>
/>
<
FormControlLabel
<
div
style
=
{{
width
:
"100%"
}}
>
control
=
{
<
Checkbox
value
=
"remember"
color
=
"primary"
/>
}
<
FormHelperText
label
=
"Remember me"
style
=
{{
marginLeft
:
"16px"
,
color
:
"red"
,
fontSize
:
"13px"
}}
/>
>
{
helperText
}
<
/FormHelperText
>
<
/div
>
<
Button
<
Button
type
=
"submit"
type
=
"submit"
fullWidth
fullWidth
variant
=
"contained"
variant
=
"contained"
color
=
"primary"
color
=
"primary"
className
=
{
classes
.
submit
}
className
=
{
classes
.
submit
}
onClick
=
{
onLogin
}
>
>
Sign
In
Đă
ng
nh
ậ
p
<
/Button
>
<
/Button
>
<
Grid
container
>
<
Grid
container
>
<
Grid
item
xs
>
<
Grid
item
xs
>
<
Link
href
=
"#"
variant
=
"body2"
>
<
Link
href
=
"#"
variant
=
"body2"
>
Forgot
password
?
Qu
ê
n
m
ậ
t
kh
ẩ
u
?
<
/Link
>
<
/Grid
>
<
Grid
item
>
<
Link
href
=
"#"
variant
=
"body2"
>
{
"Don't have an account? Sign Up"
}
<
/Link
>
<
/Link
>
<
/Grid
>
<
/Grid
>
<
/Grid
>
<
/Grid
>
<
/form
>
<
/div
>
<
/div
>
<
Box
mt
=
{
8
}
>
<
Box
mt
=
{
8
}
>
<
Copyright
/>
<
Copyright
/>
...
...
src/api/api.js
0 → 100644
View file @
5096aa74
import
axios
from
"axios"
;
axios
.
defaults
.
timeout
=
10000
;
export
async
function
GetData
(
url
,
data
)
{
const
token
=
localStorage
.
getItem
(
"TOKEN_KEY"
);
let
myRequest
=
{
method
:
"get"
,
url
,
headers
:
{
Accept
:
"application/json"
,
"Content-Type"
:
"application/json"
,
Authorization
:
"Bearer "
+
token
,
},
params
:
{
...
data
,
},
timeout
:
60
*
1000
,
// withCredentials: true,
};
console
.
log
(
"My request"
,
myRequest
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
const
err
=
{
message
:
"error"
,
status
:
error
.
request
.
status
,
};
return
err
;
});
}
export
async
function
PostLogin
(
url
,
json
,
isAuth
=
true
)
{
let
myRequest
=
{
method
:
"post"
,
url
,
headers
:
{
Accept
:
"application/json"
,
"Content-Type"
:
"application/json"
,
},
timeout
:
60
*
1000
,
data
:
JSON
.
stringify
(
json
),
};
console
.
log
(
"post data mobile"
,
myRequest
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
const
err
=
{
message
:
"error"
,
status
:
error
.
request
.
status
,
};
return
err
;
});
}
export
async
function
PostData
(
url
,
json
,
isAuth
=
true
)
{
const
token
=
localStorage
.
getItem
(
"TOKEN_KEY"
);
let
myRequest
=
{
method
:
"post"
,
url
,
headers
:
{
Accept
:
"application/json"
,
"Content-Type"
:
"application/json"
,
Authorization
:
"Bearer "
+
token
,
},
timeout
:
60
*
1000
,
data
:
JSON
.
stringify
(
json
),
};
console
.
log
(
"post data mobile"
,
myRequest
);
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
const
err
=
{
message
:
"error"
,
status
:
error
.
request
.
status
,
};
return
err
;
});
}
src/api/user.js
0 → 100644
View file @
5096aa74
import
{
GetData
,
PostLogin
,
PostData
}
from
"./api"
;
export
const
loginApi
=
async
(
body
)
=>
PostLogin
(
"http://hrm.auth.dcv.vn/api/v1/auth/login"
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
export
const
getDataApi
=
async
(
body
)
=>
GetData
(
"http://hrm.auth.dcv.vn/api/v1/auth/login"
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
export
const
checkInApi
=
async
(
body
)
=>
PostData
(
"http://hrm.japi.dcv.vn/venus-service/checkinService/checkin"
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
export
const
checkOutApi
=
async
(
body
)
=>
PostData
(
"http://hrm.japi.dcv.vn/venus-service/checkinService/checkout"
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment