Skip to content

Commit

Permalink
feat: sync resultList
Browse files Browse the repository at this point in the history
  • Loading branch information
bekossy committed Dec 16, 2023
1 parent 9e8a91a commit 518f1ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions agenta-web/src/components/Playground/TestContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import React, {PropsWithChildren, createContext, useState} from "react"
export const TestContext = createContext<{
testList: GenericObject[]
setTestList: React.Dispatch<React.SetStateAction<GenericObject[]>>
}>({testList: [{}], setTestList: () => {}})
setResultsList: React.Dispatch<React.SetStateAction<string[]>>
resultsList: string[]
}>({testList: [{}], setTestList: () => {}, resultsList: [], setResultsList: () => {}})

const TestContextProvider: React.FC<PropsWithChildren> = (props) => {
const [testList, setTestList] = useState<GenericObject[]>([{}])
const [resultsList, setResultsList] = useState<string[]>(testList.map(() => ""))

return (
<TestContext.Provider value={{testList, setTestList}}>
<TestContext.Provider value={{testList, setTestList, resultsList, setResultsList}}>
{props.children}
</TestContext.Provider>
)
Expand Down
3 changes: 1 addition & 2 deletions agenta-web/src/components/Playground/Views/TestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ const BoxComponent: React.FC<BoxComponentProps> = ({
const App: React.FC<TestViewProps> = ({inputParams, optParams, variant, isChatVariant}) => {
const router = useRouter()
const appId = router.query.app_id as unknown as string
const {testList, setTestList} = useContext(TestContext)
const [resultsList, setResultsList] = useState<string[]>(testList.map(() => ""))
const {testList, setTestList, resultsList, setResultsList} = useContext(TestContext)
const [params, setParams] = useState<Record<string, string> | null>(null)
const classes = useStylesApp()
const rootRef = React.useRef<HTMLDivElement>(null)
Expand Down

0 comments on commit 518f1ed

Please sign in to comment.