Skip to content

Guard staff candidate form pending fields#94

Open
Micru0 wants to merge 1 commit into
BAWES-Universe:masterfrom
Micru0:fix/staff-candidate-form-pendingfield-null
Open

Guard staff candidate form pending fields#94
Micru0 wants to merge 1 commit into
BAWES-Universe:masterfrom
Micru0:fix/staff-candidate-form-pendingfield-null

Conversation

@Micru0
Copy link
Copy Markdown

@Micru0 Micru0 commented May 18, 2026

Summary

Fixes the staff candidate update page blank/loading state when pendingField is null or missing.

Problem

The staff candidate form calls .filter() on this.model.pendingField inside candidateDetail() before initForm().

For some candidate records, pendingField can be null, causing:

TypeError: Cannot read properties of null (reading 'filter')

Because the error happens before initForm(), the form is never created and the page stays blank/loading.

Changes

  • Normalize pendingField to an empty array before filtering.
  • Keep isProfileCompleted calculation safe.
  • Add an error handler for candidate detail loading so the page does not remain stuck on skeleton/loading if the API fails.
  • Show a simple load failure alert.

What this does not change

  • No backend changes.
  • No AWS/IAM/S3 changes.
  • No env/secrets changes.
  • No production data changes.
  • No password validation changes.
  • No Civil ID upload backend changes.

Testing

  • git diff --check passed.
  • Build/lint not run locally because node_modules is not installed.

Manual test plan:

  1. Open /candidate-form/52788.
  2. Confirm the staff candidate update page loads instead of staying blank/loading.
  3. Confirm the console no longer shows Cannot read properties of null (reading 'filter').
  4. Confirm candidate detail fields render.
  5. Then test Save separately and capture the response if the password validation bug still appears.

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for candidate profile loading with user-friendly alert messages when profiles fail to load.
  • New Features

    • Enhanced profile completion status detection based on pending field validation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3e8c0490-7679-4a0d-a1a2-18168afcc617

📥 Commits

Reviewing files that changed from the base of the PR and between 39a33ff and d3d8114.

📒 Files selected for processing (1)
  • src/app/pages/logged-in/candidate/candidate-form/candidate-form.page.ts

📝 Walkthrough

Walkthrough

The candidate detail loading method is enhanced to handle both success and error paths. On success, the pendingField is safely normalized to an array, filtered to exclude 'experience', and the profile completion status is derived from that filtered result. On error, the loading state is cleared, the error is logged, and a user-facing alert is displayed.

Changes

Candidate Detail Loading with Error Handling

Layer / File(s) Summary
Candidate detail subscription with error handling and data normalization
src/app/pages/logged-in/candidate/candidate-form/candidate-form.page.ts
The candidateDetail() subscription callback normalizes model.pendingField to an array, filters out 'experience', and sets isProfileCompleted. An error callback now clears loading, logs the error, and alerts the user when the candidate profile fails to load.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A form that loads with grace and care,
Errors caught, no longer bare,
Fields aligned in tidy array,
Users know when things go astray,
Progress tracked with clarity!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly relates to the main change: normalizing the pendingField to prevent null reference errors and fixing the staff candidate form loading issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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