mirror of
https://github.com/IT4Change/ohmyform-ui.git
synced 2025-12-13 09:45:50 +00:00
user server settings to disable registration
This commit is contained in:
parent
85a9a4a7a5
commit
35f7a7d271
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
### Added
|
||||
|
||||
- Fetch Server Settings to determine if signup is available
|
||||
- `SPA` env variable to have static page with loading spinner before redirect
|
||||
- `de`, `fr`, `es`, `it`, `cn` base folders for translations
|
||||
- finish translating `de` and `en`
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import {UpOutlined} from '@ant-design/icons/lib'
|
||||
import {useQuery} from '@apollo/react-hooks'
|
||||
import {Button, Menu, Select} from 'antd'
|
||||
import Link from 'next/link'
|
||||
import {useRouter} from 'next/router'
|
||||
import React from 'react'
|
||||
import {useTranslation} from 'react-i18next'
|
||||
import {SETTINGS_QUERY, SettingsQueryData} from '../../graphql/query/settings.query'
|
||||
import {languages} from '../../i18n'
|
||||
import {clearAuth, withAuth} from '../with.auth'
|
||||
|
||||
@ -17,6 +19,7 @@ interface Props {
|
||||
const AuthFooterInner: React.FC<Props> = props => {
|
||||
const { t, i18n } = useTranslation()
|
||||
const router = useRouter()
|
||||
const {data} = useQuery<SettingsQueryData>(SETTINGS_QUERY)
|
||||
|
||||
const logout = () => {
|
||||
clearAuth()
|
||||
@ -70,6 +73,7 @@ const AuthFooterInner: React.FC<Props> = props => {
|
||||
<Button
|
||||
type={'link'}
|
||||
ghost
|
||||
disabled={data ? data.disabledSignUp.value : false}
|
||||
>
|
||||
{t('register')}
|
||||
</Button>
|
||||
|
||||
15
graphql/query/settings.query.ts
Normal file
15
graphql/query/settings.query.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {gql} from 'apollo-boost'
|
||||
|
||||
export interface SettingsQueryData {
|
||||
disabledSignUp: {
|
||||
value: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const SETTINGS_QUERY = gql`
|
||||
query {
|
||||
disabledSignUp: getByKey (key: "SIGNUP_DISABLED") {
|
||||
value: isTrue
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -1,4 +1,4 @@
|
||||
import {useMutation} from '@apollo/react-hooks'
|
||||
import {useMutation, useQuery} from '@apollo/react-hooks'
|
||||
import {Button, Form, Input, message} from 'antd'
|
||||
import {useForm} from 'antd/lib/form/Form'
|
||||
import {AuthFooter} from 'components/auth/footer'
|
||||
@ -10,12 +10,15 @@ import Link from 'next/link'
|
||||
import {useRouter} from 'next/router'
|
||||
import React, {useState} from 'react'
|
||||
import {useTranslation} from 'react-i18next'
|
||||
import {ErrorPage} from '../components/error.page'
|
||||
import {SETTINGS_QUERY, SettingsQueryData} from '../graphql/query/settings.query'
|
||||
|
||||
const Register: NextPage = () => {
|
||||
const { t } = useTranslation()
|
||||
const [form] = useForm()
|
||||
const router = useRouter()
|
||||
const [loading, setLoading] = useState(false)
|
||||
const {data} = useQuery<SettingsQueryData>(SETTINGS_QUERY)
|
||||
|
||||
const [register] = useMutation(REGISTER_MUTATION)
|
||||
|
||||
@ -47,6 +50,12 @@ const Register: NextPage = () => {
|
||||
message.error(t('validation:mandatoryFieldsMissing'))
|
||||
}
|
||||
|
||||
if (data && data.disabledSignUp.value) {
|
||||
return (
|
||||
<ErrorPage />
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthLayout loading={loading}>
|
||||
<Form
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user