mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
update props in Occurrence tabs
This commit is contained in:
@@ -102,7 +102,7 @@ const NewOccurrenceDialogContent = ({
|
||||
comSpecies: EditDataType<SpeciesDetailsType>
|
||||
) => void
|
||||
onClose: () => void
|
||||
localityData: EditDataType<LocalityDetailsType> | undefined
|
||||
localityData: EditDataType<LocalityDetailsType>
|
||||
validateOccurrenceFields: (editData: EditDataType<OccurrenceDetailsType>) => ValidationObject[]
|
||||
}) => {
|
||||
const { editData, fieldsWithErrors, setFieldsWithErrors } = useDetailContext<OccurrenceDetailsType>()
|
||||
@@ -155,10 +155,7 @@ const NewOccurrenceDialogContent = ({
|
||||
return (
|
||||
<>
|
||||
<DialogContent dividers>
|
||||
<OccurrenceCoreTab
|
||||
clickableLocName={false}
|
||||
existingOccurrences={(localityData?.now_ls ?? []) as Array<LocalitySpeciesDetailsType>}
|
||||
/>
|
||||
<OccurrenceCoreTab clickableLocName={false} existingOccurrences={localityData.now_ls} />
|
||||
<OccurrenceWearTab />
|
||||
<OccurrenceIsotopeTab />
|
||||
</DialogContent>
|
||||
@@ -500,7 +497,9 @@ export const OccurrencesTab = () => {
|
||||
renderReadRowActions={({ row }) => (
|
||||
<>
|
||||
<Tooltip title={`See details for species ${row.original.species_id}`}>
|
||||
<Link to={`/species/${row.original.species_id}`}>{<ManageSearchIcon />}</Link>
|
||||
<Link id={`go-to-species-${row.original.species_id}`} to={`/species/${row.original.species_id}`}>
|
||||
{<ManageSearchIcon />}
|
||||
</Link>
|
||||
</Tooltip>
|
||||
<EntryUpdateHistory
|
||||
row={row.original}
|
||||
|
||||
@@ -161,7 +161,7 @@ export const OccurrenceDetails = () => {
|
||||
const tabs: TabType[] = [
|
||||
{
|
||||
title: 'Occurrence',
|
||||
content: <OccurrenceCoreTab clickableLocName existingOccurrences={localityData?.now_ls ?? []} />,
|
||||
content: <OccurrenceCoreTab clickableLocName={true} existingOccurrences={localityData!.now_ls} />,
|
||||
},
|
||||
{ title: 'Wear', content: <OccurrenceWearTab /> },
|
||||
{ title: 'Isotopes', content: <OccurrenceIsotopeTab /> },
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useGetAllSpeciesQuery } from '@/redux/speciesReducer'
|
||||
import { SelectingTable } from '@/components/DetailView/common/SelectingTable'
|
||||
import { MRT_ColumnDef } from 'material-react-table'
|
||||
import { NewSpeciesForm } from '@/components/common/NewSpeciesForm'
|
||||
import { TaxonomySpecies } from '@/util/taxonomyUtilities'
|
||||
|
||||
const toText = (value: string | number | null | undefined) =>
|
||||
value === null || value === undefined || value === '' ? '-' : String(value)
|
||||
@@ -46,15 +47,16 @@ const speciesColumns: MRT_ColumnDef<Species>[] = [
|
||||
]
|
||||
export const OccurrenceCoreTab = ({
|
||||
clickableLocName = true,
|
||||
existingOccurrences,
|
||||
existingLocalitySpecies,
|
||||
}: {
|
||||
clickableLocName?: boolean
|
||||
existingOccurrences?: LocalitySpeciesDetailsType[]
|
||||
existingLocalitySpecies?: EditDataType<LocalitySpeciesDetailsType[]>
|
||||
additionalTaxonomyCheckSpecies?: TaxonomySpecies[]
|
||||
}) => {
|
||||
const { data: speciesQueryData, isError } = useGetAllSpeciesQuery()
|
||||
const { data, editData, setEditData, mode, textField, dropdown } = useDetailContext<OccurrenceDetailsType>()
|
||||
|
||||
const existingOccurrenceSpeciesIds = (existingOccurrences ?? []).map(occurrence => occurrence.species_id)
|
||||
const existingOccurrenceSpeciesIds = (existingLocalitySpecies ?? []).map(ls => ls.species_id)
|
||||
|
||||
const locNameArray = clickableLocName
|
||||
? [
|
||||
@@ -79,6 +81,7 @@ export const OccurrenceCoreTab = ({
|
||||
'',
|
||||
<NewSpeciesForm
|
||||
key={'new-species-form'}
|
||||
existingLocalitySpecies={existingLocalitySpecies}
|
||||
afterTaxonomyCheck={(convertedSpecies: EditDataType<Species>) => {
|
||||
setEditData({
|
||||
...editData,
|
||||
|
||||
@@ -24,7 +24,7 @@ Please contact the NOW administration to fix this taxonomy.`
|
||||
const isDuplicateTaxon = (newSpecies: EditDataType<Species>, existingSpecies: TaxonomySpecies) => {
|
||||
if (
|
||||
// the check for undefined species_id is here to make sure you cannot add two new,
|
||||
// identical species at the same time (e.g. in Locality -> Species -> Add new species)
|
||||
// identical species at the same time (e.g. in Locality -> Occurrence -> Create new occurrence)
|
||||
((newSpecies.species_id === undefined && existingSpecies.species_id === undefined) ||
|
||||
newSpecies.species_id !== existingSpecies.species_id) &&
|
||||
newSpecies.genus_name === existingSpecies.genus_name &&
|
||||
|
||||
Reference in New Issue
Block a user