Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
react-material
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HyunjinNoh
react-material
Commits
ccf83bf4
Commit
ccf83bf4
authored
1 year ago
by
HyunjinNoh
Browse files
Options
Downloads
Patches
Plain Diff
교수님 피드백 반영 ver1
parent
19918d25
No related branches found
No related tags found
No related merge requests found
Pipeline
#8502
passed
1 year ago
Stage: deploy
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/App.js
+3
-3
3 additions, 3 deletions
src/App.js
src/Favorites.js
+2
-3
2 additions, 3 deletions
src/Favorites.js
src/MusicList.js
+2
-2
2 additions, 2 deletions
src/MusicList.js
src/SnackMsg.js
+1
-1
1 addition, 1 deletion
src/SnackMsg.js
with
8 additions
and
9 deletions
src/App.js
+
3
−
3
View file @
ccf83bf4
...
@@ -18,10 +18,10 @@ export default function App () {
...
@@ -18,10 +18,10 @@ export default function App () {
//사이트 처음 들어갈 때 좋아요 목록이랑 좋아요 표시가 잘 나타나도록
//사이트 처음 들어갈 때 좋아요 목록이랑 좋아요 표시가 잘 나타나도록
useEffect
(()
=>
{
useEffect
(()
=>
{
fetch
(
`/likes`
,
{
method
:
'
GET
'
})
fetch
(
`/likes`
,
{
method
:
'
GET
'
})
.
then
((
r
)
=>
Response
.
json
())
.
then
((
r
)
=>
r
.
json
())
.
then
((
r
)
=>
{
setFavorites
(
r
),
setLikes
(
r
);})
.
then
((
r
)
=>
{
setFavorites
(
r
),
setLikes
(
r
);})
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
error
(
"
Error fetching favorites:
"
,
e
);
console
.
error
(
"
Error fetching favorites:
"
,
e
rror
);
});
});
},
[]);
},
[]);
...
@@ -33,7 +33,7 @@ export default function App () {
...
@@ -33,7 +33,7 @@ export default function App () {
setSnackState
({
open
:
true
,
msg
:
`
${
name
}
is clicked`
})
setSnackState
({
open
:
true
,
msg
:
`
${
name
}
is clicked`
})
if
(
likes
[
id
])
{
//이미 좋아요를 한 item이라면
if
(
likes
[
id
])
{
//이미 좋아요를 한 item이라면
fetch
(
`/likes/
${
collectionI
d
}
`
,
{
method
:
"
DELETE
"
})
//fetch 기능을 사용하여 서버에 대한 네트워크 요청을 보냄
fetch
(
`/likes/
${
i
d
}
`
,
{
method
:
"
DELETE
"
})
//fetch 기능을 사용하여 서버에 대한 네트워크 요청을 보냄
.
then
((
r
)
=>
r
.
json
())
.
then
((
r
)
=>
r
.
json
())
.
then
((
r
)
=>
{
.
then
((
r
)
=>
{
console
.
log
(
r
);
console
.
log
(
r
);
...
...
This diff is collapsed.
Click to expand it.
src/Favorites.js
+
2
−
3
View file @
ccf83bf4
...
@@ -11,11 +11,10 @@ import React from 'react';
...
@@ -11,11 +11,10 @@ import React from 'react';
import
MusicList
from
'
./MusicList
'
;
import
MusicList
from
'
./MusicList
'
;
const
Favorites
=
({
list
,
likes
,
toggleFavorite
})
=>
{
const
Favorites
=
({
list
,
likes
,
toggleFavorite
})
=>
{
//이미 좋아요 리스트를 서버에서 넘겨받고 있기 때문에 favList 삭제
const
favList
=
list
.
filter
(
item
=>
likes
[
item
.
collectionId
])
//filter함수를 이용하여 좋아요 한 노래들만 필터링해서 favList에 집어넣기
return
(
return
(
<
MusicList
list
=
{
favL
ist
}
likes
=
{
likes
}
toggleFavorite
=
{
toggleFavorite
}
/
>
<
MusicList
list
=
{
l
ist
}
likes
=
{
likes
}
toggleFavorite
=
{
toggleFavorite
}
/
>
);
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/MusicList.js
+
2
−
2
View file @
ccf83bf4
...
@@ -25,10 +25,10 @@ export default function MusicList ({list, likes, toggleFavorite}) {
...
@@ -25,10 +25,10 @@ export default function MusicList ({list, likes, toggleFavorite}) {
<
Card
sx
=
{
styles
.
card
}
key
=
{
item
.
collectionId
}
>
<
Card
sx
=
{
styles
.
card
}
key
=
{
item
.
collectionId
}
>
<
CardContent
>
<
CardContent
>
<
Typography
varient
=
"
subtitle1
"
>
{
item
.
artistName
}
<
/Typography
>
<
Typography
varient
=
"
subtitle1
"
>
{
item
.
artistName
}
<
/Typography
>
<
Typography
variant
=
"
subtitle2
"
>
{
item
.
collection
Censored
Name
}
<
/Typography
>
<
Typography
variant
=
"
subtitle2
"
>
{
item
.
collectionName
}
<
/Typography
>
<
/CardContent
>
<
/CardContent
>
<
CardActions
>
<
CardActions
>
<
IconButton
onClick
=
{()
=>
toggleFavorite
(
item
.
collectionId
,
item
.
collection
Censored
Name
)}
>
<
IconButton
onClick
=
{()
=>
toggleFavorite
(
item
.
collectionId
,
item
.
collectionName
)}
>
{(
likes
[
item
.
collectionId
]
===
true
)
?
<
Favorite
/>
:
<
FavoriteBorder
/>
}
{(
likes
[
item
.
collectionId
]
===
true
)
?
<
Favorite
/>
:
<
FavoriteBorder
/>
}
<
/IconButton
>
<
/IconButton
>
<
/CardActions
>
<
/CardActions
>
...
...
This diff is collapsed.
Click to expand it.
src/SnackMsg.js
+
1
−
1
View file @
ccf83bf4
...
@@ -6,7 +6,7 @@ const SnackMsg = (props) => {
...
@@ -6,7 +6,7 @@ const SnackMsg = (props) => {
return
(
return
(
<
Snackbar
<
Snackbar
open
=
{
props
.
open
}
open
=
{
props
.
open
}
anchorOrigin
=
{{
vertical
:
'
B
ottom
'
,
horizontal
:
'
right
'
}}
anchorOrigin
=
{{
vertical
:
'
b
ottom
'
,
horizontal
:
'
right
'
}}
autoHideDuration
=
{
3000
}
autoHideDuration
=
{
3000
}
onClose
=
{
props
.
onClose
}
onClose
=
{
props
.
onClose
}
message
=
{
props
.
message
}
>
message
=
{
props
.
message
}
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment