Skip to content

feat(gp): PayrollAdminOnboarding flow — mutations, schemas, and step components (PBYR-4044)#1142

Open
hamzaremote wants to merge 4 commits into
mainfrom
feat/gp-admin-onboarding-flow
Open

feat(gp): PayrollAdminOnboarding flow — mutations, schemas, and step components (PBYR-4044)#1142
hamzaremote wants to merge 4 commits into
mainfrom
feat/gp-admin-onboarding-flow

Conversation

@hamzaremote

@hamzaremote hamzaremote commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Completes the PayrollAdminOnboarding flow skeleton that was scaffolded in an earlier PR. The scaffold had step state and a render-prop container but no mutations, no schema loading, and no step components — this PR adds all of that.

Part of the GP payroll split plan (GP_PAYROLL_SPLIT_PLAN.md). Stacks on #1134.

What's added:

  • api.ts — React Query hooks for the four admin API calls: useGPFormSchema (schema per step), useGPCreateEmployment, useGPUpdateContractDetails, useGPUpdateAdministrativeDetails, useGPInviteEmployee
  • hooks.tsx — mutations wired into onSubmit, one schema query per step gated by enabled: currentStep === X (lazy, never fetches ahead), refetchSteps() called after each successful submit
  • components/SelectCountryStep, ContractDetailsStep, AdministrativeDetailsStep, InvitationStep, PayrollAdminForm, SubmitButton, BackButton, useStepSubmitHandler
  • src/flows/types.tsGPStepCallbacks<TSuccess> shared callback type (used here and by the employee flow in the next PR)
  • src/index.tsx — exports GPAdminStepCallbacks, useGPOnboardingSteps

Note on InvitationStep: this step doesn't go through useStepSubmitHandler because there's no form — it's a single button that fires the invite mutation directly. It owns its mutation instance and calls adminBag.refetchSteps() / adminBag.next() itself.

Test plan


Note

Medium Risk
Touches employment creation and contract/admin data writes via new mutations; incorrect skip-country logic was fixed but flow state still depends on API responses and step refetch.

Overview
Completes the PayrollAdminOnboarding scaffold with end-to-end admin onboarding: country selection, JSON-schema forms per step, employment create/update APIs, and employee invite.

Adds api.ts React Query hooks for country form schemas (with optional employment_id for role-aware fields), create employment, contract/administrative updates, and invite. usePayrollAdminOnboarding now loads schemas only on the active step, validates/parses via JSF, runs the right mutation in onSubmit, stores the new employment ID after create, and refetches onboarding steps after each successful save.

New step UI: country picker + basic info, contract and administrative PayrollAdminForm steps, InvitationStep (invite mutation only), and shared SubmitButton / BackButton / useStepSubmitHandler. Render-prop types move from empty placeholders to GPStepCallbacks (also exported as GPAdminStepCallbacks). Resume behavior fix: country step is skipped only when both initial countryCode and employmentId are provided, so create employment is not skipped by mistake.

Public exports add GPAdminStepCallbacks and useGPOnboardingSteps.

Reviewed by Cursor Bugbot for commit 0de1fff. Bugbot is set up for automated code reviews on this repo. Configure here.

hamzaremote and others added 2 commits July 3, 2026 16:36
Add GPStepCallbacks<TSuccess> to src/flows/types.ts — the shared callback
prop type used by all GP step components. Replace the empty scaffold types
in PayrollAdminOnboarding/types.ts with real component signatures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
GPAdminStepCallbacks is the public callback type consumers pass to each
admin step component. useGPOnboardingSteps is the hook consumers need to
read step state in an outer company-manager context.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6c04d26. Configure here.

Comment thread src/flows/PayrollAdminOnboarding/hooks.tsx
Comment thread src/flows/PayrollAdminOnboarding/hooks.tsx
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Report

Metric Current Previous Change Status
Total (gzip) 233.8 kB 226.56 kB +7.24 kB (+3.2%) 🔴
Total (raw) 629.45 kB 612.5 kB +16.95 kB (+2.8%) 🔴
CSS (gzip) 21.45 kB 21.45 kB 0 B (0%) 🟢
CSS (raw) 110.5 kB 110.5 kB 0 B (0%) 🟢

Size Limits

  • ✅ Total gzipped: 233.8 kB / 250 kB (93.5%)
  • ✅ Total raw: 629.45 kB / 650 kB (96.8%)
  • ✅ CSS gzipped: 21.45 kB / 25 kB (85.8%)

Largest Files (Top 5)

  1. chunk-NWB4KMAG.js - 14 kB (new)
  2. styles.css - 10.73 kB (0 B (0%))
  3. index.css - 10.73 kB (0 B (0%))
  4. chunk-2NTIZXKU.js - 6.44 kB (new)
  5. index.js - 6.36 kB (+20 B (+0.3%))
View All Files (358 total)
File Size (gzip) Change
chunk-NWB4KMAG.js 14 kB new
styles.css 10.73 kB 0 B (0%)
index.css 10.73 kB 0 B (0%)
chunk-2NTIZXKU.js 6.44 kB new
index.js 6.36 kB +20 B (+0.3%)
chunk-IE2PYWA5.js 6.14 kB new
chunk-CVTN3CGW.js 4.84 kB new
chunk-AVP4GGDI.js 4.77 kB new
chunk-X2UCKJED.js 4.74 kB new
chunk-LHSHHI6C.js 3.89 kB new

✅ Bundle size check passed

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📊 Coverage Report

⚠️ Coverage decreased

Metric Current Previous Change Status
Lines 85.73% 88.45% -2.72% 🔴
Statements 85.17% 87.86% -2.69% 🔴
Functions 82.89% 84.83% -1.94% 🔴
Branches 77.82% 79.83% -2.01% 🔴

Detailed Breakdown

Lines Coverage
  • Covered: 3882 / 4528
  • Coverage: 85.73%
  • Change: -2.72% (0 lines)
Statements Coverage
  • Covered: 3944 / 4631
  • Coverage: 85.17%
  • Change: -2.69% (0 statements)
Functions Coverage
  • Covered: 1051 / 1268
  • Coverage: 82.89%
  • Change: -1.94% (0 functions)
Branches Coverage
  • Covered: 2438 / 3133
  • Coverage: 77.82%
  • Change: -2.01% (0 branches)

✅ Coverage check passed

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Deploy preview for adp-cost-calculator ready!

Project:adp-cost-calculator
Status: ✅  Deploy successful!
Preview URL:https://adp-cost-calculator-6wfuxt3d2-remotecom.vercel.app
Latest Commit:0de1fff

Deployed with vercel-action

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Deploy preview for remote-flows ready!

Project:remote-flows
Status: ✅  Deploy successful!
Preview URL:https://remote-flows-eevzmkikd-remotecom.vercel.app
Latest Commit:0de1fff

Deployed with vercel-action

hamzaremote and others added 2 commits July 3, 2026 16:51
Two bugs flagged in review:

1. onSubmit guards returned undefined on failure (missing countryCode,
   missing employmentId, or no id in the create-employment response).
   useStepSubmitHandler treated undefined as success and called next(),
   advancing the wizard with no API write. Guards now throw so the catch
   block handles them correctly.

2. skipCountry only required initialCountryCode, so a pre-filled country
   with no initialEmploymentId would hide the select_country step (the
   only place createEmployment runs) and leave the flow with no
   employmentId for contract_details and beyond. skipCountry now requires
   both initialCountryCode and initialEmploymentId — meaning "skip" is
   only valid when resuming an existing employment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant