Progress so far

This commit is contained in:
Tom
2023-12-30 10:56:40 +00:00
parent d191f8fb6f
commit 8eb9b9096f
41 changed files with 1984 additions and 6018 deletions

View File

@ -0,0 +1,62 @@
"use client";
import { redirect } from "next/navigation";
import Link from "next/link";
import { useSession, signIn, signOut } from "next-auth/react";
import { useEffect, useState } from "react";
import axios from "axios";
export default function Home() {
const { data: session, status } = useSession();
const [previousUsername, setPreviousUsername] = useState<string>()
// if (status !== "authenticated") {
// redirect('/api/auth/signin?redirectUrl=/');
// }
useEffect(() => {
if (status !== "authenticated" || previousUsername == session.user?.name) {
console.log("CANCELED")
return
}
setPreviousUsername(session.user?.name as string)
async function saveAccount() {
const data = await axios.post("/api/account")
if (data == null || data == undefined) {
console.log("ERROR")
}
}
saveAccount().catch(console.error)
}, [session])
return (
<main
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "70vh",
}}
>
<div className="header">
<Link href="/">
<p className="logo">NextAuth.js</p>
</Link>
{session && (
<Link href="#" onClick={() => signOut()} className="btn-signin">
Sign out
</Link>
)}
{!session && (
<Link href="#" onClick={() => signIn()} className="btn-signin">
Sign in
</Link>
)}
</div>
</main>
);
}

View File

@ -0,0 +1,223 @@
"use client";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import axios from "axios";
import { Button } from "@/components/ui/button";
import { DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { Info } from "lucide-react";
import * as React from 'react';
import { Toggle } from "@/components/ui/toggle";
import { ApiKey, TwitchConnection, User } from "@prisma/client";
import { useEffect, useState } from "react";
import { useSession } from "next-auth/react";
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import Link from "next/link";
import { TTSBadgeFilterModal } from "@/components/modals/tts-badge-filter-modal";
const SettingsPage = () => {
const { data: session, status } = useSession();
const [previousUsername, setPreviousUsername] = useState<string>()
const [userId, setUserId] = useState<string>()
useEffect(() => {
if (status !== "authenticated" || previousUsername == session.user?.name) {
return
}
setPreviousUsername(session.user?.name as string)
if (session.user?.name) {
const fetchData = async () => {
var connection: User = (await axios.get("/api/account")).data
setUserId(connection.id)
}
fetchData().catch(console.error)
}
}, [session])
// const [twitchUser, setTwitchUser] = useState<TwitchConnection | null>(null)
// useEffect(() => {
// const fetchData = async () => {
// var connection: TwitchConnection = (await axios.get("/api/settings/connections/twitch")).data
// setTwitchUser(connection)
// }
// fetchData().catch(console.error);
// }, [])
// const OnTwitchConnectionDelete = async () => {
// try {
// await axios.post("/api/settings/connections/twitch/delete")
// setTwitchUser(null)
// } catch (error) {
// console.log("ERROR", error)
// }
// }
const [apiKeyViewable, setApiKeyViewable] = useState(0)
const [apiKeyChanges, setApiKeyChanges] = useState(0)
const [apiKeys, setApiKeys] = useState<ApiKey[]>([])
useEffect(() => {
const fetchData = async () => {
try {
const keys = (await axios.get("/api/tokens")).data ?? {};
setApiKeys(keys)
console.log(keys);
} catch (error) {
console.log("ERROR", error)
}
};
fetchData().catch(console.error);
}, [apiKeyChanges]);
const onApiKeyAdd = async () => {
try {
await axios.post("/api/token", {
label: "Key label"
});
setApiKeyChanges(apiKeyChanges + 1)
} catch (error) {
console.log("ERROR", error)
}
}
const onApiKeyDelete = async (id: string) => {
try {
await axios.delete("/api/token/" + id);
setApiKeyChanges(apiKeyChanges - 1)
} catch (error) {
console.log("ERROR", error)
}
}
useEffect(() => {
const fetchData = async () => {
try {
const keys = (await axios.get("/api/tokens")).data;
setApiKeys(keys)
console.log(keys);
} catch (error) {
console.log("ERROR", error)
}
};
fetchData().catch(console.error);
}, [apiKeyViewable]);
return (
<div>
<div className="flex text-3xl justify-center">
Settings
</div>
<div className="border-solid border-white px-10 py-5 mx-5 my-10">
<div>
<div className="text-xl justify-left">Connections</div>
<div className="px-10 py-6 rounded-md bg-purple-500 max-w-sm overflow-hidden wrap-">
<div className="inline-block max-w-md">
<Avatar>
<AvatarImage src="https://cdn2.iconfinder.com/data/icons/social-aquicons/512/Twitch.png" alt="twitch" />
<AvatarFallback></AvatarFallback>
</Avatar>
</div>
{/* <div className="inline-block ml-5"> */}
<Link href={(process.env.NEXT_PUBLIC_TWITCH_OAUTH_URL as string) + userId}>Authorize</Link>
{/* <div className="inline-block text-lg">Twitch</div>
<div className={cn("hidden", twitchUser == null && "flex")}>
<ConnectTwitchModal />
</div>
<div className={cn("hidden", twitchUser != null && "flex")}>
<p>{twitchUser?.username}</p>
</div>
</div>
<div className="inline-block pl-5 ml-3 justify-right items-right">
<button onClick={OnTwitchConnectionDelete} className={cn("hidden", twitchUser != null && "flex")}>
<Avatar>
<AvatarImage src="https://upload.wikimedia.org/wikipedia/en/b/ba/Red_x.svg" alt="twitch" />
<AvatarFallback></AvatarFallback>
</Avatar>
</button>
</div> */}
</div>
</div>
<div>
<div className="text-xl justify-left mt-10">API Keys</div>
<Table className="max-w-2xl">
<TableCaption>A list of your secret API keys.</TableCaption>
<TableHeader>
<TableRow>
<TableHead>Label</TableHead>
<TableHead>Token</TableHead>
<TableHead>View</TableHead>
<TableHead>Action</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{apiKeys.map((key, index) => (
<TableRow key={key.id}>
<TableCell className="font-medium">{key.label}</TableCell>
<TableCell>{(apiKeyViewable & (1 << index)) > 0 ? key.id : "*".repeat(key.id.length)}</TableCell>
<TableCell>
<Button onClick={() => setApiKeyViewable((v) => v ^ (1 << index))}>
{(apiKeyViewable & (1 << index)) > 0 ? "HIDE" : "VIEW"}
</Button>
</TableCell>
<TableCell><Button onClick={() => onApiKeyDelete(key.id)}>DEL</Button></TableCell>
</TableRow>
))}
<TableRow key="ADD">
<TableCell className="font-medium"></TableCell>
<TableCell></TableCell>
<TableCell></TableCell>
<TableCell><Button onClick={onApiKeyAdd}>ADD</Button></TableCell>
</TableRow>
</TableBody>
</Table>
</div>
</div>
<div className="px-10 py-5 mx-5 my-10 max-w-lg inline-block">
<div className="text-xl justify-left">
<Info className="h-4 w-4 mx-1 inline" />
TTS Voice
</div>
<div className="px-10 py-6 rounded-md bg-pink-300 max-w-sm">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline">Default Voice</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuLabel>English Voices</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuRadioGroup value="voice">
<DropdownMenuRadioItem value="brian">Brian</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="amy">Amy</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="emma">Emma</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
<div className="px-10 py-5 mx-5 my-10 max-w-lg inline-block">
<div className="text-xl justify-left">TTS Message Filter</div>
<div className="grid px-10 py-6 rounded-md bg-blue-400 max-w-sm">
<TTSBadgeFilterModal />
{/* <Button aria-label="Subscription" variant="ttsmessagefilter" className="my-2">
<Info className="h-4 w-4 mx-1" />
Subscription
</Button> */}
{/* <Button aria-label="Cheers" variant="ttsmessagefilter" className="my-2">
<Info className="h-4 w-4 mx-1" />
Cheers
</Button> */}
<Button aria-label="Username" variant="ttsmessagefilter" className="my-2">
<Info className="h-4 w-4 mx-1" />
Username
</Button>
</div>
</div>
</div>
);
}
export default SettingsPage;

View File

@ -0,0 +1,75 @@
import axios from 'axios'
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
export async function GET(req: Request) {
try {
const { searchParams } = new URL(req.url)
const code = searchParams.get('code') as string
const scope = searchParams.get('scope') as string
const state = searchParams.get('state') as string
console.log("CODE:", code)
console.log("SCOPE:", scope)
console.log("STATE:", state)
if (!code || !scope || !state) {
return new NextResponse("Bad Request", { status: 400 });
}
console.log("VERIFY")
// Verify state against user id in user table.
const user = await db.user.findFirst({
where: {
id: state
}
})
console.log("USER", user)
if (!user) {
return new NextResponse("Bad Request", { status: 400 });
}
console.log("FETCH TOKEN")
// Post to https://id.twitch.tv/oauth2/token
const token: { access_token:string, expires_in:number, refresh_token:string, token_type:string, scope:string[] } = (await axios.post("https://id.twitch.tv/oauth2/token", {
client_id: process.env.TWITCH_BOT_CLIENT_ID,
client_secret: process.env.TWITCH_BOT_CLIENT_SECRET,
code: code,
grant_type: "authorization_code",
redirect_uri: "https://hermes.goblincaves.com/api/account/authorize"
})).data
console.log("TOKEN", token)
// Fetch values from token.
const { access_token, expires_in, refresh_token, token_type } = token
console.log("AT", access_token)
console.log("RT", refresh_token)
console.log("TT", token_type)
if (!access_token || !refresh_token || token_type !== "bearer") {
return new NextResponse("Unauthorized", { status: 401 });
}
let info = await axios.get("https://api.twitch.tv/helix/users?login=" + user.username, {
headers: {
"Authorization": "Bearer " + access_token,
"Client-Id": process.env.TWITCH_BOT_CLIENT_ID
}
})
console.log(info.data.data)
const broadcasterId = info.data.data[0]['id']
await db.twitchConnection.create({
data: {
broadcasterId: broadcasterId,
accessToken: access_token,
refreshToken: refresh_token,
userId: state
}
})
return new NextResponse("", { status: 200 });
} catch (error) {
console.log("[ACCOUNT]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}

View File

@ -0,0 +1,73 @@
import axios from 'axios'
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
import { GET as authorize } from '../authorize/route'
export async function GET(req: Request) {
try {
// Verify state against user id in user table.
const key = await db.apiKey.findFirst({
where: {
id: req.headers.get('x-api-key') as string
}
})
console.log("API USER:", key)
if (!key) {
return new NextResponse("Forbidden", { status: 403 });
}
const connection = await db.twitchConnection.findFirst({
where: {
userId: key.userId
}
})
if (!connection) {
return new NextResponse("Forbidden", { status: 403 });
}
try {
const { expires_in }: { client_id:string, login:string, scopes:string[], user_id:string, expires_in:number } = (await axios.get("https://id.twitch.tv/oauth2/validate", {
headers: {
Authorization: 'OAuth ' + connection.accessToken
}
})).data;
if (expires_in > 3600)
return new NextResponse("", { status: 201 });
} catch (error) {
console.log("Oudated Twitch token.")
}
// Post to https://id.twitch.tv/oauth2/token
const token: { access_token:string, expires_in:number, refresh_token:string, token_type:string, scope:string[] } = (await axios.post("https://id.twitch.tv/oauth2/token", {
client_id: process.env.TWITCH_BOT_CLIENT_ID,
client_secret: process.env.TWITCH_BOT_CLIENT_SECRET,
grant_type: "refresh_token",
refresh_token: connection.refreshToken
})).data
// Fetch values from token.
const { access_token, expires_in, refresh_token, token_type } = token
console.log("AT", access_token)
console.log("RT", refresh_token)
console.log("TT", token_type)
if (!access_token || !refresh_token || token_type !== "bearer") {
return new NextResponse("Unauthorized", { status: 401 });
}
await db.twitchConnection.update({
where: {
userId: key.userId
},
data: {
accessToken: access_token
}
})
return new NextResponse("", { status: 200 });
} catch (error) {
console.log("[ACCOUNT]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}

67
app/api/account/route.ts Normal file
View File

@ -0,0 +1,67 @@
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { generateToken } from "../token/route";
import fetchUserUsingAPI from "@/lib/validate-api";
export async function GET(req: Request) {
try {
return NextResponse.json(await fetchUserUsingAPI(req))
} catch (error) {
console.log("[ACCOUNT]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}
export async function POST(req: Request) {
try {
const session = await getServerSession()
const user = session?.user?.name
if (!user) {
return new NextResponse("Internal Error", { status: 401 })
}
const exist = await db.user.findFirst({
where: {
username: user.toLowerCase() as string
}
});
if (exist) {
// const apikey = await db.apiKey.findFirst({
// where: {
// userId: user.toLowerCase() as string
// }
// })
return {
id: exist.id,
username: exist.username,
//key: apikey?.id as string
};
}
const newUser = await db.user.create({
data: {
username: user.toLowerCase() as string,
}
});
// const apikey = await db.apiKey.create({
// data: {
// id: generateToken(),
// label: "Default",
// userId: user.toLowerCase() as string
// }
// })
return NextResponse.json({
id: newUser.id,
username: newUser.username,
//key: apikey.id
});
} catch (error) {
console.log("[ACCOUNT]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}

View File

@ -0,0 +1,40 @@
import type { NextAuthOptions } from "next-auth";
import TwitchProvider from "next-auth/providers/twitch";
export interface TwitchProfile extends Record<string, any> {
sub: string
preferred_username: string
email: string
picture: string
}
export const options: NextAuthOptions = {
providers: [
TwitchProvider({
clientId: process.env.TWITCH_CLIENT_ID as string,
clientSecret: process.env.TWITCH_CLIENT_SECRET as string,
authorization: {
params: {
scope: "openid user:read:email",
claims: {
id_token: {
email: null,
picture: null,
preferred_username: null,
},
},
},
},
idToken: true,
profile(profile) {
return {
id: profile.sub,
name: profile.preferred_username,
email: profile.email,
image: profile.picture,
}
},
})
],
secret: process.env.NEXTAUTH_SECRET
}

View File

@ -0,0 +1,6 @@
import NextAuth from 'next-auth'
import { options } from './options'
const handler = NextAuth(options)
export { handler as GET, handler as POST }

View File

@ -0,0 +1,23 @@
import { db } from "@/lib/db"
import fetchUserUsingAPI from "@/lib/validate-api";
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
const user = await fetchUserUsingAPI(req)
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
}
const connection = await db.twitchConnection.deleteMany({
where: {
userId: user.id
}
});
return NextResponse.json(connection);
} catch (error) {
console.log("[CONNECTION/TWITCH]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}

View File

@ -0,0 +1,85 @@
import axios from "axios"
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
import fetchUserUsingAPI from "@/lib/validate-api";
export async function GET(req: Request) {
try {
const user = await fetchUserUsingAPI(req)
if (!user) {
console.log("TWITCH CONNECT", user)
return new NextResponse("Unauthorized", { status: 401 });
}
const { searchParams } = new URL(req.url)
let userId = searchParams.get('id')
if (userId == null) {
if (user != null) {
userId = user.id as string;
}
}
const connection = await db.twitchConnection.findFirst({
where: {
userId: userId as string
}
});
return NextResponse.json(connection);
} catch (error) {
console.log("[CONNECTION/TWITCH]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}
export async function POST(req: Request) {
try {
const { id, secret } = await req.json();
const user = await fetchUserUsingAPI(req)
console.log("userrr:", user)
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
}
console.log(id, secret)
let response = null;
try {
response = await axios.post("https://id.twitch.tv/oauth2/token", {
client_id: id,
client_secret: secret,
grant_type: "client_credentials"
});
console.log(response.data)
} catch (error) {
console.log("[CONNECTIONS/TWITCH/TOKEN]", error);
return;
}
console.log(user.username)
let info = await axios.get("https://api.twitch.tv/helix/users?login=" + user.username, {
headers: {
"Authorization": "Bearer " + response.data['access_token'],
"Client-Id": id
}
})
console.log(info.data.data)
const broadcasterId = info.data.data[0]['id']
const username = info.data.data[0]['login']
const connection = await db.twitchConnection.create({
data: {
id,
secret,
userId: user.id as string,
broadcasterId,
username
}
});
return NextResponse.json(connection);
} catch (error) {
console.log("[CONNECTION/TWITCH]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}

View File

@ -0,0 +1,56 @@
import axios from "axios"
import { currentUser } from "@/lib/current-user";
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
export async function GET(req: Request) {
try {
const user = await currentUser();
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
}
let badges = await axios.get("https://api.twitch.tv/helix/chat/badges")
const badgesData = await db.ttsBadgeFilter.findMany({
where: {
data: {
userId: user.id
}
}
});
// return NextResponse.json(badgesData);
return new NextResponse("Bad Request", { status: 400 });
} catch (error) {
console.log("[CONNECTION/TWITCH]", error);
return new NextResponse("Internal Error", { status: 500});
}
}
export async function POST(req: Request) {
try {
const user = await currentUser();
const badges = await req.json();
console.log("BADGES", badges);
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
}
// const badgesData = await db.tTSBadgeFilter.createMany({
// badges.map((badgeName, value) => {
// data: {
// userId: user.id
// }
// })
// });
// return NextResponse.json(badgesData);
return new NextResponse("Bad Request", { status: 400 });
} catch (error) {
console.log("[CONNECTION/TWITCH]", error);
return new NextResponse("Internal Error", { status: 500});
}
}

View File

@ -0,0 +1,42 @@
import { db } from "@/lib/db"
import fetchUserUsingAPI from "@/lib/validate-api";
import { NextResponse } from "next/server";
export async function GET(req: Request, { params } : { params: { id: string } }) {
try {
let id = req.headers?.get('x-api-key')
if (id == null) {
return NextResponse.json(null);
}
const tokens = await db.apiKey.findFirst({
where: {
id: id
}
});
return NextResponse.json(tokens);
} catch (error) {
console.log("[TOKEN/GET]", error);
return new NextResponse("Internal Error", { status: 500});
}
}
export async function DELETE(req: Request, { params } : { params: { id: string } }) {
try {
const { id } = params
const user = await fetchUserUsingAPI(req)
const token = await db.apiKey.delete({
where: {
id,
userId: user?.id
}
});
return NextResponse.json(token);
} catch (error) {
console.log("[TOKEN/DELETE]", error);
return new NextResponse("Internal Error", { status: 500});
}
}

View File

@ -0,0 +1,34 @@
import { db } from "@/lib/db"
import fetchUserUsingAPI from "@/lib/validate-api";
import { NextResponse } from "next/server";
export async function GET(req: Request) {
try {
const user = await fetchUserUsingAPI(req);
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
}
const api = await db.twitchConnection.findFirst({
where: {
userId: user.id
}
})
if (!api) {
return new NextResponse("Forbidden", { status: 403 });
}
const data = {
client_id: process.env.TWITCH_BOT_CLIENT_ID,
client_secret: process.env.TWITCH_BOT_CLIENT_SECRET,
access_token: api.accessToken,
refresh_token: api.refreshToken,
broadcaster_id: api.broadcasterId
}
return NextResponse.json(data);
} catch (error) {
console.log("[TOKENS/GET]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}

63
app/api/token/route.ts Normal file
View File

@ -0,0 +1,63 @@
import fetchUserUsingAPI from "@/lib/validate-api";
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
export async function POST(req: Request) {
try {
let { userId, label } = await req.json();
if (userId == null) {
const user = await fetchUserUsingAPI(req);
if (user != null) {
userId = user.id;
}
}
const id = generateToken()
const token = await db.apiKey.create({
data: {
id,
label,
userId: userId as string
}
});
return NextResponse.json(token);
} catch (error) {
console.log("[TOKEN/POST]", error);
return new NextResponse("Internal Error", { status: 500});
}
}
export async function DELETE(req: Request) {
try {
let { id } = await req.json();
const user = await fetchUserUsingAPI(req);
if (!id || !user) {
return NextResponse.json(null)
}
const token = await db.apiKey.delete({
where: {
id,
userId: user?.id
}
});
return NextResponse.json(token);
} catch (error) {
console.log("[TOKEN/DELETE]", error);
return new NextResponse("Internal Error", { status: 500});
}
}
export function generateToken() {
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 32;
var randomstring = '';
for (var i = 0; i < string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars[rnum];
}
return randomstring;
}

30
app/api/tokens/route.ts Normal file
View File

@ -0,0 +1,30 @@
import fetchUserUsingAPI from "@/lib/validate-api";
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
export async function GET(req: Request) {
try {
const { searchParams } = new URL(req.url)
let userId = searchParams.get('userId')
if (userId == null) {
const user = await fetchUserUsingAPI(req);
if (user != null) {
userId = user.id as string;
}
}
console.log("TOKEN KEY:", userId)
const tokens = await db.apiKey.findMany({
where: {
userId: userId as string
}
});
return NextResponse.json(tokens);
} catch (error) {
console.log("[TOKENS/GET]", error);
return new NextResponse("Internal Error", { status: 500});
}
}

22
app/api/validate/route.ts Normal file
View File

@ -0,0 +1,22 @@
import { db } from "@/lib/db"
import { NextResponse } from "next/server";
export async function GET(req: Request, { params } : { params: { id: string } }) {
try {
let id = req.headers.get('x-api-key')
if (id == null) {
return NextResponse.json(null);
}
const tokens = await db.apiKey.findFirst({
where: {
id: id as string
}
});
return NextResponse.json(tokens);
} catch (error) {
console.log("[VALIDATE/GET]", error);
return new NextResponse("Internal Error", { status: 500});
}
}

View File

@ -0,0 +1,13 @@
"use client";
import { SessionProvider } from 'next-auth/react'
export default function AuthProvider({ children }: {
children: React.ReactNode
}) {
return (
<SessionProvider>
{children}
</SessionProvider>
)
}

View File

@ -2,6 +2,12 @@
@tailwind components;
@tailwind utilities;
html,
body,
:root {
height: 100%;
}
@layer base {
:root {
--background: 0 0% 100%;

View File

@ -1,12 +1,15 @@
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'
import type { Metadata } from 'next'
import { Open_Sans } from 'next/font/google'
import AuthProvider from './context/auth-provider'
import { ThemeProvider } from '@/components/providers/theme-provider'
import { cn } from '@/lib/utils'
const inter = Inter({ subsets: ['latin'] })
const font = Open_Sans({ subsets: ['latin'] })
export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
title: 'Hermes',
description: '',
}
export default function RootLayout({
@ -15,8 +18,21 @@ export default function RootLayout({
children: React.ReactNode
}) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
<AuthProvider>
<html lang="en">
<body className={cn(
font.className,
"bg-white dark:bg-[#000000]"
)}>
<ThemeProvider
attribute="class"
defaultTheme='dark'
enableSystem={false}
storageKey='global-web-theme'>
{children}
</ThemeProvider>
</body>
</html>
</AuthProvider>
)
}

View File

@ -1,113 +0,0 @@
import Image from 'next/image'
export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 max-w-5xl w-full items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
<code className="font-mono font-bold">app/page.tsx</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:h-auto lg:w-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{' '}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className="dark:invert"
width={100}
height={24}
priority
/>
</a>
</div>
</div>
<div className="relative flex place-items-center before:absolute before:h-[300px] before:w-[480px] before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-[240px] after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 before:lg:h-[360px] z-[-1]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
<div className="mb-32 grid text-center lg:max-w-5xl lg:w-full lg:mb-0 lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Docs{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Find in-depth information about Next.js features and API.
</p>
</a>
<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Learn{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>
<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Templates{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Explore starter templates for Next.js.
</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className={`mb-3 text-2xl font-semibold`}>
Deploy{' '}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className={`m-0 max-w-[30ch] text-sm opacity-50`}>
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
</div>
</main>
)
}