diff --git a/frontend/src/components/modules/SideStepper/SideStepper.utils.tsx b/frontend/src/components/modules/SideStepper/SideStepper.utils.tsx
index b5079fcf..1e6d7d3c 100644
--- a/frontend/src/components/modules/SideStepper/SideStepper.utils.tsx
+++ b/frontend/src/components/modules/SideStepper/SideStepper.utils.tsx
@@ -1,19 +1,26 @@
import { CheckMarkIcon } from '@app/static/icons/CheckMarkIcon';
+import { StepStates } from './SideStepper.interface';
-export const Completed = () => {
+const Completed = () => {
return (
);
};
-export const InProgress = () => {
+const InProgress = () => {
return (
);
};
-export const NotStarted = () => {
+const NotStarted = () => {
return
;
};
+
+export const stepComponentsMap: { [key in StepStates]: JSX.Element } = {
+ completed:
,
+ inProgress:
,
+ notStarted:
,
+};
diff --git a/frontend/src/components/modules/SideStepper/index.ts b/frontend/src/components/modules/SideStepper/index.ts
index 34724540..3f65f2f0 100644
--- a/frontend/src/components/modules/SideStepper/index.ts
+++ b/frontend/src/components/modules/SideStepper/index.ts
@@ -1,2 +1,3 @@
export { SideStepper } from './SideStepper';
+export { stepComponentsMap } from './SideStepper.utils';
export type { SideStepperProps, Step, StepStates } from './SideStepper.interface';
diff --git a/frontend/src/components/pages/PersonalDetails/PersonalDetails.interface.ts b/frontend/src/components/pages/PersonalDetails/PersonalDetails.interface.ts
deleted file mode 100644
index 503ad06a..00000000
--- a/frontend/src/components/pages/PersonalDetails/PersonalDetails.interface.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export const PersonalDetailsFormNames = {
- firstName: 'firstName',
- lastName: 'lastName',
- email: 'email',
-} as const;
-
-export interface PersonalDetailsForm {
- [PersonalDetailsFormNames.firstName]: string;
- [PersonalDetailsFormNames.lastName]: string;
- [PersonalDetailsFormNames.email]: string;
-}
diff --git a/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/AddEmployeeForm.interface.ts b/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/AddEmployeeForm.interface.ts
new file mode 100644
index 00000000..7547ed39
--- /dev/null
+++ b/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/AddEmployeeForm.interface.ts
@@ -0,0 +1,17 @@
+import { Option } from '@app/components/common/Combobox';
+
+export const addEmployeeFormNames = {
+ firstName: 'firstName',
+ lastName: 'lastName',
+ email: 'email',
+ ladder: 'ladder',
+ technology: 'technology',
+} as const;
+
+export interface AddEmployeeForm {
+ [addEmployeeFormNames.firstName]: string;
+ [addEmployeeFormNames.lastName]: string;
+ [addEmployeeFormNames.email]: string;
+ [addEmployeeFormNames.ladder]: Option;
+ [addEmployeeFormNames.technology]: Option[];
+}
diff --git a/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/AddEmployeeForm.tsx b/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/AddEmployeeForm.tsx
new file mode 100644
index 00000000..8e654493
--- /dev/null
+++ b/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/AddEmployeeForm.tsx
@@ -0,0 +1,19 @@
+import { FC, PropsWithChildren } from 'react';
+import { useForm } from 'react-hook-form';
+
+import { FormProvider } from '@app/components/common/FormProvider';
+import { AddEmployeeForm, addEmployeeFormNames } from './AddEmployeeForm.interface';
+
+export const AddEmployeeFormProvider: FC
= ({ children }) => {
+ const form = useForm({
+ mode: 'onChange',
+ defaultValues: {
+ [addEmployeeFormNames.firstName]: '',
+ [addEmployeeFormNames.lastName]: '',
+ [addEmployeeFormNames.email]: '',
+ [addEmployeeFormNames.ladder]: {},
+ [addEmployeeFormNames.technology]: [],
+ },
+ });
+ return form={form}>{children};
+};
diff --git a/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/index.ts b/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/index.ts
new file mode 100644
index 00000000..7f7db7f2
--- /dev/null
+++ b/frontend/src/components/pages/addEmployee/AddEmployeeFormProvider/index.ts
@@ -0,0 +1,3 @@
+export { AddEmployeeFormProvider } from './AddEmployeeForm';
+export type { AddEmployeeForm } from './AddEmployeeForm.interface';
+export { addEmployeeFormNames } from './AddEmployeeForm.interface';
diff --git a/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.hooks.ts b/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.hooks.ts
new file mode 100644
index 00000000..f22bbfcc
--- /dev/null
+++ b/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.hooks.ts
@@ -0,0 +1,37 @@
+import { useFieldArray, useFormContext } from 'react-hook-form';
+import { useEffect, useState } from 'react';
+import { AddEmployeeForm, addEmployeeFormNames } from '../AddEmployeeFormProvider';
+import { usePeopleStore } from '@app/store/people';
+import { routes } from '@app/constants';
+
+export const useMainLadder = () => {
+ const form = useFormContext();
+ const updateProgress = usePeopleStore((state) => state.updateProgress);
+
+ const technologyFields = useFieldArray({
+ name: addEmployeeFormNames.technology,
+ control: form.control,
+ });
+
+ const [open, setOpen] = useState(true);
+ const [formValid, setFormValid] = useState(false);
+
+ const handleSubmit = form.handleSubmit((data) => console.log('data', data));
+ const values = form.watch();
+ const ladderSelected = values?.[addEmployeeFormNames.ladder]?.name?.length > 0;
+ const firstTechnology = values?.[addEmployeeFormNames.technology]?.[0];
+
+ useEffect(() => {
+ const technologySelected = firstTechnology && firstTechnology.name?.length > 0;
+
+ setFormValid(ladderSelected && technologySelected);
+ }, [values, ladderSelected, firstTechnology]);
+
+ // INFO: update progress in sidebar stepper
+ useEffect(() => {
+ if (formValid) updateProgress({ [routes.people.addNew.mainLadder]: 'completed' });
+ else updateProgress({ [routes.people.addNew.mainLadder]: 'inProgress' });
+ }, [formValid, updateProgress]);
+
+ return { firstTechnology, form, handleSubmit, technologyFields, open, setOpen, ladderSelected, formValid };
+};
diff --git a/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.tsx b/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.tsx
new file mode 100644
index 00000000..0a9a662f
--- /dev/null
+++ b/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.tsx
@@ -0,0 +1,86 @@
+'use client';
+import { Button } from '@app/components/common/Button';
+import { Combobox } from '@app/components/common/Combobox';
+import { Typography } from '@app/components/common/Typography';
+import { stepComponentsMap } from '@app/components/modules/SideStepper';
+import { useMainLadder } from './MainLadder.hooks';
+import { DeleteIcon } from '@app/static/icons/DeleteIcon';
+import { generateClassNames } from '@app/utils';
+import { ChevronUpIcon } from '@app/static/icons/ChevronUpIcon';
+import { Spacer, ladders, technologies } from './MainLadder.utils';
+import { addEmployeeFormNames } from '../AddEmployeeFormProvider';
+
+export const MainLadder = () => {
+ const { form, technologyFields, open, setOpen, ladderSelected, formValid, firstTechnology } = useMainLadder();
+ const values = form.watch();
+
+ return (
+
+
+
+
{formValid ? stepComponentsMap.completed : stepComponentsMap.inProgress}
+
1. Select Ladder
+
+
+
+ {open && (
+
+
+ }
+ />
+ {values?.[addEmployeeFormNames.technology].map((tech, i) => {
+ return (
+
+ i !== 0 ? (
+
+ ) : (
+
+ )
+ }
+ />
+ );
+ })}
+ {ladderSelected && (
+
+ )}
+
+
+
+
+
+ )}
+
+ );
+};
diff --git a/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.utils.tsx b/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.utils.tsx
new file mode 100644
index 00000000..e61f0302
--- /dev/null
+++ b/frontend/src/components/pages/addEmployee/MainLadder/MainLadder.utils.tsx
@@ -0,0 +1,55 @@
+export const ladders = [
+ {
+ name: 'Frontend',
+ id: 'frontend',
+ },
+ {
+ name: 'Backend',
+ id: 'backend',
+ },
+ {
+ name: 'Design',
+ id: 'design',
+ },
+ {
+ name: 'QA',
+ id: 'qa',
+ },
+ {
+ name: 'Project Manager',
+ id: 'project-manager',
+ },
+ {
+ name: 'Dev Ops',
+ id: 'dev-ops',
+ },
+];
+
+export const technologies = [
+ {
+ name: 'Next.js',
+ id: 'next.js',
+ },
+ {
+ name: 'React',
+ id: 'react',
+ },
+ {
+ name: 'Python',
+ id: 'python',
+ },
+ {
+ name: 'Django',
+ id: 'django',
+ },
+ {
+ name: 'Typescript',
+ id: 'typescript',
+ },
+ {
+ name: 'Docker',
+ id: 'docker',
+ },
+];
+
+export const Spacer = () => ;
diff --git a/frontend/src/components/pages/addEmployee/MainLadder/index.ts b/frontend/src/components/pages/addEmployee/MainLadder/index.ts
new file mode 100644
index 00000000..77d8ce3c
--- /dev/null
+++ b/frontend/src/components/pages/addEmployee/MainLadder/index.ts
@@ -0,0 +1 @@
+export { MainLadder } from './MainLadder';
diff --git a/frontend/src/components/pages/PersonalDetails/PersonalDetails.hooks.ts b/frontend/src/components/pages/addEmployee/PersonalDetails/PersonalDetails.hooks.ts
similarity index 64%
rename from frontend/src/components/pages/PersonalDetails/PersonalDetails.hooks.ts
rename to frontend/src/components/pages/addEmployee/PersonalDetails/PersonalDetails.hooks.ts
index f7fcda6e..dc91569a 100644
--- a/frontend/src/components/pages/PersonalDetails/PersonalDetails.hooks.ts
+++ b/frontend/src/components/pages/addEmployee/PersonalDetails/PersonalDetails.hooks.ts
@@ -1,18 +1,12 @@
import { routes } from '@app/constants';
import { useEffect, useState } from 'react';
-import { useForm } from 'react-hook-form';
-import { PersonalDetailsForm, PersonalDetailsFormNames } from './PersonalDetails.interface';
+import { useFormContext } from 'react-hook-form';
+
import { usePeopleStore } from '@app/store/people/store';
+import { AddEmployeeForm } from '../AddEmployeeFormProvider';
export const usePersonalDetails = () => {
- const form = useForm({
- mode: 'onChange',
- defaultValues: {
- [PersonalDetailsFormNames.firstName]: '',
- [PersonalDetailsFormNames.lastName]: '',
- [PersonalDetailsFormNames.email]: '',
- },
- });
+ const form = useFormContext();
const { isDirty, isValid } = form.formState;
const [formValid, setFormValid] = useState(false);
const updateProgress = usePeopleStore((state) => state.updateProgress);
@@ -27,5 +21,5 @@ export const usePersonalDetails = () => {
else updateProgress({ [routes.people.addNew.personalDetails]: 'inProgress' });
}, [formValid, updateProgress]);
- return { form, formValid };
+ return { formValid };
};
diff --git a/frontend/src/components/pages/PersonalDetails/PersonalDetails.tsx b/frontend/src/components/pages/addEmployee/PersonalDetails/PersonalDetails.tsx
similarity index 71%
rename from frontend/src/components/pages/PersonalDetails/PersonalDetails.tsx
rename to frontend/src/components/pages/addEmployee/PersonalDetails/PersonalDetails.tsx
index 86aee9a4..7bf94d13 100644
--- a/frontend/src/components/pages/PersonalDetails/PersonalDetails.tsx
+++ b/frontend/src/components/pages/addEmployee/PersonalDetails/PersonalDetails.tsx
@@ -1,22 +1,24 @@
'use client';
import { Button } from '@app/components/common/Button';
-import { FormProvider } from '@app/components/common/FormProvider';
import { Input } from '@app/components/common/Input';
import { Typography } from '@app/components/common/Typography';
-import { PersonalDetailsForm, PersonalDetailsFormNames } from './PersonalDetails.interface';
import { usePersonalDetails } from './PersonalDetails.hooks';
+import { routes } from '@app/constants';
+import { useRouter } from 'next/navigation';
+import { addEmployeeFormNames } from '../AddEmployeeFormProvider';
export const PersonalDetails = () => {
- const { form, formValid } = usePersonalDetails();
+ const { formValid } = usePersonalDetails();
+ const router = useRouter();
return (
- form={form}>
+ <>
Personal details
{
}}
/>
{
}}
/>
{
/>
-
-
+ >
);
};
diff --git a/frontend/src/components/pages/PersonalDetails/index.ts b/frontend/src/components/pages/addEmployee/PersonalDetails/index.ts
similarity index 100%
rename from frontend/src/components/pages/PersonalDetails/index.ts
rename to frontend/src/components/pages/addEmployee/PersonalDetails/index.ts
diff --git a/frontend/src/constants/routes.ts b/frontend/src/constants/routes.ts
index 4f927cd9..95cb813d 100644
--- a/frontend/src/constants/routes.ts
+++ b/frontend/src/constants/routes.ts
@@ -12,8 +12,8 @@ export const routes = {
index: '/people',
myProfile: '/people/my-profile',
addNew: {
- personalDetails: 'people/add-new/personal-details',
- mainLadder: 'people/add-new/main-ladder',
+ personalDetails: '/people/add-new/personal-details',
+ mainLadder: '/people/add-new/main-ladder',
},
},
} as const;
diff --git a/frontend/src/static/icons/ChevronUpIcon.tsx b/frontend/src/static/icons/ChevronUpIcon.tsx
new file mode 100644
index 00000000..c2b7538d
--- /dev/null
+++ b/frontend/src/static/icons/ChevronUpIcon.tsx
@@ -0,0 +1,11 @@
+export const ChevronUpIcon: React.FC> = (props) => (
+
+);