From 48d77429db0d3ea9e04f0a25aa65f968efc75a12 Mon Sep 17 00:00:00 2001 From: Francisco Pessano Date: Mon, 14 Oct 2024 01:16:58 -0300 Subject: [PATCH] Profile show --- src/app/_components/h2.tsx | 15 ++++++++++++++ src/app/_components/showcase.tsx | 7 ++++++- src/app/_components/spotify-data.tsx | 28 +++++++++++++++----------- src/app/_components/user-showcase.tsx | 29 +++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 src/app/_components/h2.tsx create mode 100644 src/app/_components/user-showcase.tsx diff --git a/src/app/_components/h2.tsx b/src/app/_components/h2.tsx new file mode 100644 index 0000000..aa13fdf --- /dev/null +++ b/src/app/_components/h2.tsx @@ -0,0 +1,15 @@ +export function TypographyH2({ + children, + className, +}: { + children: React.ReactNode; + className?: string; +}) { + return ( +

+ {children} +

+ ); +} diff --git a/src/app/_components/showcase.tsx b/src/app/_components/showcase.tsx index b42f8f4..e584ed4 100644 --- a/src/app/_components/showcase.tsx +++ b/src/app/_components/showcase.tsx @@ -4,11 +4,15 @@ import React, { useState } from "react"; import Switch from "./switch"; import AlbumShowcase from "./album-showcase"; import ArtistShowcase from "./artist-showcase"; +import UserShowcase from "./user-showcase"; +import { TypographyH2 } from "./h2"; export function Showcase({ + userData, tracksByAlbum, artists, }: { + userData: Record; tracksByAlbum: Record; artists: any[]; }) { @@ -24,7 +28,8 @@ export function Showcase({ -

Tracks by album

+ + Tracks by album {Object.values(tracksByAlbum) .sort((a, b) => b.position - a.position) .map((album, index) => { diff --git a/src/app/_components/spotify-data.tsx b/src/app/_components/spotify-data.tsx index fd340fa..6ba3ce0 100644 --- a/src/app/_components/spotify-data.tsx +++ b/src/app/_components/spotify-data.tsx @@ -29,19 +29,19 @@ export default async function SpotifyData({ }); spotifyApi.setAccessToken(accessToken); - const albumsData = await spotifyApi.getMySavedAlbums({ limit: 20 }); - const albums = albumsData.body.items; + const [artistsData, tracksData, userData] = await Promise.all([ + spotifyApi.getMyTopArtists({ + limit: FETCH_ARTISTS_LIMIT, + time_range: "short_term", + }), + spotifyApi.getMyTopTracks({ + limit: FETCH_TRACKS_LIMIT, + time_range: "short_term", + }), + spotifyApi.getMe(), + ]); - const artistsData = await spotifyApi.getMyTopArtists({ - limit: FETCH_ARTISTS_LIMIT, - time_range: "short_term", - }); const artists = artistsData.body.items; - - const tracksData = await spotifyApi.getMyTopTracks({ - limit: FETCH_TRACKS_LIMIT, - time_range: "short_term", - }); const tracks = tracksData.body.items.map((track, i) => ({ ...track, position: i + 1, @@ -184,7 +184,11 @@ export default async function SpotifyData({ })} */} - + ); } diff --git a/src/app/_components/user-showcase.tsx b/src/app/_components/user-showcase.tsx new file mode 100644 index 0000000..17ea0c7 --- /dev/null +++ b/src/app/_components/user-showcase.tsx @@ -0,0 +1,29 @@ +"use client"; +import { TypographyH1 } from "./h1"; +import { TypographyH2 } from "./h2"; + +export default function UserShowcase({ + display_name, + spookify, + images, +}: { + display_name: string; + spookify: boolean; + images: { url: string }[]; +}) { + const imageSource = images && images[0]; + return ( +
+ {display_name} +
+ + {display_name} {spookify && "Spooky"} Showcase + +
+
+ ); +}