This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cf6918
commit e17592e
Showing
10 changed files
with
150 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Home() { | ||
return <>Please Login</>; | ||
} |
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,40 @@ | ||
import { useSession } from "next-auth/react"; | ||
import DefaultLayout from "~/components/layout/default"; | ||
import Hero from "~/components/Hero"; | ||
import { api } from "~/utils/api"; | ||
|
||
type Props = { | ||
landingPage: true; | ||
}; | ||
|
||
export default function Home(props: Props) { | ||
const { data: sessionData } = useSession(); | ||
if (!sessionData) return null; | ||
const { data: twitch, isLoading: postLoading } = api.twitch.getUser.useQuery({ | ||
accessToken: sessionData.accessToken, | ||
}); | ||
|
||
return ( | ||
<> | ||
<DefaultLayout>{twitch?.data[0]}</DefaultLayout> | ||
</> | ||
); | ||
} | ||
|
||
// export default function Home() { | ||
// // get token from session and pass it to the server | ||
// const { data: sessionData } = useSession(); | ||
// if (!sessionData) return <Hero />; | ||
|
||
// const { data: twitch, isLoading: postLoading } = api.twitch.getUser.useQuery({ | ||
// accessToken: sessionData.accessToken, | ||
// }); | ||
|
||
// if (postLoading) return <>Loading...</>; | ||
|
||
// return ( | ||
// <> | ||
// <DefaultLayout>{twitch?.data[0]?.display_name}</DefaultLayout> | ||
// </> | ||
// ); | ||
// } |
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,21 @@ | ||
"use client"; | ||
|
||
import { useParams } from "next/navigation"; | ||
import { useSession } from "next-auth/react"; | ||
import DefaultLayout from "~/components/layout/default"; | ||
|
||
export default function ExampleClientComponent() { | ||
const params = useParams(); | ||
|
||
// get token from session and pass it to the server | ||
const { data: sessionData } = useSession(); | ||
|
||
console.log(sessionData); | ||
console.log(params); | ||
|
||
return ( | ||
<> | ||
<DefaultLayout></DefaultLayout> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { useSession } from "next-auth/react"; | ||
import DefaultLayout from "~/components/layout/default"; | ||
import Hero from "~/components/Hero"; | ||
|
||
export default function Home() { | ||
const { data: sessionData } = useSession(); | ||
|
||
return ( | ||
<> | ||
<DefaultLayout></DefaultLayout> | ||
<DefaultLayout> | ||
{sessionData ? (InfoPanel(u)} | ||
</DefaultLayout> | ||
</> | ||
); | ||
} |
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 was deleted.
Oops, something went wrong.
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,56 @@ | ||
import { z } from "zod"; | ||
|
||
import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc"; | ||
|
||
type Headers = { | ||
Authorization: string; | ||
"Client-Id": string; | ||
}; | ||
type UserResponse = { | ||
id: string; | ||
login: string; | ||
display_name: string; | ||
type: string; | ||
broadcaster_type: string; | ||
description: string; | ||
profile_image_url: string; | ||
offline_image_url: string; | ||
view_count: number; | ||
email: string; | ||
created_at: string; | ||
}; | ||
|
||
export const twitchRouter = createTRPCRouter({ | ||
// create: protectedProcedure | ||
// .input(z.object({ name: z.string().min(1) })) | ||
// .mutation(async ({ input }) => { | ||
// // simulate a slow db call | ||
// await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
|
||
// post = { id: post.id + 1, name: input.name }; | ||
// return post; | ||
// }), | ||
|
||
// getUser: protectedProcedure.query(() => { | ||
|
||
// const | ||
// }), | ||
// make a requiest to GET https://api.twitch.tv/helix/users?login=USERNAME using fetch and the access token priv | ||
// return the response | ||
getUser: protectedProcedure | ||
.input( | ||
z.object({ | ||
accessToken: z.string(), | ||
}), | ||
) | ||
.query(async ({ input }) => { | ||
const response = await fetch("https://api.twitch.tv/helix/users", { | ||
headers: { | ||
Authorization: `Bearer ${input.accessToken}`, | ||
"Client-Id": process.env.TWITCH_CLIENT_ID, | ||
} as Headers, | ||
}); | ||
const json = (await response.json()) as { data: UserResponse[] }; | ||
return json; | ||
}), | ||
}); |
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