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
b2869ee6
Commit
b2869ee6
authored
Nov 10, 2021
by
Kim, Subin
Browse files
Menu check
parent
55179450
Changes
2
Show whitespace changes
Inline
Side-by-side
client/src/components/Menu/Menu.js
View file @
b2869ee6
...
@@ -19,8 +19,18 @@ const Menu = () => {
...
@@ -19,8 +19,18 @@ const Menu = () => {
try
{
try
{
setError
(
""
)
setError
(
""
)
const
result
=
await
todoApi
.
getTodopercent
(
user
.
id
,
moment
().
format
(
"
YYYY-MM-DD
"
))
const
result
=
await
todoApi
.
getTodopercent
(
user
.
id
,
moment
().
format
(
"
YYYY-MM-DD
"
))
console
.
log
(
"
client resList
"
,
result
)
setTodoList
({
...
todoList
,
...
result
})
setTodoList
({...
todoList
,
...
result
})
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
async
function
checkFn
(
e
,
todoId
)
{
try
{
setError
(
""
)
const
check_v
=
e
.
target
.
value
===
"
true
"
?
true
:
false
await
todoApi
.
edit
({
id
:
todoId
,
done
:
check_v
},
user
.
id
)
todayTodo
()
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
...
@@ -41,13 +51,11 @@ const Menu = () => {
...
@@ -41,13 +51,11 @@ const Menu = () => {
<
div
className
=
"
d-flex flex-column justify-content-between flex-grow-1 py-4 ps-3 text-dark
"
>
<
div
className
=
"
d-flex flex-column justify-content-between flex-grow-1 py-4 ps-3 text-dark
"
>
<
div
className
=
"
user-select-none w-75 ps-3
"
>
<
div
className
=
"
user-select-none w-75 ps-3
"
>
<
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
)
=>
<
div
className
=
"
d-flex
"
>
if
(
idx
<=
2
)
return
<
div
className
=
"
d-flex
"
>
<
p
className
=
{
`form-check-label border-bottom border-2 text-nowrap 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
=
{
"
todoCheck
"
+
idx
}
value
=
{
todo
.
done
}
aria
-
label
=
"
checkbox
"
onClick
=
{(
e
)
=>
checkFn
(
e
,
todo
.
id
)}
checked
=
{
todo
.
done
}
/
>
<
/div
>
<
/div>
)
: <div className="text-center border-bottom border-2 pb-1">오늘의 Todo를 등록해 보세요!</
div
>
}
})
:
null
}
<
Link
className
=
"
d-flex justify-content-center text-dark text-decoration-none mt-2
"
to
=
{
`/todo/
${
moment
().
format
(
"
YYYY-MM-DD
"
)}
`
}
>
<
Link
className
=
"
d-flex justify-content-center text-dark text-decoration-none
"
to
=
{
`/todo/
${
moment
().
format
(
"
YYYY-MM-DD
"
)}
`
}
>
<
i
className
=
"
bi bi-plus-lg me-2
"
><
/i
>
<
i
className
=
"
bi bi-plus-lg me-2
"
><
/i
>
<
p
className
=
"
mb-0
"
>
더보기
<
/p
>
<
p
className
=
"
mb-0
"
>
더보기
<
/p
>
<
/Link
>
<
/Link
>
...
...
server/controllers/todo.controller.js
View file @
b2869ee6
...
@@ -37,24 +37,26 @@ const findbyDate = async (req, res, next) => {
...
@@ -37,24 +37,26 @@ const findbyDate = async (req, res, next) => {
const
findforPercent
=
async
(
req
,
res
)
=>
{
const
findforPercent
=
async
(
req
,
res
)
=>
{
try
{
try
{
let
doneTodo
=
null
let
sendList
=
null
const
userId
=
req
.
userId
const
userId
=
req
.
userId
const
{
start
,
end
}
=
req
.
query
const
{
start
,
end
}
=
req
.
query
if
(
end
)
{
if
(
end
)
{
// weekly에서 불러올 todoList
console
.
log
(
"
week 실행하냐
"
)
console
.
log
(
"
week 실행하냐
"
)
const
findList
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
userId
:
userId
},
{
date
:
[
start
,
end
]
}]
},
group
:
[
'
date
'
]
})
//
const findList
= await Todo.findAndCountAll({ where: { [Op.and]: [{ userId: userId }, { date: [start, end] }] },
order: [[]]
group: ['date'] })
console
.
log
(
"
week findList
"
,
findList
)
//
console.log("week findList",
findList)
}
else
{
}
else
{
// Menu
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
}]
},
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
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
}]
},
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
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
))
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
})
if
(
nonCheck
.
count
<
3
)
check
.
rows
.
forEach
(
el
=>
nonCheck
.
rows
.
push
(
el
.
dataValues
))
return
res
.
json
({
percent
:
percent
,
list
:
nonCheck
.
rows
.
slice
(
0
,
3
)
})
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
...
@@ -77,9 +79,11 @@ const edit = async (req, res) => {
...
@@ -77,9 +79,11 @@ const edit = async (req, res) => {
let
updated
=
null
let
updated
=
null
const
userId
=
req
.
userId
const
userId
=
req
.
userId
const
{
todoId
}
=
req
.
query
const
{
todoId
}
=
req
.
query
const
{
todoTitle
,
todoDate
}
=
req
.
body
const
{
todoTitle
,
todoDate
,
done
}
=
req
.
body
console
.
log
(
"
done==
"
,
done
,
userId
,
todoId
)
if
(
todoTitle
)
updated
=
await
Todo
.
update
({
title
:
todoTitle
,
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
if
(
todoTitle
)
updated
=
await
Todo
.
update
({
title
:
todoTitle
,
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
else
updated
=
await
Todo
.
update
({
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
else
if
(
todoDate
)
updated
=
await
Todo
.
update
({
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
else
updated
=
await
Todo
.
update
({
done
:
!
done
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
if
(
!
updated
)
throw
new
Error
(
"
해당 todo의 일부 정보를 수정하는데 실패하였습니다.
"
)
if
(
!
updated
)
throw
new
Error
(
"
해당 todo의 일부 정보를 수정하는데 실패하였습니다.
"
)
else
return
res
.
send
(
200
)
else
return
res
.
send
(
200
)
}
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