@@ -35,10 +35,6 @@ interface CreateFlowModalProps {
3535 onClose : ( ) => void
3636}
3737
38- // TODO: find a better way to do this
39- const AI_MODE : 'ai-chat' | 'ai-form' =
40- Math . random ( ) < 0.5 ? 'ai-chat' : 'ai-form'
41-
4238type FLOW_CREATE_MODE = 'ai-chat' | 'ai-form' | 'new' | 'template'
4339
4440function FlowNameAndModeContent ( {
@@ -51,6 +47,7 @@ function FlowNameAndModeContent({
5147 handleInputChange,
5248 handleSubmit,
5349 setCreateMode,
50+ aiBuilderType,
5451} : {
5552 canUseAiBuilder : boolean
5653 createMode : FLOW_CREATE_MODE | null
@@ -61,6 +58,7 @@ function FlowNameAndModeContent({
6158 handleInputChange : ( ) => void
6259 handleSubmit : ( event : FormEvent < HTMLFormElement > ) => void
6360 setCreateMode : ( mode : FLOW_CREATE_MODE ) => void
61+ aiBuilderType : string
6462} ) {
6563 return (
6664 < Form onSubmit = { handleSubmit } >
@@ -90,8 +88,10 @@ function FlowNameAndModeContent({
9088 < Tile
9189 icon = { BiSolidMagicWand }
9290 flex = { 1 }
93- onClick = { ( ) => setCreateMode ( AI_MODE ) }
94- isSelected = { createMode === AI_MODE }
91+ onClick = { ( ) =>
92+ setCreateMode ( aiBuilderType as FLOW_CREATE_MODE )
93+ }
94+ isSelected = { createMode === aiBuilderType }
9595 >
9696 < Text textStyle = "h5" > Build with AI</ Text >
9797 < Text textStyle = "body-2" >
@@ -124,7 +124,7 @@ function FlowNameAndModeContent({
124124 </ ModalBody >
125125 < ModalFooter >
126126 < Button type = "submit" isDisabled = { isButtonDisabled } isLoading = { loading } >
127- { createMode === AI_MODE ? 'Next' : 'Create' }
127+ { createMode === aiBuilderType ? 'Next' : 'Create' }
128128 </ Button >
129129 </ ModalFooter >
130130 </ Form >
@@ -135,6 +135,7 @@ export default function CreateFlowModal(props: CreateFlowModalProps) {
135135 const { onClose } = props
136136
137137 // TODO (kevinkim-ogp): remove the flag value once GA
138+ // the flag returns either ai-form, ai-chat or none
138139 const { getFlagValue } = useContext ( LaunchDarklyContext )
139140 const aiBuilderType = getFlagValue ( 'ai-builder-type' , 'none' )
140141 const canUseAiBuilder = aiBuilderType !== 'none'
@@ -248,6 +249,7 @@ export default function CreateFlowModal(props: CreateFlowModalProps) {
248249 handleInputChange = { handleInputChange }
249250 handleSubmit = { handleSubmit }
250251 setCreateMode = { setCreateMode }
252+ aiBuilderType = { aiBuilderType }
251253 />
252254 ) }
253255 < ModalCloseButton mt = { 3 } />
0 commit comments