"use client"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import axios from "axios"; import * as React from 'react'; import { ApiKey, TwitchConnection, User } from "@prisma/client"; import { useEffect, useState } from "react"; import { useSession } from "next-auth/react"; import Link from "next/link"; import { cn } from "@/lib/utils"; import { Skeleton } from "@/components/ui/skeleton"; const SettingsPage = () => { const { data: session, status } = useSession(); const [previousUsername, setPreviousUsername] = useState() const [userId, setUserId] = useState() const [loading, setLoading] = useState(true) 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) setLoading(false) } fetchData().catch(console.error) } }, [session]) const [twitchUser, setTwitchUser] = useState(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) } } return (
Connections
Twitch
Connect your Twitch account!

{twitchUser?.broadcasterId}

); } export default SettingsPage;