improvements

This commit is contained in:
Michael Schramm 2021-05-15 10:25:22 +02:00
parent c793321ecb
commit 94f1de3e25
6 changed files with 17 additions and 44 deletions

View File

@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- combined notificationts to become more versatile - combined notificationts to become more versatile
- use exported hooks for graphql - use exported hooks for graphql
- disable swipe gesture
### Fixed ### Fixed

View File

@ -1,5 +1,4 @@
import { Button, Select } from 'antd' import { Button, Select } from 'antd'
import getConfig from 'next/config'
import Link from 'next/link' import Link from 'next/link'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import React from 'react' import React from 'react'
@ -7,12 +6,9 @@ import GitHubButton from 'react-github-button'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useSettingsQuery } from '../../graphql/query/settings.query' import { useSettingsQuery } from '../../graphql/query/settings.query'
import { languages } from '../../i18n' import { languages } from '../../i18n'
import { NextConfigType } from '../../next.config.type'
import { clearAuth, withAuth } from '../with.auth' import { clearAuth, withAuth } from '../with.auth'
import scss from './footer.module.scss' import scss from './footer.module.scss'
const { publicRuntimeConfig } = getConfig() as NextConfigType
interface Props { interface Props {
me?: { me?: {
id: string id: string
@ -42,7 +38,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link key={'admin'} href={'/admin'}> <Link key={'admin'} href={'/admin'}>
<Button <Button
type={'link'} type={'link'}
ghost
style={{ style={{
color: '#FFF', color: '#FFF',
}} }}
@ -54,7 +49,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link key={'profile'} href={'/admin/profile'}> <Link key={'profile'} href={'/admin/profile'}>
<Button <Button
type={'link'} type={'link'}
ghost
style={{ style={{
color: '#FFF', color: '#FFF',
}} }}
@ -65,7 +59,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Button <Button
key={'logout'} key={'logout'}
type={'link'} type={'link'}
ghost
onClick={logout} onClick={logout}
style={{ style={{
color: '#FFF', color: '#FFF',
@ -78,7 +71,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link href={'/login'} key={'login'}> <Link href={'/login'} key={'login'}>
<Button <Button
type={'link'} type={'link'}
ghost
style={{ style={{
color: '#FFF', color: '#FFF',
}} }}
@ -90,7 +82,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link href={'/register'} key={'register'}> <Link href={'/register'} key={'register'}>
<Button <Button
type={'link'} type={'link'}
ghost
style={{ style={{
color: '#FFF', color: '#FFF',
}} }}
@ -124,7 +115,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
type={'link'} type={'link'}
target={'_blank'} target={'_blank'}
rel={'noreferrer'} rel={'noreferrer'}
ghost
href={'https://www.ohmyform.com'} href={'https://www.ohmyform.com'}
style={{ style={{
color: '#FFF', color: '#FFF',
@ -136,7 +126,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
type={'link'} type={'link'}
target={'_blank'} target={'_blank'}
rel={'noreferrer'} rel={'noreferrer'}
ghost
href={'https://lokalise.com/'} href={'https://lokalise.com/'}
style={{ style={{
color: '#FFF', color: '#FFF',

View File

@ -1,5 +1,5 @@
import { message } from 'antd' import { message } from 'antd'
import ExcelJS from 'exceljs' import ExcelJS, { CellValue } from 'exceljs'
import { useCallback, useState } from 'react' import { useCallback, useState } from 'react'
import { SubmissionFragment } from '../../../graphql/fragment/submission.fragment' import { SubmissionFragment } from '../../../graphql/fragment/submission.fragment'
import { useFormQuery } from '../../../graphql/query/form.query' import { useFormQuery } from '../../../graphql/query/form.query'
@ -53,8 +53,8 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => {
start: 0, start: 0,
}) })
const buildRow = (data: SubmissionFragment): any[] => { const buildRow = (data: SubmissionFragment): CellValue[] => {
const row = [ const row: CellValue[] = [
data.id, data.id,
data.created, data.created,
data.lastModified, data.lastModified,
@ -66,8 +66,9 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => {
data.fields.forEach((field) => { data.fields.forEach((field) => {
try { try {
const decoded = JSON.parse(field.value) // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
row.push(decoded.value) const decoded: { value: CellValue } = JSON.parse(field.value)
row.push(decoded.value || '')
} catch (e) { } catch (e) {
row.push('') row.push('')
} }

View File

@ -1,12 +1,13 @@
import { ApolloClient, from, HttpLink, InMemoryCache } from '@apollo/client' import { ApolloClient, from, HttpLink, InMemoryCache } from '@apollo/client'
import { NormalizedCacheObject } from '@apollo/client/cache/inmemory/types'
import { setContext } from '@apollo/client/link/context' import { setContext } from '@apollo/client/link/context'
import 'isomorphic-fetch' import 'isomorphic-fetch'
import getConfig from 'next/config' import getConfig from 'next/config'
import { NextConfigType } from '../next.config.type' import { NextConfigType } from '../next.config.type'
let client: ApolloClient<any> let client: ApolloClient<NormalizedCacheObject>
const getClient = (): ApolloClient<any> => { const getClient = (): ApolloClient<NormalizedCacheObject> => {
if (!client) { if (!client) {
const config = getConfig() as NextConfigType const config = getConfig() as NextConfigType
@ -14,7 +15,7 @@ const getClient = (): ApolloClient<any> => {
const { publicRuntimeConfig, serverRuntimeConfig } = config const { publicRuntimeConfig, serverRuntimeConfig } = config
client = new ApolloClient({ client = new ApolloClient<NormalizedCacheObject>({
cache: new InMemoryCache(), cache: new InMemoryCache(),
link: from([ link: from([
setContext((request, context) => { setContext((request, context) => {

View File

@ -3,21 +3,14 @@ import 'antd/dist/antd.css'
import 'assets/global.scss' import 'assets/global.scss'
import 'assets/variables.scss' import 'assets/variables.scss'
import 'i18n' import 'i18n'
import { AppInitialProps } from 'next/app' import App, { AppInitialProps } from 'next/app'
import getConfig from 'next/config'
import { AppType } from 'next/dist/next-server/lib/utils' import { AppType } from 'next/dist/next-server/lib/utils'
import Head from 'next/head' import Head from 'next/head'
import React from 'react' import React from 'react'
import { wrapper } from 'store' import { wrapper } from 'store'
import getClient from '../graphql/client' import getClient from '../graphql/client'
const { publicRuntimeConfig } = getConfig() as { const MyApp: AppType = ({ Component, pageProps }) => {
publicRuntimeConfig: {
endpoint: string
}
}
const App: AppType = ({ Component, pageProps }) => {
return ( return (
<ApolloProvider client={getClient()}> <ApolloProvider client={getClient()}>
<Head> <Head>
@ -29,8 +22,6 @@ const App: AppType = ({ Component, pageProps }) => {
) )
} }
App.getInitialProps = (): AppInitialProps => ({ MyApp.getInitialProps = (context): Promise<AppInitialProps> => App.getInitialProps(context as any)
pageProps: {},
})
export default wrapper.withRedux(App) export default wrapper.withRedux(MyApp)

View File

@ -14,11 +14,7 @@ import { Omf } from '../../../components/omf'
import { useSubmission } from '../../../components/use.submission' import { useSubmission } from '../../../components/use.submission'
import { useFormPublicQuery } from '../../../graphql/query/form.public.query' import { useFormPublicQuery } from '../../../graphql/query/form.public.query'
interface Props { const Index: NextPage = () => {
id: string
}
const Index: NextPage<Props> = () => {
const { t, i18n } = useTranslation() const { t, i18n } = useTranslation()
const router = useRouter() const router = useRouter()
const id = router.query.id as string const id = router.query.id as string
@ -67,6 +63,7 @@ const Index: NextPage<Props> = () => {
direction: 'vertical', direction: 'vertical',
allowSlideNext: false, allowSlideNext: false,
allowSlidePrev: true, allowSlidePrev: true,
noSwiping: true,
updateOnWindowResize: true, updateOnWindowResize: true,
} }
@ -147,10 +144,4 @@ const Index: NextPage<Props> = () => {
) )
} }
Index.getInitialProps = ({ query }) => {
return {
id: query.id as string,
}
}
export default Index export default Index