Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
H
hw87AlenBolatov
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Болатов Ален
hw87AlenBolatov
Commits
f62cd5a1
Commit
f62cd5a1
authored
Mar 25, 2023
by
Болатов Ален
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
albums show in ascending order
parent
00b0ce0f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
6 deletions
+23
-6
Albums.tsx
frontend/src/containers/Albums.tsx
+15
-2
HomePage.tsx
frontend/src/containers/HomePage.tsx
+5
-2
albumSlice.ts
frontend/src/features/album/albumSlice.ts
+0
-1
IAlbum.ts
frontend/src/interfaces/IAlbum.ts
+3
-1
No files found.
frontend/src/containers/Albums.tsx
View file @
f62cd5a1
import
React
,
{
useEffect
}
from
'react'
;
import
{
getAlbumsByQueryParams
}
from
'../features/album/albumSlice'
;
import
{
useAppDispatch
,
useAppSelector
}
from
'../store/hooks'
;
import
{
useLocation
}
from
'react-router-dom'
;
const
Albums
=
()
=>
{
const
{
albums
}
=
useAppSelector
((
state
)
=>
state
.
album
);
const
dispatch
=
useAppDispatch
();
const
params
=
new
URLSearchParams
(
window
.
location
.
search
);
const
artist
=
params
.
get
(
'artist'
);
const
{
state
}
=
useLocation
();
useEffect
(()
=>
{
dispatch
(
getAlbumsByQueryParams
(
artist
!
));
},
[]);
},
[
dispatch
]);
return
(
<
div
>
<
h2
>
{
state
.
artist
}
</
h2
>
{
albums
.
map
((
album
)
=>
{
return
<
div
key=
{
album
.
_id
}
>
{
album
.
name
}
</
div
>;
return
(
<
div
key=
{
album
.
_id
}
>
<
img
className=
"w-48 h-48 object-cover "
src=
{
`${import.meta.env.VITE_MY_URL}/${album.image}`
}
alt=
{
album
.
name
}
/>
<
p
>
{
album
.
name
}
</
p
>
<
p
>
{
album
.
year
}
</
p
>
</
div
>
);
})
}
</
div
>
);
...
...
frontend/src/containers/HomePage.tsx
View file @
f62cd5a1
...
...
@@ -19,10 +19,13 @@ const HomePage = () => {
<
div
key=
{
artist
.
_id
}
>
<
img
onClick=
{
()
=>
navigate
({
pathname
:
'/albums'
,
search
:
`?artist=${artist._id}`
})
navigate
(
{
pathname
:
'/albums'
,
search
:
`?artist=${artist._id}`
},
{
state
:
{
artist
:
artist
.
name
}}
)
}
className=
"w-48 h-48 object-cover "
src=
{
`
http://localhost:3000
/${artist.photo}`
}
src=
{
`
${import.meta.env.VITE_MY_URL}
/${artist.photo}`
}
alt=
{
artist
.
name
}
/>
<
span
>
{
artist
.
name
}
</
span
>
...
...
frontend/src/features/album/albumSlice.ts
View file @
f62cd5a1
...
...
@@ -46,7 +46,6 @@ export const albumSlice = createSlice({
.
addCase
(
getAlbumsByQueryParams
.
fulfilled
,
(
state
,
{
payload
}:
PayloadAction
<
IAlbum
[]
>
)
=>
{
console
.
log
(
payload
);
state
.
albums
=
payload
;
}
);
...
...
frontend/src/interfaces/IAlbum.ts
View file @
f62cd5a1
import
IArtist
from
'./IArtist'
;
export
default
interface
IAlbum
{
name
:
string
;
artist
:
string
;
artist
:
IArtist
;
year
:
number
;
image
:
string
;
_id
:
string
;
...
...
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