diff --git a/app/src/components/alert/FormikErrorSnackbar.tsx b/app/src/components/alert/FormikErrorSnackbar.tsx index e311e0d8c8..847f797cac 100644 --- a/app/src/components/alert/FormikErrorSnackbar.tsx +++ b/app/src/components/alert/FormikErrorSnackbar.tsx @@ -14,6 +14,7 @@ const FormikErrorSnackbar = () => { } setOpenSnackbar({ open: true, msg: 'One or more fields are invalid.' }); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [submitCount, isSubmitting]); const closeSnackBar = () => diff --git a/app/src/components/attachments/EditFileWithMeta.tsx b/app/src/components/attachments/EditFileWithMeta.tsx deleted file mode 100644 index 09bf9f61f9..0000000000 --- a/app/src/components/attachments/EditFileWithMeta.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import Box from '@mui/material/Box'; -import { useFormikContext } from 'formik'; -import React from 'react'; -import EditReportMetaForm, { IEditReportMetaForm } from '../attachments/EditReportMetaForm'; - -export const EditFileWithMeta: React.FC = () => { - const { handleSubmit } = useFormikContext(); - - return ( -
- - - -
- ); -}; - -export default EditFileWithMeta; diff --git a/app/src/components/boundary/FullScreenViewMapDialog.tsx b/app/src/components/boundary/FullScreenViewMapDialog.tsx deleted file mode 100644 index f3730b6ee6..0000000000 --- a/app/src/components/boundary/FullScreenViewMapDialog.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { mdiArrowLeft } from '@mdi/js'; -import Icon from '@mdi/react'; -import AppBar from '@mui/material/AppBar'; -import Box from '@mui/material/Box'; -import Button from '@mui/material/Button'; -import Dialog from '@mui/material/Dialog'; -import Toolbar from '@mui/material/Toolbar'; -import Typography from '@mui/material/Typography'; -import React from 'react'; - -export interface IFullScreenViewMapProps { - open: boolean; - onClose: () => void; - map: any; - description: any; - layers: any; - mapTitle: string; - backButtonTitle: string; -} - -/** - * A dialog for displaying a component for editing purposes and giving the user the option to say - * `Yes`(Save) or `No`. - * - * @param {*} props - * @return {*} - */ -export const FullScreenViewMapDialog: React.FC = (props) => { - if (!props.open) { - return <>; - } - - return ( - - - - - - - - - - {props.mapTitle} - - - - Location description - - {props.description ? <>{props.description} : 'No Description'} - - {props.layers} - - {props.map} - - - ); -}; - -export default FullScreenViewMapDialog; diff --git a/app/src/components/chips/SubmitStatusChip.tsx b/app/src/components/chips/SubmitStatusChip.tsx deleted file mode 100644 index c6250c45b3..0000000000 --- a/app/src/components/chips/SubmitStatusChip.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { Theme } from '@mui/material'; -import Chip, { ChipProps } from '@mui/material/Chip'; -import { makeStyles } from '@mui/styles'; -import clsx from 'clsx'; -import { PublishStatus } from 'constants/attachments'; -import React from 'react'; - -const useStyles = makeStyles((theme: Theme) => ({ - chipUnSubmitted: { - color: '#fff', - backgroundColor: theme.palette.error.main - }, - chipSubmitted: { - color: '#fff', - backgroundColor: theme.palette.success.main - }, - chipNoData: {} -})); - -export const SubmitStatusChip: React.FC<{ status: PublishStatus; chipProps?: Partial }> = (props) => { - const classes = useStyles(); - - let chipLabel; - let chipTitle; - let chipStatusClass; - - if (props.status === PublishStatus.NO_DATA) { - chipLabel = 'No Data'; - chipTitle = 'No data to submit'; - chipStatusClass = classes.chipNoData; - } else if (props.status === PublishStatus.SUBMITTED) { - chipLabel = 'Submitted'; - chipTitle = 'All data has been submitted'; - chipStatusClass = classes.chipSubmitted; - } else { - chipLabel = 'Unsubmitted'; - chipTitle = 'Data has not been submitted'; - chipStatusClass = classes.chipUnSubmitted; - } - - return ( - - ); -}; diff --git a/app/src/components/data-grid/DatePickerDataGrid.tsx b/app/src/components/data-grid/DatePickerDataGrid.tsx deleted file mode 100644 index 6dc09b88fb..0000000000 --- a/app/src/components/data-grid/DatePickerDataGrid.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import useEnhancedEffect from '@mui/material/utils/useEnhancedEffect'; -import { GridRenderEditCellParams, GridValidRowModel } from '@mui/x-data-grid'; -import { DatePicker, DatePickerProps, LocalizationProvider } from '@mui/x-date-pickers'; -import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; -import { default as dayjs } from 'dayjs'; -import { useRef } from 'react'; - -interface IDatePickerDataGridProps { - dateFieldProps?: DatePickerProps; - dataGridProps: GridRenderEditCellParams; -} - -const DatePickerDataGrid = ({ - dateFieldProps, - dataGridProps -}: IDatePickerDataGridProps) => { - const ref = useRef(null); - - useEnhancedEffect(() => { - if (dataGridProps.hasFocus) { - ref.current?.focus(); - } - }, [dataGridProps.hasFocus]); - - return ( - - { - dataGridProps.api.setEditCellValue({ id: dataGridProps.id, field: dataGridProps.field, value: value }); - }} - onAccept={(value) => { - dataGridProps.api.setEditCellValue({ - id: dataGridProps.id, - field: dataGridProps.field, - value: value?.format('HH:mm:ss') - }); - }} - {...dateFieldProps} - /> - - ); -}; - -export default DatePickerDataGrid; diff --git a/app/src/components/dialog/ComponentDialog.test.tsx b/app/src/components/dialog/ComponentDialog.test.tsx index 0b1def6638..ea7ba8e5ab 100644 --- a/app/src/components/dialog/ComponentDialog.test.tsx +++ b/app/src/components/dialog/ComponentDialog.test.tsx @@ -24,18 +24,6 @@ const renderContainer = ({ dialogTitle, open = true }: { dialogTitle: string; op }; describe('ComponentDialog', () => { - it.skip('matches the snapshot when not open', () => { - const { baseElement } = renderContainer({ dialogTitle: 'this is a test', open: false }); - - expect(baseElement).toMatchSnapshot(); - }); - - it.skip('matches snapshot when open', () => { - const { baseElement } = renderContainer({ dialogTitle: 'this is a test' }); - - expect(baseElement).toMatchSnapshot(); - }); - it('calls the onClose prop when `Close` button is clicked', async () => { const { findByText } = renderContainer({ dialogTitle: 'this is a test' }); diff --git a/app/src/components/dialog/DialogVisual.tsx b/app/src/components/dialog/DialogVisual.tsx deleted file mode 100644 index 149a926b82..0000000000 --- a/app/src/components/dialog/DialogVisual.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { mdiAlert, mdiCheck, mdiExclamation, mdiFileCheckOutline } from '@mdi/js'; -import Icon from '@mdi/react'; -import { Theme } from '@mui/material'; -import Avatar from '@mui/material/Avatar'; -import { makeStyles } from '@mui/styles'; -import clsx from 'clsx'; - -const useStyles = makeStyles((theme: Theme) => ({ - dialogVisual: { - padding: 24, - boxSizing: 'content-box', - margin: '48px auto 0' - }, - error: { - color: '#a12622', - backgroundColor: '#F5E9E8' - }, - warning: { - color: '#a12622', - backgroundColor: '#a12622 10%' - }, - info: { - color: '#0972d3', - backgroundColor: '#F2F8FD' - }, - success: { - color: '#2d4821', - backgroundColor: '#dff0d8' - } -})); - -type Severity = 'error' | 'info' | 'success' | 'warning'; - -const defaultIcons: Record = { - error: mdiExclamation, - info: mdiFileCheckOutline, - success: mdiCheck, - warning: mdiAlert -}; - -interface IDialogVisualProps { - severity?: Severity; - icon?: string; -} - -const DialogVisual = (props: IDialogVisualProps) => { - const classes = useStyles(); - - const severity: Severity = props.severity || 'info'; - - return ( - - - - ); -}; - -export default DialogVisual; diff --git a/app/src/components/dialog/ErrorDialog.test.tsx b/app/src/components/dialog/ErrorDialog.test.tsx deleted file mode 100644 index 8f8741f3af..0000000000 --- a/app/src/components/dialog/ErrorDialog.test.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { fireEvent, render, waitFor } from 'test-helpers/test-utils'; -import { ErrorDialog } from './ErrorDialog'; - -describe('ErrorDialog', () => { - it.skip('renders correctly with no error message', () => { - const { baseElement } = render( -
- jest.fn()} - onOk={() => jest.fn()} - /> -
- ); - - expect(baseElement).toMatchSnapshot(); - }); - - it.skip('renders correctly with a non-detailed error message', () => { - const { baseElement } = render( -
- jest.fn()} - onOk={() => jest.fn()} - /> -
- ); - - expect(baseElement).toMatchSnapshot(); - }); - - it.skip('renders correctly with a detailed error message', async () => { - const { baseElement, getByText } = render( -
- jest.fn()} - onOk={() => jest.fn()} - /> -
- ); - - fireEvent.click(getByText('Show detailed error message')); - - await waitFor(() => { - expect(getByText('an error')).toBeVisible(); - expect(getByText('{"error":"another error"}')).toBeVisible(); - }); - - expect(baseElement).toMatchSnapshot(); - - fireEvent.click(getByText('Hide detailed error message')); - - await waitFor(() => { - expect(getByText('an error')).not.toBeVisible(); - expect(getByText('{"error":"another error"}')).not.toBeVisible(); - }); - }); -}); diff --git a/app/src/components/dialog/YesNoDialog.test.tsx b/app/src/components/dialog/YesNoDialog.test.tsx index aa040c21d8..53b6e0f5c0 100644 --- a/app/src/components/dialog/YesNoDialog.test.tsx +++ b/app/src/components/dialog/YesNoDialog.test.tsx @@ -29,24 +29,6 @@ const renderContainer = ({ }; describe('EditDialog', () => { - it.skip('matches the snapshot when not open', () => { - const { baseElement } = renderContainer({ dialogTitle: 'this is a test', dialogText: 'this is text', open: false }); - - expect(baseElement).toMatchSnapshot(); - }); - - it.skip('matches the snapshot when open, with no error message', () => { - const { baseElement } = renderContainer({ dialogTitle: 'this is a test', dialogText: 'this is text' }); - - expect(baseElement).toMatchSnapshot(); - }); - - it.skip('matches snapshot when open, with error message', () => { - const { baseElement } = renderContainer({ dialogTitle: 'this is a test', dialogText: 'This is an error' }); - - expect(baseElement).toMatchSnapshot(); - }); - it('calls the onYes prop when `Yes` button is clicked', async () => { const { findByText } = renderContainer({ dialogTitle: 'this is a test', dialogText: 'this is text' }); diff --git a/app/src/components/fields/AutocompleteFreeSoloField.tsx b/app/src/components/fields/AutocompleteFreeSoloField.tsx deleted file mode 100644 index 3f7e82a6e2..0000000000 --- a/app/src/components/fields/AutocompleteFreeSoloField.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import Autocomplete, { createFilterOptions } from '@mui/material/Autocomplete'; -import TextField from '@mui/material/TextField'; -import { useFormikContext } from 'formik'; -import get from 'lodash-es/get'; -import React from 'react'; - -export interface IAutocompleteFreeSoloField { - id: string; - label: string; - name: string; - options: string[]; - required?: boolean; - filterLimit?: number; -} - -const AutocompleteFreeSoloField: React.FC = (props) => { - const { touched, errors, setFieldValue, values } = useFormikContext(); - - const { id, label, name, options, required, filterLimit } = props; - - return ( - option} - filterOptions={createFilterOptions({ limit: filterLimit })} - onChange={(event, option) => { - setFieldValue(name, option); - }} - renderInput={(params) => ( - - )} - /> - ); -}; - -export default AutocompleteFreeSoloField; diff --git a/app/src/components/fields/CustomFieldArray.tsx b/app/src/components/fields/CustomFieldArray.tsx deleted file mode 100644 index 82b02dd640..0000000000 --- a/app/src/components/fields/CustomFieldArray.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { mdiTrashCanOutline } from '@mdi/js'; -import Icon from '@mdi/react'; -import { grey } from '@mui/material/colors'; -import IconButton from '@mui/material/IconButton'; -import List from '@mui/material/List'; -import ListItem from '@mui/material/ListItem'; -import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction'; -import ListItemText from '@mui/material/ListItemText'; -import { makeStyles } from '@mui/styles'; -import { FieldArray, FieldArrayRenderProps, useFormikContext } from 'formik'; -import { get } from 'lodash-es'; - -const useStyles = makeStyles({ - list: { - '& li': { - border: `1px solid ${grey[400]}` - }, - '& li + li': { - borderTop: 'none' - }, - '& li:first-of-type': { - mt: 1, - borderTopLeftRadius: '4px', - borderTopRightRadius: '4px' - }, - '& li:last-of-type': { - borderBottomLeftRadius: '4px', - borderBottomRightRadius: '4px' - } - }, - listItem: { - borderStyle: 'solid', - borderColor: 'grey.300' - }, - listItemText: { - overflow: 'hidden', - textOverflow: 'ellipsis' - } -}); - -export interface CustomFieldArrayProps { - /** - * The name of the array field. - * - * @type {string} - * @memberof CustomFieldArrayProps - */ - name: string; - /** - * Get a label for the raw array value. - * - * @memberof CustomFieldArrayProps - */ - getLabelForValue: (value: ValueType) => { - primaryLabel: string; - secondaryLabel?: string; - }; -} - -/** - * Render a list of items (with a delete button) for each item in an array field control, identified by its `name`. - * - * @example - * name="array_field_name" getLabelForValue={(value) => SomeLabelLookup(value)} /> - * - * @param {*} props - * @return {*} - */ -const CustomFieldArray = >(props: CustomFieldArrayProps) => { - const classes = useStyles(); - - const formikProps = useFormikContext(); - - const values = get(formikProps.values, props.name); - - if (!values || !Array.isArray(values) || !values.length) { - return <>; - } - - return ( - ( - <> - - {values.map((value: ValueType, index: number) => { - const label = props.getLabelForValue(value); - return ( - - - - { - arrayHelpers.remove(index); - }}> - - - - - ); - })} - - - )} - /> - ); -}; - -export default CustomFieldArray; diff --git a/app/src/components/fields/CustomNumberField.tsx b/app/src/components/fields/CustomNumberField.tsx deleted file mode 100644 index cdbb664d10..0000000000 --- a/app/src/components/fields/CustomNumberField.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import TextField, { TextFieldProps } from '@mui/material/TextField'; -import { useFormikContext } from 'formik'; -import get from 'lodash-es/get'; -import React from 'react'; -import NumberFormat, { NumberFormatProps } from 'react-number-format'; - -type BaseNumberFieldProps = { - name: string; - min?: number; - max?: number; - float?: boolean; -}; - -type INumberFieldProps = TextFieldProps & BaseNumberFieldProps & { required?: boolean; label: string }; - -type NumberFormatCustomProps = BaseNumberFieldProps & { - onChange: (event: { target: { name: string; value: number } }) => void; -}; - -const NumberFormatCustom = React.forwardRef(function NumericFormatCustom( - props, - ref -) { - const { onChange, min, max, float, ...other } = props; - - return ( - { - onChange({ - target: { - name: props.name, - value: float ? parseFloat(values.value) : parseInt(values.value) - } - }); - }} - decimalScale={float ? 7 : 0} - isAllowed={(values) => { - const value = float ? parseFloat(values.value) : parseInt(values.value); - return ( - values.value === '' || - (value >= (min ?? Number.MIN_SAFE_INTEGER) && value <= (max ?? Number.MAX_SAFE_INTEGER)) - ); - }} - /> - ); -}); - -const CustomNumberField: React.FC = (props) => { - const { values, handleChange, touched, errors } = useFormikContext(); - - const { name, min, max, float, ...rest } = props; - - return ( - - ); -}; - -export default CustomNumberField; diff --git a/app/src/components/fields/HorizontalSplitFormComponent.test.tsx b/app/src/components/fields/HorizontalSplitFormComponent.test.tsx deleted file mode 100644 index 4372c99c05..0000000000 --- a/app/src/components/fields/HorizontalSplitFormComponent.test.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import Box from '@mui/material/Box'; -import Typography from '@mui/material/Typography'; -import { render } from 'test-helpers/test-utils'; -import HorizontalSplitFormComponent from './HorizontalSplitFormComponent'; - -describe('HorizontalSplitFormComponent', () => { - it.skip('renders correctly', () => { - const { asFragment } = render( - - Hey this is my content - - } - /> - ); - - expect(asFragment()).toMatchSnapshot(); - }); -}); diff --git a/app/src/components/fields/SearchAutocompleteField.tsx b/app/src/components/fields/SearchAutocompleteField.tsx deleted file mode 100644 index c49eaff676..0000000000 --- a/app/src/components/fields/SearchAutocompleteField.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import { mdiMagnify } from '@mdi/js'; -import Icon from '@mdi/react'; -import { Autocomplete, Box, CircularProgress, TextField } from '@mui/material'; -import { DebouncedFunc } from 'lodash-es'; - -interface ISearchAutocompleteFieldProps { - id: string; - displayNameKey: keyof T; - placeholderText: string; - searchOptions: T[]; - selectedOptions: T[]; - handleSearch: DebouncedFunc<(inputValue: string, existingValues: T[]) => Promise>; - isSearching: boolean; - handleOnChange: (arg0: T) => void; - renderSearch: (arg0: any) => JSX.Element; -} - -const SearchAutocompleteField = (props: ISearchAutocompleteFieldProps) => { - const { - id, - placeholderText, - isSearching, - displayNameKey, - searchOptions, - selectedOptions, - handleSearch, - handleOnChange, - renderSearch - } = props; - - return ( - null} - id={id} - options={searchOptions} - filterSelectedOptions - filterOptions={(options) => options} // https://mui.com/material-ui/react-autocomplete/#search-as-you-type - isOptionEqualToValue={(option, value) => option[displayNameKey] === value[displayNameKey]} - getOptionLabel={(option) => String(option[displayNameKey] || '')} - onInputChange={(_, value) => { - handleSearch(value, selectedOptions); - }} - onChange={(_, option) => { - const newItem = option.pop(); - if (newItem) { - handleOnChange(newItem); - } - }} - renderInput={(params) => ( - - - - ), - endAdornment: ( - <> - {isSearching ? : null} - {params.InputProps.endAdornment} - - ) - }} - /> - )} - renderOption={(renderProps, renderOption) => { - return ( - - {renderSearch(renderOption)} - - ); - }} - /> - ); -}; - -export default SearchAutocompleteField; diff --git a/app/src/components/layout/Footer.test.tsx b/app/src/components/layout/Footer.test.tsx deleted file mode 100644 index 867dd988ef..0000000000 --- a/app/src/components/layout/Footer.test.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { render } from 'test-helpers/test-utils'; -import Footer from './Footer'; - -describe('Footer', () => { - it.skip('renders correctly', () => { - const { asFragment } = render(