Skip to content

Commit 5585bf5

Browse files
committed
refactor, use close button for update
1 parent 709ba41 commit 5585bf5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/frontend/src/components/AiBuilder/components/AIFormModalContent.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
FormControl,
88
FormErrorMessage,
99
ModalBody,
10+
ModalCloseButton,
1011
ModalFooter,
1112
ModalHeader,
1213
Text,
@@ -64,12 +65,15 @@ export const AIFormModalContent = ({
6465
setValue('actions', (idea as AiFormIdea).actions, { shouldValidate: true })
6566
}
6667

68+
const isCreate = type === 'create'
69+
6770
return (
6871
<>
6972
<Form onSubmit={handleSubmit(onSubmit)}>
7073
<ModalHeader p="2.5rem 2rem 1.5rem">
7174
<Text textStyle="h4">Build with AI</Text>
7275
</ModalHeader>
76+
{!isCreate && <ModalCloseButton onClick={onBack} />}
7377
<ModalBody>
7478
<Flex gap={4} flexDir="column">
7579
{AI_FORM_FIELDS.map((field) => (
@@ -92,7 +96,7 @@ export const AIFormModalContent = ({
9296
)}
9397
</FormControl>
9498
))}
95-
{type === 'create' && (
99+
{isCreate && (
96100
<IdeaButtons
97101
ideas={AI_FORM_IDEAS}
98102
onClick={(idea: AiChatIdea | AiFormIdea) =>
@@ -111,15 +115,21 @@ export const AIFormModalContent = ({
111115
</Flex>
112116
)}
113117
<Flex gap={4}>
114-
<Button variant="clear" colorScheme="secondary" onClick={onBack}>
115-
Back
116-
</Button>
118+
{isCreate && (
119+
<Button
120+
variant="clear"
121+
colorScheme="secondary"
122+
onClick={onBack}
123+
>
124+
Back
125+
</Button>
126+
)}
117127
<Button
118128
type="submit"
119129
leftIcon={<FaWandMagicSparkles />}
120130
isDisabled={!isValid}
121131
>
122-
{type === 'update' ? 'Update workflow' : 'Create'}
132+
{isCreate ? 'Create' : 'Update'}
123133
</Button>
124134
</Flex>
125135
</Flex>

0 commit comments

Comments
 (0)