-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FE][CPF-65] Add employee - personal details #77
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e774cfc
feat: basic layout
r1skz3ro c65f844
feat: add react form hooks
r1skz3ro 6c12fb0
feat: error state for input
r1skz3ro 892b3e3
feat: after merge
r1skz3ro 8917050
feat: adjust layouts, group routes, categorize people components
r1skz3ro 8e78081
Merge branch 'develop' into feat/cpf-65-add-employee-layout
r1skz3ro 1b26b45
fix: remove unused exports
r1skz3ro 3bad864
feat: add global store for adding people
r1skz3ro a41044f
chore: after merge
r1skz3ro 2f006b4
feat: improve stepper and routes types
r1skz3ro 5996a62
feat: move steps to constants folder
r1skz3ro e6fdf0d
feat: add typography to add people page
r1skz3ro b8f3f36
feat: code review reafactor
r1skz3ro 6bf0d30
Merge branch 'develop' into feat/cpf-65-add-employee-layout
r1skz3ro d16f9ee
feat: move static components to utils
r1skz3ro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# hooks start from the project root directory | ||
|
||
cd frontend | ||
|
||
yarn lint:fix && yarn format | ||
yarn lint:fix | ||
yarn format | ||
yarn compile |
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
18 changes: 18 additions & 0 deletions
18
frontend/src/app/(app)/(peopleFlow)/people/add-new/layout.tsx
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,18 @@ | ||
import { EmployeeSideStepper } from '@app/components/modules/EmployeeSideStepper'; | ||
import { WorkflowTopbar } from '@app/components/modules/WorkflowTopbar'; | ||
|
||
export default function PeopleLayout({ children }: Readonly<{ children: React.ReactNode }>) { | ||
return ( | ||
<div className="flex"> | ||
<div className="w-full"> | ||
<WorkflowTopbar /> | ||
<main className="p-8"> | ||
<div className="grid grid-cols-workflow"> | ||
<EmployeeSideStepper /> | ||
<div className="col-span-1 px-8">{children}</div> | ||
</div> | ||
</main> | ||
</div> | ||
</div> | ||
); | ||
} |
3 changes: 3 additions & 0 deletions
3
frontend/src/app/(app)/(peopleFlow)/people/add-new/personal-details/page.tsx
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,3 @@ | ||
import { PersonalDetails } from '@app/components/pages/PersonalDetails/PersonalDetails'; | ||
|
||
export default PersonalDetails; |
File renamed without changes.
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,14 @@ | ||
import { Sidebar } from '@app/components/modules/Sidebar'; | ||
import { Topbar } from '@app/components/modules/Topbar'; | ||
|
||
export default function AppLayout({ children }: Readonly<{ children: React.ReactNode }>) { | ||
return ( | ||
<div className="flex"> | ||
<Sidebar /> | ||
<div className="w-full"> | ||
<Topbar /> | ||
<main className="p-8">{children}</main> | ||
</div> | ||
</div> | ||
); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,16 @@ | ||
import { Button } from '@app/components/common/Button'; | ||
import { routes } from '@app/constants'; | ||
import Link from 'next/link'; | ||
|
||
export default function People() { | ||
return ( | ||
<div> | ||
<div className="mb-6 flex items-center justify-between"> | ||
<h1 className="text-lg font-semibold leading-6 text-navy-900">People</h1> | ||
<Button> | ||
<Link href={routes.people.addNew.personalDetails}>+ Employee</Link> | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import type { Metadata } from 'next'; | ||
import { Inter } from 'next/font/google'; | ||
|
||
import './globals.css'; | ||
|
||
const inter = Inter({ subsets: ['latin'] }); | ||
|
||
export const metadata: Metadata = { | ||
title: 'CPF - Career Progression Framework', | ||
description: 'Career Progression Framework Application', | ||
}; | ||
|
||
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) { | ||
return ( | ||
<html lang="en"> | ||
<body className={`${inter.className} h-full bg-navy-50`}>{children}</body> | ||
</html> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export { Button } from './Button'; | ||
export type { StyleTypes, Variants, Props } from './Button.interface'; |
15 changes: 15 additions & 0 deletions
15
frontend/src/components/common/FormProvider/FormProvider.tsx
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,15 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { FieldValues, FormProvider as RHFFormProvider, UseFormReturn } from 'react-hook-form'; | ||
|
||
interface Props<T extends FieldValues> extends PropsWithChildren { | ||
form: UseFormReturn<T>; | ||
onSubmit?: (values: T) => void; | ||
} | ||
|
||
export const FormProvider = <T extends FieldValues>({ form, onSubmit, children }: Props<T>) => { | ||
return ( | ||
<RHFFormProvider {...form}> | ||
<form {...(onSubmit && { onSubmit: form.handleSubmit(onSubmit) })}>{children}</form> | ||
</RHFFormProvider> | ||
); | ||
}; |
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 @@ | ||
export { FormProvider } from './FormProvider'; |
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,8 @@ | ||
import { FieldValues, RegisterOptions } from 'react-hook-form'; | ||
|
||
export interface InputProps { | ||
label?: string; | ||
placeholder?: string; | ||
name: string; | ||
options?: RegisterOptions<FieldValues, string>; | ||
} |
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,43 @@ | ||
import { FC, memo } from 'react'; | ||
import { InputProps } from './Input.interface'; | ||
import { useFormContext } from 'react-hook-form'; | ||
import { generateClassNames } from '@app/utils'; | ||
import { ErrorMessage } from '@hookform/error-message'; | ||
import { CheckMarkIcon } from '@app/static/icons/AlertTriangleIcon'; | ||
|
||
export const Input: FC<InputProps> = memo(({ label, name, placeholder, options = {}, ...otherProps }) => { | ||
const { formState, register, getFieldState } = useFormContext(); | ||
const error = getFieldState(name).error; | ||
|
||
return ( | ||
<div className="flex flex-col gap-y-3"> | ||
{label && ( | ||
<label className="text-navy-900" htmlFor={`input-${name}`}> | ||
{label} | ||
</label> | ||
)} | ||
<input | ||
className={generateClassNames( | ||
'outline-black h-12 w-full rounded-xl border border-navy-200 px-4 outline-none focus:border-navy-700', | ||
{ 'border-red-600 focus:border-red-600': !!error }, | ||
)} | ||
placeholder={placeholder} | ||
id={`input-${name}`} | ||
{...register(name, options)} | ||
{...otherProps} | ||
/> | ||
<ErrorMessage | ||
errors={formState.errors} | ||
name={name} | ||
render={({ message }) => ( | ||
<div className="flex items-center gap-x-2"> | ||
<CheckMarkIcon /> | ||
<div className="text-sm text-red-600 first-letter:uppercase">{message}</div> | ||
</div> | ||
)} | ||
/> | ||
</div> | ||
); | ||
}); | ||
|
||
Input.displayName = 'Input'; |
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,2 @@ | ||
export { Input } from './Input'; | ||
export type { InputProps } from './Input.interface'; |
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
8 changes: 8 additions & 0 deletions
8
frontend/src/components/modules/EmployeeSideStepper/EmployeeSideStepper.const.ts
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,8 @@ | ||
import { routes } from '@app/constants'; | ||
import { Step } from '../SideStepper'; | ||
import { AddNewPersonRouteKeys } from './EmployeeSideStepper.interface'; | ||
|
||
export const addEmployeeInitialSteps: Step<AddNewPersonRouteKeys>[] = [ | ||
{ label: '1. Personal details', state: 'notStarted', current: true, href: routes.people.addNew.personalDetails }, | ||
{ label: '2. Main ladder', state: 'notStarted', current: false, href: routes.people.addNew.mainLadder }, | ||
]; |
4 changes: 4 additions & 0 deletions
4
frontend/src/components/modules/EmployeeSideStepper/EmployeeSideStepper.interface.tsx
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,4 @@ | ||
import { routes } from '@app/constants'; | ||
|
||
type AddNewPersonRoutes = typeof routes.people.addNew; | ||
export type AddNewPersonRouteKeys = AddNewPersonRoutes[keyof AddNewPersonRoutes]; |
30 changes: 30 additions & 0 deletions
30
frontend/src/components/modules/EmployeeSideStepper/EmployeeSideStepper.tsx
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,30 @@ | ||
'use client'; | ||
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); | ||
const pathname = usePathname(); | ||
const [addEmployeeSteps, setAddEmployeeSteps] = useState(addEmployeeInitialSteps); | ||
|
||
// INFO: If current step is not 'completed', then set 'inProgress' state to the current path | ||
useEffect(() => { | ||
setAddEmployeeSteps((prevState) => | ||
prevState.map((step) => { | ||
const state: StepStates = | ||
progress[step.href] !== 'completed' && pathname.endsWith(step.href) ? 'inProgress' : progress[step.href]; | ||
|
||
return { | ||
...step, | ||
state: state, | ||
}; | ||
}), | ||
); | ||
}, [pathname, progress]); | ||
|
||
return <SideStepper<AddNewPersonRouteKeys> steps={addEmployeeSteps} />; | ||
}; |
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,2 @@ | ||
export { EmployeeSideStepper } from './EmployeeSideStepper'; | ||
export type { AddNewPersonRouteKeys } from './EmployeeSideStepper.interface'; |
12 changes: 12 additions & 0 deletions
12
frontend/src/components/modules/SideStepper/SideStepper.interface.ts
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,12 @@ | ||
export type StepStates = 'completed' | 'inProgress' | 'notStarted'; | ||
|
||
export interface Step<T> { | ||
label: string; | ||
state: StepStates; | ||
current: boolean; | ||
href: T; | ||
} | ||
|
||
export interface SideStepperProps<T> { | ||
steps: Step<T>[]; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some props for the icon at the beginning/end of the field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add input styles from Figma styleguide in the next PR. I didn't want to make this PR too big with all the extras.