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
e574ccfa
Commit
e574ccfa
authored
Jan 17, 2021
by
letrongtri99
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update_display
parent
5096aa74
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
236 additions
and
38 deletions
+236
-38
index.html
public/index.html
+12
-11
logoDCV_2.png
public/logoDCV_2.png
+0
-0
HomeContainer.js
src/View/Home/HomeContainer.js
+69
-9
HomeView.css
src/View/Home/HomeView.css
+28
-0
HomeView.js
src/View/Home/HomeView.js
+68
-10
LoginScreen.js
src/View/Login/LoginScreen.js
+8
-4
RootView.js
src/View/RootView.js
+46
-4
user.js
src/api/user.js
+5
-0
No files found.
public/index.html
View file @
e574ccfa
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<head>
<meta
charset=
"utf-8"
/>
<link
rel=
"icon"
href=
"%PUBLIC_URL%/favicon.ico
"
/>
<link
rel=
"icon"
href=
"%PUBLIC_URL%/logoDCV_2.png
"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<meta
name=
"theme-color"
content=
"#000000"
/>
<meta
name=
"description"
content=
"Web site created using create-react-app"
/>
<link
rel=
"apple-touch-icon"
href=
"%PUBLIC_URL%/logo192.png"
/>
<meta
name=
"description"
content=
"Web site created using create-react-app"
/>
<link
rel=
"apple-touch-icon"
href=
"%PUBLIC_URL%/logo-DCV.png"
/>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
...
...
@@ -24,9 +22,10 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>
React App
</title>
</head>
<body>
<title>
HRM CheckIn
</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div
id=
"root"
></div>
<!--
...
...
@@ -39,5 +38,6 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</body>
</html>
\ No newline at end of file
public/logoDCV_2.png
0 → 100644
View file @
e574ccfa
16 KB
src/View/Home/HomeContainer.js
View file @
e574ccfa
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
HomeView
from
"./HomeView"
;
import
{
useLocation
}
from
"react-router-dom"
;
import
{
checkInApi
,
checkOutApi
}
from
"../../api/user"
;
import
{
useHistory
}
from
"react-router-dom"
;
import
Alert
from
"@material-ui/lab/Alert"
;
const
HomeContainer
=
(
props
)
=>
{
const
location
=
useLocation
();
...
...
@@ -9,17 +12,23 @@ const HomeContainer = (props) => {
latitude
:
null
,
longitude
:
null
,
});
const
[
changeStatus
,
setChangeStatus
]
=
useState
(
""
);
const
[
changeId
,
setChangeId
]
=
useState
(
""
);
const
[
user
,
setUser
]
=
useState
({});
let
history
=
useHistory
();
const
changeIdCheck
=
(
id
)
=>
{
setChangeId
(
id
);
};
useEffect
(()
=>
{
const
infoUser
=
JSON
.
parse
(
localStorage
.
getItem
(
"user"
));
setUser
(
infoUser
);
getPosition
();
},
[]);
const
[
user
,
setUser
]
=
useState
({
name
:
location
.
state
.
fullName
,
code
:
location
.
state
.
code
,
});
const
getPosition
=
async
()
=>
{
const
getPosition
=
()
=>
{
navigator
.
geolocation
.
getCurrentPosition
((
position
)
=>
{
if
(
position
.
coords
.
longitude
)
setState
({
...
...
@@ -29,11 +38,62 @@ const HomeContainer = (props) => {
});
};
const
onCheckIn
=
()
=>
{
console
.
log
(
state
);
const
onCheckIn
=
async
(
status
)
=>
{
if
(
status
==
0
)
{
let
res
=
await
checkInApi
({
employeeCode
:
user
.
code
,
companyCode
:
"DCV"
,
checkinId
:
null
,
lat
:
"20.99847600"
,
lng
:
"105.80720300"
,
deviceName
:
"Xiaomi"
,
deviceMac
:
"Xiaomi Mac"
,
});
if
(
res
.
data
&&
res
.
data
.
errorCode
==
200
)
{
alert
(
"Checkin thành công"
);
setChangeStatus
(
5
);
}
else
if
(
res
.
status
==
403
||
res
.
status
==
401
)
{
localStorage
.
removeItem
(
"TOKEN_KEY"
);
localStorage
.
removeItem
(
"user"
);
setTimeout
(()
=>
{
history
.
push
(
"/"
);
},
100
);
}
else
{
alert
(
"Lỗi thông tin"
);
}
}
else
if
(
status
==
1
)
{
let
res
=
await
checkOutApi
({
employeeCode
:
user
.
code
,
companyCode
:
"DCV"
,
checkinId
:
changeId
,
lat
:
"20.99847600"
,
lng
:
"105.80720300"
,
deviceName
:
"Xiaomi"
,
deviceMac
:
"Xiaomi Mac"
,
});
if
(
res
.
data
&&
res
.
data
.
errorCode
==
200
)
{
alert
(
"Checkout thành công"
);
setChangeStatus
(
6
);
}
else
if
(
res
.
status
==
403
||
res
.
status
==
401
)
{
localStorage
.
removeItem
(
"TOKEN_KEY"
);
localStorage
.
removeItem
(
"user"
);
setTimeout
(()
=>
{
history
.
push
(
"/"
);
},
100
);
}
else
{
alert
(
"Lỗi thông tin"
);
}
}
};
return
<
HomeView
user
=
{
user
}
onCheckIn
=
{
onCheckIn
}
/>
;
return
(
<
HomeView
user
=
{
user
}
onCheckIn
=
{
onCheckIn
}
changeStatus
=
{
changeStatus
}
changeIdCheck
=
{
changeIdCheck
}
/
>
);
};
export
default
HomeContainer
;
src/View/Home/HomeView.css
0 → 100644
View file @
e574ccfa
.checkin
{
background-color
:
#cc534f
!important
;
color
:
white
!important
;
}
.checkin
:hover
{
background-color
:
#cc534f
!important
;
color
:
white
!important
;
}
.checkout
{
background-color
:
rgb
(
60
,
141
,
188
)
!important
;
color
:
white
!important
;
}
.checkout
:hover
{
background-color
:
rgb
(
60
,
141
,
188
)
!important
;
color
:
white
!important
;
}
.complete
{
background-color
:
green
!important
;
color
:
white
!important
;
}
.complete
:hover
{
background-color
:
green
!important
;
color
:
white
!important
;
cursor
:
auto
!important
;
}
src/View/Home/HomeView.js
View file @
e574ccfa
...
...
@@ -7,33 +7,91 @@ import {
Card
,
Typography
,
Fab
,
Button
,
}
from
"@material-ui/core"
;
import
{
statusCheckIn
}
from
"../../api/user"
;
import
{
useHistory
}
from
"react-router-dom"
;
import
Alert
from
"@material-ui/lab/Alert"
;
import
"./HomeView.css"
;
import
ButtonCheckIn
from
"./ButtonCheckIn"
;
const
HomeView
=
(
props
)
=>
{
const
{
user
,
onCheckIn
}
=
props
;
const
{
user
,
onCheckIn
,
changeStatus
,
changeIdCheck
}
=
props
;
const
[
status
,
setStatus
]
=
useState
(
0
);
const
[
status
,
setStatus
]
=
useState
(
""
);
let
history
=
useHistory
();
useEffect
(()
=>
{
getInfo
();
},
[
changeStatus
]);
const
getInfo
=
async
()
=>
{
const
res
=
await
statusCheckIn
({
empCode
:
JSON
.
parse
(
localStorage
.
getItem
(
"user"
)).
code
,
});
if
(
res
.
data
&&
res
.
data
.
errorCode
==
0
)
{
if
(
res
.
data
.
data
.
notCheckInYet
==
1
)
{
setStatus
(
0
);
}
else
if
(
res
.
data
.
data
.
notCheckOutYet
==
1
)
{
setStatus
(
1
);
changeIdCheck
(
res
.
data
.
data
.
checkInID
);
}
else
if
(
res
.
data
.
data
.
doneCheck
==
1
)
{
setStatus
(
2
);
}
}
else
if
(
res
.
status
==
403
||
res
.
status
==
401
)
{
localStorage
.
removeItem
(
"TOKEN_KEY"
);
localStorage
.
removeItem
(
"user"
);
setTimeout
(()
=>
{
history
.
push
(
"/"
);
},
100
);
}
else
{
window
.
alert
(
"Lỗi"
);
}
};
const
signOut
=
()
=>
{
localStorage
.
removeItem
(
"TOKEN_KEY"
);
localStorage
.
removeItem
(
"user"
);
setTimeout
(()
=>
{
history
.
push
(
"/"
);
},
100
);
};
return
(
<
Container
fixed
style
=
{{
height
:
"100vh"
}}
>
<
div
style
=
{{
marginTop
:
50
}}
/
>
<
div
style
=
{{
textAlign
:
"center"
,
fontSize
:
"35px"
}}
>
<
Container
fixed
style
=
{{
height
:
"100vh"
,
position
:
"relative"
}}
>
<
div
style
=
{{
marginTop
:
10
}}
/
>
<
br
/>
<
div
style
=
{{
textAlign
:
"right"
}}
>
<
Button
variant
=
"contained"
color
=
"secondary"
onClick
=
{
signOut
}
>
Đă
ng
xu
ấ
t
<
/Button
>
<
/div
>
<
div
style
=
{{
textAlign
:
"center"
,
fontSize
:
"35px"
,
marginTop
:
"15px"
}}
>
<
Typography
variant
=
{
"h4"
}
style
=
{{
color
:
" #3399ff"
}}
>
Ch
à
o
m
ừ
ng
{
user
?
user
.
name
:
""
}
Ch
à
o
m
ừ
ng
<
/Typography
>
<
h6
style
=
{{
fontSize
:
"30px"
,
margin
:
"0px"
,
color
:
" #3399ff"
}}
>
{
user
?
user
.
name
:
""
}
<
/h6
>
<
/div
>
<
br
/>
<
Grid
container
style
=
{{
height
:
"
100vh
"
,
justifyContent
:
"center"
}}
>
<
Grid
container
style
=
{{
height
:
"
65%
"
,
justifyContent
:
"center"
}}
>
<
Fab
color
=
"secondary"
aria
-
label
=
"edit"
style
=
{{
width
:
"30vw"
,
height
:
"30vw"
}}
onClick
=
{
onCheckIn
}
onClick
=
{()
=>
{
onCheckIn
(
status
);
}}
className
=
{
status
==
0
?
"checkin"
:
status
==
1
?
"checkout"
:
"complete"
}
>
<
span
style
=
{{
fontSize
:
"3vw"
}}
>
{
status
==
0
?
"Checkin"
:
"Checkout"
}
{
status
==
0
?
"CHECK-IN"
:
status
==
1
?
"CHECK-OUT"
:
"Hoàn thành"
}
<
/span
>
<
/Fab
>
<
/Grid
>
...
...
src/View/Login/LoginScreen.js
View file @
e574ccfa
...
...
@@ -52,18 +52,22 @@ const LoginScreen = () => {
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
);
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
({
name
:
res
.
data
.
data
.
fullName
,
code
:
res
.
data
.
data
.
code
,
})
);
history
.
push
({
pathname
:
"/home"
,
state
:
{
code
:
res
.
data
.
data
.
code
,
fullName
:
res
.
data
.
data
.
fullName
},
...
...
@@ -92,7 +96,7 @@ const LoginScreen = () => {
margin
=
"normal"
required
fullWidth
label
=
"
e
mail"
label
=
"
E
mail"
autoComplete
=
"email"
onChange
=
{(
e
)
=>
{
setState
({
...
...
src/View/RootView.js
View file @
e574ccfa
...
...
@@ -6,15 +6,57 @@ import HomeScreen from "./Home/HomeContainer";
const
RootView
=
()
=>
{
let
history
=
useHistory
();
function
PrivateRoute
({
children
,
...
rest
})
{
let
accessToken
=
localStorage
.
getItem
(
"TOKEN_KEY"
);
return
(
<
Route
{...
rest
}
render
=
{({
location
})
=>
accessToken
?
(
children
)
:
(
<
Redirect
to
=
{{
pathname
:
"/"
,
state
:
{
from
:
location
},
}}
/
>
)
}
/
>
);
}
function
PublicRoute
({
children
,
...
rest
})
{
let
accessToken
=
localStorage
.
getItem
(
"TOKEN_KEY"
);
return
(
<
Route
{...
rest
}
render
=
{({
location
})
=>
!
accessToken
?
(
children
)
:
(
<
Redirect
to
=
{{
pathname
:
"/home"
,
state
:
{
from
:
location
},
}}
/
>
)
}
/
>
);
}
return
(
<
BrowserRouter
>
<
Switch
>
<
Route
exact
path
=
"/"
>
<
Public
Route
exact
path
=
"/"
>
<
LoginScreen
/>
<
/Route
>
<
Route
path
=
"/home"
>
<
/
Public
Route
>
<
Private
Route
path
=
"/home"
>
<
HomeScreen
/>
<
/Route
>
<
/
Private
Route
>
<
/Switch
>
<
/BrowserRouter
>
);
...
...
src/api/user.js
View file @
e574ccfa
...
...
@@ -19,3 +19,8 @@ export const checkOutApi = async (body) =>
PostData
(
"http://hrm.japi.dcv.vn/venus-service/checkinService/checkout"
,
body
)
.
then
((
res
)
=>
res
)
.
catch
((
err
)
=>
err
);
export
const
statusCheckIn
=
async
(
body
)
=>
GetData
(
"http://hrm.api.dcv.vn/api/v1/checkin/personaldailycheckin"
,
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