mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Fix referencetab crashing after type change
This commit is contained in:
@@ -21,7 +21,7 @@ import { EditDataType } from '@/backendTypes'
|
||||
|
||||
const fieldWidth = '14em'
|
||||
|
||||
export type DropdownOption = { value: string; display: string }
|
||||
export type DropdownOption = { value: string | number; display: string }
|
||||
|
||||
export const DropdownSelector = <T extends object>({
|
||||
options,
|
||||
|
||||
@@ -13,23 +13,25 @@ export const ReferenceTab = () => {
|
||||
const referenceTypeOptions = referenceTypes
|
||||
.map(refType => ({
|
||||
display: refType.ref_type ?? 'Unknown',
|
||||
value: refType.ref_type_id + '',
|
||||
value: refType.ref_type_id,
|
||||
}))
|
||||
.sort((a, b) => a.display.localeCompare(b.display))
|
||||
|
||||
const refTypeSelection = [['Reference type', dropdown('ref_type_id', referenceTypeOptions, 'Reference type')]]
|
||||
|
||||
const selectedRefType = referenceTypes.find(refType => {
|
||||
if (mode.read) {
|
||||
return data.ref_type_id === refType.ref_type_id
|
||||
}
|
||||
return editData.ref_type_id === refType.ref_type_id
|
||||
})
|
||||
|
||||
const fields = selectedRefType?.ref_field_name.filter(field => field.display)
|
||||
|
||||
const fieldsArray = fields!.map(field => [
|
||||
const fieldsArray = fields?.map(field => [
|
||||
field.ref_field_name,
|
||||
textField(field.field_name! as keyof ReferenceDetailsType),
|
||||
])
|
||||
]) ?? [['Encountered error. Field type could not be found. Please contact project administrators.']]
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user