Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
react-material
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nahyun
react-material
Commits
35b64778
Commit
35b64778
authored
1 year ago
by
nahyun
Browse files
Options
Downloads
Patches
Plain Diff
ㅠ
parent
64be09d5
No related branches found
No related tags found
No related merge requests found
Pipeline
#8491
passed
1 year ago
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/App.js
+34
-3
34 additions, 3 deletions
src/App.js
src/SearchPage.js
+1
-1
1 addition, 1 deletion
src/SearchPage.js
src/favorites.js
+15
-13
15 additions, 13 deletions
src/favorites.js
with
50 additions
and
17 deletions
src/App.js
+
34
−
3
View file @
35b64778
...
@@ -14,6 +14,37 @@ export default function App() {
...
@@ -14,6 +14,37 @@ export default function App() {
const
[
favorites
,
setFavorites
]
=
React
.
useState
([]);
const
[
favorites
,
setFavorites
]
=
React
.
useState
([]);
//const [like, setLike] = React.useState([]);
//const [like, setLike] = React.useState([]);
const
fetchfunc
=
()
=>
{
axios
.
get
(
'
http://localhost:8888/likes
'
)
.
then
((
response
)
=>
{
const
data
=
response
.
data
;
data
.
map
(
item
=>
{
console
.
log
(
item
);
handleOnLike
(
item
);
})
//onLike(data);
//setFavorites(data);
console
.
log
(
data
);
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Error:
'
,
error
);
});
}
useEffect
(()
=>
{
// axios.get('http://localhost:8888/likes')
// .then((response) => {
// const data = response.data;
// //onLike(data);
// //setFavorites(data);
// console.log(data);
// })
// .catch((error) => {
// console.error('Error:', error);
// });
fetchfunc
();
},
[]);
const
handleTabChange
=
(
event
,
newValue
)
=>
{
const
handleTabChange
=
(
event
,
newValue
)
=>
{
setCurrentTab
(
newValue
);
setCurrentTab
(
newValue
);
}
}
...
@@ -100,7 +131,7 @@ export default function App() {
...
@@ -100,7 +131,7 @@ export default function App() {
let
b
=
favorites
.
filter
((
it
)
=>
it
.
collectionId
!==
item
.
collectionId
);
let
b
=
favorites
.
filter
((
it
)
=>
it
.
collectionId
!==
item
.
collectionId
);
setFavorites
(
b
);
setFavorites
(
b
);
axios
.
delete
(
`/likes/
${
item
.
collectionId
}
`
)
axios
.
delete
(
`
http://localhost:8888
/likes/
${
item
.
collectionId
}
`
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
);
console
.
log
(
response
.
data
);
})
})
...
@@ -119,7 +150,7 @@ export default function App() {
...
@@ -119,7 +150,7 @@ export default function App() {
//setFavorites([...favorites, { ...item, like: true }]);
//setFavorites([...favorites, { ...item, like: true }]);
//좋아요 아이템 spring 서버로 보내기
//좋아요 아이템 spring 서버로 보내기
axios
.
post
(
'
/likes
'
,
{
axios
.
post
(
'
http://localhost:8888
/likes
'
,
{
collectionId
:
item
.
collectionId
,
collectionId
:
item
.
collectionId
,
collectionType
:
item
.
collectionType
,
collectionType
:
item
.
collectionType
,
artistId
:
item
.
artistId
,
artistId
:
item
.
artistId
,
...
@@ -209,7 +240,7 @@ export default function App() {
...
@@ -209,7 +240,7 @@ export default function App() {
</Box>
</Box>
{currentTab == 0 && <SearchPage list={searchResult} onSearch={setSearchResult} onLike={handleOnLike} />}
{currentTab == 0 && <SearchPage list={searchResult} onSearch={setSearchResult} onLike={handleOnLike} />}
{currentTab == 1 && <Favorites list={favorites} onLike={handleOnLike} />}
{currentTab == 1 && <Favorites list={favorites}
onFavorite={setFavorites}
onLike={handleOnLike} />}
{currentTab == 2 &&
{currentTab == 2 &&
<Typography align="center" variant="h2">Item Three</Typography>}
<Typography align="center" variant="h2">Item Three</Typography>}
</React.Fragment>
</React.Fragment>
...
...
This diff is collapsed.
Click to expand it.
src/SearchPage.js
+
1
−
1
View file @
35b64778
...
@@ -33,7 +33,7 @@ export default function SearchPage({ list, onSearch, onLike }) {
...
@@ -33,7 +33,7 @@ export default function SearchPage({ list, onSearch, onLike }) {
// console.error('Error:', error);
// console.error('Error:', error);
// });
// });
fetch
(
`/musicSearch/
${(
searchWord
)}
`
,
{
fetch
(
`
http://localhost:8888
/musicSearch/
${(
searchWord
)}
`
,
{
method
:
'
GET
'
,
// HTTP 메서드는 GET입니다.
method
:
'
GET
'
,
// HTTP 메서드는 GET입니다.
headers
:
{},
headers
:
{},
})
})
...
...
This diff is collapsed.
Click to expand it.
src/favorites.js
+
15
−
13
View file @
35b64778
...
@@ -5,19 +5,21 @@ import axios from 'axios';
...
@@ -5,19 +5,21 @@ import axios from 'axios';
import
React
,
{
useEffect
}
from
'
react
'
;
import
React
,
{
useEffect
}
from
'
react
'
;
import
App
from
'
./App
'
;
import
App
from
'
./App
'
;
const
Favorites
=
({
list
,
onLike
})
=>
{
const
Favorites
=
({
list
,
onSearch
,
onLike
})
=>
{
const
[
Favorites
,
setFavorites
]
=
React
.
useState
([]);
//const [Favorites, setFavorites] = React.useState([]);
useEffect
(()
=>
{
// useEffect(() => {
axios
.
get
(
'
/likes
'
)
// axios.get('http://localhost:8888/likes')
.
then
((
response
)
=>
{
// .then((response) => {
const
data
=
response
.
data
;
// const data = response.data;
setFavorites
(
data
);
// onLike(data);
})
// //setFavorites(data);
.
catch
((
error
)
=>
{
// console.log(data);
console
.
error
(
'
Error:
'
,
error
);
// })
});
// .catch((error) => {
},
[]);
// console.error('Error:', error);
// });
// }, []);
return
(
return
(
<
React
.
Fragment
>
<
React
.
Fragment
>
...
...
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