Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
송용우
2020-08-25 21:59:18 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
112fc5b560d342036bd432abd377e700f2e705f6
112fc5b5
2 parents
b7662131
0a64d87a
Merge commit '
0a64d87a
' into develop
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
79 additions
and
6 deletions
jaksimsamil-page/package.json
jaksimsamil-page/src/components/home/HeatMap.js
jaksimsamil-page/src/components/home/HomeForm.js
jaksimsamil-page/src/containers/home/HomeContainer.js
jaksimsamil-page/yarn.lock
jaksimsamil-page/package.json
View file @
112fc5b
...
...
@@ -13,6 +13,7 @@
"moment"
:
"^2.27.0"
,
"open-color"
:
"^1.7.0"
,
"react"
:
"^16.13.1"
,
"react-calendar-heatmap"
:
"^1.8.1"
,
"react-dom"
:
"^16.13.1"
,
"react-redux"
:
"^7.2.0"
,
"react-router-dom"
:
"^5.2.0"
,
...
...
jaksimsamil-page/src/components/home/HeatMap.js
0 → 100644
View file @
112fc5b
import
React
,
{
use
}
from
'react'
;
import
CalendarHeatmap
from
'react-calendar-heatmap'
;
import
'react-calendar-heatmap/dist/styles.css'
;
/*
TODO: 날짜 범위 지정, 날짜별 검색 추가
*/
/*
solvedBJbyDATE:
solvedBJbyDATE:{
20190304 : [Object]
...
}
*/
const
HeatMap
=
(
HMArr
)
=>
{
return
(
<
div
>
<
CalendarHeatmap
onClick
=
{()
=>
{
console
.
log
(
HMArr
);
}}
startDate
=
{
new
Date
(
'2020-01-01'
)}
endDate
=
{
new
Date
(
'2020-12-01'
)}
values
=
{
HMArr
.
HMArr
}
classForValue
=
{(
value
)
=>
{
if
(
!
value
)
{
return
'color-empty'
;
}
return
`color-github-
${
value
.
count
}
`
;
}}
tooltipDataAttrs
=
{(
value
)
=>
{
return
{
'data-tooltip'
:
`
${
value
.
date
}
has count:
${
value
.
count
}
`
,
};
}}
showWeekdayLabels
=
{
true
}
/
>
<
/div
>
);
};
export
default
HeatMap
;
jaksimsamil-page/src/components/home/HomeForm.js
View file @
112fc5b
...
...
@@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles';
import
Paper
from
'@material-ui/core/Paper'
;
import
Grid
from
'@material-ui/core/Grid'
;
import
palette
from
'../../lib/styles/palette'
;
import
AuthForm
from
'../auth/AuthForm
'
;
import
HeatMap
from
'./HeatMap
'
;
const
useStyles
=
makeStyles
((
theme
)
=>
({
root
:
{
flexGrow
:
1
,
...
...
@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
color
:
theme
.
palette
.
text
.
secondary
,
},
}));
const
HomeForm
=
({
PSdata
,
goalNum
})
=>
{
const
HomeForm
=
({
PSdata
,
HMArr
,
goalNum
})
=>
{
const
classes
=
useStyles
();
return
PSdata
?
(
<
div
className
=
{
classes
.
root
}
>
...
...
@@ -48,7 +48,11 @@ const HomeForm = ({ PSdata, goalNum }) => {
<
h3
>
마지막으로
푼
문제
<
/h3
>
<
/Paper
>
<
/Grid
>
<
Grid
item
xs
=
{
12
}
>
<
Paper
className
=
{
classes
.
paper
}
>
<
HeatMap
HMArr
=
{
HMArr
}
/
>
<
/Paper
>
<
/Grid
>
<
Grid
item
xs
=
{
4
}
>
<
Paper
className
=
{
classes
.
paper
}
>
<
h1
>
{
PSdata
.
weekNum
}
<
/h1
>
...
...
jaksimsamil-page/src/containers/home/HomeContainer.js
View file @
112fc5b
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
withRouter
}
from
'react-router-dom'
;
import
HomeForm
from
'../../components/home/HomeForm'
;
import
{
getPROFILE
,
initializeProfile
}
from
'../../modules/profile'
;
const
HomeContainer
=
({
history
})
=>
{
const
dispatch
=
useDispatch
();
const
[
HMArr
,
setHMArr
]
=
useState
([]);
const
{
user
,
profile
}
=
useSelector
(({
user
,
profile
})
=>
({
user
:
user
.
user
,
profile
:
profile
,
}));
const
makeHeatmapValues
=
(
PSdata
)
=>
{
let
obj_keys
=
Object
.
keys
(
PSdata
);
let
result
=
[];
for
(
let
i
=
0
;
i
<
obj_keys
.
length
;
i
++
)
{
result
.
push
({
date
:
//2019-10-15
obj_keys
[
i
].
slice
(
0
,
4
)
+
'-'
+
obj_keys
[
i
].
slice
(
4
,
6
)
+
'-'
+
obj_keys
[
i
].
slice
(
6
,
8
),
count
:
PSdata
[
obj_keys
[
i
]].
length
,
});
}
return
result
;
};
useEffect
(()
=>
{
if
(
!
user
)
{
alert
(
'로그인이 필요합니다 '
);
...
...
@@ -23,7 +42,9 @@ const HomeContainer = ({ history }) => {
}
},
[
dispatch
,
user
,
history
]);
useEffect
(()
=>
{
console
.
log
(
profile
);
if
(
profile
.
solvedBJ_date
)
{
setHMArr
(
makeHeatmapValues
(
profile
.
solvedBJ_date
.
solvedBJbyDATE
));
}
},
[
profile
]);
useEffect
(()
=>
{
if
(
user
)
{
...
...
@@ -31,6 +52,12 @@ const HomeContainer = ({ history }) => {
dispatch
(
getPROFILE
({
username
}));
}
},
[
dispatch
,
user
]);
return
<
HomeForm
PSdata
=
{
profile
.
solvedBJ_date
}
goalNum
=
{
profile
.
goalNum
}
/>
;
return
(
<
HomeForm
PSdata
=
{
profile
.
solvedBJ_date
}
HMArr
=
{
HMArr
}
goalNum
=
{
profile
.
goalNum
}
/
>
);
};
export
default
withRouter
(
HomeContainer
);
...
...
jaksimsamil-page/yarn.lock
View file @
112fc5b
This diff is collapsed. Click to expand it.
Please
register
or
login
to post a comment