-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(forms): 🎉 update forms and buttons
- Loading branch information
1 parent
a93f418
commit e346aa8
Showing
24 changed files
with
564 additions
and
542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import CFCancelButton from "../CFCancelButton/CFCancelButton"; | ||
import useCreateRobot from "../../hooks/useCreateRobot"; | ||
import { envApplication } from "../../helpers/envProvider"; | ||
import { useParams } from "react-router-dom"; | ||
import Button from "../Button/Button"; | ||
import { ReactElement } from "react"; | ||
|
||
interface ICFRobotButtons { | ||
step: 1 | 2 | 3 | 4; | ||
formik: any; | ||
isImportRobot?: boolean; | ||
} | ||
|
||
export default function CFRobotButtons({ | ||
step, | ||
formik, | ||
isImportRobot, | ||
}: ICFRobotButtons): ReactElement { | ||
const url = useParams(); | ||
|
||
const { robotData } = useCreateRobot(); | ||
|
||
function handleDisabled(): boolean { | ||
switch (step) { | ||
case 1: | ||
return ( | ||
!formik.isValid || | ||
formik.isSubmitting || | ||
JSON.stringify(formik.initialValues) === JSON.stringify(formik.values) | ||
); | ||
|
||
case 2: | ||
return !!( | ||
!formik?.isValid || | ||
formik.isSubmitting || | ||
JSON.stringify(formik.initialValues) === | ||
JSON.stringify(formik.values) || | ||
(envApplication && url?.robotName) | ||
); | ||
|
||
case 3: | ||
return ( | ||
!formik?.isValid || | ||
formik.isSubmitting || | ||
JSON.stringify(formik.initialValues) === JSON.stringify(formik.values) | ||
); | ||
case 4: | ||
return !formik?.isValid || formik.isSubmitting; | ||
} | ||
} | ||
|
||
function handleText(): string { | ||
switch (step) { | ||
case 1: | ||
return isImportRobot ? "Update Robot" : `Next Step`; | ||
|
||
case 2: | ||
return isImportRobot | ||
? "Update Robot" | ||
: robotData?.step1?.isDevelopmentMode | ||
? envApplication | ||
? "Create Application with Workspaces" | ||
: "Create Robot" | ||
: "Next Step"; | ||
|
||
case 3: | ||
return isImportRobot ? `Update Build Configration` : `Next Step`; | ||
|
||
case 4: | ||
return url?.robotName ? `Add Launch Step` : `Create Robot`; | ||
} | ||
} | ||
|
||
return ( | ||
<div className="mt-10 flex gap-2"> | ||
{!isImportRobot && <CFCancelButton disabled={formik?.isSubmitting} />} | ||
<Button | ||
type="submit" | ||
className="!h-11 text-xs" | ||
disabled={handleDisabled()} | ||
loading={formik?.isSubmitting} | ||
text={handleText()} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.