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

feat(my-pages): add back "other" for organ donation registration #17228

Merged
merged 10 commits into from
Dec 19, 2024

Conversation

disaerna
Copy link
Member

@disaerna disaerna commented Dec 13, 2024

My pages - Health - Organ donation

What

Adding back in "other" section for compatibility with current Heilsuvera
Adding logic to display a message when user is a minor and is a "kerfiskennitala"

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

  • New Features

    • Enhanced donor information with new attributes: isMinor and isTemporaryResident.
    • Introduced new messaging for organ donation eligibility.
    • Implemented a new NoAccess component for users who do not meet donor criteria.
    • Added a new Limitations component for managing organ donation limitations.
    • Streamlined donor status retrieval with updated API endpoints.
  • Bug Fixes

    • Streamlined logic for determining donor status and limitations.
  • Chores

    • Removed outdated components and styles related to organ donation registration.

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning jest > jest-cli > jest-config > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > jest-runtime > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/reporters > [email protected]: Glob versions prior to v9 are no longer supported
warning jest > @jest/core > @jest/transform > babel-plugin-istanbul > test-exclude > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > puppeteer-core > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > tempy > del > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > [email protected]: Rimraf versions prior to v4 are no longer supported
warning storybook > @storybook/cli > jscodeshift > temp > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning storybook > @storybook/cli > jscodeshift > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/codegen > [email protected]: Glob versions prior to v9 are no longer supported
warning react-native > @react-native/community-cli-plugin > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning react-native > @react-native-community/cli > @react-native-community/cli-tools > [email protected]: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
warning react-native > @react-native/community-cli-plugin > @react-native/dev-middleware > @rnx-kit/chromium-edge-launcher > [email protected]: Rimraf versions prior to v4 are no longer supported
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-catch-binding instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-logical-assignment-operators instead.
warning react-native > @react-native/community-cli-plugin > @react-native/metro-babel-transformer > @react-native/babel-preset > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-async-generator-functions instead.
warning next-auth > [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
warning next-auth > [email protected]: this version is no longer supported
warning next-auth > @next-auth/typeorm-legacy-adapter > typeorm > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > stylus > [email protected]: Glob versions prior to v9 are no longer supported
warning @nx/next > @nx/webpack > webpack-dev-server > [email protected]: Rimraf versions prior to v4 are no longer supported
warning @nx/next > @nx/webpack > fork-ts-checker-webpack-plugin > [email protected]: this will be v4
warning @nx/next > @nx/webpack > webpack-dev-server > webpack-dev-middleware > [email protected]: this will be v4
warning workspace-aggregator-8834b4ab-df86-44b7-abb2-9e39ad95882e > [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning "@nx/eslint > @nx/js > [email protected]" has unmet peer dependency "@types/node@".
warning "@nx/next > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "styled-components > babel-plugin-styled-components > @babel/[email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning " > [email protected]" has unmet peer dependency "react-is@>= 16.8.0".
warning "@nx/react > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
warning " > [email protected]" has unmet peer dependency "@types/node@
".
warning " > [email protected]" has incorrect peer dependency "[email protected]".
warning "react-native > @react-native/[email protected]" has unmet peer dependency "@babel/preset-env@^7.1.6".
warning "react-native > @react-native/community-cli-plugin > @react-native/[email protected]" has unmet peer dependency "@babel/core@*".
warning "@vanilla-extract/next-plugin > @vanilla-extract/[email protected]" has unmet peer dependency "webpack@^4.30.0 || ^5.20.2".
warning " > [email protected]" has incorrect peer dependency "react@^16.13.1 || ^17".
warning " > [email protected]" has incorrect peer dependency "react-dom@^16.13.1 || ^17".
warning "next-auth > @next-auth/[email protected]" has unmet peer dependency "@prisma/client@^2.16.1".
warning "@nx/next > [email protected]" has unmet peer dependency "webpack@^5.1.0".

Walkthrough

This pull request introduces comprehensive changes to the organ donation feature across multiple files. The modifications focus on enhancing the donor status handling by adding new properties like isMinor and isTemporaryResident, updating the data model, API configuration, and user interface components. The changes improve the logic for determining donor eligibility, provide more detailed donor information, and refactor the existing codebase to support these new requirements.

Changes

File Path Change Summary
libs/api/domains/health-directorate/src/lib/health-directorate.service.ts Updated donor status handling with new boolean variables and simplified logic.
libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts Added new fields isMinor, isTemporaryResident, and comment to donor models.
libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json Modified API endpoint configuration and response schemas.
libs/portals/my-pages/health/src/lib/messages.ts Added new messages for minor and temporary resident organ donation restrictions.
libs/portals/my-pages/health/src/module.tsx Updated import path for OrganDonationRegistration component.
libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.css.ts Introduced new CSS styles and animations for the Organ Donation screen.
libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.graphql Modified GraphQL queries to include new fields in getDonorStatus and removed getOrgansList.
libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx Refactored logic for rendering based on donor status and introduced new NoAccess component.
libs/portals/my-pages/health/src/screens/OrganDonation/components/Limitations.tsx Added a new component for managing organ donation limitations.
libs/portals/my-pages/health/src/screens/OrganDonation/components/NoAccess.tsx Introduced a new component to handle access restrictions for minors and temporary residents.
libs/portals/my-pages/health/src/screens/OrganDonation/helpers/textMapper.ts Added a new function getOrganText for generating text based on donor status.
libs/portals/my-pages/health/src/screens/OrganDonationRegistration/Limitations.tsx Removed the old Limitations component.
libs/portals/my-pages/health/src/screens/OrganDonationRegistration/OrganDonationRegistration.css.ts Removed the old CSS file for the registration component.

Possibly related PRs

Suggested labels

automerge, deploy-feature

Suggested reviewers

  • thorkellmani
  • snaerseljan

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.

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.68%. Comparing base (075a58e) to head (28c5b53).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #17228   +/-   ##
=======================================
  Coverage   35.68%   35.68%           
=======================================
  Files        6922     6922           
  Lines      148524   148524           
  Branches    42419    42419           
=======================================
  Hits        53008    53008           
  Misses      95516    95516           
Flag Coverage Δ
api 3.33% <ø> (ø)
application-system-api 38.73% <ø> (-0.02%) ⬇️
application-template-api-modules 27.69% <ø> (+0.02%) ⬆️
application-ui-shell 22.31% <ø> (ø)
web 2.40% <ø> (ø)

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


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 075a58e...28c5b53. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Dec 13, 2024

Datadog Report

All test runs cacf4a1 🔗

5 Total Test Services: 0 Failed, 5 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.01%), 14 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 2.42s 1 no change Link
application-system-api 0 0 0 46 0 2m 13.64s 1 decreased (-0.01%) Link
application-template-api-modules 0 0 0 118 0 2m 5.33s 1 no change Link
application-ui-shell 0 0 0 74 0 31.76s 1 no change Link
web 0 0 0 84 0 25.37s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-system-api - jest 35.58% (-0.01%) - Details

@disaerna disaerna marked this pull request as ready for review December 17, 2024 12:57
@disaerna disaerna requested a review from a team as a code owner December 17, 2024 12:57
@disaerna disaerna added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Dec 17, 2024
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

🧹 Nitpick comments (12)
libs/portals/my-pages/health/src/screens/OrganDonation/components/NoAccess.tsx (1)

3-3: Define Props interface for 'NoAccess' component

To improve readability and reusability, consider defining a Props interface for the NoAccess component.

Apply this change:

+interface NoAccessProps {
+  text: string
+}
+
-export const NoAccess = ({ text }: { text: string }) => {
+export const NoAccess = ({ text }: NoAccessProps) => {
libs/portals/my-pages/health/src/screens/OrganDonation/helpers/textMapper.ts (1)

4-13: Define a TypeScript interface for 'texts' parameter

To enhance code maintainability and clarity, consider defining a TypeScript interface for the texts parameter.

Apply this change:

+interface OrganTexts {
+  iAmOrganDonorWithExceptionsText: string
+  iAmOrganDonorText: string
+  iAmNotOrganDonorText: string
+  iAmOrganDonorWithExceptions: string
+  iAmOrganDonor: string
+  iAmNotOrganDonor: string
+}
+
-export const getOrganText = (
-  isDonor: boolean,
-  hasLimitations: boolean,
-  texts: {
-    iAmOrganDonorWithExceptionsText: string
-    iAmOrganDonorText: string
-    iAmNotOrganDonorText: string
-    iAmOrganDonorWithExceptions: string
-    iAmOrganDonor: string
-    iAmNotOrganDonor: string
-  },
-  limitations: string[],
-) => {
+export const getOrganText = (
+  isDonor: boolean,
+  hasLimitations: boolean,
+  texts: OrganTexts,
+  limitations: string[],
+) => {
libs/portals/my-pages/health/src/screens/OrganDonation/components/Limitations.tsx (3)

30-31: Consider adding validation for comment state

The initial state setup looks good, but consider adding validation for the comment length and content.

 const [checked, setChecked] = useState<Array<string>>(selected ?? [])
-const [comment, setComment] = useState<string>(exceptionComment ?? '')
+const [comment, setComment] = useState<string>(exceptionComment ?? '')
+const [commentError, setCommentError] = useState<string | null>(null)
+
+const validateComment = (value: string) => {
+  if (value.length > 220) {
+    setCommentError('Comment exceeds maximum length')
+    return false
+  }
+  setCommentError(null)
+  return true
+}

67-78: Enhance accessibility for the 'other' checkbox

While the implementation is functional, consider adding aria-labels and description for better accessibility.

 <Checkbox
   id={'other'}
   name={`selected-limitations-other`}
   label={formatMessage(messages.otherPascalCase)}
   value={comment}
+  aria-label={formatMessage(messages.otherPascalCase)}
+  aria-describedby="other-limitation-description"
   onChange={(e) => {
     setComment(e.target.value)
     handleCheckboxChange('other', e.target.checked)
   }}
   checked={checked.includes('other')}
 />

92-103: Consider adding error handling for the comment input

The textarea implementation could benefit from error state display and aria-invalid attribute.

 <Input
   id="organ-donation-limitation"
   name="otherLimitatons"
   textarea
   label={formatMessage(messages.organRegistrationOtherLabel)}
   placeholder={formatMessage(
     messages.organRegistrationOtherText,
   )}
   maxLength={220}
+  error={commentError}
+  aria-invalid={!!commentError}
   onChange={(e) => setComment(e.target.value)}
   value={comment}
 />
libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx (2)

32-37: Consider extracting limitations logic to a helper function

The limitations array construction logic could be moved to a separate helper function for better maintainability.

+const getLimitationsArray = (
+  limitations?: { limitedOrgansList?: { name: string }[] | null, comment?: string | null }
+): string[] => {
+  const result = limitations?.limitedOrgansList?.map((item) => item.name) ?? []
+  if (limitations?.comment?.length) {
+    result.push(limitations.comment)
+  }
+  return result
+}
+
-const allLimitations: Array<string> =
-  donorStatus?.limitations?.limitedOrgansList?.map((item) => item.name) ?? []
-
-if (comment !== undefined && comment !== null && comment.length > 0) {
-  allLimitations.push(comment)
-}
+const allLimitations = getLimitationsArray(donorStatus?.limitations)

75-96: Consider extracting the ActionCard rendering to a separate component

The conditional rendering block for ActionCard is quite large and could be moved to a separate component for better maintainability.

+const DonorActionCard = ({ texts, loading }: { texts: ReturnType<typeof getOrganText>, loading: boolean }) => (
+  <Box>
+    <Text variant="eyebrow" color="purple400" marginBottom={1}>
+      {formatMessage(m.takeOnOrganDonation)}
+    </Text>
+    <ActionCard
+      heading={texts.heading}
+      text={texts.cardText}
+      cta={{
+        url: HealthPaths.HealthOrganDonationRegistration,
+        label: formatMessage(m.changeTake),
+        centered: true,
+        variant: 'text',
+      }}
+      loading={loading}
+    />
+  </Box>
+)
libs/api/domains/health-directorate/src/lib/health-directorate.service.ts (3)

31-34: Improve variable naming for clarity.

The boolean variables could be more descriptive to better convey their purpose.

-const hasExceptionComment: boolean =
-  data.exceptionComment !== undefined && data.exceptionComment.length > 0
-const hasExceptions: boolean =
-  data.exceptions !== undefined && data.exceptions.length > 0
+const hasValidExceptionComment: boolean =
+  data.exceptionComment !== undefined && data.exceptionComment.length > 0
+const hasValidExceptions: boolean =
+  data.exceptions !== undefined && data.exceptions.length > 0

39-41: Simplify boolean expression.

The nullish coalescing operator is unnecessary since the expression already evaluates to a boolean.

-hasLimitations:
-  ((hasExceptionComment || hasExceptions) && data.isDonor) ?? false,
+hasLimitations: (hasExceptionComment || hasExceptions) && data.isDonor,

71-72: Consider adding type safety for the filter operation.

The optional chaining and nullish coalescing are good, but type safety could be improved.

-const filteredList =
-  input.organLimitations?.filter((item) => item !== 'other') ?? []
+const filteredList =
+  input.organLimitations?.filter((item: string) => item !== 'other') ?? []
libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json (1)

71-82: Consider marking IP parameter as deprecated.

The IP parameter might be redundant as it can be obtained from the request context.

 {
   "name": "ip",
   "required": false,
   "in": "query",
+  "deprecated": true,
   "description": "The IP address of the user",
   "schema": { "type": "string" }
 }
libs/portals/my-pages/health/src/lib/messages.ts (1)

1039-1042: Consider using a consistent naming pattern.

The message ID for otherPascalCase could follow the same pattern as other message IDs.

-  id: 'sp.health:other',
+  id: 'sp.health:other-pascal-case',
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 980afb0 and 5ad2517.

📒 Files selected for processing (15)
  • libs/api/domains/health-directorate/src/lib/health-directorate.service.ts (2 hunks)
  • libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts (2 hunks)
  • libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json (7 hunks)
  • libs/portals/my-pages/health/src/lib/messages.ts (1 hunks)
  • libs/portals/my-pages/health/src/module.tsx (1 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.css.ts (1 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.graphql (1 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx (2 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/components/Limitations.tsx (1 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/components/Loader.tsx (1 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/components/NoAccess.tsx (1 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (5 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonation/helpers/textMapper.ts (1 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonationRegistration/Limitations.tsx (0 hunks)
  • libs/portals/my-pages/health/src/screens/OrganDonationRegistration/OrganDonationRegistration.css.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • libs/portals/my-pages/health/src/screens/OrganDonationRegistration/Limitations.tsx
  • libs/portals/my-pages/health/src/screens/OrganDonationRegistration/OrganDonationRegistration.css.ts
✅ Files skipped from review due to trivial changes (3)
  • libs/portals/my-pages/health/src/screens/OrganDonation/components/Loader.tsx
  • libs/portals/my-pages/health/src/module.tsx
  • libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.css.ts
🧰 Additional context used
📓 Path-based instructions (10)
libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.graphql (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/portals/my-pages/health/src/screens/OrganDonation/components/NoAccess.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/portals/my-pages/health/src/lib/messages.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/api/domains/health-directorate/src/lib/health-directorate.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/api/domains/health-directorate/src/lib/models/organ-donation.model.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/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.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/portals/my-pages/health/src/screens/OrganDonation/helpers/textMapper.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/portals/my-pages/health/src/screens/OrganDonation/components/Limitations.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/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json (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/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.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."
🔇 Additional comments (11)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (1)

32-32: Component renamed to 'OrganRegistrationForm' enhances clarity

Renaming the component to OrganRegistrationForm improves readability and clarity of the codebase.

Also applies to: 214-214

libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.graphql (1)

13-14: GraphQL query updated with new fields 'isMinor' and 'isTemporaryResident'

The addition of isMinor and isTemporaryResident fields to the donor object aligns the frontend with the updated API schema.

libs/api/domains/health-directorate/src/lib/models/organ-donation.model.ts (2)

37-41: LGTM: New donor eligibility flags properly defined

The addition of isMinor and isTemporaryResident flags with appropriate GraphQL Field decorators and default values enhances the donor validation model.


64-65: LGTM: Comment field addition supports 'other' option

The nullable comment field in DonorInput aligns with the PR objective of adding back the 'other' option for organ donation registration.

libs/portals/my-pages/health/src/screens/OrganDonation/components/Limitations.tsx (1)

17-21: LGTM: Props interface well defined

The interface clearly defines the component's contract with proper typing.

libs/portals/my-pages/health/src/screens/OrganDonation/OrganDonation.tsx (1)

27-28: LGTM: Clear status flags extraction

The extraction of isMinor and isTemporaryResident flags is clean and follows TypeScript best practices.

libs/api/domains/health-directorate/src/lib/health-directorate.service.ts (2)

43-44: LGTM! Proper null handling.

The nullish coalescing operator is correctly used to provide default values for the new properties.


78-79: LGTM! Clean and clear assignment.

The property assignments are straightforward and maintain consistency with the API contract.

libs/clients/health-directorate/src/lib/clients/organ-donation/clientConfig.json (2)

Line range hint 4-63: LGTM! Well-structured endpoint configuration.

The new endpoint /v1/donation-exceptions is properly configured with appropriate responses and error handling.


252-266: LGTM! Proper schema definition for new properties.

The OrganDonorDto schema is well-defined with appropriate types and required fields.

libs/portals/my-pages/health/src/lib/messages.ts (1)

1027-1034: LGTM! Clear and informative messages.

The new messages for minor and temporary national ID restrictions are well-written and informative.

Copy link
Member

@thorkellmani thorkellmani left a comment

Choose a reason for hiding this comment

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

LGTM

@disaerna disaerna removed the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Dec 18, 2024
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 comments (1)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (1)

Line range hint 89-101: Add form data validation

The current form data handling lacks validation:

  • Direct string conversion without type checking
  • No validation of form values
  • No error handling for invalid form data

Consider adding validation:

  const formData = new FormData(e.currentTarget)
  const data = Object.fromEntries(formData.entries())
  const idKey = 'selected-limitations-'
- const otherLimitations = data['otherLimitatons'].toString()
+ const otherLimitations = data['otherLimitatons']
+ if (typeof otherLimitations !== 'string') {
+   toast.error(formatMessage(messages.invalidFormData))
+   return
+ }
  const limitations = Object.keys(data)
    .filter((key) => key.includes(idKey))
    .map((key) => key.replace(idKey, '').toLowerCase())
🧹 Nitpick comments (1)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (1)

Line range hint 125-209: Enhance form accessibility

The form controls could benefit from improved accessibility:

  • Radio buttons lack aria-labels
  • Form sections could use fieldset and legend
  • Missing form validation feedback

Consider these improvements:

- <form onSubmit={onSubmit}>
+ <form onSubmit={onSubmit} aria-label={formatMessage(messages.organDonation)}>
+  <fieldset>
+    <legend className="visually-hidden">
+      {formatMessage(messages.organDonationOptions)}
+    </legend>
     <Stack space={2}>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ad2517 and b1418ba.

📒 Files selected for processing (1)
  • libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.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."
🔇 Additional comments (2)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (2)

90-90: Fix typo 'otherLimitatons' in form data retrieval

The typo in otherLimitatons needs to be corrected to otherLimitations to match the type definition.


1-26: LGTM! Component name change improves clarity.

The renaming from Form2 to OrganRegistrationForm better reflects the component's purpose and follows TypeScript naming conventions.

Let's verify the component's reusability across NextJS apps as per the libs/** guidelines:

✅ Verification successful

Component renaming and imports are appropriate for its scope

The component is correctly scoped within the health portal's organ donation feature and is not intended for cross-application reuse. The renaming from Form2 to OrganRegistrationForm improves code clarity while maintaining proper encapsulation within its specific domain.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if this component is imported in other NextJS apps
rg -l "OrganRegistrationForm" --type ts --type tsx

Length of output: 78


Script:

#!/bin/bash
# Let's try a different approach to check component usage
rg -t typescript -t javascriptreact -t typescriptreact "OrganRegistrationForm" 

# Also check the directory structure to understand the component's scope
fd -t f "RegistrationForm.tsx"

Length of output: 231


Script:

#!/bin/bash
# Let's try one more time with ripgrep without specific file type flags
rg "OrganRegistrationForm"

# Also check the imports structure to understand component usage
rg -l "from.*OrganDonation/components"

Length of output: 323

@disaerna disaerna added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Dec 19, 2024
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: 0

♻️ Duplicate comments (1)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (1)

90-90: ⚠️ Potential issue

Fix the 'otherLimitatons' typo

The typo in the form field name persists and needs to be corrected to match the type definition.

Apply this diff:

- const otherLimitations = data['otherLimitatons'].toString()
+ const otherLimitations = data['otherLimitations'].toString()

Also applies to: 100-100

🧹 Nitpick comments (2)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (2)

116-124: Consider extracting the access restriction condition

The conditional logic for access restriction could be more readable by extracting it into a constant.

Consider this improvement:

+ const isAccessRestricted = isMinor || isTemporaryResident;
+ const accessRestrictionMessage = isMinor
+   ? formatMessage(messages.organMinor)
+   : formatMessage(messages.organTemporaryNationalId);

- {!loading && (isMinor || isTemporaryResident) && (
+ {!loading && isAccessRestricted && (
    <NoAccess
-     text={
-       isMinor
-         ? formatMessage(messages.organMinor)
-         : formatMessage(messages.organTemporaryNationalId)
-     }
+     text={accessRestrictionMessage}
    />
  )}

166-167: Consider using more explicit TypeScript types

While the null coalescing operators provide runtime safety, consider adding explicit type annotations for better type checking during development.

- selected={updatedLimitations ?? []}
- exceptionComment={exceptionComment ?? undefined}
+ selected={updatedLimitations as string[] ?? []}
+ exceptionComment={exceptionComment as string | undefined}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1418ba and 665e754.

📒 Files selected for processing (1)
  • libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.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."
🔇 Additional comments (2)
libs/portals/my-pages/health/src/screens/OrganDonation/components/RegistrationForm.tsx (2)

32-32: LGTM! Improved component naming

The rename from Form2 to OrganRegistrationForm better reflects the component's purpose and follows React naming conventions.


57-59: LGTM! Safe array manipulation implemented

The implementation uses immutable array operations with spread operator, addressing the previous review comment about type safety and array mutation.

@kodiakhq kodiakhq bot merged commit 6167d4f into main Dec 19, 2024
52 checks passed
@kodiakhq kodiakhq bot deleted the my-pages/organ-donation-other branch December 19, 2024 13:07
thorkellmani pushed a commit that referenced this pull request Dec 19, 2024
)

* feat: add back "other" for organ donation registration

* refactor: update api client for organ donations

* refactor: texts

* fix: as

* fix: type safety

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
kodiakhq bot added a commit that referenced this pull request Dec 19, 2024
…#17298)

* fix: merge conflicts

* fix(my-pages-assets): chart fixes (#17289)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

* feat(my-pages): add back "other" for organ donation registration (#17228)

* feat: add back "other" for organ donation registration

* refactor: update api client for organ donations

* refactor: texts

* fix: as

* fix: type safety

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Ásdís Erna Guðmundsdóttir <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants