@@ -73,8 +118,8 @@ function TopAlbums() {
>
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- topAlbums.map((album: any) => (
-
+ topAlbums.map((album: any, index: number) => (
+
diff --git a/apps/web/src/pages/profile/overview/topartists/TopArtists.tsx b/apps/web/src/pages/profile/overview/topartists/TopArtists.tsx
index a9c1bd9a..d1c9fc67 100644
--- a/apps/web/src/pages/profile/overview/topartists/TopArtists.tsx
+++ b/apps/web/src/pages/profile/overview/topartists/TopArtists.tsx
@@ -14,6 +14,17 @@ import Artist from "../../../../components/Icons/Artist";
import { useArtistsQuery } from "../../../../hooks/useLibrary";
import { useProfileStatsByDidQuery } from "../../../../hooks/useProfile";
import styles from "./styles";
+import { IconChevronDown } from "@tabler/icons-react";
+import { getLastDays } from "../../../../lib/date";
+import LastDaysMenu from "../../../../components/LastDaysMenu";
+import {
+ LAST_180_DAYS,
+ LAST_30_DAYS,
+ LAST_365_DAYS,
+ LAST_7_DAYS,
+ LAST_90_DAYS,
+ LAST_DAYS_LABELS,
+} from "../../../../consts";
const Group = styled.div<{ mb?: number }>`
display: flex;
@@ -40,17 +51,29 @@ interface TopArtistsProps {
offset?: number;
size?: number;
showPagination?: boolean;
+ withDateRange?: boolean;
}
function TopArtists(props: TopArtistsProps) {
- const { showTitle = true, size = 30, showPagination } = props;
+ const { showTitle = true, size = 30, showPagination, withDateRange } = props;
+ const [topArtistsRange, setTopArtistsRange] = useState(
+ withDateRange ? LAST_7_DAYS : undefined,
+ );
+ const [range, setRange] = useState<[Date, Date] | []>(
+ withDateRange ? getLastDays(7) : [],
+ );
const setTopArtists = useSetAtom(topArtistsAtom);
const topArtists = useAtomValue(topArtistsAtom);
const { darkMode } = useAtomValue(themeAtom);
const { did } = useParams({ strict: false });
const profileStats = useProfileStatsByDidQuery(did!);
const [currentPage, setCurrentPage] = useState(1);
- const artistsResult = useArtistsQuery(did!, (currentPage - 1) * size, size);
+ const artistsResult = useArtistsQuery(
+ did!,
+ (currentPage - 1) * size,
+ size,
+ ...range,
+ );
const user = useAtomValue(userAtom);
const pages = useMemo(() => {
if (!did || !profileStats.data || !props.size) {
@@ -59,6 +82,29 @@ function TopArtists(props: TopArtistsProps) {
return Math.ceil(profileStats.data.artists / props.size) || 1;
}, [profileStats.data, did, props.size]);
+ const onSelectLastDays = (id: string) => {
+ setTopArtistsRange(id);
+ switch (id) {
+ case LAST_7_DAYS:
+ setRange(getLastDays(7));
+ break;
+ case LAST_30_DAYS:
+ setRange(getLastDays(30));
+ break;
+ case LAST_90_DAYS:
+ setRange(getLastDays(90));
+ break;
+ case LAST_180_DAYS:
+ setRange(getLastDays(180));
+ break;
+ case LAST_365_DAYS:
+ setRange(getLastDays(365));
+ break;
+ default:
+ setRange([]);
+ }
+ };
+
useEffect(() => {
if (artistsResult.isLoading || artistsResult.isError) {
return;
@@ -84,12 +130,17 @@ function TopArtists(props: TopArtistsProps) {
>
Top Artists
-
- See All
-
+
+
+
)}
diff --git a/apps/web/src/pages/profile/overview/toptracks/TopTracks.tsx b/apps/web/src/pages/profile/overview/toptracks/TopTracks.tsx
index 7adc6361..b67ba0ad 100644
--- a/apps/web/src/pages/profile/overview/toptracks/TopTracks.tsx
+++ b/apps/web/src/pages/profile/overview/toptracks/TopTracks.tsx
@@ -13,6 +13,17 @@ import { userAtom } from "../../../../atoms/user";
import { useTracksQuery } from "../../../../hooks/useLibrary";
import { useProfileStatsByDidQuery } from "../../../../hooks/useProfile";
import styles from "./styles";
+import { IconChevronDown } from "@tabler/icons-react";
+import { getLastDays } from "../../../../lib/date";
+import {
+ LAST_7_DAYS,
+ LAST_30_DAYS,
+ LAST_90_DAYS,
+ LAST_180_DAYS,
+ LAST_365_DAYS,
+ LAST_DAYS_LABELS,
+} from "../../../../consts";
+import LastDaysMenu from "../../../../components/LastDaysMenu";
type Row = {
id: string;
@@ -51,6 +62,7 @@ interface TopTracksProps {
offset?: number;
size?: number;
showPagination?: boolean;
+ withDateRange?: boolean;
}
function TopTracks(props: TopTracksProps) {
@@ -60,6 +72,11 @@ function TopTracks(props: TopTracksProps) {
showPagination: false,
...props,
};
+
+ const [range, setRange] = useState<[Date, Date] | []>(
+ props.withDateRange ? getLastDays(7) : [],
+ );
+ const [topTracksRange, setTopTracksRange] = useState