diff --git a/frontend/src/components/nlp/components/NlpValue.tsx b/frontend/src/components/nlp/components/NlpValue.tsx index 12c462e8..46393d22 100644 --- a/frontend/src/components/nlp/components/NlpValue.tsx +++ b/frontend/src/components/nlp/components/NlpValue.tsx @@ -220,7 +220,12 @@ export const NlpValues = ({ entityId }: { entityId: string }) => { startIcon={} variant="contained" sx={{ float: "right" }} - onClick={() => dialogs.open(NlpValueFormDialog, null)} + onClick={() => + dialogs.open(NlpValueFormDialog, { + data: null, + canHaveSynonyms, + }) + } > {t("button.add")} diff --git a/frontend/src/components/nlp/components/NlpValueForm.tsx b/frontend/src/components/nlp/components/NlpValueForm.tsx index 03cc3d2a..31490c6b 100644 --- a/frontend/src/components/nlp/components/NlpValueForm.tsx +++ b/frontend/src/components/nlp/components/NlpValueForm.tsx @@ -22,10 +22,17 @@ import { EntityType, Format } from "@/services/types"; import { ComponentFormProps } from "@/types/common/dialogs.types"; import { INlpValue, INlpValueAttributes } from "@/types/nlp-value.types"; -export const NlpValueForm: FC< - ComponentFormProps<{ data: INlpValue; canHaveSynonyms: boolean }> -> = ({ data: props, Wrapper = Fragment, WrapperProps, ...rest }) => { - const { data } = props || {}; +export type NlpValueFormProps = { + data?: INlpValue | null; + canHaveSynonyms?: boolean; +}; +export const NlpValueForm: FC> = ({ + data: props, + Wrapper = Fragment, + WrapperProps, + ...rest +}) => { + const { data, canHaveSynonyms } = props || {}; const { t } = useTranslate(); const { toast } = useToast(); const { query } = useRouter(); @@ -112,15 +119,17 @@ export const NlpValueForm: FC< /> - - ( - - )} - /> - + {canHaveSynonyms ? ( + + ( + + )} + /> + + ) : null} diff --git a/frontend/src/components/nlp/components/NlpValueFormDialog.tsx b/frontend/src/components/nlp/components/NlpValueFormDialog.tsx index a8ef383a..dbc8c75e 100644 --- a/frontend/src/components/nlp/components/NlpValueFormDialog.tsx +++ b/frontend/src/components/nlp/components/NlpValueFormDialog.tsx @@ -8,15 +8,11 @@ import { GenericFormDialog } from "@/app-components/dialogs"; import { ComponentFormDialogProps } from "@/types/common/dialogs.types"; -import { INlpValue } from "@/types/nlp-value.types"; -import { NlpValueForm } from "./NlpValueForm"; +import { NlpValueForm, NlpValueFormProps } from "./NlpValueForm"; export const NlpValueFormDialog = < - T extends { data: INlpValue; canHaveSynonyms: boolean } = { - data: INlpValue; - canHaveSynonyms: boolean; - }, + T extends NlpValueFormProps = NlpValueFormProps, >( props: ComponentFormDialogProps, ) => (