-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MRTK-26: implements artist spotlight with API data (#656)
* implements artist spotlight with API data * moves artist logic to artist module * moves just released logic to own component * only features artists with marketplace sales * updates artist skeleton styling * removes errant code * minor updates
- Loading branch information
Showing
15 changed files
with
294 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export enum Tags { | ||
Artist = "Artist", | ||
Sale = "Sale", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { FunctionComponent } from "react"; | ||
import { Grid, Stack, Typography } from "@mui/material"; | ||
import { useRouter } from "next/navigation"; | ||
import ArtistsSkeleton from "./skeletons/ArtistsSkeleton"; | ||
import Artist from "./Artist"; | ||
import { Artist as ArtistItem } from "../modules/artist"; | ||
|
||
interface ArtistsProps { | ||
readonly artists?: ReadonlyArray<ArtistItem>; | ||
readonly hasTitle?: boolean; | ||
readonly isLoading?: boolean; | ||
readonly itemOrientation: "row" | "column"; | ||
readonly numSkeletons?: number; | ||
readonly title?: string; | ||
} | ||
|
||
const Artists: FunctionComponent<ArtistsProps> = ({ | ||
hasTitle = true, | ||
isLoading = false, | ||
itemOrientation, | ||
numSkeletons = 10, | ||
artists = [], | ||
title, | ||
}) => { | ||
const router = useRouter(); | ||
|
||
const handleSelectArtist = (id: string) => { | ||
router.push(`/artist/${id}`); | ||
}; | ||
|
||
if (isLoading) { | ||
return ( | ||
<Stack alignItems="center" mb={ 3.5 } mt={ 17 }> | ||
<ArtistsSkeleton | ||
hasTitle={ hasTitle } | ||
itemOrientation={ itemOrientation } | ||
numItems={ numSkeletons } | ||
/> | ||
</Stack> | ||
); | ||
} | ||
|
||
return ( | ||
<Stack> | ||
<Stack alignItems="center" mb={ 3.5 } mt={ 17 }> | ||
<Typography fontSize={ ["24px", "24px", "32px"] } variant="h3"> | ||
ARTIST SPOTLIGHT | ||
</Typography> | ||
</Stack> | ||
|
||
<Grid justifyContent="flex-start" rowGap={ 5 } container> | ||
{ artists.map(({ id, pictureUrl, name, marketplaceSongCount }, idx) => { | ||
return ( | ||
<Grid | ||
display="flex" | ||
justifyContent="center" | ||
key={ id } | ||
lg={ 2.4 } | ||
md={ 3 } | ||
sm={ 4 } | ||
xs={ 6 } | ||
item | ||
> | ||
<Artist | ||
imageUrl={ pictureUrl } | ||
isLoading={ isLoading } | ||
orientation="column" | ||
subtitle={ `${marketplaceSongCount} songs` } | ||
title={ name } | ||
onSelectArtist={ () => handleSelectArtist(id) } | ||
/> | ||
</Grid> | ||
); | ||
}) } | ||
</Grid> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default Artists; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Box } from "@mui/material"; | ||
import { FunctionComponent } from "react"; | ||
import Sales from "./Sales"; | ||
import { useGetSalesQuery } from "../modules/sale/api"; | ||
|
||
const RecentSongs: FunctionComponent = () => { | ||
const { data, isLoading } = useGetSalesQuery({ | ||
limit: 8, | ||
sortOrder: "desc", | ||
}); | ||
|
||
return ( | ||
<Box mt={ [7.5, 5.5, 10] }> | ||
<Sales isLoading={ isLoading } sales={ data } title="JUST RELEASED" /> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default RecentSongs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
apps/marketplace/src/components/skeletons/ArtistsSkeleton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Box, Grid, Skeleton, Stack } from "@mui/material"; | ||
import { FunctionComponent } from "react"; | ||
import ArtistSkeleton from "./ArtistSkeleton"; | ||
|
||
interface SalesSkeletonProps { | ||
readonly hasTitle?: boolean; | ||
readonly itemOrientation: "column" | "row"; | ||
readonly numItems?: number; | ||
} | ||
|
||
const SalesSkeleton: FunctionComponent<SalesSkeletonProps> = ({ | ||
hasTitle = true, | ||
numItems = 10, | ||
itemOrientation, | ||
}) => { | ||
return ( | ||
<Stack alignItems="center"> | ||
{ hasTitle && ( | ||
<Box mb={ 3.5 }> | ||
<Skeleton height={ 76 } width={ 480 } /> | ||
</Box> | ||
) } | ||
|
||
<Grid justifyContent="flex-start" pb={ 1 } rowGap={ 1.5 } container> | ||
{ new Array(numItems).fill(null).map((_, idx) => { | ||
return ( | ||
<Grid | ||
key={ idx } | ||
lg={ itemOrientation === "column" ? 2.4 : 3 } | ||
md={ 3 } | ||
sm={ 4 } | ||
xs={ 6 } | ||
item | ||
> | ||
<ArtistSkeleton orientation={ itemOrientation } /> | ||
</Grid> | ||
); | ||
}) } | ||
</Grid> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default SalesSkeleton; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
GetArtistResponse, | ||
GetArtistsParams, | ||
GetArtistsResponse, | ||
} from "./types"; | ||
import { newmApi } from "../../api"; | ||
import { setToastMessage } from "../ui"; | ||
import { Tags } from "../../api/newm/types"; | ||
|
||
export const extendedApi = newmApi.injectEndpoints({ | ||
endpoints: (build) => ({ | ||
getArtist: build.query<GetArtistResponse, string>({ | ||
async onQueryStarted(body, { dispatch, queryFulfilled }) { | ||
try { | ||
await queryFulfilled; | ||
} catch (error) { | ||
dispatch( | ||
setToastMessage({ | ||
message: "An error occurred while fetching artist", | ||
severity: "error", | ||
}) | ||
); | ||
} | ||
}, | ||
|
||
providesTags: [Tags.Artist], | ||
|
||
query: (id) => ({ | ||
method: "GET", | ||
url: `v1/marketplace/artists/${id}`, | ||
}), | ||
}), | ||
getArtists: build.query<GetArtistsResponse, GetArtistsParams | void>({ | ||
async onQueryStarted(body, { dispatch, queryFulfilled }) { | ||
try { | ||
await queryFulfilled; | ||
} catch (error) { | ||
dispatch( | ||
setToastMessage({ | ||
message: "An error occurred while fetching artists", | ||
severity: "error", | ||
}) | ||
); | ||
} | ||
}, | ||
|
||
providesTags: [Tags.Artist], | ||
|
||
query: ({ ids, genres, ...rest } = {}) => ({ | ||
method: "GET", | ||
params: { | ||
...(ids ? { ids: ids.join(",") } : {}), | ||
...(genres ? { genres: genres.join(",") } : {}), | ||
...rest, | ||
}, | ||
url: "v1/marketplace/artists", | ||
}), | ||
}), | ||
}), | ||
}); | ||
|
||
export const { useGetArtistsQuery, useGetArtistQuery } = extendedApi; | ||
|
||
export default extendedApi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./api"; | ||
export * from "./types"; |
Oops, something went wrong.