-
Notifications
You must be signed in to change notification settings - Fork 61
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): Digital mailbox API #16301
Conversation
WalkthroughThe changes in this pull request primarily enhance the error handling and logging capabilities within the Changes
Possibly related PRs
Suggested reviewers
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
…nd-is/island.is into j-s/fix-digital-mailbox-api
There was a problem hiding this 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 (5)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (1)
Line range hint
1-47
: Consider broader impact and next steps.The changes to the
Subpoena
interface improve type safety and provide more detailed information about subpoena status, aligning with the PR objectives. However, consider the following next steps:
- Update any components or API routes that use the
Subpoena
interface to handle the newserviceStatus
property.- Ensure that the
ServiceStatus
enum is properly defined in the@island.is/judicial-system/types
module.- Update relevant documentation to reflect these changes.
- Consider adding unit tests to verify the correct usage of the new
serviceStatus
property.These steps will ensure that the changes are fully integrated into the NextJS application and maintain overall code quality.
Would you like assistance in identifying the components or API routes that might need updates based on these changes?
libs/judicial-system/types/src/lib/defendant.ts (2)
45-47
: Approved with suggestion: Type-safe check for successful service statusThe
isSuccessfulServiceStatus
function is a valuable addition, providing a reusable way to check if a service status is successful. It's well-typed and concise, adhering to the coding guidelines for thelibs
directory.However, to improve type safety, consider updating the
successfulServiceStatus
constant to useServiceStatus[]
instead ofstring[]
. This change would ensure that only validServiceStatus
values can be included in the array.Here's the suggested change:
-export const successfulServiceStatus: string[] = [ +export const successfulServiceStatus: ServiceStatus[] = [ ServiceStatus.ELECTRONICALLY, ServiceStatus.DEFENDER, ServiceStatus.IN_PERSON, ]This modification will make the
isSuccessfulServiceStatus
function more robust and prevent potential errors from invalid status strings.
38-47
: Summary: Valuable additions for handling service statusesThe new exports,
successfulServiceStatus
andisSuccessfulServiceStatus
, are valuable additions to thedefendant.ts
file. They provide a clear, reusable way to define and check successful service statuses, which aligns well with the PR objectives of including more detailed information regarding defender choices and API responses.These additions adhere to the coding guidelines for the
libs
directory, ensuring reusability across different NextJS apps and proper TypeScript usage. They will likely improve the consistency and reliability of service status checks throughout the judicial system components.Consider documenting these new exports in the relevant API documentation to ensure other developers are aware of their availability and proper usage.
libs/judicial-system/types/src/index.ts (1)
Line range hint
1-11
: LGTM! Consider adding JSDoc comment for the new export.The addition of
isSuccessfulServiceStatus
is consistent with the existing exports and adheres to the coding guidelines for thelibs
directory. It enhances the module's functionality without breaking existing exports.To improve documentation, consider adding a JSDoc comment for the new export in the
./lib/defendant
file. For example:/** * Checks if the given service status is considered successful. * @param status The service status to check * @returns True if the status is successful, false otherwise */ export function isSuccessfulServiceStatus(status: ServiceStatus): boolean;This will provide better context for developers using this function across different NextJS apps.
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts (1)
47-50
: Improved logic for determininghasBeenServed
The update to use
isSuccessfulServiceStatus
enhances the accuracy of determining if a case has been served. This change aligns well with NextJS best practices by improving data transformation logic.For better readability, consider using optional chaining:
hasBeenServed: isSuccessfulServiceStatus(subpoenas[0]?.serviceStatus) ?? false,This would eliminate the need for the length check and make the code more concise.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (6)
- apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts (0 hunks)
- apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts (2 hunks)
- apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (2 hunks)
- apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (4 hunks)
- libs/judicial-system/types/src/index.ts (1 hunks)
- libs/judicial-system/types/src/lib/defendant.ts (1 hunks)
💤 Files with no reviewable changes (1)
- apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts
🧰 Additional context used
📓 Path-based instructions (5)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.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/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.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/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.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."
libs/judicial-system/types/src/index.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/judicial-system/types/src/lib/defendant.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
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts
[error] 122-125: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
🔇 Additional comments (5)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/internal/internalCase.response.ts (2)
Line range hint
1-7
: LGTM: Import statement updated correctly.The addition of
ServiceStatus
to the import statement is consistent with its usage in theSubpoena
interface and follows TypeScript best practices.
Line range hint
42-47
: Approve change with verification suggestion.The replacement of
acknowledged: boolean
withserviceStatus?: ServiceStatus
provides a more detailed representation of the subpoena's status, aligning with the PR objectives. However, asserviceStatus
is optional, it's important to ensure proper handling in the code that uses this interface.To verify the proper usage of the new
serviceStatus
property, please run the following script:This will help identify areas where the
Subpoena
interface orserviceStatus
property is used, allowing you to verify that the optional nature ofserviceStatus
is properly handled.libs/judicial-system/types/src/lib/defendant.ts (1)
39-43
: LGTM: Well-defined constant for successful service statusesThe
successfulServiceStatus
constant is a good addition. It provides a clear, reusable definition of what constitutes a successful service status, which can be easily used across different parts of the application. The use of TypeScript for explicit typing (string[]
) is appropriate and aligns with the coding guidelines for thelibs
directory.apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts (1)
4-7
: LGTM: Import changes are well-structuredThe addition of
isSuccessfulServiceStatus
import is properly grouped with related imports from the same module. This follows good TypeScript practices and improves code organization.apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (1)
9-13
: Approved: ImportingisSuccessfulServiceStatus
The addition of
isSuccessfulServiceStatus
import is appropriate and necessary for the functionality implemented.
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts
Outdated
Show resolved
Hide resolved
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts
Outdated
Show resolved
Hide resolved
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts
Outdated
Show resolved
Hide resolved
To get changes through. Ive already resolved all comments but git doesnt seem to recognize it.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16301 +/- ##
==========================================
- Coverage 36.86% 36.84% -0.02%
==========================================
Files 6798 6796 -2
Lines 140495 140394 -101
Branches 39945 39917 -28
==========================================
- Hits 51792 51729 -63
+ Misses 88703 88665 -38
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 17 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 73 Total Test Services: 0 Failed, 71 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (5)
|
There was a problem hiding this 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 (2)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (2)
66-71
: LGTM: New properties align with PR objectives.The added properties
hasChosenDefender
anddefaultDefenderChoice
in theSubpoenaData
class provide the necessary information about defender choices as per the PR objectives. The use of appropriate types and@ApiProperty
decorators is commendable.For consistency, consider adding a description to the
@ApiProperty
decorators:@ApiProperty({ type: Boolean, description: 'Indicates if a defender has been chosen' }) hasChosenDefender?: boolean @ApiProperty({ enum: DefenderChoice, description: 'Default choice for the defender' }) defaultDefenderChoice?: DefenderChoiceThis will enhance the API documentation.
123-127
: SimplifyhasChosenDefender
logic and LGTM fordefaultDefenderChoice
.The addition of
hasChosenDefender
anddefaultDefenderChoice
to the returned object aligns well with the PR objectives. However, thehasChosenDefender
logic can be simplified:hasChosenDefender: defendantInfo?.defenderChoice !== undefined && defendantInfo.defenderChoice !== DefenderChoice.DELAY,This eliminates the need for the
Boolean
constructor and makes the logic more straightforward.The
defaultDefenderChoice: DefenderChoice.DELAY
is correct and aligns with the PR objectives.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.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."
🔇 Additional comments (2)
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts (2)
9-13
: LGTM: New imports are relevant and necessary.The added imports from '@island.is/judicial-system/types' are appropriate for the changes made in this file. They introduce necessary types and functions used in the updated code.
100-104
: LGTM: Improved handling of subpoenas and service status.The changes in this segment effectively address previous concerns and improve the code:
- Renaming
subpoena
tosubpoenas
better reflects the handling of multiple subpoenas.- The added check
subpoenas.length > 0
prevents potential undefined access, addressing a previous review comment.- Using
isSuccessfulServiceStatus
centralizes the logic for checking service status, improving maintainability.These changes enhance the robustness and clarity of the code.
* feat(j-s): Block create subpoena on staging and dev * Update subpoena.service.ts * fix(j-s): Fix mailbox API * remove changes not meant for this branch * Update subpoena.service.ts * fix(j-s): reverting changes from other branch * Update subpoena.response.ts * Update subpoena.response.ts * Update subpoena.response.ts * Update subpoena.response.ts --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
…-pages (#16234) * Service portal removal. Add portals my pages * minor fixes * Fix * path fix * fix(portals-admin): locklist (#16279) * fix(portals-admin): locklist * tweak * msg id fix * tweak --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(service-portal): feature flag resolver for documents (#16285) * fix: def info and alert * feat: add feature flag to resolver * fix: move ff call to seperate function --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(vehicles-bulk-mileage): Fixes after testing review (#16295) * fix: testing fixes v1 * fix: testing comments v2 * fix: better message * fix: function name * fix: duplicate loading --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(tests): New @island/testing/e2e library (#16287) * Add @swc-node/register and @swc/core * Add testing/e2e library * update project.json for testing/e2e * fix import for libTestingE2e --------- Co-authored-by: Kristofer <kristofer@andes.is> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(parental-leave): ApplicationRights (#15901) * feat(parental-leave): ApplicationRights Added applicationRights to parental-leave when sending application. Since we are using a new way of calculating periods * Fix days used by period calculation * Tests for new periods * rename function with proper camelCase * Refactor: Made duplicate code into a function * Make ApplicationRights nullable * refactor: function instead of duplicate code * remove console.log * error handling for period data * clientConfig nullable fix * Fixes for calculation of months. And using clamp to get correct value of daysLeft * Multiply amount of months by 30 for period calculation with month durations * Fix old calculation of endDate with months --------- Co-authored-by: hfhelgason <hfhelgason@deloitte.is> Co-authored-by: veronikasif <54938148+veronikasif@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(passport-application): Updated readme (#16296) * updated readme * updated readme * chore: nx format:write update dirty files --------- Co-authored-by: andes-it <builders@andes.is> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(regulations-admin): date format signature, remove self affect, disclaimer text (#16288) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(regulations-admin): No diff no addition in appendix (#16293) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(web): Global alert banner - Handle null case (#16298) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(web): Change custom syslumenn pages config for header (#16299) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(j-s): Digital mailbox API (#16301) * feat(j-s): Block create subpoena on staging and dev * Update subpoena.service.ts * fix(j-s): Fix mailbox API * remove changes not meant for this branch * Update subpoena.service.ts * fix(j-s): reverting changes from other branch * Update subpoena.response.ts * Update subpoena.response.ts * Update subpoena.response.ts * Update subpoena.response.ts --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * fix(signature-collection): Fix list reviewed toggle (#16300) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * chore(scripts): Stricter shell script checking (#16242) * Set style level for shellcheck * Linting & formatting scripts * Remove _podman.sh script * Format all scripts * Add reviewdog/action-shfmt step * Configure shfmt * Merge from main * Linting * Move shfmt to before lint * Remove reviewdog * Allow external sources in shellcheck * Use Reviewdog for shellcheck * Set version for Reviewdog --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * chore(new-primary-school): Update messages namespace (#16302) Co-authored-by: veronikasif <54938148+veronikasif@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(driving-license): check if 65+ renewal is possible (#16292) * check if 65 renewal is possible * remove console log * cleanup * coderabbit tweaks * coderabbit changes * quick fix * add type? --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * feat(service-portal): default defender and has chosen fields for subpoena (#16306) * fix: def info and alert * feat: add feature flag to resolver * fix: move ff call to seperate function * feat: add default choices ans has chosen + loading states * fix: use type * fix: undefined type issue * fix: simplify check * Update service setup for my pages infra * chore: charts update dirty files * Remove from infra * undo rename --------- Co-authored-by: albinagu <47886428+albinagu@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 <disa@hugsmidjan.is> Co-authored-by: Þorkell Máni Þorkelsson <wowthorkell@gmail.com> Co-authored-by: Svanhildur Einarsdóttir <54863023+svanaeinars@users.noreply.github.com> Co-authored-by: Kristofer <kristofer@andes.is> Co-authored-by: helgifr <helgifreyr95@gmail.com> Co-authored-by: hfhelgason <hfhelgason@deloitte.is> Co-authored-by: veronikasif <54938148+veronikasif@users.noreply.github.com> Co-authored-by: Rafn Árnason <rafnarnason@gmail.com> Co-authored-by: andes-it <builders@andes.is> Co-authored-by: Rúnar Vestmann <43557895+RunarVestmann@users.noreply.github.com> Co-authored-by: mannipje <135017126+mannipje@users.noreply.github.com> Co-authored-by: unakb <una@kolibri.is> Co-authored-by: juni-haukur <158475136+juni-haukur@users.noreply.github.com> Co-authored-by: birkirkristmunds <142495885+birkirkristmunds@users.noreply.github.com> Co-authored-by: Kristján Albert <kal@juni.is>
What
Fix digital mailbox API after db changes and added 2 new values to return object
Why
Because it's not returning correct information and we need more concrete info about defender choices
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores