Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
Today KU
Commits
f07adc61
Commit
f07adc61
authored
Nov 08, 2021
by
Kim, Subin
Browse files
Todo
parent
a16ab1b4
Changes
4
Show whitespace changes
Inline
Side-by-side
client/src/components/Calendar/Weekly.js
View file @
f07adc61
import
{
useState
,
useEffect
,
useRef
}
from
"
react
"
;
import
{
useState
,
useEffect
,
useRef
}
from
"
react
"
;
import
{
useHistory
,
useParams
}
from
"
react-router-dom
"
;
import
{
useHistory
,
useParams
}
from
"
react-router-dom
"
;
import
Date
from
"
./DateSet
"
;
import
Date
from
"
./DateSet
"
;
import
todoApi
from
"
../../apis/todo.api
"
;
import
{
useAuth
}
from
"
../../utils/context
"
;
import
catchErrors
from
"
../../utils/catchErrors
"
;
import
moment
from
'
moment
'
;
import
moment
from
'
moment
'
;
import
FullCalendar
,
{
createPlugin
}
from
'
@fullcalendar/react
'
;
import
FullCalendar
,
{
createPlugin
}
from
'
@fullcalendar/react
'
;
import
interactionPlugin
from
"
@fullcalendar/interaction
"
;
import
interactionPlugin
from
"
@fullcalendar/interaction
"
;
import
bootstrapPlugin
from
'
@fullcalendar/bootstrap
'
;
import
bootstrapPlugin
from
'
@fullcalendar/bootstrap
'
;
const
Weekly
=
()
=>
{
const
Weekly
=
()
=>
{
const
{
user
}
=
useAuth
()
const
history
=
useHistory
()
const
history
=
useHistory
()
const
{
date
}
=
useParams
()
const
{
date
}
=
useParams
()
const
[
initialDate
,
setInitialDate
]
=
useState
(
moment
().
format
(
"
YYYY-MM-DD
"
))
const
[
chooseDate
,
setChooseDate
]
=
useState
(
moment
(
date
).
format
(
"
YYYY-MM-DD
"
))
const
[
chooseDate
,
setChooseDate
]
=
useState
(
moment
(
date
).
format
(
"
YYYY-MM-DD
"
))
const
[
week
,
setWeek
]
=
useState
([
const
[
week
,
setWeek
]
=
useState
([
{
date
:
moment
(
date
).
day
(
0
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
75
"
},
{
date
:
moment
(
date
).
day
(
0
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
75
"
},
...
@@ -19,6 +24,7 @@ const Weekly = () => {
...
@@ -19,6 +24,7 @@ const Weekly = () => {
{
date
:
moment
(
date
).
day
(
5
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
0
"
},
{
date
:
moment
(
date
).
day
(
5
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
0
"
},
{
date
:
moment
(
date
).
day
(
6
).
format
(
"
YYYY-MM-DD
"
),
rate
:
""
}
{
date
:
moment
(
date
).
day
(
6
).
format
(
"
YYYY-MM-DD
"
),
rate
:
""
}
])
])
const
[
error
,
setError
]
=
useState
(
""
)
const
calendarRef
=
useRef
(
null
)
const
calendarRef
=
useRef
(
null
)
let
calendar
=
null
let
calendar
=
null
...
@@ -30,6 +36,7 @@ const Weekly = () => {
...
@@ -30,6 +36,7 @@ const Weekly = () => {
useEffect
(()
=>
{
useEffect
(()
=>
{
setChooseDate
(
moment
(
date
).
format
(
"
YYYY-MM-DD
"
))
setChooseDate
(
moment
(
date
).
format
(
"
YYYY-MM-DD
"
))
getTodoList
()
setWeek
([
setWeek
([
{
date
:
moment
(
date
).
day
(
0
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
7
"
},
{
date
:
moment
(
date
).
day
(
0
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
7
"
},
{
date
:
moment
(
date
).
day
(
1
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
8
"
},
{
date
:
moment
(
date
).
day
(
1
).
format
(
"
YYYY-MM-DD
"
),
rate
:
"
8
"
},
...
@@ -41,6 +48,16 @@ const Weekly = () => {
...
@@ -41,6 +48,16 @@ const Weekly = () => {
])
])
},
[
date
])
},
[
date
])
async
function
getTodoList
()
{
try
{
setError
(
""
)
const
result
=
await
todoApi
.
getTodopercent
(
user
.
id
,
moment
(
date
).
day
(
0
).
format
(
"
YYYY-MM-DD
"
),
moment
(
date
).
day
(
6
).
format
(
"
YYYY-MM-DD
"
))
console
.
log
(
"
result==
"
,
result
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
function
prev
()
{
function
prev
()
{
calendar
.
prev
()
calendar
.
prev
()
let
date
=
moment
(
calendar
.
getDate
()).
format
(
'
YYYY-MM-DD
'
)
let
date
=
moment
(
calendar
.
getDate
()).
format
(
'
YYYY-MM-DD
'
)
...
@@ -91,8 +108,8 @@ const Weekly = () => {
...
@@ -91,8 +108,8 @@ const Weekly = () => {
views
=
{{
views
=
{{
week
:
{
week
:
{
validRange
:
{
validRange
:
{
start
:
moment
(
choose
Date
).
subtract
(
3
,
'
years
'
).
format
(
'
YYYY-MM[-01]
'
),
start
:
moment
(
initial
Date
).
subtract
(
3
,
'
years
'
).
format
(
'
YYYY-MM[-01]
'
),
end
:
moment
(
choose
Date
).
add
(
3
,
'
years
'
).
add
(
1
,
'
months
'
).
format
(
'
YYYY-MM[-01]
'
)
end
:
moment
(
initial
Date
).
add
(
3
,
'
years
'
).
add
(
1
,
'
months
'
).
format
(
'
YYYY-MM[-01]
'
)
},
},
dateIncrement
:
{
dateIncrement
:
{
days
:
7
days
:
7
...
...
client/src/components/Menu/Menu.js
View file @
f07adc61
...
@@ -43,7 +43,7 @@ const Menu = () => {
...
@@ -43,7 +43,7 @@ const Menu = () => {
<
h2
className
=
"
mb-4
"
>
To
-
do
<
/h2
>
<
h2
className
=
"
mb-4
"
>
To
-
do
<
/h2
>
{
todoList
.
list
.
length
!==
0
?
todoList
.
list
.
map
((
todo
,
idx
)
=>
{
{
todoList
.
list
.
length
!==
0
?
todoList
.
list
.
map
((
todo
,
idx
)
=>
{
if
(
idx
<=
2
)
return
<
div
className
=
"
d-flex
"
>
if
(
idx
<=
2
)
return
<
div
className
=
"
d-flex
"
>
<
p
className
=
{
`form-check-label border-bottom border-2 fs-5 pb-1 me-3
${
styles
.
title
}
`
}
>
{
todo
.
title
}
<
/p
>
<
p
className
=
{
`form-check-label border-bottom border-2
text-nowrap
fs-5 pb-1 me-3
${
styles
.
title
}
`
}
>
{
todo
.
title
}
<
/p
>
<
input
className
=
{
`form-check-input rounded-0 border-dark shadow-none mt-1
${
styles
.
checkBox
}
`
}
type
=
"
checkbox
"
id
=
"
inlineCheckbox1
"
aria
-
label
=
"
checkbox
"
checked
=
{
todo
.
done
}
/
>
<
input
className
=
{
`form-check-input rounded-0 border-dark shadow-none mt-1
${
styles
.
checkBox
}
`
}
type
=
"
checkbox
"
id
=
"
inlineCheckbox1
"
aria
-
label
=
"
checkbox
"
checked
=
{
todo
.
done
}
/
>
<
/div
>
<
/div
>
})
:
null
}
})
:
null
}
...
...
client/src/components/TodoList.js
View file @
f07adc61
...
@@ -52,19 +52,19 @@ const TodoList = () => {
...
@@ -52,19 +52,19 @@ const TodoList = () => {
}
}
return
(
return
(
<
div
className
=
{
"
mt-3
"
+
(
todoList
.
length
?
"
d-flex
"
:
"
d-block
"
)}
>
<
div
className
=
{
"
mt-3
"
+
(
todoList
.
length
?
"
d-flex
flex-column
"
:
"
d-block
"
)}
>
{
todoList
.
length
!==
0
?
{
todoList
.
length
!==
0
?
todoList
.
map
((
todo
,
idx
)
=>
<>
todoList
.
map
((
todo
,
idx
)
=>
<
div
className
=
"
d-flex
"
>
<
div
className
=
"
d-flex align-items-center
"
style
=
{{
width
:
"
75%
"
}}
>
<
div
className
=
"
d-flex align-items-center
"
style
=
{{
width
:
"
75%
"
}}
>
<
input
className
=
{
`form-check-input rounded-0 shadow-none mt-0
${
styles
.
checkBox
}
`
}
type
=
"
checkbox
"
checked
=
{
todo
.
done
}
/
>
<
input
className
=
{
`form-check-input rounded-0 shadow-none mt-0
me-2
${
styles
.
checkBox
}
`
}
type
=
"
checkbox
"
checked
=
{
todo
.
done
}
/
>
<
label
className
=
"
form-check-label fs-5
ms-3
pe-2 text-nowrap
"
style
=
{{
overflow
:
"
hidden
"
,
textOverflow
:
"
ellipsis
"
}}
>
{
todo
.
todoTitle
}
<
/label
>
<
label
className
=
"
form-check-label fs-5 pe-2 text-nowrap
"
style
=
{{
overflow
:
"
hidden
"
,
textOverflow
:
"
ellipsis
"
}}
>
{
todo
.
todoTitle
}
<
/label
>
<
/div
>
<
/div
>
<
div
className
=
"
d-flex justify-content-between
"
style
=
{{
cursor
:
"
pointer
"
,
width
:
"
25%
"
}}
>
<
div
className
=
"
d-flex justify-content-between
"
style
=
{{
cursor
:
"
pointer
"
,
width
:
"
25%
"
}}
>
<
i
className
=
"
bi bi-arrow-right fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#postmodal
"
onClick
=
{()
=>
setSelectTodo
(
todo
)}
><
/i
>
<
i
className
=
"
bi bi-arrow-right fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#postmodal
"
onClick
=
{()
=>
setSelectTodo
(
todo
)}
><
/i
>
<
i
className
=
"
bi bi-pencil-square fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#todomodal
"
onClick
=
{()
=>
setSelectTodo
(
todo
)}
><
/i
>
<
i
className
=
"
bi bi-pencil-square fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#todomodal
"
onClick
=
{()
=>
setSelectTodo
(
todo
)}
><
/i
>
<
i
className
=
"
bi bi-trash fs-5
"
onClick
=
{()
=>
delTodo
(
todo
.
id
)}
><
/i
>
<
i
className
=
"
bi bi-trash fs-5
"
onClick
=
{()
=>
delTodo
(
todo
.
id
)}
><
/i
>
<
/div
>
<
/div
>
<
/>
)
: <p className="text-center">등록된 할일이 없습니다.</
p
>
}
<
/
div
>
)
: <p className="text-center">등록된 할일이 없습니다.</
p
>
}
<
TodoPostModal
handleClick
=
{
delayTodo
}
/
>
<
TodoPostModal
handleClick
=
{
delayTodo
}
/
>
<
TodoModal
curDate
=
{
date
}
selectTodo
=
{
selectTodo
}
/
>
<
TodoModal
curDate
=
{
date
}
selectTodo
=
{
selectTodo
}
/
>
<
/div
>
<
/div
>
...
...
server/controllers/todo.controller.js
View file @
f07adc61
...
@@ -41,17 +41,19 @@ const findforPercent = async (req, res) => {
...
@@ -41,17 +41,19 @@ const findforPercent = async (req, res) => {
const
userId
=
req
.
userId
const
userId
=
req
.
userId
const
{
start
,
end
}
=
req
.
query
const
{
start
,
end
}
=
req
.
query
if
(
end
)
{
if
(
end
)
{
const
{
count
,
rows
}
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
}]
}
})
console
.
log
(
"
week 실행하냐
"
)
const
findList
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
userId
:
userId
},
{
date
:
[
start
,
end
]
}]
},
group
:
[
'
date
'
]
})
console
.
log
(
"
week findList
"
,
findList
)
}
else
{
}
else
{
let
percent
=
0
let
percent
=
0
console
.
log
(
"
findforPercent end 없음
"
)
console
.
log
(
"
findforPercent end 없음
"
)
const
nonCheck
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
false
}]
}
})
const
nonCheck
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
false
}]
}
,
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
const
check
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
true
}]
}
})
const
check
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
true
}]
}
,
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
let
total
=
nonCheck
.
count
+
check
.
count
let
total
=
nonCheck
.
count
+
check
.
count
check
.
rows
.
forEach
(
el
=>
nonCheck
.
rows
.
push
(
el
.
dataValues
))
check
.
rows
.
forEach
(
el
=>
nonCheck
.
rows
.
push
(
el
.
dataValues
))
console
.
log
(
"
non
"
,
nonCheck
)
console
.
log
(
"
non
"
,
nonCheck
)
if
(
total
===
0
)
percent
=
0
if
(
total
===
0
)
percent
=
0
else
percent
=
Math
.
round
((
check
.
count
/
total
)
*
100
)
else
percent
=
Math
.
round
((
check
.
count
/
total
)
*
100
)
return
res
.
json
({
percent
:
percent
,
list
:
nonCheck
.
rows
})
return
res
.
json
({
percent
:
percent
,
list
:
nonCheck
.
rows
})
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
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