Skip to content

Commit e8ffd62

Browse files
committed
fix: fix payroll breadcrumbs and align with design
1 parent 18b282b commit e8ffd62

File tree

10 files changed

+190
-22
lines changed

10 files changed

+190
-22
lines changed

src/components/Payroll/PayrollFlow/payrollStateMachine.ts

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const payrollFlowBreadcrumbsNodes: BreadcrumbNodes = {
4848
parent: null,
4949
item: {
5050
id: 'landing',
51-
label: 'labels.breadcrumbLabel',
51+
label: 'breadcrumbs.landing',
5252
namespace: 'Payroll.PayrollLanding',
5353
onNavigate: ((ctx: PayrollFlowContextInterface) => ({
5454
...ctx,
@@ -90,6 +90,14 @@ export const payrollFlowBreadcrumbsNodes: BreadcrumbNodes = {
9090
})) as (context: unknown) => unknown,
9191
},
9292
},
93+
submittedOverview: {
94+
parent: 'landing',
95+
item: {
96+
id: 'submittedOverview',
97+
label: 'breadcrumbs.overview',
98+
namespace: 'Payroll.PayrollLanding',
99+
},
100+
},
93101
editEmployee: {
94102
parent: 'configuration',
95103
item: {
@@ -106,6 +114,14 @@ export const payrollFlowBreadcrumbsNodes: BreadcrumbNodes = {
106114
namespace: 'Payroll.PayrollReceipts',
107115
},
108116
},
117+
submittedReceipts: {
118+
parent: 'landing',
119+
item: {
120+
id: 'submittedReceipts',
121+
label: 'breadcrumbs.receipt',
122+
namespace: 'Payroll.PayrollLanding',
123+
},
124+
},
109125
blockers: {
110126
parent: 'landing',
111127
item: {
@@ -300,7 +316,23 @@ export const payrollMachine = {
300316
},
301317
),
302318
),
303-
319+
transition(
320+
componentEvents.RUN_PAYROLL_PROCESSED,
321+
'submittedOverview',
322+
reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => {
323+
return {
324+
...updateBreadcrumbs('submittedOverview', ctx, {
325+
startDate: ctx.payPeriod?.startDate ?? '',
326+
endDate: ctx.payPeriod?.endDate ?? '',
327+
}),
328+
component: PayrollOverviewContextual,
329+
ctaConfig: {
330+
labelKey: 'exitFlowCta',
331+
namespace: 'Payroll.PayrollOverview',
332+
},
333+
}
334+
}),
335+
),
304336
transition(
305337
componentEvents.RUN_PAYROLL_RECEIPT_GET,
306338
'receipts',
@@ -330,6 +362,45 @@ export const payrollMachine = {
330362
),
331363
exitFlowTransition,
332364
),
365+
submittedOverview: state<MachineTransition>(
366+
breadcrumbNavigateTransition('landing'),
367+
transition(
368+
componentEvents.RUN_PAYROLL_RECEIPT_GET,
369+
'submittedReceipts',
370+
reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => {
371+
return {
372+
...updateBreadcrumbs('submittedReceipts', ctx, {
373+
startDate: ctx.payPeriod?.startDate ?? '',
374+
endDate: ctx.payPeriod?.endDate ?? '',
375+
}),
376+
component: PayrollReceiptsContextual,
377+
progressBarType: 'breadcrumbs',
378+
alerts: undefined,
379+
ctaConfig: {
380+
labelKey: 'exitFlowCta',
381+
namespace: 'Payroll.PayrollReceipts',
382+
},
383+
}
384+
}),
385+
),
386+
transition(
387+
componentEvents.RUN_PAYROLL_CANCELLED,
388+
'landing',
389+
reduce(
390+
createReducer({
391+
component: PayrollLandingContextual,
392+
progressBarType: null,
393+
alerts: undefined,
394+
currentBreadcrumbId: 'landing',
395+
}),
396+
),
397+
),
398+
exitFlowTransition,
399+
),
400+
submittedReceipts: state<MachineTransition>(
401+
breadcrumbNavigateTransition('landing'),
402+
exitFlowTransition,
403+
),
333404
editEmployee: state<MachineTransition>(
334405
breadcrumbNavigateTransition('landing'),
335406
breadcrumbNavigateTransition('configuration'),

src/components/Payroll/PayrollHistory/PayrollHistory.test.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ describe('PayrollHistory', () => {
161161
// Verify the correct event was emitted
162162
expect(onEvent).toHaveBeenCalledWith(componentEvents.RUN_PAYROLL_SUMMARY_VIEWED, {
163163
payrollId: 'payroll-1',
164+
startDate: '2024-12-01',
165+
endDate: '2024-12-15',
164166
})
165167
})
166168

@@ -182,6 +184,8 @@ describe('PayrollHistory', () => {
182184

183185
expect(onEvent).toHaveBeenCalledWith(componentEvents.RUN_PAYROLL_RECEIPT_VIEWED, {
184186
payrollId: 'payroll-1',
187+
startDate: '2024-12-01',
188+
endDate: '2024-12-15',
185189
})
186190
})
187191

src/components/Payroll/PayrollHistory/PayrollHistory.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ export const Root = ({ onEvent, companyId, dictionary }: PayrollHistoryProps) =>
7777

7878
const payrollHistory = payrollsData.payrollList || []
7979

80-
const handleViewSummary = (payrollId: string) => {
81-
onEvent(componentEvents.RUN_PAYROLL_SUMMARY_VIEWED, { payrollId })
80+
const handleViewSummary = (payrollId: string, startDate?: string, endDate?: string) => {
81+
onEvent(componentEvents.RUN_PAYROLL_SUMMARY_VIEWED, { payrollId, startDate, endDate })
8282
}
8383

84-
const handleViewReceipt = (payrollId: string) => {
85-
onEvent(componentEvents.RUN_PAYROLL_RECEIPT_VIEWED, { payrollId })
84+
const handleViewReceipt = (payrollId: string, startDate?: string, endDate?: string) => {
85+
onEvent(componentEvents.RUN_PAYROLL_RECEIPT_VIEWED, { payrollId, startDate, endDate })
8686
}
8787

8888
const handleCancelPayroll = async (item: Payroll) => {

src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ interface PayrollHistoryPresentationProps {
2121
wireInRequests: WireInRequest[]
2222
selectedTimeFilter: TimeFilterOption
2323
onTimeFilterChange: (value: TimeFilterOption) => void
24-
onViewSummary: (payrollId: string) => void
25-
onViewReceipt: (payrollId: string) => void
24+
onViewSummary: (payrollId: string, startDate?: string, endDate?: string) => void
25+
onViewReceipt: (payrollId: string, startDate?: string, endDate?: string) => void
2626
onCancelPayroll: (item: Payroll) => void
2727
cancelDialogItem: Payroll | null
2828
onCancelDialogOpen: (item: Payroll) => void
@@ -140,14 +140,14 @@ export const PayrollHistoryPresentation = ({
140140
label: t('menu.viewSummary'),
141141
icon: <FileIcon aria-hidden />,
142142
onClick: () => {
143-
onViewSummary(payrollId)
143+
onViewSummary(payrollId, item.payPeriod?.startDate, item.payPeriod?.endDate)
144144
},
145145
},
146146
{
147147
label: t('menu.viewReceipt'),
148148
icon: <ReceiptIcon aria-hidden />,
149149
onClick: () => {
150-
onViewReceipt(payrollId)
150+
onViewReceipt(payrollId, item.payPeriod?.startDate, item.payPeriod?.endDate)
151151
},
152152
},
153153
]

src/components/Payroll/PayrollLanding/PayrollLanding.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ describe('PayrollLanding', () => {
222222
componentEvents.RUN_PAYROLL_SUMMARY_VIEWED,
223223
{
224224
payrollId: 'payroll-1',
225+
startDate: '2024-12-01',
226+
endDate: '2024-12-15',
225227
},
226228
)
227229
await waitFor(() => {
@@ -257,7 +259,7 @@ describe('PayrollLanding', () => {
257259
// Verify the event was emitted to parent
258260
expect(defaultProps.onEvent).toHaveBeenCalledWith(
259261
componentEvents.RUN_PAYROLL_RECEIPT_VIEWED,
260-
{ payrollId: 'payroll-1' },
262+
{ payrollId: 'payroll-1', startDate: '2024-12-01', endDate: '2024-12-15' },
261263
)
262264
})
263265
})

src/components/Payroll/PayrollLanding/PayrollLanding.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMemo } from 'react'
22
import { createMachine } from 'robot3'
33
import type { ConfirmWireDetailsComponentType } from '../ConfirmWireDetails/ConfirmWireDetails'
4-
import { payrollLandingMachine } from './payrollLandingStateMachine'
4+
import { payrollLandingMachine, payrollLandingBreadcrumbNodes } from './payrollLandingStateMachine'
55
import {
66
PayrollLandingTabsContextual,
77
type PayrollLandingFlowContextInterface,
@@ -11,6 +11,7 @@ import { Flow } from '@/components/Flow/Flow'
1111
import type { BaseComponentInterface } from '@/components/Base/Base'
1212
import { BaseComponent } from '@/components/Base/Base'
1313
import { useComponentDictionary } from '@/i18n'
14+
import { buildBreadcrumbs } from '@/helpers/breadcrumbHelpers'
1415

1516
interface PayrollLandingProps extends BaseComponentInterface<'Payroll.PayrollLanding'> {
1617
companyId: string
@@ -47,6 +48,9 @@ export function PayrollLandingFlow({
4748
selectedTab: 'run-payroll',
4849
withReimbursements,
4950
ConfirmWireDetailsComponent,
51+
breadcrumbs: buildBreadcrumbs(payrollLandingBreadcrumbNodes),
52+
currentBreadcrumbId: 'tabs',
53+
progressBarType: null,
5054
}),
5155
),
5256
[companyId, withReimbursements, ConfirmWireDetailsComponent],

src/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export interface PayrollLandingFlowContextInterface extends FlowContextInterface
3131
selectedTab?: string
3232
withReimbursements: boolean
3333
ConfirmWireDetailsComponent?: ConfirmWireDetailsComponentType
34+
startDate?: string
35+
endDate?: string
3436
}
3537

3638
export function PayrollLandingTabsContextual() {

0 commit comments

Comments
 (0)