Skip to content

Commit

Permalink
More lint errors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
NatSquared committed Mar 11, 2024
1 parent 331a540 commit 43127af
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TaxonFormValues } from 'components/metadataManagement/types';
import { useTheme } from '@mui/material/styles';
import { ActionContext } from '../../../ActionContext';
import * as yup from 'yup';
import { defaultAutocomplete } from './TaxonInputComponents';
import { DefaultAutocomplete } from './TaxonInputComponents';
import { yupResolver } from '@hookform/resolvers/yup';
import { bulkPatchEngagementMetadata } from 'services/engagementMetadataService';
import { openNotification } from 'services/notificationService/notificationSlice';
Expand Down Expand Up @@ -110,11 +110,11 @@ const EngagementMetadata = forwardRef((_props, ref) => {
},
}));

const renderTaxonTile = (taxon: MetadataTaxon, index: number) => {
const TaxonTile = (taxon: MetadataTaxon, index: number) => {
const taxonType = TaxonTypes[taxon.data_type as keyof typeof TaxonTypes];
const theme = useTheme();
const taxonValue = watch(taxon.id.toString());
const TaxonInput = taxonType.customInput ?? defaultAutocomplete;
const TaxonInput = taxonType.customInput ?? DefaultAutocomplete;
return (
<Grid
item
Expand Down Expand Up @@ -192,7 +192,7 @@ const EngagementMetadata = forwardRef((_props, ref) => {
spacing={3}
padding={2}
>
{tenantTaxa.map(renderTaxonTile)}
{tenantTaxa.map(TaxonTile)}
</Grid>
</form>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@mui/material';
import { FieldError } from 'react-hook-form';

export const defaultAutocomplete = ({ taxon, taxonType, field, setValue, errors, trigger }: TaxonInputProps) => {
export const DefaultAutocomplete = ({ taxon, taxonType, field, setValue, errors, trigger }: TaxonInputProps) => {
const [inputValue, setInputValue] = useState('');

const valueErrors = (errors[taxon.id.toString()] as unknown as Array<FieldError> | FieldError) ?? [];
Expand All @@ -30,7 +30,7 @@ export const defaultAutocomplete = ({ taxon, taxonType, field, setValue, errors,
errorMessage = (valueErrors as Array<FieldError>)?.map((error: FieldError, index: number) => {
errorIndices.add(index);
return (
<span>
<span key={index.toString() + error.message ?? ''}>
Entry #{index + 1}: {error.message}
<br />
</span>
Expand Down
1 change: 1 addition & 0 deletions met-web/src/components/metadataManagement/TaxonEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export const TaxonEditor = () => {
orderedMetadataTaxa.map((taxon: MetadataTaxon, index) => {
return (
<TaxonCard
key={taxon.id}
taxon={taxon}
index={index}
onExpand={handleExpandTaxon}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const PresetValuesEditor = ({
const errorMessage = valueErrors?.map((error: FieldError, index: number) => {
errorIndices.add(index);
return (
<span key={index}>
<span key={index.toString() + error.message ?? ''}>
Entry #{index + 1}: {error.message}
<br />
</span>
Expand Down Expand Up @@ -56,7 +56,7 @@ const PresetValuesEditor = ({
variant="outlined"
label={option}
{...getTagProps({ index })}
key={index}
key={option}
color={errorIndices.has(index) ? 'error' : 'default'}
/>
))}
Expand Down

0 comments on commit 43127af

Please sign in to comment.