Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wodka committed May 15, 2021
1 parent c793321 commit 94f1de3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 44 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- combined notificationts to become more versatile
- use exported hooks for graphql

- disable swipe gesture

### Fixed

Expand Down
11 changes: 0 additions & 11 deletions components/auth/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { Button, Select } from 'antd'
import getConfig from 'next/config'
import Link from 'next/link'
import { useRouter } from 'next/router'
import React from 'react'
import GitHubButton from 'react-github-button'
import { useTranslation } from 'react-i18next'
import { useSettingsQuery } from '../../graphql/query/settings.query'
import { languages } from '../../i18n'
import { NextConfigType } from '../../next.config.type'
import { clearAuth, withAuth } from '../with.auth'
import scss from './footer.module.scss'

const { publicRuntimeConfig } = getConfig() as NextConfigType

interface Props {
me?: {
id: string
Expand Down Expand Up @@ -42,7 +38,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link key={'admin'} href={'/admin'}>
<Button
type={'link'}
ghost
style={{
color: '#FFF',
}}
Expand All @@ -54,7 +49,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link key={'profile'} href={'/admin/profile'}>
<Button
type={'link'}
ghost
style={{
color: '#FFF',
}}
Expand All @@ -65,7 +59,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Button
key={'logout'}
type={'link'}
ghost
onClick={logout}
style={{
color: '#FFF',
Expand All @@ -78,7 +71,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link href={'/login'} key={'login'}>
<Button
type={'link'}
ghost
style={{
color: '#FFF',
}}
Expand All @@ -90,7 +82,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
<Link href={'/register'} key={'register'}>
<Button
type={'link'}
ghost
style={{
color: '#FFF',
}}
Expand Down Expand Up @@ -124,7 +115,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
type={'link'}
target={'_blank'}
rel={'noreferrer'}
ghost
href={'https://www.ohmyform.com'}
style={{
color: '#FFF',
Expand All @@ -136,7 +126,6 @@ const AuthFooterInner: React.FC<Props> = (props) => {
type={'link'}
target={'_blank'}
rel={'noreferrer'}
ghost
href={'https://lokalise.com/'}
style={{
color: '#FFF',
Expand Down
11 changes: 6 additions & 5 deletions components/form/admin/export.submission.action.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { message } from 'antd'
import ExcelJS from 'exceljs'
import ExcelJS, { CellValue } from 'exceljs'
import { useCallback, useState } from 'react'
import { SubmissionFragment } from '../../../graphql/fragment/submission.fragment'
import { useFormQuery } from '../../../graphql/query/form.query'
Expand Down Expand Up @@ -53,8 +53,8 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => {
start: 0,
})

const buildRow = (data: SubmissionFragment): any[] => {
const row = [
const buildRow = (data: SubmissionFragment): CellValue[] => {
const row: CellValue[] = [
data.id,
data.created,
data.lastModified,
Expand All @@ -66,8 +66,9 @@ export const ExportSubmissionAction: React.FC<Props> = (props) => {

data.fields.forEach((field) => {
try {
const decoded = JSON.parse(field.value)
row.push(decoded.value)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const decoded: { value: CellValue } = JSON.parse(field.value)
row.push(decoded.value || '')
} catch (e) {
row.push('')
}
Expand Down
7 changes: 4 additions & 3 deletions graphql/client.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { ApolloClient, from, HttpLink, InMemoryCache } from '@apollo/client'
import { NormalizedCacheObject } from '@apollo/client/cache/inmemory/types'
import { setContext } from '@apollo/client/link/context'
import 'isomorphic-fetch'
import getConfig from 'next/config'
import { NextConfigType } from '../next.config.type'

let client: ApolloClient<any>
let client: ApolloClient<NormalizedCacheObject>

const getClient = (): ApolloClient<any> => {
const getClient = (): ApolloClient<NormalizedCacheObject> => {
if (!client) {
const config = getConfig() as NextConfigType

if (!config) return client

const { publicRuntimeConfig, serverRuntimeConfig } = config

client = new ApolloClient({
client = new ApolloClient<NormalizedCacheObject>({
cache: new InMemoryCache(),
link: from([
setContext((request, context) => {
Expand Down
17 changes: 4 additions & 13 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@ import 'antd/dist/antd.css'
import 'assets/global.scss'
import 'assets/variables.scss'
import 'i18n'
import { AppInitialProps } from 'next/app'
import getConfig from 'next/config'
import App, { AppInitialProps } from 'next/app'
import { AppType } from 'next/dist/next-server/lib/utils'
import Head from 'next/head'
import React from 'react'
import { wrapper } from 'store'
import getClient from '../graphql/client'

const { publicRuntimeConfig } = getConfig() as {
publicRuntimeConfig: {
endpoint: string
}
}

const App: AppType = ({ Component, pageProps }) => {
const MyApp: AppType = ({ Component, pageProps }) => {
return (
<ApolloProvider client={getClient()}>
<Head>
Expand All @@ -29,8 +22,6 @@ const App: AppType = ({ Component, pageProps }) => {
)
}

App.getInitialProps = (): AppInitialProps => ({
pageProps: {},
})
MyApp.getInitialProps = (context): Promise<AppInitialProps> => App.getInitialProps(context as any)

export default wrapper.withRedux(App)
export default wrapper.withRedux(MyApp)
13 changes: 2 additions & 11 deletions pages/form/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ import { Omf } from '../../../components/omf'
import { useSubmission } from '../../../components/use.submission'
import { useFormPublicQuery } from '../../../graphql/query/form.public.query'

interface Props {
id: string
}

const Index: NextPage<Props> = () => {
const Index: NextPage = () => {
const { t, i18n } = useTranslation()
const router = useRouter()
const id = router.query.id as string
Expand Down Expand Up @@ -67,6 +63,7 @@ const Index: NextPage<Props> = () => {
direction: 'vertical',
allowSlideNext: false,
allowSlidePrev: true,
noSwiping: true,
updateOnWindowResize: true,
}

Expand Down Expand Up @@ -147,10 +144,4 @@ const Index: NextPage<Props> = () => {
)
}

Index.getInitialProps = ({ query }) => {
return {
id: query.id as string,
}
}

export default Index

0 comments on commit 94f1de3

Please sign in to comment.