Skip to content
Snippets Groups Projects
Commit ccf83bf4 authored by HyunjinNoh's avatar HyunjinNoh
Browse files

교수님 피드백 반영 ver1

parent 19918d25
No related branches found
No related tags found
No related merge requests found
Pipeline #8502 passed
...@@ -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:", error);
}); });
}, []); }, []);
...@@ -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/${collectionId}`, {method: "DELETE"})//fetch 기능을 사용하여 서버에 대한 네트워크 요청을 보냄 fetch(`/likes/${id}`, {method: "DELETE"})//fetch 기능을 사용하여 서버에 대한 네트워크 요청을 보냄
.then((r)=>r.json()) .then((r)=>r.json())
.then((r)=>{ .then((r)=>{
console.log(r); console.log(r);
......
...@@ -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={favList} likes={likes} toggleFavorite={toggleFavorite}/> <MusicList list={list} likes={likes} toggleFavorite={toggleFavorite}/>
); );
} }
......
...@@ -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.collectionCensoredName} </Typography> <Typography variant = "subtitle2"> {item.collectionName} </Typography>
</CardContent> </CardContent>
<CardActions> <CardActions>
<IconButton onClick = {() => toggleFavorite(item.collectionId, item.collectionCensoredName)}> <IconButton onClick = {() => toggleFavorite(item.collectionId, item.collectionName)}>
{(likes[item.collectionId] === true) ? <Favorite/> : <FavoriteBorder/>} {(likes[item.collectionId] === true) ? <Favorite/> : <FavoriteBorder/>}
</IconButton> </IconButton>
</CardActions> </CardActions>
......
...@@ -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: 'Bottom', horizontal: 'right'}} anchorOrigin = {{vertical: 'bottom', horizontal: 'right'}}
autoHideDuration = {3000} autoHideDuration = {3000}
onClose = {props.onClose} onClose = {props.onClose}
message = {props.message}> message = {props.message}>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment