diff --git a/src/admin/components/elements/Banner/index.tsx b/src/admin/components/elements/Banner/index.tsx index 3bea04b684..6e16058e4d 100644 --- a/src/admin/components/elements/Banner/index.tsx +++ b/src/admin/components/elements/Banner/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Link } from 'react-router-dom'; -import { Props } from './types'; +import { Props, RenderedTypeProps } from './types'; import './index.scss'; @@ -25,7 +25,7 @@ const Banner: React.FC = ({ icon && `${baseClass}--align-icon-${alignIcon}`, ].filter(Boolean).join(' '); - let RenderedType = 'div'; + let RenderedType: string | React.ComponentType = 'div'; if (onClick && !to) RenderedType = 'button'; if (to) RenderedType = Link; @@ -34,7 +34,6 @@ const Banner: React.FC = ({ {(icon && alignIcon === 'left') && ( diff --git a/src/admin/components/elements/Banner/types.ts b/src/admin/components/elements/Banner/types.ts index a7e366b31e..9cd1d45e7e 100644 --- a/src/admin/components/elements/Banner/types.ts +++ b/src/admin/components/elements/Banner/types.ts @@ -1,11 +1,19 @@ import { MouseEvent } from 'react'; +type onClick = (event: MouseEvent) => void + export type Props = { children?: React.ReactNode, className?: string, icon?: React.ReactNode, alignIcon?: 'left' | 'right', - onClick?: (event: MouseEvent) => void, + onClick?: onClick to?: string, type?: 'error' | 'success' | 'info' | 'default', } + +export type RenderedTypeProps = { + className?: string + onClick?: onClick + to: string +} diff --git a/src/admin/components/elements/ColumnSelector/getInitialState.tsx b/src/admin/components/elements/ColumnSelector/getInitialState.tsx deleted file mode 100644 index 041985d494..0000000000 --- a/src/admin/components/elements/ColumnSelector/getInitialState.tsx +++ /dev/null @@ -1,42 +0,0 @@ -const getInitialColumnState = (fields, useAsTitle, defaultColumns) => { - let initialColumns = []; - - if (Array.isArray(defaultColumns) && defaultColumns.length >= 1) { - return { - columns: defaultColumns, - }; - } - - - if (useAsTitle) { - initialColumns.push(useAsTitle); - } - - const remainingColumns = fields.reduce((remaining, field) => { - if (field.name === useAsTitle) { - return remaining; - } - - if (!field.name && Array.isArray(field.fields)) { - return [ - ...remaining, - ...field.fields.map((subField) => subField.name), - ]; - } - - return [ - ...remaining, - field.name, - ]; - }, []); - - initialColumns = initialColumns.concat(remainingColumns); - initialColumns = initialColumns.slice(0, 4); - - return { - columns: initialColumns, - }; -}; - - -module.exports = getInitialColumnState; diff --git a/src/admin/components/elements/ColumnSelector/types.ts b/src/admin/components/elements/ColumnSelector/types.ts index e44d71d2dd..a27578745b 100644 --- a/src/admin/components/elements/ColumnSelector/types.ts +++ b/src/admin/components/elements/ColumnSelector/types.ts @@ -1,6 +1,6 @@ -import { Collection } from '../../../../collections/config/types'; +import { CollectionConfig } from '../../../../collections/config/types'; export type Props = { - collection: Collection, + collection: CollectionConfig, handleChange: (columns) => void, } diff --git a/src/admin/components/elements/DatePicker/index.tsx b/src/admin/components/elements/DatePicker/index.tsx index e1297bc820..1143563725 100644 --- a/src/admin/components/elements/DatePicker/index.tsx +++ b/src/admin/components/elements/DatePicker/index.tsx @@ -3,7 +3,7 @@ import Loading from '../Loading'; const DatePicker = lazy(() => import('./DatePicker')); -export default (props) => ( +export default (props: unknown): React.ReactNode => ( }> diff --git a/src/admin/components/elements/DeleteDocument/index.tsx b/src/admin/components/elements/DeleteDocument/index.tsx index 8eef3fb4ec..6b96dd5105 100644 --- a/src/admin/components/elements/DeleteDocument/index.tsx +++ b/src/admin/components/elements/DeleteDocument/index.tsx @@ -83,7 +83,6 @@ const DeleteDocument: React.FC = (props) => {