Skip to content

Commit

Permalink
added aiResponseReady state. Editbutton only appears when aiResponseR…
Browse files Browse the repository at this point in the history
…eady is true
  • Loading branch information
Catrovitch committed Aug 6, 2024
1 parent a7e8fc3 commit 3d56e1c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/client/pages/InventorsAssistant/FourthStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import LlmResponse from './LlmResponse'
type FourthStepProps = {
setAiResponse3: Dispatch<SetStateAction<string>>
aiResponse: string
aiResponseReady: boolean
setEditModeGlobal: Dispatch<SetStateAction<boolean>>
}

const FourthStep = ({
setAiResponse3,
aiResponse,
aiResponseReady,
setEditModeGlobal,
}: FourthStepProps) => (
<>
Expand Down Expand Up @@ -45,6 +47,7 @@ const FourthStep = ({

<LlmResponse
aiResponse={aiResponse}
aiResponseReady={aiResponseReady}
setEditedResponse={setAiResponse3}
setEditModeGlobal={setEditModeGlobal}
/>
Expand Down
8 changes: 7 additions & 1 deletion src/client/pages/InventorsAssistant/InventionReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import LlmResponse from './LlmResponse'

type InventionReportProps = {
aiResponse: string
aiResponseReady: boolean
setAiResponse: Dispatch<SetStateAction<string>>
headingLevel: 'h2' | 'h3'
}

const InventionReport = ({
aiResponse,
aiResponseReady,
setAiResponse,
headingLevel,
}: InventionReportProps) => {
Expand All @@ -26,7 +28,11 @@ const InventionReport = ({
{t('inventorsAssistant:finalStepSummary')}
</SectionHeading>

<LlmResponse aiResponse={aiResponse} setEditedResponse={setAiResponse} />
<LlmResponse
aiResponse={aiResponse}
aiResponseReady={aiResponseReady}
setEditedResponse={setAiResponse}
/>
</Box>
)
}
Expand Down
3 changes: 3 additions & 0 deletions src/client/pages/InventorsAssistant/InventorPhase2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const InventorPhase2 = () => {
<SecondStep
setAiResponse1={setAiResponse1}
aiResponse={aiResponse1}
aiResponseReady={aiResponse1Ready}
setEditModeGlobal={setEditModeGlobal}
/>
)}
Expand Down Expand Up @@ -112,6 +113,7 @@ const InventorPhase2 = () => {
<ThirdStep
setAiResponse2={setAiResponse2}
aiResponse={aiResponse2}
aiResponseReady={aiResponse2Ready}
setEditModeGlobal={setEditModeGlobal}
/>
)}
Expand Down Expand Up @@ -142,6 +144,7 @@ const InventorPhase2 = () => {
<FourthStep
setAiResponse3={setAiResponse3}
aiResponse={aiResponse3}
aiResponseReady={aiResponse3Ready}
setEditModeGlobal={setEditModeGlobal}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions src/client/pages/InventorsAssistant/InventorPhase3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const InventorPhase3 = () => {
{currentStep > 7 && (
<FinalStep
aiResponse={aiResponse4}
aiResponseReady={aiResponse4Ready}
originalIdea={inventiveMessage}
ideaRefinement={aiResponse1}
industrialApplicability={aiResponse2}
Expand Down
4 changes: 3 additions & 1 deletion src/client/pages/InventorsAssistant/LlmResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import Markdown from '../../components/Common/Markdown'

type LlmResponseProps = {
aiResponse: string
aiResponseReady: boolean
setEditedResponse: Dispatch<SetStateAction<string>>
setEditModeGlobal?: Dispatch<SetStateAction<boolean>>
}

const LlmResponse = ({
aiResponse,
aiResponseReady,
setEditedResponse,
setEditModeGlobal,
}: LlmResponseProps) => {
Expand Down Expand Up @@ -73,7 +75,7 @@ const LlmResponse = ({
<Alert severity='success' sx={{ py: 4, px: 2, width: '100%' }}>
<Markdown>{aiResponse}</Markdown>
</Alert>
{aiResponse && aiResponse.length > 0 && (
{aiResponse && aiResponseReady && (
<Button
data-cy='edit-ai-response-button'
variant='contained'
Expand Down
3 changes: 3 additions & 0 deletions src/client/pages/InventorsAssistant/SecondStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import LlmResponse from './LlmResponse'
type SecondStepProps = {
setAiResponse1: Dispatch<SetStateAction<string>>
aiResponse: string
aiResponseReady: boolean
setEditModeGlobal: Dispatch<SetStateAction<boolean>>
}

const SecondStep = ({
setAiResponse1,
aiResponse,
aiResponseReady,
setEditModeGlobal,
}: SecondStepProps) => (
<>
Expand All @@ -32,6 +34,7 @@ const SecondStep = ({

<LlmResponse
aiResponse={aiResponse}
aiResponseReady={aiResponseReady}
setEditedResponse={setAiResponse1}
setEditModeGlobal={setEditModeGlobal}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/client/pages/InventorsAssistant/ThirdStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import LlmResponse from './LlmResponse'
type ThirdStepProps = {
setAiResponse2: React.Dispatch<React.SetStateAction<string>>
aiResponse: string
aiResponseReady: boolean
setEditModeGlobal: Dispatch<SetStateAction<boolean>>
}

const ThirdStep: React.FC<ThirdStepProps> = ({
setAiResponse2,
aiResponse,
aiResponseReady,
setEditModeGlobal,
}) => (
<>
Expand All @@ -30,6 +32,7 @@ const ThirdStep: React.FC<ThirdStepProps> = ({
<Box component='section' sx={{ mt: 4 }}>
<LlmResponse
aiResponse={aiResponse}
aiResponseReady={aiResponseReady}
setEditedResponse={setAiResponse2}
setEditModeGlobal={setEditModeGlobal}
/>
Expand Down

0 comments on commit 3d56e1c

Please sign in to comment.