diff --git a/apps/marketplace/src/components/ArtistSongs.tsx b/apps/marketplace/src/components/ArtistSongs.tsx index eef3d831..8378cfd3 100644 --- a/apps/marketplace/src/components/ArtistSongs.tsx +++ b/apps/marketplace/src/components/ArtistSongs.tsx @@ -2,13 +2,17 @@ import { Box } from "@mui/material"; import { FunctionComponent } from "react"; import Sales from "./Sales"; import { useGetSalesQuery } from "../modules/sale/api"; +import { SaleStatus } from "../modules/sale"; interface ArtistSongsProps { readonly artistId: string; } const ArtistSongs: FunctionComponent = ({ artistId }) => { - const { isLoading, data = [] } = useGetSalesQuery({ artistIds: [artistId] }); + const { isLoading, data = [] } = useGetSalesQuery({ + artistIds: [artistId], + saleStatuses: [SaleStatus.Started], + }); return ( diff --git a/apps/marketplace/src/components/MoreSongs.tsx b/apps/marketplace/src/components/MoreSongs.tsx index 8e94967c..8ff2367d 100644 --- a/apps/marketplace/src/components/MoreSongs.tsx +++ b/apps/marketplace/src/components/MoreSongs.tsx @@ -1,7 +1,7 @@ import { FunctionComponent } from "react"; import { Box, Typography, useTheme } from "@mui/material"; import Sales from "./Sales"; -import { useGetSalesQuery } from "../modules/sale"; +import { SaleStatus, useGetSalesQuery } from "../modules/sale"; interface MoreSongsProps { readonly artistId?: string; @@ -22,6 +22,7 @@ const MoreSongs: FunctionComponent = ({ artistIds: artistId ? [artistId] : undefined, ids: currentSaleId ? [`-${currentSaleId}`] : undefined, limit: 8, + saleStatuses: [SaleStatus.Started], }, { skip } ); diff --git a/apps/marketplace/src/components/RecentSongs.tsx b/apps/marketplace/src/components/RecentSongs.tsx index 3e72d8dc..7342ace0 100644 --- a/apps/marketplace/src/components/RecentSongs.tsx +++ b/apps/marketplace/src/components/RecentSongs.tsx @@ -2,10 +2,12 @@ import { Box } from "@mui/material"; import { FunctionComponent } from "react"; import Sales from "./Sales"; import { useGetSalesQuery } from "../modules/sale/api"; +import { SaleStatus } from "../modules/sale"; const RecentSongs: FunctionComponent = () => { const { data, isLoading } = useGetSalesQuery({ limit: 8, + saleStatuses: [SaleStatus.Started], sortOrder: "desc", }); diff --git a/apps/marketplace/src/components/SearchResults.tsx b/apps/marketplace/src/components/SearchResults.tsx index e4cbf4e8..bb21edea 100644 --- a/apps/marketplace/src/components/SearchResults.tsx +++ b/apps/marketplace/src/components/SearchResults.tsx @@ -1,7 +1,7 @@ import { FunctionComponent } from "react"; import { Box, Skeleton, Stack, Typography, useTheme } from "@mui/material"; import Sales from "./Sales"; -import { useGetSalesQuery } from "../modules/sale"; +import { SaleStatus, useGetSalesQuery } from "../modules/sale"; interface SearchResultsProps { readonly query: string; @@ -9,7 +9,10 @@ interface SearchResultsProps { const SearchResults: FunctionComponent = ({ query }) => { const theme = useTheme(); - const { isLoading, data: sales = [] } = useGetSalesQuery({ phrase: query }); + const { isLoading, data: sales = [] } = useGetSalesQuery({ + phrase: query, + saleStatuses: [SaleStatus.Started], + }); return ( diff --git a/apps/marketplace/src/components/SimilarSongs.tsx b/apps/marketplace/src/components/SimilarSongs.tsx index f4ba547f..319b98f3 100644 --- a/apps/marketplace/src/components/SimilarSongs.tsx +++ b/apps/marketplace/src/components/SimilarSongs.tsx @@ -1,7 +1,7 @@ import { FunctionComponent } from "react"; import { Box } from "@mui/material"; import Sales from "./Sales"; -import { useGetSalesQuery } from "../modules/sale"; +import { SaleStatus, useGetSalesQuery } from "../modules/sale"; interface SimilarSongsProps { readonly currentArtistId?: string; @@ -19,6 +19,7 @@ const SimilarSongs: FunctionComponent = ({ artistIds: currentArtistId ? [`-${currentArtistId}`] : undefined, genres, limit: 8, + saleStatuses: [SaleStatus.Started], }, { skip } ); diff --git a/apps/marketplace/src/modules/sale/api.ts b/apps/marketplace/src/modules/sale/api.ts index 474b281f..1cefab89 100644 --- a/apps/marketplace/src/modules/sale/api.ts +++ b/apps/marketplace/src/modules/sale/api.ts @@ -109,7 +109,7 @@ export const extendedApi = newmApi.injectEndpoints({ genres, moods, songIds, - statuses, + saleStatuses, ...rest } = {}) => ({ method: "GET", @@ -119,7 +119,7 @@ export const extendedApi = newmApi.injectEndpoints({ ...(genres ? { genres: genres.join(",") } : {}), ...(moods ? { moods: moods.join(",") } : {}), ...(songIds ? { songIds: songIds.join(",") } : {}), - ...(statuses ? { statuses: statuses.join(",") } : {}), + ...(saleStatuses ? { saleStatuses: saleStatuses.join(",") } : {}), ...rest, }, url: "v1/marketplace/sales", diff --git a/apps/marketplace/src/modules/sale/types.ts b/apps/marketplace/src/modules/sale/types.ts index 94ad26e5..7a78030e 100644 --- a/apps/marketplace/src/modules/sale/types.ts +++ b/apps/marketplace/src/modules/sale/types.ts @@ -100,12 +100,12 @@ export interface GetSalesParams { readonly olderThan?: string; // Case-insensitive phrase to filter by song title and artist name readonly phrase?: string; + // List of sale statuses to filter results + readonly saleStatuses?: ReadonlyArray; // List of song UUID's to filter results readonly songIds?: ReadonlyArray; // Sort order of the results based on createdAt field. Default is asc readonly sortOrder?: "asc" | "desc"; - // List of sale statuses to filter results - readonly statuses?: ReadonlyArray; } export interface GenerateOrderRequest {