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(j-s): Default service status fix #16332

Merged
merged 10 commits into from
Oct 10, 2024
Merged

fix(j-s): Default service status fix #16332

merged 10 commits into from
Oct 10, 2024

Conversation

oddsson
Copy link
Member

@oddsson oddsson commented Oct 9, 2024

Default service status fix

Asana

What

If nothing has happened with the service of a subpoena we show a "Service failed" alert message. This is not correct. We now show a info box explaining that the subpoena is being served.

Why

It's a bug

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

    • Added a new message for when a subpoena is in the publication process.
  • Improvements

    • Enhanced logic for displaying service status messages and error handling in the Service Announcement component.
    • Improved conditional rendering for the Service Announcement based on subpoenaId.
  • Bug Fixes

    • Corrected descriptions in internationalization strings for better clarity and accuracy.
  • Updates

    • Updated internationalization strings for better clarity and accuracy.

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 2.94118% with 33 lines in your changes missing coverage. Please review.

Project coverage is 36.77%. Comparing base (dcba071) to head (598dfc9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...onents/ServiceAnnouncement/ServiceAnnouncement.tsx 0.00% 17 Missing ⚠️
...m/backend/src/app/modules/police/police.service.ts 0.00% 11 Missing ⚠️
...outes/Prosecutor/Indictments/Overview/Overview.tsx 0.00% 3 Missing ⚠️
.../app/modules/police/models/subpoenaStatus.model.ts 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16332      +/-   ##
==========================================
+ Coverage   36.73%   36.77%   +0.04%     
==========================================
  Files        6805     6802       -3     
  Lines      140764   140600     -164     
  Branches    40030    40005      -25     
==========================================
- Hits        51709    51705       -4     
+ Misses      89055    88895     -160     
Flag Coverage Δ
api 3.37% <ø> (ø)
application-system-api 41.51% <ø> (+<0.01%) ⬆️
application-template-api-modules 28.03% <ø> (-0.02%) ⬇️
application-ui-shell 21.29% <ø> (ø)
download-service 44.20% <ø> (ø)
judicial-system-api 18.29% <0.00%> (ø)
judicial-system-backend 55.14% <8.33%> (-0.01%) ⬇️
judicial-system-web 27.94% <0.00%> (-0.03%) ⬇️

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

Files with missing lines Coverage Δ
...src/app/modules/subpoena/dto/updateSubpoena.dto.ts 100.00% <100.00%> (ø)
...ServiceAnnouncement/ServiceAnnouncement.strings.ts 100.00% <ø> (ø)
.../app/modules/police/models/subpoenaStatus.model.ts 0.00% <0.00%> (ø)
...outes/Prosecutor/Indictments/Overview/Overview.tsx 0.00% <0.00%> (ø)
...m/backend/src/app/modules/police/police.service.ts 63.39% <0.00%> (-0.87%) ⬇️
...onents/ServiceAnnouncement/ServiceAnnouncement.tsx 6.15% <0.00%> (-1.26%) ⬇️

... and 16 files with indirect coverage changes


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 dcba071...598dfc9. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 9, 2024

Datadog Report

All test runs 5b64987 🔗

8 Total Test Services: 0 Failed, 8 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.02%), 17 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.6s 1 no change Link
application-system-api 0 0 0 120 2 3m 34.63s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 44.7s 1 no change Link
application-ui-shell 0 0 0 74 0 36.73s 1 no change Link
download-service 0 0 0 1 0 21.57s 1 no change Link
judicial-system-api 0 0 0 57 0 5.93s 1 no change Link
judicial-system-backend 0 0 0 21230 0 19m 5.48s 1 decreased (-0.02%) Link
judicial-system-web 0 0 0 338 0 1m 5.69s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • judicial-system-backend - jest 58.58% (-0.02%) - Details

@oddsson oddsson marked this pull request as ready for review October 9, 2024 13:02
@oddsson oddsson requested a review from a team as a code owner October 9, 2024 13:02
Copy link
Contributor

coderabbitai bot commented Oct 9, 2024

Walkthrough

The pull request introduces modifications to several components within the judicial system application. Key changes include an update to the getSubpoenaStatus method in the PoliceService to refine service status determination, updates to the SubpoenaStatus model to allow nullable service status, corrections to internationalization strings, and enhancements to the rendering logic in the ServiceAnnouncement component. These changes aim to improve the clarity and accuracy of service status messages and streamline the component logic.

Changes

File Change Summary
apps/judicial-system/backend/src/app/modules/police/police.service.ts Modified the getSubpoenaStatus method to refine the logic for determining serviceStatus, adding a check for response.delivered === false and response.acknowledged === false to set ServiceStatus.FAILED.
apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts Changed the serviceStatus field in the SubpoenaStatus class from a non-nullable type to a nullable type, allowing it to be optional.
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts Updated the defaultMessage for serviceStatusUnknown and added a new entry subpoenaCreated with specified id and defaultMessage.
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx Enhanced rendering logic for service status messages, simplified the return statement, and refined the handling of the type prop for the AlertMessage component.
apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts Removed the IsDate import from the class-validator package in the UpdateSubpoenaDto class, while the rest of the class structure remains unchanged.

Possibly related PRs


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
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 (7)
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (4)

42-46: Improved null handling, consider template literal for better readability

The changes effectively handle potential undefined values for servedBy and serviceDate. This aligns well with TypeScript best practices.

For improved readability, consider using a template literal:

`${subpoena.servedBy ?? ''}${subpoena.serviceDate ? ` - ${formatDate(subpoena.serviceDate, 'Pp')}` : ''}`

This change would make the code more concise and easier to read.


63-67: Improved null handling, consider template literal for consistency

The changes effectively handle potential undefined values for servedBy and serviceDate, improving the robustness of the code.

For consistency with the earlier suggestion and improved readability, consider using a template literal:

`${subpoena.servedBy ?? ''}${subpoena.serviceDate ? ` - ${formatDate(subpoena.serviceDate, 'Pp')}` : ''}`

This change would make the code more concise and consistent throughout the component.


73-77: Improved default case handling, consider consistent date formatting

The addition of a default case improves the robustness of the code by handling all possible scenarios. The use of optional chaining for subpoena.created is a good practice.

For consistency with other date formatting in the file, consider using the null coalescing operator:

date: subpoena.created ? formatDate(subpoena.created, 'Pp') : '',

This would make the date handling consistent throughout the component.


Line range hint 130-155: Improved rendering logic and type handling

The changes significantly improve the clarity and robustness of the rendering logic. The use of optional chaining and nullish coalescing aligns well with TypeScript best practices, and the conditional rendering follows React best practices.

For improved readability, consider extracting the type logic into a separate function:

const getAlertType = (serviceStatus?: ServiceStatus | null): 'info' | 'warning' | 'success' => {
  if (!serviceStatus) return 'info';
  if (serviceStatus === ServiceStatus.FAILED || serviceStatus === ServiceStatus.EXPIRED) return 'warning';
  return 'success';
};

// Then in the JSX:
type={getAlertType(subpoena?.serviceStatus)}

This would make the rendering logic more concise and easier to understand at a glance.

apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (3)

82-88: Improved rendering of ServiceAnnouncement components

The refactoring of the ServiceAnnouncement rendering logic is a good improvement. It simplifies the code and makes it more readable by removing the unnecessary conditional check.

Consider further optimizing the code by moving the mapping of subpoenas outside the JSX:

const serviceAnnouncements = workingCase.defendants?.flatMap((defendant) =>
  (defendant.subpoenas ?? []).map((subpoena) => (
    <ServiceAnnouncement
      key={`${subpoena.id}-${subpoena.created}`}
      subpoena={subpoena}
      defendantName={defendant.name}
    />
  ))
);

// Then in the JSX:
{serviceAnnouncements}

This approach would slightly improve readability and potentially performance by reducing nesting in the JSX.


Line range hint 158-164: Consider alternative approach for temporarily removed feature

The comments explain that the return indictment feature has been temporarily removed, but the code is kept for potential future use. While this approach preserves the functionality, it may lead to code clutter over time.

Consider the following alternatives:

  1. Move the removed code to a separate file or document, clearly marked as a potential future feature.
  2. Use feature flags to toggle the functionality, allowing for easier reintegration and testing.
  3. If using version control (e.g., Git), rely on the version history to retrieve the code when needed, and remove it from the current version entirely.

These approaches can help maintain a cleaner codebase while still preserving the ability to reintroduce the feature in the future.


Line range hint 1-180: Overall assessment: Good improvements with room for further optimization

The changes in this file, particularly the refactoring of the ServiceAnnouncement rendering, represent a positive step towards improved code readability and efficiency. The component adheres to NextJS and React best practices, demonstrating good use of hooks, context, and TypeScript.

To further enhance the component:

  1. Consider extracting some of the larger JSX blocks into separate components to improve modularity.
  2. Evaluate the use of memoization (e.g., useMemo, useCallback) for complex calculations or callback functions to optimize performance.
  3. Review the error handling and loading states to ensure a smooth user experience under all conditions.

These suggestions aim to improve the overall architecture and maintainability of the component while building upon the good practices already in place.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 68290a6 and 2627008.

📒 Files selected for processing (5)
  • apps/judicial-system/backend/src/app/modules/police/police.service.ts (1 hunks)
  • apps/judicial-system/web/pages/krafa/rannsoknarheimild/domkrofur-og-lagagrundvollur/[id].ts (1 hunks)
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts (2 hunks)
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (5 hunks)
  • apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/judicial-system/web/pages/krafa/rannsoknarheimild/domkrofur-og-lagagrundvollur/[id].ts
🧰 Additional context used
📓 Path-based instructions (4)
apps/judicial-system/backend/src/app/modules/police/police.service.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/web/src/routes/Court/Indictments/Overview/Overview.tsx (2)
Learnt from: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-06-27T14:37:07.823Z
Learning: User unakb prefers explicit case handling in switch statements for key functionalities like `getRulingDecisionTagColor` to ensure clarity and avoid assumptions that a case was overlooked.
Learnt from: unakb
PR: island-is/island.is#15378
File: apps/judicial-system/web/src/routes/Court/Indictments/Summary/Summary.tsx:86-100
Timestamp: 2024-10-08T15:39:04.351Z
Learning: User unakb prefers explicit case handling in switch statements for key functionalities like `getRulingDecisionTagColor` to ensure clarity and avoid assumptions that a case was overlooked.
🔇 Additional comments (4)
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts (2)

26-26: Approved: Updated message for unknown service status

The change from "Birtingastaða óþekkt" (Unknown service status) to "Fyrirkall er í birtingarferli" (Subpoena is in the publication process) aligns with the PR objective. This update provides clearer information about the subpoena status when it's being served, addressing the issue of incorrectly displaying a "Service failed" message.


Line range hint 1-43: Summary: Changes align with PR objectives and follow best practices

The modifications to this file effectively address the PR's goal of improving the display of service status for subpoenas. The updated serviceStatusUnknown message and the new subpoenaCreated message provide clearer information about the subpoena status during the publication process.

The changes adhere to NextJS best practices for internationalization, utilizing react-intl effectively. The use of TypeScript for defining message structures ensures type safety.

These updates contribute to a more informative and user-friendly interface for the judicial system application.

apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (1)

55-57: Improved null handling for serviceDate

The changes effectively handle a potential undefined value for serviceDate. This aligns well with TypeScript best practices and improves the robustness of the code.

apps/judicial-system/backend/src/app/modules/police/police.service.ts (1)

368-369: Improved logic for determining service status.

The new condition for setting ServiceStatus.FAILED when both response.acknowledged and response.delivered are false aligns with the PR objective to fix the default service status display. This change should prevent incorrect "Service failed" alerts when there's no activity regarding the service of a subpoena.

Please verify if this logic covers all possible scenarios for subpoena service status. Additionally, there's a TODO comment about handling expired status. Consider addressing this in a future update to ensure comprehensive status handling.

✅ Verification successful

Verification of ServiceStatus.FAILED Usage

The ServiceStatus.FAILED is consistently used in both police.service.ts and app.service.ts. Please ensure that the TODO comments regarding handling expired status are addressed to cover all scenarios for subpoena service statuses.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify if there are any other occurrences of ServiceStatus.FAILED in the codebase
rg --type typescript "ServiceStatus\.FAILED"

Length of output: 81


Script:

#!/bin/bash
# Verify if there are any other occurrences of ServiceStatus.FAILED in TypeScript files
rg "ServiceStatus\.FAILED" --glob "*.ts"

Length of output: 232


Script:

#!/bin/bash
# Extract lines surrounding ServiceStatus.FAILED in TypeScript files for context
rg "ServiceStatus\.FAILED" --glob "*.ts" -A 3

Length of output: 764

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

🧹 Outside diff range and nitpick comments (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx (1)

198-207: Approved: Improved robustness in ServiceAnnouncement rendering

The addition of the subpoena.subpoenaId && condition enhances the component's robustness by ensuring that the ServiceAnnouncement is only rendered when a valid subpoenaId exists. This change aligns well with TypeScript best practices and prevents potential rendering errors.

Consider using optional chaining and nullish coalescing for a more concise expression:

{workingCase.defendants?.flatMap(defendant =>
  defendant.subpoenas?.filter(subpoena => subpoena.subpoenaId)
    .map(subpoena => (
      <ServiceAnnouncement
        key={`${subpoena.id}-${subpoena.created}`}
        subpoena={subpoena}
        defendantName={defendant.name}
      />
    ))
) ?? []}

This refactoring maintains the same logic while potentially improving readability and reducing nesting.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2627008 and 8c2de52.

📒 Files selected for processing (2)
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts (2 hunks)
  • apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
📓 Learnings (1)
apps/judicial-system/web/src/routes/Prosecutor/Indictments/Overview/Overview.tsx (1)
Learnt from: unakb
PR: island-is/island.is#14712
File: apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/IndictmentOverview.tsx:0-0
Timestamp: 2024-10-08T15:39:04.351Z
Learning: The judicial system application uses a toaster notification system to handle errors globally.

Copy link
Member

@unakb unakb left a comment

Choose a reason for hiding this comment

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

Nice!

@oddsson oddsson added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Oct 9, 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

🧹 Outside diff range and nitpick comments (4)
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (4)

42-46: Improved robustness, consider using template literals for better readability

The changes effectively handle potential undefined values using optional chaining and nullish coalescing, which is a good TypeScript practice. The conditional formatting of the date also prevents potential errors.

For improved readability, consider using template literals throughout:

`${subpoena.servedBy ?? ''}${
  subpoena.serviceDate
    ? ` - ${formatDate(subpoena.serviceDate, 'Pp')}`
    : ''
}`

63-67: Consistent improvement in robustness, consider using template literals

The changes for the IN_PERSON and FAILED cases are consistent with earlier improvements, effectively handling potential undefined values. This enhances the overall robustness of the function.

For consistency and improved readability, consider using template literals here as well:

`${subpoena.servedBy ?? ''}${
  subpoena.serviceDate
    ? ` - ${formatDate(subpoena.serviceDate, 'Pp')}`
    : ''
}`

73-77: Good addition of default case, consider consistent date handling

The addition of a default case is a good improvement, ensuring that the function always returns a meaningful message. This enhances the robustness of the component by handling unexpected service statuses.

For consistency with other date handling in this function, consider using the same pattern:

formatMessage(strings.subpoenaCreated, {
  date: subpoena.created
    ? formatDate(subpoena.created, 'Pp')
    : '',
})

This approach maintains consistency and handles potential undefined values for subpoena.created.


116-116: Improved error handling and rendering logic

The changes in the useEffect hook and rendering logic significantly improve the component's robustness and readability. The conditional inclusion of defendantName in the title and the refinement of the AlertMessage type prop enhance the component's flexibility and user-friendliness.

Consider simplifying the type prop logic for AlertMessage using an object lookup:

type={
  {
    [ServiceStatus.FAILED]: 'warning',
    [ServiceStatus.EXPIRED]: 'warning',
  }[subpoena?.serviceStatus ?? ''] ?? 'info'
}

This approach can make the code more maintainable if you need to add more status-to-type mappings in the future.

Also applies to: 130-132, 139-141, 152-155

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8c2de52 and 598dfc9.

📒 Files selected for processing (5)
  • apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/police/police.service.ts (1 hunks)
  • apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts (1 hunks)
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts (1 hunks)
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/judicial-system/backend/src/app/modules/police/police.service.ts
  • apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.strings.ts
🧰 Additional context used
📓 Path-based instructions (3)
apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (1)

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

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
🔇 Additional comments (4)
apps/judicial-system/api/src/app/modules/police/models/subpoenaStatus.model.ts (1)

7-8: LGTM! The change aligns with the PR objectives.

The modification to make serviceStatus nullable is appropriate and aligns with the PR's goal of fixing the default service status issue. This change allows for a more accurate representation when there's no activity regarding the service of a subpoena.

To ensure this change doesn't introduce any unintended side effects, please run the following verification script:

✅ Verification successful

Verified: serviceStatus nullability is appropriately handled.

The check for serviceStatus === undefined in police.service.ts properly accounts for the nullable serviceStatus field. No non-null assertions were found, ensuring that the nullable changes do not introduce unintended side effects.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any non-null assertions (!.) or non-null checks on serviceStatus field

# Test: Search for non-null assertions or checks on serviceStatus
rg --type typescript '(serviceStatus!\.|\bif\s*\(\s*serviceStatus\s*[^?])'

# Note: If this script returns results, those locations may need to be updated to handle the now nullable serviceStatus.

Length of output: 111


Script:

#!/bin/bash
# Description: Check for any non-null assertions (!.) or non-null checks on serviceStatus field in TypeScript files.

# Test: Search for non-null assertions or checks on serviceStatus in .ts and .tsx files
rg --glob '*.ts' --glob '*.tsx' '(serviceStatus!\.|\bif\s*\(\s*serviceStatus\s*[^?])'

# Note: If this script returns results, those locations may need to be updated to handle the now nullable serviceStatus.

Length of output: 202

apps/judicial-system/backend/src/app/modules/subpoena/dto/updateSubpoena.dto.ts (2)

Line range hint 1-54: LGTM: Well-structured DTO with appropriate use of decorators

The overall structure of the UpdateSubpoenaDto class is well-implemented. It makes good use of:

  • Optional properties with @IsOptional() decorators
  • Type validation with @IsEnum() and @IsString() decorators
  • Swagger documentation with @ApiPropertyOptional() decorators

This implementation aligns well with TypeScript and NestJS best practices for DTOs.


1-1: Verify the impact of removing the IsDate import

The IsDate import from class-validator has been removed. However, the serviceDate property is still present and typed as a string. This change might affect date validation for the serviceDate field.

To ensure this change doesn't introduce any issues, please run the following script to check for any remaining uses of IsDate in the codebase:

If there are no other uses of IsDate, consider updating the serviceDate property to use appropriate date validation, such as:

@IsOptional()
@IsISO8601()
@ApiPropertyOptional({ type: String, format: 'date' })
readonly serviceDate?: string

This ensures that the serviceDate is properly validated as a date string in ISO8601 format.

apps/judicial-system/web/src/components/ServiceAnnouncement/ServiceAnnouncement.tsx (1)

55-57: Improved date handling for ELECTRONICALLY status

The conditional formatting of the date for the ELECTRONICALLY status is a good improvement. It prevents potential errors when serviceDate is undefined, enhancing the robustness of the component.

@kodiakhq kodiakhq bot merged commit 95e25d7 into main Oct 10, 2024
50 checks passed
@kodiakhq kodiakhq bot deleted the j-s/fix-service-status branch October 10, 2024 10:37
busla pushed a commit that referenced this pull request Oct 10, 2024
* Fix service status

* Checkpoint

* Fix default case

* Fix texts

* Only show ServiceAnnouncement for subpoenas with subpoenaId

* Only fetch new data to RLS

* Minor fixes

* Fix description
@coderabbitai coderabbitai bot mentioned this pull request Oct 21, 2024
6 tasks
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