mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
remove species options that are already occurrences for the locality
This commit is contained in:
@@ -121,7 +121,7 @@ export const OccurrenceDetails = () => {
|
||||
|
||||
const {
|
||||
data: occurrenceData,
|
||||
isLoading,
|
||||
isLoading: occurrenceDataLoading,
|
||||
isError: occurrenceQueryError,
|
||||
} = useGetOccurrenceDetailsQuery(
|
||||
{ lid: parsedLid, speciesId: parsedSpeciesId },
|
||||
@@ -149,7 +149,7 @@ export const OccurrenceDetails = () => {
|
||||
}
|
||||
if (occurrenceQueryError) return <div>Error loading occurrence data</div>
|
||||
if (localityQueryError) return <div>Error loading locality data</div>
|
||||
if (isLoading || mutationLoading || localityDataLoading) return <CircularProgress />
|
||||
if (occurrenceDataLoading || localityDataLoading || mutationLoading) return <CircularProgress />
|
||||
|
||||
const initialOccurrence = emptyOccurrence
|
||||
|
||||
@@ -214,7 +214,7 @@ export const OccurrenceDetails = () => {
|
||||
}
|
||||
|
||||
const tabs: TabType[] = [
|
||||
{ title: 'Occurrence', content: <OccurrenceCoreTab /> },
|
||||
{ title: 'Occurrence', content: <OccurrenceCoreTab existingOccurrences={localityData!.now_ls} /> },
|
||||
{ title: 'Wear', content: <OccurrenceWearTab /> },
|
||||
{ title: 'Isotopes', content: <OccurrenceIsotopeTab /> },
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useDetailContext } from '@/components/DetailView/Context/DetailContext'
|
||||
import { ArrayFrame, HalfFrames } from '@/components/DetailView/common/tabLayoutHelpers'
|
||||
import { EditDataType, LocalityDetailsType, OccurrenceDetailsType, Species, SpeciesDetailsType } from '@/shared/types'
|
||||
import { LocalitySpeciesDetailsType, OccurrenceDetailsType, Species } from '@/shared/types'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { idStatusOptions, quantityOptions } from '../constants'
|
||||
import { useGetAllSpeciesQuery } from '@/redux/speciesReducer'
|
||||
@@ -43,10 +43,12 @@ const speciesColumns: MRT_ColumnDef<Species>[] = [
|
||||
header: 'Taxon status',
|
||||
},
|
||||
]
|
||||
export const OccurrenceCoreTab = () => {
|
||||
export const OccurrenceCoreTab = ({ existingOccurrences }: { existingOccurrences: LocalitySpeciesDetailsType[] }) => {
|
||||
const { data: speciesQueryData, isError } = useGetAllSpeciesQuery()
|
||||
const { data, editData, setEditData, mode, textField, dropdown } = useDetailContext<OccurrenceDetailsType>()
|
||||
|
||||
const existingOccurrenceSpeciesIds = existingOccurrences.map(occurrence => occurrence.species_id)
|
||||
|
||||
return (
|
||||
<>
|
||||
<HalfFrames>
|
||||
@@ -67,7 +69,9 @@ export const OccurrenceCoreTab = () => {
|
||||
<SelectingTable
|
||||
key={'selecting-table'}
|
||||
buttonText="Select Species"
|
||||
data={speciesQueryData}
|
||||
data={speciesQueryData?.filter(
|
||||
species => !existingOccurrenceSpeciesIds.includes(species.species_id)
|
||||
)}
|
||||
title="Species"
|
||||
isError={isError}
|
||||
columns={speciesColumns}
|
||||
|
||||
Reference in New Issue
Block a user