You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
import type { NextPage, GetServerSideProps } from 'next';
|
|
import React, { useState, useEffect } from 'react';
|
|
import { DiscordUser } from "../../utils/types";
|
|
|
|
import {
|
|
BrowserRouter,
|
|
Routes,
|
|
Route,
|
|
} from "react-router-dom";
|
|
import { useRouter } from 'next/router'
|
|
import { useSelector } from 'react-redux';
|
|
import { Main } from './main'
|
|
import { Login } from './login';
|
|
|
|
import { selectTokenData } from '../../redux/login/selectors';
|
|
|
|
const Index: NextPage = () => {
|
|
const router = useRouter();
|
|
const { token, status_token } = useSelector(selectTokenData);
|
|
const [login, setLogin] = useState(false);
|
|
|
|
useEffect(() => {
|
|
// token.length ? router.push('/admin/main'): router.push('/admin/login')
|
|
console.log(status_token, 'token');
|
|
//setLogin(true);
|
|
|
|
});
|
|
|
|
return (
|
|
<></>
|
|
)
|
|
}
|
|
|
|
interface Props {
|
|
user: DiscordUser;
|
|
}
|
|
|
|
export const getServerSideProps: GetServerSideProps<Props> = async function (ctx) {
|
|
const user = true;//await parseUser(ctx);
|
|
const isDashboardPage = ["/guilds", "/dashboard"].includes(ctx.resolvedUrl);
|
|
|
|
if (!user && isDashboardPage) {
|
|
return {
|
|
redirect: {
|
|
destination: "/admin/login",
|
|
permanent: false,
|
|
},
|
|
};
|
|
}
|
|
|
|
return { props: { user } };
|
|
};
|
|
|
|
|
|
export default Index;
|
|
|