diff --git a/src/lib/insight-sharing/FormInsight.tsx b/src/lib/insight-sharing/FormInsight.tsx index 530a5fd3a9bf178e2ddc6f9ef4df31a64b75b5f7..535d381a9c60caf22447e68e703a10aa3151915f 100644 --- a/src/lib/insight-sharing/FormInsight.tsx +++ b/src/lib/insight-sharing/FormInsight.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { TextEditor } from '@/lib/components/textEditor'; -import { useAppDispatch, useSessionCache, useGraphQueryResult } from '@/lib/data-access'; +import { useAppDispatch, useSessionCache, useGraphQueryResult, useActiveSaveState } from '@/lib/data-access'; import { Button, Input } from '@/lib/components'; import { addError } from '@/lib/data-access/store/configSlice'; import { SerializedEditorState } from 'lexical'; @@ -19,6 +19,7 @@ const FrequencyWeekDays = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']; export function FormInsight(props: Props) { const dispatch = useAppDispatch(); const session = useSessionCache(); + const activeSS = useActiveSaveState(); const [localInsight, setLocalInsight] = useState<InsightModel>(props.insight); const [editorState, setEditorState] = useState<SerializedEditorState | null>(null); const [frequency, setFrequency] = useState<{ @@ -33,6 +34,11 @@ export function FormInsight(props: Props) { dayOfWeek: 'SUN', }); const [valid, setValid] = useState(true); + const [selectedQueryID, setSelectedQueryID] = useState<number | undefined>(undefined); + const queryOptions = activeSS?.queryStates.openQueryArray.map(query => ({ + label: query.name, + value: query.id, +})); const result = useGraphQueryResult(); const nodeTypes = Object.keys(result.metaData?.nodes.types || {}); @@ -339,6 +345,22 @@ export function FormInsight(props: Props) { <div className="bg-base-200 min-h-[1px] my-2" /> <h2 className="font-bold">{capitalizeFirstLetter(props.insight.type)}ing text</h2> + + {activeSS && ( + <Input + label="Select Query" + type="dropdown" + value={selectedQueryID ?? ''} + onChange={val => { + setSelectedQueryID(val); + }} + options={queryOptions} + inline={false} + size="md" + /> + )} + + {selectedQueryID !== undefined && ( <TextEditor key={`editor-${props.insight.id}`} editorState={editorState} @@ -357,7 +379,8 @@ export function FormInsight(props: Props) { }} /> </TextEditor> + )} </div> </div> ); -} +} \ No newline at end of file