mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: support synonyms when we add NLU Values
This commit is contained in:
parent
7a2c8532d0
commit
8126b6f37b
@ -220,7 +220,12 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
startIcon={<AddIcon />}
|
||||
variant="contained"
|
||||
sx={{ float: "right" }}
|
||||
onClick={() => dialogs.open(NlpValueFormDialog, null)}
|
||||
onClick={() =>
|
||||
dialogs.open(NlpValueFormDialog, {
|
||||
data: null,
|
||||
canHaveSynonyms,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("button.add")}
|
||||
</Button>
|
||||
|
@ -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<ComponentFormProps<NlpValueFormProps>> = ({
|
||||
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<
|
||||
/>
|
||||
</ContentItem>
|
||||
|
||||
<ContentItem>
|
||||
<Controller
|
||||
name="expressions"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<MultipleInput label={t("label.synonyms")} {...field} />
|
||||
)}
|
||||
/>
|
||||
</ContentItem>
|
||||
{canHaveSynonyms ? (
|
||||
<ContentItem>
|
||||
<Controller
|
||||
name="expressions"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<MultipleInput label={t("label.synonyms")} {...field} />
|
||||
)}
|
||||
/>
|
||||
</ContentItem>
|
||||
) : null}
|
||||
</ContentContainer>
|
||||
</form>
|
||||
</Wrapper>
|
||||
|
@ -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<T>,
|
||||
) => (
|
||||
|
Loading…
Reference in New Issue
Block a user