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.
56 lines
1.1 KiB
56 lines
1.1 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 = withSession(async function ({ req, res }) {
|
|
const { user } = req.session
|
|
|
|
if (!user) {
|
|
return {
|
|
redirect: {
|
|
destination: '/login',
|
|
permanent: false,
|
|
},
|
|
}
|
|
}
|
|
|
|
return {
|
|
props: { user },
|
|
}
|
|
})
|
|
|
|
|
|
export default Index;
|
|
|