+
diff --git a/frontend/src/app/(app)/(peopleFlow)/people/add-new/personal-details/page.tsx b/frontend/src/app/(app)/(peopleFlow)/people/add-new/personal-details/page.tsx
index a894ea09..41475a48 100644
--- a/frontend/src/app/(app)/(peopleFlow)/people/add-new/personal-details/page.tsx
+++ b/frontend/src/app/(app)/(peopleFlow)/people/add-new/personal-details/page.tsx
@@ -1,83 +1,3 @@
-'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 { routes } from '@app/constants';
-import { usePeopleStore } from '@app/store/peopleStore';
-import { useEffect, useState } from 'react';
-import { useForm } from 'react-hook-form';
+import { PersonalDetails } from '@app/components/pages/PersonalDetails/PersonalDetails';
-enum PersonalDetailsFormNames {
- firstName = 'firstName',
- lastName = 'lastName',
- email = 'email',
-}
-interface PersonalDetailsForm {
- [PersonalDetailsFormNames.firstName]: string;
- [PersonalDetailsFormNames.lastName]: string;
- [PersonalDetailsFormNames.email]: string;
-}
-
-export default function PersonalDetails() {
- const form = useForm({
- mode: 'onChange',
- defaultValues: {
- [PersonalDetailsFormNames.firstName]: '',
- [PersonalDetailsFormNames.lastName]: '',
- [PersonalDetailsFormNames.email]: '',
- },
- });
- const { isDirty, isValid } = form.formState;
- const [formValid, setFormValid] = useState(false);
- const updateProgress = usePeopleStore((state) => state.updateProgress);
-
- useEffect(() => {
- setFormValid(isDirty && isValid);
- }, [isDirty, isValid]);
-
- // INFO: update progress in sidebar stepper
- useEffect(() => {
- if (formValid) updateProgress({ [routes.people.addNew.personalDetails]: 'completed' });
- else updateProgress({ [routes.people.addNew.personalDetails]: 'inProgress' });
- }, [formValid, updateProgress]);
-
- return (
- form={form}>
-
- Personal details
-
-
- );
-}
+export default PersonalDetails;
diff --git a/frontend/src/app/(app)/(root)/people/page.tsx b/frontend/src/app/(app)/(root)/people/page.tsx
index 24872115..5ba7e75a 100644
--- a/frontend/src/app/(app)/(root)/people/page.tsx
+++ b/frontend/src/app/(app)/(root)/people/page.tsx
@@ -5,10 +5,12 @@ import Link from 'next/link';
export default function People() {
return (
({
+ mode: 'onChange',
+ defaultValues: {
+ [PersonalDetailsFormNames.firstName]: '',
+ [PersonalDetailsFormNames.lastName]: '',
+ [PersonalDetailsFormNames.email]: '',
+ },
+ });
+ const { isDirty, isValid } = form.formState;
+ const [formValid, setFormValid] = useState(false);
+ const updateProgress = usePeopleStore((state) => state.updateProgress);
+
+ useEffect(() => {
+ setFormValid(isDirty && isValid);
+ }, [isDirty, isValid]);
+
+ // INFO: update progress in sidebar stepper
+ useEffect(() => {
+ if (formValid) updateProgress({ [routes.people.addNew.personalDetails]: 'completed' });
+ else updateProgress({ [routes.people.addNew.personalDetails]: 'inProgress' });
+ }, [formValid, updateProgress]);
+
+ return { form, formValid };
+};
diff --git a/frontend/src/components/pages/PersonalDetails/PersonalDetails.interface.ts b/frontend/src/components/pages/PersonalDetails/PersonalDetails.interface.ts
new file mode 100644
index 00000000..503ad06a
--- /dev/null
+++ b/frontend/src/components/pages/PersonalDetails/PersonalDetails.interface.ts
@@ -0,0 +1,11 @@
+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/PersonalDetails/PersonalDetails.tsx b/frontend/src/components/pages/PersonalDetails/PersonalDetails.tsx
new file mode 100644
index 00000000..86aee9a4
--- /dev/null
+++ b/frontend/src/components/pages/PersonalDetails/PersonalDetails.tsx
@@ -0,0 +1,50 @@
+'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';
+
+export const PersonalDetails = () => {
+ const { form, formValid } = usePersonalDetails();
+
+ return (
+ form={form}>
+
+ Personal details
+
+
+ );
+};
diff --git a/frontend/src/components/pages/PersonalDetails/index.ts b/frontend/src/components/pages/PersonalDetails/index.ts
new file mode 100644
index 00000000..865eb9da
--- /dev/null
+++ b/frontend/src/components/pages/PersonalDetails/index.ts
@@ -0,0 +1 @@
+export { PersonalDetails } from './PersonalDetails';
diff --git a/frontend/src/store/people/index.ts b/frontend/src/store/people/index.ts
new file mode 100644
index 00000000..f201f623
--- /dev/null
+++ b/frontend/src/store/people/index.ts
@@ -0,0 +1 @@
+export { usePeopleStore } from './store';
diff --git a/frontend/src/store/people/interfaces.ts b/frontend/src/store/people/interfaces.ts
new file mode 100644
index 00000000..54cc8f3f
--- /dev/null
+++ b/frontend/src/store/people/interfaces.ts
@@ -0,0 +1,9 @@
+import { AddNewPersonRouteKeys } from '@app/components/modules/EmployeeSideStepper';
+import { StepStates } from '@app/components/modules/SideStepper';
+
+export type Progress = Record;
+
+export interface PeopleState {
+ progress: Progress;
+ updateProgress: (newProgress: Partial
{children}
-
-
-
-
-
-
-
-
-
);
}
diff --git a/frontend/src/components/modules/EmployeeSideStepper/EmployeeSideStepper.tsx b/frontend/src/components/modules/EmployeeSideStepper/EmployeeSideStepper.tsx
index dc6ba550..4bbff74f 100644
--- a/frontend/src/components/modules/EmployeeSideStepper/EmployeeSideStepper.tsx
+++ b/frontend/src/components/modules/EmployeeSideStepper/EmployeeSideStepper.tsx
@@ -1,10 +1,10 @@
'use client';
-import { usePeopleStore } from '@app/store/peopleStore';
import { SideStepper, StepStates } from '../SideStepper';
import { useEffect, useState } from 'react';
import { usePathname } from 'next/navigation';
import { AddNewPersonRouteKeys } from './EmployeeSideStepper.interface';
import { addEmployeeInitialSteps } from './EmployeeSideStepper.const';
+import { usePeopleStore } from '@app/store/people/store';
export const EmployeeSideStepper = () => {
const progress = usePeopleStore((state) => state.progress);
diff --git a/frontend/src/components/pages/PersonalDetails/PersonalDetails.hooks.ts b/frontend/src/components/pages/PersonalDetails/PersonalDetails.hooks.ts
new file mode 100644
index 00000000..f7fcda6e
--- /dev/null
+++ b/frontend/src/components/pages/PersonalDetails/PersonalDetails.hooks.ts
@@ -0,0 +1,31 @@
+import { routes } from '@app/constants';
+import { useEffect, useState } from 'react';
+import { useForm } from 'react-hook-form';
+import { PersonalDetailsForm, PersonalDetailsFormNames } from './PersonalDetails.interface';
+import { usePeopleStore } from '@app/store/people/store';
+
+export const usePersonalDetails = () => {
+ const form = useFormPeople
- +
+
People
+ +
+
+
+
+
+
+
+
+