mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 18:29:08 +00:00
absolutely massive typescript porting time
This commit is contained in:
parent
01f238f515
commit
30d08a630f
159 changed files with 2563 additions and 3861 deletions
|
@ -6,8 +6,8 @@ import DiscordButton from '../../components/discord-button'
|
|||
import RPC from '../../config/rpc'
|
||||
import redirect from '../../util/redirect'
|
||||
import dynamic from 'next/dynamic'
|
||||
import type { PageProps } from '../../types'
|
||||
import type { ServerSlug } from '@roleypoly/types'
|
||||
import { PageProps } from '../../types'
|
||||
import { ServerSlug } from '@roleypoly/types'
|
||||
import getConfig from 'next/config'
|
||||
const { publicRuntimeConfig: { BOT_HANDLE } } = getConfig()
|
||||
|
||||
|
@ -17,8 +17,8 @@ type AuthLoginState = {
|
|||
}
|
||||
|
||||
type AuthLoginProps = PageProps & {
|
||||
redirect: ?string,
|
||||
redirectSlug: ?ServerSlug
|
||||
redirect?: string,
|
||||
redirectSlug?: ServerSlug
|
||||
}
|
||||
|
||||
const Wrapper = styled.div`
|
||||
|
@ -124,8 +124,8 @@ export default class AuthLogin extends React.Component<AuthLoginProps, AuthLogin
|
|||
waiting: false
|
||||
}
|
||||
|
||||
static async getInitialProps (ctx: *, rpc: typeof RPC, router: *) {
|
||||
let { r } = (router.query: { r: string })
|
||||
static async getInitialProps (ctx: any, rpc: typeof RPC, router: any) {
|
||||
let { r } = (router.query as { r?: string })
|
||||
|
||||
if (ctx.user != null) {
|
||||
redirect(ctx, r || '/')
|
||||
|
@ -133,17 +133,19 @@ export default class AuthLogin extends React.Component<AuthLoginProps, AuthLogin
|
|||
|
||||
ctx.robots = 'NOINDEX, NOFOLLOW'
|
||||
|
||||
if (r != null) {
|
||||
let redirectSlug = null
|
||||
if (r !== undefined) {
|
||||
let redirectSlug: ServerSlug | null = null
|
||||
if (r.startsWith('/s/') && r !== '/s/add') {
|
||||
redirectSlug = await rpc.getServerSlug(r.replace('/s/', ''))
|
||||
}
|
||||
return { redirect: r, redirectSlug }
|
||||
}
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
if (this.props.redirect != null) {
|
||||
if (this.props.redirect !== undefined) {
|
||||
this.props.router.replace(this.props.router.pathname)
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +178,7 @@ export default class AuthLogin extends React.Component<AuthLoginProps, AuthLogin
|
|||
render () {
|
||||
return <Wrapper>
|
||||
<div>
|
||||
{(this.props.redirectSlug != null) ? <Slug {...this.props.redirectSlug} /> : null}
|
||||
{(this.props.redirectSlug !== undefined) ? <Slug {...this.props.redirectSlug} /> : null}
|
||||
<DiscordButton href={`/api/auth/redirect?r=${this.props.redirect || '/'}`}>Sign in with Discord</DiscordButton>
|
||||
<Line />
|
||||
<div>
|
Loading…
Add table
Add a link
Reference in a new issue