diff --git a/frontend/src/components/Header.tsx b/frontend/src/components/Header.tsx
new file mode 100644
index 0000000..a0f4406
--- /dev/null
+++ b/frontend/src/components/Header.tsx
@@ -0,0 +1,37 @@
+import { Box, Flex, Heading } from "@chakra-ui/layout";
+import { Text } from "@chakra-ui/react";
+import React, { FC } from "react";
+
+const Header: FC = ({ children }) => {
+ return (
+
+
+ Watch Together
+
+ admin
+
+
+ {children}
+
+ );
+};
+
+export default Header;
diff --git a/frontend/src/components/UserData.tsx b/frontend/src/components/UserData.tsx
new file mode 100644
index 0000000..95aa2b7
--- /dev/null
+++ b/frontend/src/components/UserData.tsx
@@ -0,0 +1,21 @@
+import { Avatar } from "@chakra-ui/avatar";
+import { Box, Flex, Text } from "@chakra-ui/layout";
+import { Session } from "next-auth";
+import React, { FC } from "react";
+
+interface UserDataProps {
+ user: Session["user"];
+}
+
+const UserData: FC = ({ user: { name, image } }) => {
+ return (
+
+
+
+ {name}
+
+
+ );
+};
+
+export default UserData;
diff --git a/frontend/src/pages/admin/index.tsx b/frontend/src/pages/admin/index.tsx
new file mode 100644
index 0000000..987acc0
--- /dev/null
+++ b/frontend/src/pages/admin/index.tsx
@@ -0,0 +1,70 @@
+import { Text } from "@chakra-ui/layout";
+import { Flex as Box } from "@chakra-ui/react";
+import { GetServerSideProps, NextPage } from "next";
+import { Session } from "next-auth";
+import { getSession } from "next-auth/react";
+import React from "react";
+import { Container } from "../../components/Container";
+import Header from "../../components/Header";
+import UserData from "../../components/UserData";
+
+interface AdminPageProps {
+ isAuthed: boolean;
+ isAdmin: boolean;
+ session?: Session;
+}
+
+const AdminPage: NextPage = ({
+ isAuthed,
+ isAdmin,
+ session,
+}) => {
+ console.log(session);
+ return (
+ <>
+
+
+
+ Hello
+
+
+ >
+ );
+};
+
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ const session = await getSession(context);
+ if (session) {
+ const isAdmin = session.user.name.includes("qpixel");
+ if (!isAdmin) {
+ return {
+ redirect: {
+ destination: "/",
+ permanent: false,
+ },
+ };
+ }
+ return {
+ props: {
+ isAuthed: true,
+ isAdmin: isAdmin,
+ session: session,
+ } as AdminPageProps,
+ };
+ }
+ return {
+ props: {
+ isAdmin: false,
+ isAuthed: false,
+ } as AdminPageProps,
+ };
+};
+
+export default AdminPage;
diff --git a/frontend/src/pages/admin/signout.tsx b/frontend/src/pages/admin/signout.tsx
new file mode 100644
index 0000000..b1b3eed
--- /dev/null
+++ b/frontend/src/pages/admin/signout.tsx
@@ -0,0 +1,54 @@
+import { GetServerSideProps, NextPage } from "next";
+import React, { useEffect } from "react";
+import { Container } from "../../components/Container";
+import { Text } from "@chakra-ui/react";
+import { useRouter } from "next/router";
+import {
+ getSession,
+ signOut,
+ SignOutResponse,
+ useSession,
+} from "next-auth/react";
+
+const SignOutPage: NextPage = () => {
+ const router = useRouter();
+ const session = useSession();
+ let data: SignOutResponse | null;
+ const signout = async () => {
+ data = await signOut({ redirect: false, callbackUrl: "/" });
+ };
+ if (session) {
+ useEffect(() => {
+ signout();
+ setTimeout(() => {
+ if (data) {
+ router.push(data.url);
+ } else {
+ router.push("/");
+ }
+ }, 600);
+ }, []);
+ }
+ return (
+
+ Signing out!
+
+ );
+};
+
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ const session = await getSession(context);
+ if (!session) {
+ return {
+ redirect: {
+ destination: "/",
+ permanent: false,
+ },
+ };
+ }
+ return {
+ props: {},
+ };
+};
+
+export default SignOutPage;
diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx
index 46f4a4c..1ef804f 100644
--- a/frontend/src/pages/index.tsx
+++ b/frontend/src/pages/index.tsx
@@ -28,8 +28,9 @@ const Index: NextPage = () => {
};
export const getServerSideProps: GetServerSideProps = async (context) => {
- const session = getSession(context);
- if (session) {
+ const session = await getSession(context);
+ const isDev = true;
+ if (session && !isDev) {
return {
redirect: {
destination: "/player",
diff --git a/frontend/src/pages/player.tsx b/frontend/src/pages/player.tsx
index 6cdb16a..16fa322 100644
--- a/frontend/src/pages/player.tsx
+++ b/frontend/src/pages/player.tsx
@@ -1,10 +1,15 @@
-import { NextPage } from "next";
+import { GetServerSideProps, NextPage } from "next";
+import { getSession } from "next-auth/react";
import dynamic from "next/dynamic";
import React from "react";
import { Container } from "../components/Container";
const Player = dynamic(() => import("../components/Player"));
+interface PlayerPage {
+ id: string;
+}
+
const PlayerPage: NextPage = () => {
return (
@@ -13,4 +18,21 @@ const PlayerPage: NextPage = () => {
);
};
+export const getServerSideProps: GetServerSideProps = async (context) => {
+ const session = getSession(context);
+ if (!session) {
+ return {
+ redirect: {
+ destination: "/",
+ permanent: false,
+ },
+ };
+ }
+ return {
+ props: {
+ id: "BELLE",
+ },
+ };
+};
+
export default PlayerPage;