diff --git a/.eslintrc.js b/.eslintrc.js index b810847..4fc05f5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,21 +2,25 @@ module.exports = { root: true, parser: '@typescript-eslint/parser', parserOptions: { - ecmaFeatures: { jsx: true } + ecmaFeatures: { jsx: true }, }, extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react/recommended', - "plugin:jsx-a11y/recommended", + 'plugin:jsx-a11y/recommended', 'prettier/@typescript-eslint', 'plugin:prettier/recommended', ], rules: { - 'prettier/prettier': [ - "error", {}, { "usePrettierrc": true } - ], + 'prettier/prettier': ['error', {}, { usePrettierrc: true }], 'react/prop-types': 'off', + '@typescript-eslint/no-empty-interface': 'off', }, -}; + settings: { + react: { + version: 'detect', + }, + }, +} diff --git a/.travis.yml b/.travis.yml index f5a7d57..0ab8eb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,3 @@ cache: script: - yarn - yarn lint - - yarn build diff --git a/components/auth/footer.tsx b/components/auth/footer.tsx index 21f8d10..584b8db 100644 --- a/components/auth/footer.tsx +++ b/components/auth/footer.tsx @@ -1,13 +1,12 @@ -import {UpOutlined} from '@ant-design/icons/lib' -import {useQuery} from '@apollo/react-hooks' -import {Button, Menu, Select} from 'antd' +import { useQuery } from '@apollo/react-hooks' +import { Button, Select } from 'antd' import Link from 'next/link' -import {useRouter} from 'next/router' +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' +import { useTranslation } from 'react-i18next' +import { SETTINGS_QUERY, SettingsQueryData } from '../../graphql/query/settings.query' +import { languages } from '../../i18n' +import { clearAuth, withAuth } from '../with.auth' interface Props { me?: { @@ -16,10 +15,10 @@ interface Props { } } -const AuthFooterInner: React.FC = props => { +const AuthFooterInner: React.FC = (props) => { const { t, i18n } = useTranslation() const router = useRouter() - const {data} = useQuery(SETTINGS_QUERY) + const { data } = useQuery(SETTINGS_QUERY) const logout = () => { clearAuth() @@ -38,67 +37,55 @@ const AuthFooterInner: React.FC = props => { }} > - - {props.me ? ( - [ - - Hi, {props.me.username} - , - - ] - ): ( - [ - - - , - - - - ] - )} -
+ {props.me + ? [ + + Hi, {props.me.username} + , + , + ] + : [ + + + , + + + , + ]} +
+
- )} - actions={[ - remove(index)} /> - ]} + } + actions={[ remove(index)} />]} > - + + + - setNextTitle(e.target.value)}/> + setNextTitle(e.target.value)} /> = props => { - + ) } diff --git a/components/form/admin/fields.tab.tsx b/components/form/admin/fields.tab.tsx index dcca2fc..31ad96d 100644 --- a/components/form/admin/fields.tab.tsx +++ b/components/form/admin/fields.tab.tsx @@ -1,86 +1,90 @@ -import {PlusOutlined} from '@ant-design/icons/lib' -import {Button, Form, Select, Space, Tabs} from 'antd' -import {FormInstance} from 'antd/lib/form' -import {TabPaneProps} from 'antd/lib/tabs' -import React, {useCallback, useState} from 'react' -import {useTranslation} from 'react-i18next' -import {AdminFormFieldFragment} from '../../../graphql/fragment/admin.form.fragment' -import {FieldCard} from './field.card' -import {adminTypes} from './types' +import { PlusOutlined } from '@ant-design/icons/lib' +import { Button, Form, Select, Space, Tabs } from 'antd' +import { FormInstance } from 'antd/lib/form' +import { TabPaneProps } from 'antd/lib/tabs' +import React, { useCallback, useState } from 'react' +import { useTranslation } from 'react-i18next' +import { AdminFormFieldFragment } from '../../../graphql/fragment/admin.form.fragment' +import { FieldCard } from './field.card' +import { adminTypes } from './types' interface Props extends TabPaneProps { form: FormInstance fields: AdminFormFieldFragment[] - onChangeFields: (fields: AdminFormFieldFragment[]) => any + onChangeFields: (fields: AdminFormFieldFragment[]) => void } -export const FieldsTab: React.FC = props => { +export const FieldsTab: React.FC = (props) => { const { t } = useTranslation() const [nextType, setNextType] = useState('textfield') - const renderType = useCallback((field, index, remove) => { - return ( - - ) - }, [props.fields]) + const renderType = useCallback( + (field, index, remove) => { + return ( + + ) + }, + [props.fields] + ) - const addField = useCallback((add, index) => { - return ( - - - - - - - ) - }, [props.fields, nextType]) + + + + + ) + }, + [props.fields, nextType] + ) return ( - - + {(fields, { add, remove, move }) => { const addAndMove = (index) => (defaults) => { add(defaults) @@ -102,7 +106,6 @@ export const FieldsTab: React.FC = props => { ) }} - ) } diff --git a/components/form/admin/is.live.tsx b/components/form/admin/is.live.tsx index 51aebd7..863b4b7 100644 --- a/components/form/admin/is.live.tsx +++ b/components/form/admin/is.live.tsx @@ -1,22 +1,26 @@ -import {CheckCircleOutlined, CloseCircleOutlined} from '@ant-design/icons/lib' +import { CheckCircleOutlined, CloseCircleOutlined } from '@ant-design/icons/lib' import React from 'react' interface Props { isLive: boolean } -export const FormIsLive: React.FC = props => { +export const FormIsLive: React.FC = (props) => { if (props.isLive) { return ( - + ) } return ( - + ) } diff --git a/components/form/admin/respondent.notifications.tab.tsx b/components/form/admin/respondent.notifications.tab.tsx index f849ba6..905e75b 100644 --- a/components/form/admin/respondent.notifications.tab.tsx +++ b/components/form/admin/respondent.notifications.tab.tsx @@ -1,17 +1,17 @@ -import {InfoCircleOutlined} from '@ant-design/icons/lib' -import {Form, Input, Select, Switch, Tabs} from 'antd' -import {FormInstance} from 'antd/lib/form' -import {TabPaneProps} from 'antd/lib/tabs' -import React, {useEffect, useState} from 'react' -import {Trans, useTranslation} from 'react-i18next' -import {AdminFormFieldFragment} from '../../../graphql/fragment/admin.form.fragment' +import { InfoCircleOutlined } from '@ant-design/icons/lib' +import { Form, Input, Select, Switch, Tabs } from 'antd' +import { FormInstance } from 'antd/lib/form' +import { TabPaneProps } from 'antd/lib/tabs' +import React, { useEffect, useState } from 'react' +import { Trans, useTranslation } from 'react-i18next' +import { AdminFormFieldFragment } from '../../../graphql/fragment/admin.form.fragment' interface Props extends TabPaneProps { form: FormInstance fields: AdminFormFieldFragment[] } -export const RespondentNotificationsTab: React.FC = props => { +export const RespondentNotificationsTab: React.FC = (props) => { const { t } = useTranslation() const [enabled, setEnabled] = useState() @@ -33,7 +33,7 @@ export const RespondentNotificationsTab: React.FC = props => { const groups = {} - props.fields.forEach(field => { + props.fields.forEach((field) => { if (!groups[field.type]) { groups[field.type] = [] } @@ -47,7 +47,7 @@ export const RespondentNotificationsTab: React.FC = props => { name={['form', 'respondentNotifications', 'enabled']} valuePropName={'checked'} > - setEnabled(e.valueOf())} /> + setEnabled(e.valueOf())} /> = props => { message: t('validation:templateRequired'), }, ]} - extra={( + extra={
form:respondentNotifications.htmlTemplateInfo = props => {
- )} + } >
@@ -102,10 +103,12 @@ export const RespondentNotificationsTab: React.FC = props => { ]} > - {Object.keys(groups).map(key => ( + {Object.keys(groups).map((key) => ( - {groups[key].map(field => ( - {field.title} + {groups[key].map((field) => ( + + {field.title} + ))} ))} diff --git a/components/form/admin/start.page.tab.tsx b/components/form/admin/start.page.tab.tsx index 9763654..e79ca09 100644 --- a/components/form/admin/start.page.tab.tsx +++ b/components/form/admin/start.page.tab.tsx @@ -1,11 +1,11 @@ -import {DeleteOutlined, PlusOutlined} from '@ant-design/icons/lib' -import {Button, Card, Form, Input, Switch, Tabs} from 'antd' -import {TabPaneProps} from 'antd/lib/tabs' +import { DeleteOutlined, PlusOutlined } from '@ant-design/icons/lib' +import { Button, Card, Form, Input, Switch, Tabs } from 'antd' +import { TabPaneProps } from 'antd/lib/tabs' import React from 'react' -import {useTranslation} from 'react-i18next' -import {InputColor} from '../../input/color' +import { useTranslation } from 'react-i18next' +import { InputColor } from '../../input/color' -export const StartPageTab: React.FC = props => { +export const StartPageTab: React.FC = (props) => { const { t } = useTranslation() return ( @@ -18,17 +18,11 @@ export const StartPageTab: React.FC = props => { - + - + @@ -39,54 +33,65 @@ export const StartPageTab: React.FC = props => { - + {(fields, { add, remove }) => { return (
{fields.map((field, index) => ( - - remove(index)} /> - ]} + + remove(index)} />]}> + - - - - - - - - - - - - - - - - - - - - - ) - )} + + + + + + + + + + + + + + + + + + + + ))} = props => {