diff --git a/src/features/home/ClickBox.tsx b/src/features/home/ClickBox.tsx index b1dc735..922510c 100644 --- a/src/features/home/ClickBox.tsx +++ b/src/features/home/ClickBox.tsx @@ -4,14 +4,16 @@ import { useAppDispatch, useAppSelector } from '../../app/hooks/reduxHooks' import { listFormData, loadForm, removeForm } from '../wizard/FormDataSlice' import { red } from '@mui/material/colors' import { replaceSchema, replaceUISchema } from '../wizard/WizardSlice' +import {ConfirmButton} from "../modals/ChatGptModal"; type ClickBoxProps = { id: string title: string avatar?: string disableActions?: boolean + originalPrompt?: string } -export const ClickBox = ({ id, title, avatar, disableActions }: ClickBoxProps) => { +export const ClickBox = ({ id, title, avatar, originalPrompt, disableActions }: ClickBoxProps) => { const dispatch = useAppDispatch() const formList = useAppSelector(listFormData) const handleLoad = useCallback(() => { @@ -48,6 +50,7 @@ export const ClickBox = ({ id, title, avatar, disableActions }: ClickBoxProps) = + {originalPrompt && KI text bearbeiten } )} diff --git a/src/features/home/DragBox.tsx b/src/features/home/DragBox.tsx index ef9a4f7..b34119a 100644 --- a/src/features/home/DragBox.tsx +++ b/src/features/home/DragBox.tsx @@ -5,14 +5,16 @@ import { DraggableComponent, replaceSchema, replaceUISchema } from '../wizard/Wi import { useAppDispatch } from '../../app/hooks/reduxHooks' import { newForm } from '../wizard/FormDataSlice' import { removeTemplate } from '../wizard/TemplateSlice' +import {ConfirmButton} from "../modals/ChatGptModal"; type DragBoxProps = { name: string img?: string componentMeta: DraggableComponent - disableActions?: boolean + disableActions?: boolean, + originalPrompt?: string } -const DragBox = ({ name = 'Eingabefeld', img = '', componentMeta, disableActions }: DragBoxProps) => { +const DragBox = ({ name = 'Eingabefeld', img = '', componentMeta, disableActions, originalPrompt}: DragBoxProps) => { const dispatch = useAppDispatch() const [, dragRef] = useDrag( () => ({ @@ -33,7 +35,7 @@ const DragBox = ({ name = 'Eingabefeld', img = '', componentMeta, disableActions const handleReplace = useCallback(() => { dispatch(replaceSchema(componentMeta.jsonSchemaElement)) dispatch(replaceUISchema(componentMeta.uiSchema)) - dispatch(newForm({ jsonSchema: componentMeta.jsonSchemaElement, uiSchema: componentMeta.uiSchema })) + dispatch(newForm({ jsonSchema: componentMeta.jsonSchemaElement, uiSchema: componentMeta.uiSchema, originalPrompt: componentMeta.originalPrompt })) }, [dispatch, componentMeta]) const handleRemove = useCallback(() => { @@ -52,6 +54,7 @@ const DragBox = ({ name = 'Eingabefeld', img = '', componentMeta, disableActions + {originalPrompt && KI text bearbeiten } )} diff --git a/src/features/home/LeftDrawer.tsx b/src/features/home/LeftDrawer.tsx index 5423dcc..fd94fe4 100644 --- a/src/features/home/LeftDrawer.tsx +++ b/src/features/home/LeftDrawer.tsx @@ -5,7 +5,7 @@ import Drawer from '@mui/material/Drawer' import Toolbar from '@mui/material/Toolbar' import DragBox from './DragBox' -import { DraggableComponent, selectJsonSchema, selectUiSchema } from '../wizard/WizardSlice' +import {DraggableComponent, selectJsonSchema, selectOriginalPrompt, selectUiSchema} from '../wizard/WizardSlice' import { TabContext, TabList, TabPanel } from '@mui/lab' import { Button, Tab } from '@mui/material' import { useCallback } from 'react' @@ -142,9 +142,10 @@ export const NewEntryButton = () => { const dispatch = useAppDispatch() const jsonSchema = useAppSelector(selectJsonSchema) const uiSchema = useAppSelector(selectUiSchema) + const originalPrompt = useAppSelector(selectOriginalPrompt) const handleNewEntry = useCallback(() => { - dispatch(newForm({ jsonSchema, uiSchema })) - }, [dispatch, jsonSchema, uiSchema]) + dispatch(newForm({ jsonSchema, uiSchema, originalPrompt })) + }, [dispatch, jsonSchema, uiSchema, originalPrompt]) return ( + diff --git a/src/features/wizard/FormDataSlice.ts b/src/features/wizard/FormDataSlice.ts index b706b5e..4e26058 100644 --- a/src/features/wizard/FormDataSlice.ts +++ b/src/features/wizard/FormDataSlice.ts @@ -7,6 +7,7 @@ export type FormContent = { id: string title: string avatar?: string + originalPrompt?: string, jsonSchema: JsonSchema uiSchema: ScopableUISchemaElement | null | undefined formData: any @@ -72,11 +73,12 @@ export const formsContentSlice = createSlice({ setAvatar: (state: FormsContentReducer, action: PayloadAction) => { state.formData[state.currentID].avatar = action.payload }, - newForm: (state: FormsContentReducer, action: PayloadAction<{ jsonSchema: JsonSchema; uiSchema: any }>) => { + newForm: (state: FormsContentReducer, action: PayloadAction<{ jsonSchema: JsonSchema; uiSchema: any, originalPrompt?: string }>) => { const newID = new Date().getTime().toString() state.formData[newID] = { id: newID, title: 'New Form', + originalPrompt: action.payload.originalPrompt, jsonSchema: action.payload.jsonSchema, uiSchema: action.payload.uiSchema, formData: {}, diff --git a/src/features/wizard/WizardSlice.ts b/src/features/wizard/WizardSlice.ts index 9c09993..0175731 100644 --- a/src/features/wizard/WizardSlice.ts +++ b/src/features/wizard/WizardSlice.ts @@ -48,6 +48,7 @@ const initialState: JsonFormsEditState = { export type DraggableComponent = { name: string + originalPrompt?: string jsonSchemaElement: JsonSchema uiSchema?: UISchemaElement } @@ -55,6 +56,8 @@ export const selectJsonSchema = (state: RootState) => state.jsonFormsEdit.jsonSc export const selectUiSchema = (state: RootState) => state.jsonFormsEdit.uiSchema +export const selectOriginalPrompt = (state: RootState) => state.jsonFormsEdit.uiSchema?.originalPrompt + export const selectSelectedElementKey = (state: RootState) => state.jsonFormsEdit.selectedElementKey export const selectUIElementByScope = (state: RootState, scope: string) => {