import { GetServerSideProps, NextPage } from 'next' import dynamic from 'next/dynamic' import { get, management } from '@utils/Query' import { checkUserFlag, getUserFlags, parseCookie } from '@utils/Tools' import { User, UserSpec } from '@types' const Forbidden = dynamic(() => import('@components/Forbidden')) const Container = dynamic(() => import('@components/Container')) const ManagementPage: NextPage = ({ target, user }) => { if(checkUserFlag(user?.flags, 'staff')) return

{target ? `${target.username}#${target.tag} (${target.id})` : 'Not Found'}

return } export const getServerSideProps: GetServerSideProps = async (ctx) => { const parsed = parseCookie(ctx.req) const userID = await get.Authorization(parsed?.token) const user = userID && await get.user.load(userID) if(!checkUserFlag(user?.flags, 'staff')) return { props: {} } return { props: { target: await management.user.get(ctx.params.id as string), user: user } } } interface ManagementProps { target?: UserSpec user?: User } export default ManagementPage