fix(client): cannot read properties of undefined (reading 'interface') (#1245)
This commit is contained in:
parent
26e27c814b
commit
63581688e9
@ -1,7 +1,7 @@
|
|||||||
import { useFieldSchema } from "@formily/react";
|
import { useFieldSchema } from '@formily/react';
|
||||||
import { useMemo } from "react";
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useCollectionManager, useCollection } from "../../collection-manager";
|
import { useCollection, useCollectionManager } from '../../collection-manager';
|
||||||
|
|
||||||
export const useFieldComponentOptions = () => {
|
export const useFieldComponentOptions = () => {
|
||||||
const { getCollectionJoinField } = useCollectionManager();
|
const { getCollectionJoinField } = useCollectionManager();
|
||||||
@ -11,11 +11,11 @@ export const useFieldComponentOptions = () => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const fieldComponentOptions = useMemo(() => {
|
const fieldComponentOptions = useMemo(() => {
|
||||||
if (
|
if (!collectionField || !collectionField?.interface) {
|
||||||
!['o2o', 'oho', 'obo', 'o2m', 'linkTo', 'm2o', 'm2m']
|
|
||||||
.includes(collectionField.interface)
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!['o2o', 'oho', 'obo', 'o2m', 'linkTo', 'm2o', 'm2m'].includes(collectionField.interface)) return;
|
||||||
|
|
||||||
switch (collectionField.interface) {
|
switch (collectionField.interface) {
|
||||||
case 'o2m':
|
case 'o2m':
|
||||||
@ -31,7 +31,7 @@ export const useFieldComponentOptions = () => {
|
|||||||
return [
|
return [
|
||||||
{ label: t('Record picker'), value: 'CollectionField' },
|
{ label: t('Record picker'), value: 'CollectionField' },
|
||||||
{ label: t('Select'), value: 'AssociationSelect' },
|
{ label: t('Select'), value: 'AssociationSelect' },
|
||||||
]
|
];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return [
|
return [
|
||||||
@ -39,7 +39,6 @@ export const useFieldComponentOptions = () => {
|
|||||||
{ label: t('Subform'), value: 'FormField' },
|
{ label: t('Subform'), value: 'FormField' },
|
||||||
{ label: t('Select'), value: 'AssociationSelect' },
|
{ label: t('Select'), value: 'AssociationSelect' },
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [t, collectionField?.interface]);
|
}, [t, collectionField?.interface]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user