Skip to content

Commit

Permalink
Filter to only show active sales in marketplace (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
escobarjonatan authored Jul 9, 2024
1 parent 7bf5ad2 commit a55ce8c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
6 changes: 5 additions & 1 deletion apps/marketplace/src/components/ArtistSongs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArtistSongsProps> = ({ artistId }) => {
const { isLoading, data = [] } = useGetSalesQuery({ artistIds: [artistId] });
const { isLoading, data = [] } = useGetSalesQuery({
artistIds: [artistId],
saleStatuses: [SaleStatus.Started],
});

return (
<Box mt={ 7 }>
Expand Down
3 changes: 2 additions & 1 deletion apps/marketplace/src/components/MoreSongs.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,6 +22,7 @@ const MoreSongs: FunctionComponent<MoreSongsProps> = ({
artistIds: artistId ? [artistId] : undefined,
ids: currentSaleId ? [`-${currentSaleId}`] : undefined,
limit: 8,
saleStatuses: [SaleStatus.Started],
},
{ skip }
);
Expand Down
2 changes: 2 additions & 0 deletions apps/marketplace/src/components/RecentSongs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});

Expand Down
7 changes: 5 additions & 2 deletions apps/marketplace/src/components/SearchResults.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
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;
}

const SearchResults: FunctionComponent<SearchResultsProps> = ({ query }) => {
const theme = useTheme();
const { isLoading, data: sales = [] } = useGetSalesQuery({ phrase: query });
const { isLoading, data: sales = [] } = useGetSalesQuery({
phrase: query,
saleStatuses: [SaleStatus.Started],
});

return (
<Stack my={ 8 } rowGap={ 2.5 }>
Expand Down
3 changes: 2 additions & 1 deletion apps/marketplace/src/components/SimilarSongs.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,6 +19,7 @@ const SimilarSongs: FunctionComponent<SimilarSongsProps> = ({
artistIds: currentArtistId ? [`-${currentArtistId}`] : undefined,
genres,
limit: 8,
saleStatuses: [SaleStatus.Started],
},
{ skip }
);
Expand Down
4 changes: 2 additions & 2 deletions apps/marketplace/src/modules/sale/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const extendedApi = newmApi.injectEndpoints({
genres,
moods,
songIds,
statuses,
saleStatuses,
...rest
} = {}) => ({
method: "GET",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions apps/marketplace/src/modules/sale/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
// List of song UUID's to filter results
readonly songIds?: ReadonlyArray<string>;
// 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<string>;
}

export interface GenerateOrderRequest {
Expand Down

0 comments on commit a55ce8c

Please sign in to comment.