diff --git a/frontend/public/index.html b/frontend/public/index.html index c7c1060d..61a285e5 100644 --- a/frontend/public/index.html +++ b/frontend/public/index.html @@ -7,9 +7,9 @@ { + console.log("CRUD updated fields obj", updated_fields_obj); + }, [updated_fields_obj]); useEffect(() => { setInstanceObj(old_instance ? old_instance : {}); - setUpdatedFields({ id: old_instance?.id ? old_instance.id : -1 }); + if (old_instance.length >= 0 && old_instance.hasOwnProperty("id")) { + setUpdatedFields({ id: old_instance.id }); + } }, [old_instance]); const handleModelChange = (updated_fields: LooseObject) => { - // console.log("HandleModelChange: ", updated_fields); + console.log("HandleModelChange: ", updated_fields); setInstanceObj((instance_obj) => ({ ...instance_obj, ...updated_fields })); setUpdatedFields((updated_fields_obj) => ({ ...updated_fields_obj, @@ -92,7 +98,13 @@ export function CRUDModal({ } return ( - onClose()}> + onClose()} + > - onSubmit(mode === "EDIT" ? updated_fields_obj : instance_obj) - } + onClick={() => { + console.log( + "Submitting", + mode === "EDIT" ? updated_fields_obj : instance_obj + ); + onSubmit(mode === "EDIT" ? updated_fields_obj : instance_obj); + }} > {mode === "EDIT" ? "Update" : "Create"} diff --git a/frontend/src/components/widgets/modals/CreateColumnModal.tsx b/frontend/src/components/widgets/modals/CreateColumnModal.tsx new file mode 100644 index 00000000..231bd886 --- /dev/null +++ b/frontend/src/components/widgets/modals/CreateColumnModal.tsx @@ -0,0 +1,181 @@ +import React, { useState } from "react"; +import { + Modal, + Form, + FormInput, + TextArea, + FormGroup, + FormButton, + FormField, + TextAreaProps, + InputOnChangeData, + Checkbox, + Grid, + Button, +} from "semantic-ui-react"; +import { LanguageModelDropdown } from "../selectors/LanguageModelDropdown"; +import { LooseObject } from "../../types"; + +interface CreateColumnModalProps { + open: boolean; + onClose: () => void; + onSubmit: (data: any) => void; +} + +export const CreateColumnModal: React.FC = ({ + open, + onClose, + onSubmit, +}) => { + const [objData, setObjData] = useState({}); + + const { + name, + query, + matchText, + outputType, + limitToLabel, + instructions, + agentic, + languageModelId, + } = objData; + + const handleChange = ( + event: React.ChangeEvent, + data: TextAreaProps | InputOnChangeData, + name: string + ) => { + setObjData({ ...objData, [name]: data.value }); + }; + + const handleSubmit = () => { + console.log("Submit data", objData); + onSubmit(objData); + }; + + return ( + + "Create a New Column" + + + + +
+ + + setObjData({ ...objData, name: value }) + } + style={{ minWidth: "50vw important!" }} + /> +