Skip to content

Commit

Permalink
refactor(create-forms): 🎉 update form fields
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Aug 29, 2023
1 parent 54938b0 commit b276f8f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 22 deletions.
36 changes: 22 additions & 14 deletions src/components/CreateForms/CreateRobotFormStep1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import { createRobot } from "../../toolkit/RobotSlice";
import InputToggle from "../InputToggle/InputToggle";
import useFunctions from "../../hooks/useFunctions";
import { useAppDispatch } from "../../hooks/redux";
import InputError from "../InputError/InputError";
import InputText from "../InputText/InputText";
import Seperator from "../Seperator/Seperator";
import { useParams } from "react-router-dom";
import useMain from "../../hooks/useMain";
import InfoTip from "../InfoTip/InfoTip";
import Button from "../Button/Button";
import { useFormik } from "formik";
import { toast } from "sonner";
import FormInputText from "../FormInputText/FormInputText";

interface ICreateRobotFormStep1 {
isImportRobot?: boolean;
Expand Down Expand Up @@ -166,19 +167,26 @@ export default function CreateRobotFormStep1({
className="flex flex-col gap-3 animate__animated animate__fadeIn relative"
>
{/* RobotName */}
<FormInputText
labelText="Robot Name:"
InfoTipText="Type a new robot name."
formikProps={{ ...formik.getFieldProps("robotName") }}
disabled={formik.isSubmitting || isImportRobot}
inputHoverText={
formik.isSubmitting || isImportRobot
? "You can't change robot name because this robot is created before."
: ""
}
validationError={formik.errors.robotName}
validationTouched={formik.touched.robotName}
/>
<div>
<div className="min-w-fit flex gap-1 text-xs font-medium text-layer-light-700 pb-3">
Robot Name:
<InfoTip content="Type a new robot name." />
</div>
<InputText
{...formik.getFieldProps("robotName")}
className="!text-sm"
disabled={formik.isSubmitting || isImportRobot}
inputHoverText={
formik.isSubmitting || isImportRobot
? "You can't change robot name because this robot is created before."
: ""
}
/>
<InputError
error={formik.errors.robotName}
touched={formik.touched.robotName}
/>
</div>
{/* RobotName */}

<Seperator />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import {
IRobotWorkspace,
IRobotWorkspaces,
} from "../../interfaces/robotInterfaces";
import CreateRobotWorkspaceItemAccordionHeader from "../CreateRobotWorkspaceItemAccordionHeader/CreateRobotWorkspaceItemAccordionHeader";
import { FormikProps } from "formik/dist/types";
import InputText from "../InputText/InputText";
import InputError from "../InputError/InputError";
import InputSelect from "../InputSelect/InputSelect";
import CreateRobotFormRepositoryItem from "../CreateRobotFormRepositoryItem/CreateRobotFormRepositoryItem";
import useCreateRobot from "../../hooks/useCreateRobot";
import { stringCapitalization } from "../../functions/GeneralFunctions";
import CreateRobotFormDeleteButton from "../CreateRobotFormDeleteButton/CreateRobotFormDeleteButton";
import CreateRobotFormAddButton from "../CreateRobotFormAddButton/CreateRobotFormAddButton";
import { stringCapitalization } from "../../functions/GeneralFunctions";
import { envOnPremiseRobot } from "../../helpers/envProvider";
import useCreateRobot from "../../hooks/useCreateRobot";
import InputSelect from "../InputSelect/InputSelect";
import InputError from "../InputError/InputError";
import { FormikProps } from "formik/dist/types";
import InputText from "../InputText/InputText";
import InfoTip from "../InfoTip/InfoTip";
import { envOnPremiseRobot } from "../../helpers/envProvider";
import CreateRobotWorkspaceItemAccordionHeader from "../CreateRobotWorkspaceItemAccordionHeader/CreateRobotWorkspaceItemAccordionHeader";

interface ICreateRobotFormWorkspaceItem {
formik: FormikProps<IRobotWorkspaces>;
Expand Down
37 changes: 37 additions & 0 deletions src/components/FormInputSelect/FormInputSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { ReactElement } from "react";
import InputSelect from "../InputSelect/InputSelect";
import InputError from "../InputError/InputError";
import InfoTip from "../InfoTip/InfoTip";

interface IFormInputSelect {
labelText: string;
InfoTipText: string;
formikProps: any;
disabled?: boolean;
validationError?: any;
validationTouched?: any;
children?: ReactElement | ReactElement[];
}

export default function FormInputSelect({
labelText,
InfoTipText,
formikProps,
disabled,
validationError,
validationTouched,
children,
}: IFormInputSelect): ReactElement {
return (
<div className="flex flex-col gap-2">
<div className="flex gap-1 min-w-fit text-xs font-medium text-layer-light-700">
{labelText}
<InfoTip content={InfoTipText} />
</div>
<InputSelect {...formikProps} disabled={disabled}>
{children}
</InputSelect>
<InputError error={validationError} touched={validationTouched} />
</div>
);
}

0 comments on commit b276f8f

Please sign in to comment.