generated from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Ifechukwudaniel/dashboard-ui
Dashboard UI
- Loading branch information
Showing
7 changed files
with
166 additions
and
77 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
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,62 @@ | ||
import { GetServerSideProps } from "next"; | ||
import { getSession } from "next-auth/react"; | ||
import DashboardLayout from "~~/components/dashboard/DashboardLayout"; | ||
import ArtistList from "~~/components/spotify/ArtistList"; | ||
import Heading from "~~/components/spotify/Heading"; | ||
import Layout from "~~/components/spotify/Layout"; | ||
import { MySession } from "~~/types/session"; | ||
import { Artist } from "~~/types/spotify"; | ||
import { customGet } from "~~/utils/beat-bridge/customGet"; | ||
import { isAuthenticated } from "~~/utils/beat-bridge/isAuthenticated"; | ||
|
||
interface IProps { | ||
topArtists: Artist[]; | ||
} | ||
|
||
export default function FollowedArtists({ topArtists }: IProps) { | ||
return ( | ||
<Layout title="Beat Bridge - Your Library"> | ||
<DashboardLayout> | ||
<Heading text="Your Artists" /> | ||
<select | ||
name="time-range" | ||
onChange={e => e.target.value} | ||
className="mx-2 pr-1 bg-transparent border-none rounded cursor-pointer text-base p-2 " | ||
> | ||
<option className="text-black" value="short_term"> | ||
the last 4 weeks | ||
</option> | ||
<option className="text-black" value="medium_term"> | ||
the last 6 months | ||
</option> | ||
<option className="text-black" value="long_term"> | ||
all time | ||
</option> | ||
</select> | ||
<ArtistList artists={topArtists} /> | ||
</DashboardLayout> | ||
</Layout> | ||
); | ||
} | ||
|
||
export const getServerSideProps: GetServerSideProps = async ctx => { | ||
const session = (await getSession(ctx)) as MySession | null; | ||
|
||
if (!(await isAuthenticated(session))) { | ||
return { | ||
redirect: { | ||
destination: "/login", | ||
permanent: false, | ||
}, | ||
}; | ||
} | ||
|
||
const timeRange = ctx.query.time_range || "short_term"; | ||
|
||
const topArtists = await customGet( | ||
`https://api.spotify.com/v1/me/top/artists?time_range=${timeRange}&limit=50`, | ||
session, | ||
); | ||
|
||
return { props: { topArtists: topArtists.items } }; | ||
}; |
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