feat: extract Deductions card from DashboardFlow into standalone management block#2008
Draft
serikjensen wants to merge 1 commit into
Draft
Conversation
…gement block Migrates the Deductions card on the Dashboard's Job & Pay tab into a card-as-block following the pattern documented in .claude/skills/migrate-dashboard-card-to-block. Adds four standalone-consumable surfaces: - `EmployeeManagement.Deductions` — orchestrated block (card + add/edit form + success-alert chrome), wired via a local robot3 state machine. - `EmployeeManagement.DeductionsCard` — self-fetching standalone card that emits scoped `EMPLOYEE_DEDUCTION_MANAGEMENT_*` events. - `EmployeeManagement.DeductionsEditForm` — standalone add/edit form that adapts the shared onboarding `DeductionsForm` and emits scoped events on save/cancel. - `useDeductionsList` (existing) — already returns the `BaseHookReady` shape; now consumed directly by the card and the edit form. Dashboard integration: - `dashboardStateMachine` and `DashboardComponents` retargeted to the scoped `EMPLOYEE_DEDUCTION_MANAGEMENT_*` events; the dashboard's Job & Pay view now renders `<DeductionsCard />` inline and routes to `<DeductionsEditForm />` via the renamed `editDeduction` state. - Card chrome strings and success-alert labels relocated from `Employee.Dashboard:jobAndPay.deductions.*` into the new `Employee.Deductions.Management.json` namespace; alert labels duplicated into `Employee.Dashboard.json` so dashboard chrome still renders the toast above the tabs. Testing: - `DeductionsCard.test.tsx` — card-in-isolation contract (loading, ready, empty, scoped event emission for add/edit/delete). - `Deductions.test.tsx` — block integration (card↔edit transitions, cancel, delete + alert dismissal). - `Dashboard.test.tsx` — existing assertions retargeted to the scoped event names; all other dashboard coverage retained. Dev app: `npx tsx sdk-app/scripts/analyze-component-props.ts` re-run; the registry now surfaces `EmployeeManagement.Deductions`, `EmployeeManagement.DeductionsCard`, and `EmployeeManagement.DeductionsEditForm` under the Employee Management sidebar section. Docs: partner-facing entry added to `docs/workflows-overview/employee-management/employee-management.md` covering the block, the per-piece composition pattern, props, and the full scoped event surface. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Migrates the Deductions card off
DashboardFlow's monolithic state machine and into a standaloneEmployeeManagement.Deductionsblock underDeductions/management/, following the canonical pattern set byPaymentMethod/management/and the per-card skill at.claude/skills/migrate-dashboard-card-to-block. After this PR a partner can drop in any of three pieces independently — the block, the card, or the edit form — and the dashboard composes the card + edit form pieces directly (the block is the partner convenience, not whatDashboardFlowimports).This PR is stacked on top of #1995 (the precursor PR that relocated the existing top-level Deductions onboarding flow into
Deductions/onboarding/to free upDeductions/management/). Merge #1995 first, then re-target this PR's base tomain.What changed
Deductions/management/DeductionsCard/DeductionsCard.tsx(+ test, + index) — self-fetches via the existinguseDeductionsList, owns its own delete-confirm dialog, emits scoped card events. Replaces the inline markupJobAndPayViewhad for the Deductions section.DeductionsEditForm.tsx— thin per-flow wrapper around the sharedDeductionsFormfromonboarding/. Looks up the row to edit by id, translates the form'sonSaved/onCancelcallbacks into scoped management events.Deductions.tsx+deductionsStateMachine.ts+DeductionsComponents.tsx— robot3-based orchestrator that swaps card ↔ edit form in-place inside the sameBox, renders the success alert above the card viaDeductionsCardContextual.Deductions.test.tsx(block integration),DeductionsCard/DeductionsCard.test.tsx(card-in-isolation).management/index.tsexports all three pieces;Employee/exports/employeeManagement.tsre-exports them underEmployeeManagement.{Deductions,DeductionsCard,DeductionsEditForm}.DeleteDeductionDialogis now presentational.title/description/confirmLabel/cancelLabelare props, supplied per-consumer from their own namespace. Matches the same decoupling ruleDeleteBankAccountDialogjust adopted — partner overrides on one flow's namespace don't leak into another.JobAndPayViewnow renders<DeductionsCard employeeId={…} onEvent={onEvent} />directly;dashboardStateMachinelistens for the scoped card events and routes itseditDeductionsub-state to<DeductionsEditFormContextual>. The dashboard chrome'sdeductionAdded/deductionUpdated/deductionDeletedalerts continue to render at the page level via the existingreturnToIndexWithAlert(…)pattern — same event drives both the block-level alert and the dashboard-level alert.Employee.Management.Deductions. Card chrome, list columns, empty state, delete-dialog copy, row CTAs (editCta/deleteCta/hamburgerTitle), and success-alert labels all live here. The card and block read from this namespace and only this namespace. Dashboard-side alert keys stay inEmployee.Dashboard(duplicated — intentional per the skill).EMPLOYEE_MANAGEMENT_DEDUCTIONS_*(reads as "management event for deductions"), split per-component (_CARD_*vs_EDIT_FORM_*).Employee.Management.Deductions.json(prefix-style), not the older suffix-styleEmployee.Deductions.Management.json.DeductionsCardContextual(mirrors the wrapped component name) instead of the unqualifiedCardContextual.BaseBoundariescomponentNameisEmployee.Management.Deductions.withPadding={false}+<DataView isWithinBox />so the table runs flush with the box edges, matching Compensation / Paystubs.Scoped event surface
EMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_ADD_REQUESTEDDeductionsCardAdd deduction buttonEMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_EDIT_REQUESTEDDeductionsCardrow Edit menu itemEMPLOYEE_MANAGEMENT_DEDUCTIONS_CARD_DELETEDDeductionsCarddelete-dialog confirmEMPLOYEE_MANAGEMENT_DEDUCTIONS_EDIT_FORM_CREATEDDeductionsEditFormsave in add modeEMPLOYEE_MANAGEMENT_DEDUCTIONS_EDIT_FORM_UPDATEDDeductionsEditFormsave in edit modeEMPLOYEE_MANAGEMENT_DEDUCTIONS_EDIT_FORM_CANCELLEDDeductionsEditFormcancelEMPLOYEE_MANAGEMENT_DEDUCTIONS_ALERT_DISMISSEDThe pre-existing un-scoped
componentEvents.EMPLOYEE_DEDUCTION_*constants used byuseDeductionForm/useDeductionsListare unchanged — those continue to fire from the underlying form/list hooks for any partner already listening to them.Test plan
npm run test -- --run— 2999 passed, 1 expected fail (no regressions vs. pre-rebase baseline)npm run lint:check— 0 errors (26 pre-existing warnings unrelated)npm run format:check— cleannpm run tsc— cleanmanagement/Deductions.test.tsx) covers card ↔ edit transitions, cancel, soft-delete via PUT, and alert dismissalmanagement/DeductionsCard/DeductionsCard.test.tsx) covers empty / ready branches and event emission for each CTADashboard.test.tsx) updated to assert the new scoped event namesEmployeeManagement.{Deductions,DeductionsCard,DeductionsEditForm}show up under "Employee Management"docs/workflows-overview/employee-management/employee-management.mdwith composition exampleMade with Cursor