Skip to content
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

fix(citizenship): error indexing child #17106

Merged
merged 8 commits into from
Dec 4, 2024
Merged

Conversation

berglindoma13
Copy link
Member

@berglindoma13 berglindoma13 commented Dec 2, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of custody children data to ensure it is always an array, reducing the risk of runtime errors.
    • Enhanced data access patterns to streamline operations when accessing child information.
    • Refined error handling in application submission to ensure safe data access and default values.
  • New Features
    • Updated passport data handling to filter out null entries, ensuring only valid passport information is processed.
    • Enhanced logic for displaying child names based on available data, improving accuracy in the user interface.
    • Streamlined retrieval of custody child information for better control flow in forms.
    • Simplified presentation of country options in the passport section by removing sorting logic.

@berglindoma13 berglindoma13 added the automerge Merge this PR as soon as all checks pass label Dec 2, 2024
@berglindoma13 berglindoma13 requested a review from a team as a code owner December 2, 2024 14:55
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Project coverage is 35.71%. Comparing base (4a229a4) to head (6883979).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...-of-immigration/citizenship/citizenship.service.ts 0.00% 9 Missing ⚠️
...-immigration/citizenship/src/utils/childrenInfo.ts 0.00% 5 Missing ⚠️
...ration/citizenship/src/utils/selectedIndividual.ts 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #17106      +/-   ##
==========================================
- Coverage   35.72%   35.71%   -0.01%     
==========================================
  Files        6920     6920              
  Lines      147485   147498      +13     
  Branches    41987    42001      +14     
==========================================
  Hits        52686    52686              
- Misses      94799    94812      +13     
Flag Coverage Δ
api 3.34% <ø> (ø)
application-system-api 38.76% <0.00%> (-0.02%) ⬇️
application-template-api-modules 27.77% <0.00%> (+<0.01%) ⬆️
application-ui-shell 22.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...e-of-immigration/citizenship/src/lib/dataSchema.ts 21.64% <ø> (ø)
...ration/citizenship/src/utils/selectedIndividual.ts 25.00% <0.00%> (-2.78%) ⬇️
...-immigration/citizenship/src/utils/childrenInfo.ts 14.81% <0.00%> (-1.86%) ⬇️
...-of-immigration/citizenship/citizenship.service.ts 8.64% <0.00%> (-0.40%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4a229a4...6883979. Read the comment docs.

Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

The changes involve modifications across several components related to the handling of child information within the citizenship application process. Key updates include enhancements to the getSelectedCustodyChild function to ensure it always initializes custodyChildren as an array, improved error handling in the CitizenshipService for applicant passport data, and refinements in the ChildrenPassportReview and DocumentReview components to utilize optional chaining for safer property access. Additionally, the management of child names and the rendering of form fields have been adjusted for better data handling and clarity.

Changes

File Change Summary
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts Modified getSelectedCustodyChild to initialize custodyChildren to an empty array if undefined and refined child access logic.
libs/application/template-api-modules/src/lib/modules/templates/directorate-of-immigration/citizenship/citizenship.service.ts Enhanced handling of applicant passport data by filtering null entries and improving error handling in submitApplication.
libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/ChildrenPassportReview.tsx Updated ChildrenPassportReview to use optional chaining for accessing nationalId, ensuring safer property access.
libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/DocumentReview.tsx Added optional chaining to the mapping of passportFiles.attachment to enhance error handling.
libs/application/templates/directorate-of-immigration/citizenship/src/fields/SelectChildren/index.tsx Modified label construction logic for children in childrenCheckboxes to improve accuracy based on available names.
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenSupportingDocuments/ChildrenOtherDocumentsSubSection.ts Imported getSelectedCustodyChild and updated logic for national ID and written consent fields to enhance control flow.
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenPassportSubSection.ts Replaced buildCustomField with buildHiddenInput to streamline handling of national ID linked to custody child.
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/SupportingDocumentsSection/PassportSubSection.ts Removed sorting logic for country options in countryOfIssuerId select field, simplifying the dropdown presentation.
libs/application/templates/directorate-of-immigration/citizenship/src/lib/dataSchema.ts Changed childrenPassport field type to allow nullable entries in CitizenshipSchema.
libs/application/templates/directorate-of-immigration/citizenship/src/utils/selectedIndividual.ts Updated getSelectedIndividualName logic to conditionally return names based on availability, enhancing flexibility.

Possibly related PRs

Suggested reviewers

  • sigruntg
  • Toti91
  • johannaagma

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4bc8665 and 6883979.

📒 Files selected for processing (2)
  • libs/application/templates/directorate-of-immigration/citizenship/src/fields/SelectChildren/index.tsx (1 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/utils/selectedIndividual.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • libs/application/templates/directorate-of-immigration/citizenship/src/utils/selectedIndividual.ts
  • libs/application/templates/directorate-of-immigration/citizenship/src/fields/SelectChildren/index.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 2, 2024

Datadog Report

All test runs df15564 🔗

4 Total Test Services: 0 Failed, 4 Passed
➡️ Test Sessions change in coverage: 8 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 3.27s 1 no change Link
application-system-api 0 0 0 46 0 2m 37.65s 1 no change Link
application-template-api-modules 0 0 0 118 0 2m 37.31s 1 no change Link
application-ui-shell 0 0 0 74 0 36.53s 1 no change Link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (1)

Line range hint 53-65: Consider enhancing type safety and reusability.

While the function handles both lookup by nationalId and index, it could benefit from:

  1. A more explicit return type instead of using undefined
  2. A custom type guard for better type narrowing

Consider this enhancement:

type CustodyChildResult = {
  child: ApplicantChildCustodyInformation | null;
  isSelected: boolean;
};

function getSelectedCustodyChild(
  externalData: ExternalData,
  answers: FormValue,
  index: number,
  childNationalId?: string,
): CustodyChildResult {
  const custodyChildren = getValueViaPath(
    externalData,
    'childrenCustodyInformation.data',
    [],
  ) as ApplicantChildCustodyInformation[];

  const childInfo = childNationalId
    ? custodyChildren.find((x) => x.nationalId === childNationalId)
    : (index < custodyChildren.length ? custodyChildren[index] : null);

  const selectedChildren = (answers as Citizenship).selectedChildren;
  const isSelected = selectedChildren?.includes(childNationalId ?? childInfo?.nationalId ?? '');

  return {
    child: childInfo ?? null,
    isSelected,
  };
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d8e5cd2 and d15499a.

📒 Files selected for processing (1)
  • libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (2)
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (2)

53-54: LGTM! Improved array initialization.

The explicit empty array initialization ensures type safety and prevents undefined access issues.


Line range hint 53-65: Verify function usage across the codebase.

Let's ensure all consumers of this function handle both the index and nationalId cases correctly.

✅ Verification successful

Function usage is consistent with both index and nationalId parameters

Based on the verification results, all consumers of getSelectedCustodyChild are correctly handling both the index and nationalId cases:

  • In selectedIndividual.ts, the function is called with sectionIndex parameter, which aligns with the index-based lookup
  • In SelectedChildrenExtra/index.tsx, it's called with both index and child parameters, supporting both lookup methods
  • No test files were found that need updates
  • The function is used consistently across all its implementations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for all usages of getSelectedCustodyChild
rg "getSelectedCustodyChild" --type typescript -B 2 -A 2

# Look for potential test files
fd "childrenInfo.spec.ts|childrenInfo.test.ts"

Length of output: 140


Script:

#!/bin/bash
# Search for all usages of getSelectedCustodyChild using ripgrep without file type filter
rg "getSelectedCustodyChild" -B 2 -A 2

# Look for test files using a more generic pattern
fd "childrenInfo" | grep -E "\.(spec|test)\.(ts|tsx|js|jsx)$"

# Find all TypeScript files that might reference this function
fd "\.(ts|tsx)$" | xargs rg "getSelectedCustodyChild"

Length of output: 11796


Script:

#!/bin/bash
# Let's examine the implementation of the functions that use getSelectedCustodyChild
ast-grep --pattern 'const selectedChild = getSelectedCustodyChild($$$)'

# Let's also check the implementation of the component that uses it
ast-grep --pattern 'const childCustodyData = getSelectedCustodyChild($$$)'

# And check how the index parameter is passed in these calls
rg "getSelectedCustodyChild.*index" -B 2 -A 2

Length of output: 2824

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (6)
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/SupportingDocumentsSection/PassportSubSection.ts (1)

Line range hint 1-190: Consider enhancing type safety

While the code follows TypeScript patterns, there are opportunities to improve type safety:

  1. The form field builder functions could benefit from stricter typing for their configuration objects
  2. The external data paths could be typed to prevent runtime errors

Consider creating a type-safe accessor for external data paths:

type ExternalDataPaths = {
  'individual.data': NationalRegistryIndividual;
  'applicantInformation.data.currentPassportItem': TravelDocumentViewModel;
  'travelDocumentTypes.data': OptionSetItem[];
  'countries.data': OptionSetItem[];
};

function getTypedValueViaPath<T extends keyof ExternalDataPaths>(
  data: unknown,
  path: T,
  defaultValue: ExternalDataPaths[T]
): ExternalDataPaths[T] {
  return getValueViaPath(data, path, defaultValue) as ExternalDataPaths[T];
}
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (1)

63-64: Improve code readability with optional chaining

The current implementation can be simplified using optional chaining.

Apply this diff to improve readability:

-    selectedChildren &&
-    selectedChildren.find((sc) => sc === childInfo?.nationalId)
+    selectedChildren?.find((sc) => sc === childInfo?.nationalId)
🧰 Tools
🪛 Biome (1.9.4)

[error] 63-64: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenSupportingDocuments/ChildrenPassportSubSection.ts (1)

51-61: LGTM! Consider adding error handling documentation

The switch to buildHiddenInput and use of getSelectedCustodyChild improves the robustness of nationalId handling. The implementation correctly handles potential undefined values through the optional chaining operator.

Consider adding a code comment explaining the error handling behavior when no custody child is found, to help future maintainers understand the expected undefined return value.

libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/DocumentReview.tsx (1)

Line range hint 1-150: Consider refactoring document rendering logic

The component has multiple nested conditional renderings and repeated patterns for handling different document types. This could be simplified to improve maintainability.

Consider:

  1. Creating a reusable document rendering component
  2. Extracting document type mapping logic
  3. Using a configuration object for document types

Example approach:

interface DocumentConfig {
  key: keyof Citizenship['supportingDocuments'];
  getFiles: (doc: any) => Array<{name: string}>;
}

const documentConfigs: DocumentConfig[] = [
  {
    key: 'birthCertificate',
    getFiles: (doc) => doc?.birthCertificate || [],
  },
  // ... other document types
];

// Reusable component
const DocumentList: FC<{documents: DocumentConfig[], data: any}> = ({
  documents,
  data,
}) => (
  <>
    {documents.map(({key, getFiles}) => 
      getFiles(data).map(file => <Text>{file.name}</Text>)
    )}
  </>
);
🧰 Tools
🪛 Biome (1.9.4)

[error] 113-113: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

libs/application/template-api-modules/src/lib/modules/templates/directorate-of-immigration/citizenship/citizenship.service.ts (2)

286-286: Consider using Array.prototype.filter with type predicate.

The current filtering can be improved for better type inference.

- const nonNullPassports = answers.childrenPassport?.filter((x) => !!x)
+ const nonNullPassports = answers.childrenPassport?.filter((x): x is NonNullable<typeof x> => !!x)

396-403: Improve null handling in passport mapping.

While the null coalescing operators provide safety, the code can be more concise using object destructuring with defaults.

- nonNullPassports?.map(async (p) => ({
-   nationalId: p?.nationalId ?? '',
-   dateOfIssue: new Date(p?.publishDate ?? ''),
-   dateOfExpiry: new Date(p?.expirationDate ?? ''),
-   passportNumber: p?.passportNumber ?? '',
-   passportTypeId: parseInt(p?.passportTypeId ?? ''),
-   countryIdOfIssuer: p?.countryOfIssuerId ?? '',
-   file: await this.getUrlForAttachment(application, p?.attachment),
+ nonNullPassports?.map(async ({
+   nationalId = '',
+   publishDate = '',
+   expirationDate = '',
+   passportNumber = '',
+   passportTypeId = '',
+   countryOfIssuerId = '',
+   attachment
+ }) => ({
+   nationalId,
+   dateOfIssue: new Date(publishDate),
+   dateOfExpiry: new Date(expirationDate),
+   passportNumber,
+   passportTypeId: parseInt(passportTypeId),
+   countryIdOfIssuer: countryOfIssuerId,
+   file: await this.getUrlForAttachment(application, attachment),
})) || [],
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d15499a and 4bc8665.

📒 Files selected for processing (10)
  • libs/application/template-api-modules/src/lib/modules/templates/directorate-of-immigration/citizenship/citizenship.service.ts (2 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/ChildrenPassportReview.tsx (1 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/DocumentReview.tsx (1 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/fields/SelectChildren/index.tsx (1 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenSupportingDocuments/ChildrenOtherDocumentsSubSection.ts (2 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenSupportingDocuments/ChildrenPassportSubSection.ts (2 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/SupportingDocumentsSection/PassportSubSection.ts (1 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/lib/dataSchema.ts (1 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (1 hunks)
  • libs/application/templates/directorate-of-immigration/citizenship/src/utils/selectedIndividual.ts (1 hunks)
👮 Files not reviewed due to content moderation or server errors (1)
  • libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenSupportingDocuments/ChildrenOtherDocumentsSubSection.ts
🧰 Additional context used
📓 Path-based instructions (10)
libs/application/templates/directorate-of-immigration/citizenship/src/lib/dataSchema.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/SupportingDocumentsSection/PassportSubSection.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/ChildrenPassportReview.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/DocumentReview.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenSupportingDocuments/ChildrenOtherDocumentsSubSection.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/fields/SelectChildren/index.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/utils/selectedIndividual.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/template-api-modules/src/lib/modules/templates/directorate-of-immigration/citizenship/citizenship.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/ChildrenSupportingDocuments/ChildrenPassportSubSection.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🪛 Biome (1.9.4)
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts

[error] 63-64: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (5)
libs/application/templates/directorate-of-immigration/citizenship/src/utils/childrenInfo.ts (2)

53-54: LGTM! Improved array initialization

The default empty array initialization prevents undefined errors and improves code robustness.


58-60: LGTM! Added array bounds checking

Proper array bounds checking prevents potential undefined behavior when accessing array elements.

libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/ChildrenPassportReview.tsx (1)

43-43: LGTM! Added safe property access

The addition of optional chaining for accessing nationalId prevents potential runtime errors and aligns with best practices for TypeScript/JavaScript property access.

libs/application/templates/directorate-of-immigration/citizenship/src/fields/Review/DocumentReview.tsx (1)

112-112: LGTM! Null safety improvement

The addition of optional chaining operator prevents potential runtime errors when handling passport attachments.

libs/application/templates/directorate-of-immigration/citizenship/src/lib/dataSchema.ts (1)

350-350: LGTM: Schema change aligns with service implementation.

The modification to allow nullable elements in the childrenPassport array improves type safety and matches the filtering logic in the service.

@kodiakhq kodiakhq bot merged commit be2291a into main Dec 4, 2024
34 checks passed
@kodiakhq kodiakhq bot deleted the fix/citizenship-child-indexing branch December 4, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants