-
Notifications
You must be signed in to change notification settings - Fork 57
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
chore(j-s): Fix date and set default format #15537
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe recent changes across several files mainly focus on standardizing date formatting within the judicial system application's backend and frontend components. The Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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, codebase verification and nitpick comments (2)
apps/judicial-system/web/src/routes/PublicProsecutor/components/ReviewDecision/ReviewDecision.tsx (1)
83-83
: Inconsistent date format usage informatDate
function.The
formatDate
function does not consistently use the default date format ('dd.MM.yyyy'). Instead, it appears to use custom formats in different contexts. This suggests that the function might be designed to handle multiple formats based on the context. Please review and ensure that the default date format is applied consistently where required.
- Files affected:
apps/judicial-system/backend/migrations/20210608081018-update-case.js
apps/judicial-system/backend/migrations/20210831141153-update-case.js
Analysis chain
Verify the default date format.
Ensure that the
formatDate
function applies the default date format ('dd.MM.yyyy') consistently across the application.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the `formatDate` function applies the default date format ('dd.MM.yyyy') consistently. # Test: Search for the `formatDate` function usage. Expect: Consistent usage of the default date format. rg --type js -A 5 $'formatDate'Length of output: 3340
apps/judicial-system/backend/src/app/formatters/confirmedIndictmentPdf.ts (1)
180-180
: InconsistentformatDate
Function Calls DetectedThe
formatDate
function is still being called with specific format strings in several locations. To ensure consistent date formatting across the codebase, these instances should be reviewed and updated to use the default format where appropriate.Locations:
apps/judicial-system/backend/src/app/formatters/courtRecordPdf.ts
apps/judicial-system/backend/src/app/formatters/custodyNoticePdf.ts
apps/judicial-system/backend/src/app/formatters/indictmentPdf.ts
apps/judicial-system/backend/src/app/formatters/requestPdf.ts
apps/judicial-system/backend/src/app/formatters/rulingPdf.ts
apps/judicial-system/backend/src/app/formatters/subpoenaPdf.ts
apps/judicial-system/backend/src/app/formatters/caseFilesRecordPdf.ts
apps/judicial-system/backend/src/app/formatters/formatters.ts
apps/judicial-system/backend/src/app/formatters/pdfHelpers.ts
apps/judicial-system/backend/src/app/modules/case/case.controller.ts
apps/judicial-system/backend/src/app/modules/event/event.service.ts
apps/judicial-system/backend/src/app/modules/notification/notification.service.ts
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/case.response.ts
apps/judicial-system/digital-mailbox-api/src/app/modules/cases/models/subpoena.response.ts
apps/judicial-system/web/src/utils/stepHelper.ts
apps/web/components/Charts/v2/utils/format.ts
libs/api/domains/license-service/src/lib/mappers/huntingLicenseMapper.ts
libs/application/api/files/src/lib/pdfGenerators/residenceChange.ts
libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/children-residence-change.service.ts
libs/application/template-api-modules/src/lib/modules/templates/children-residence-change-v2/pdfGenerators/templates/residenceChange.ts
libs/application/template-api-modules/src/lib/modules/templates/children-residence-change/children-residence-change.service.ts
libs/application/template-api-modules/src/lib/modules/templates/health-insurance/health-insurance.utils.ts
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/InformationSection/MaritalStatusSubSection.ts
libs/application/templates/directorate-of-immigration/citizenship/src/forms/CitizenshipForm/PersonalSection/UserInformationSubSection.ts
libs/application/templates/financial-aid/src/lib/formatters.ts
libs/application/templates/healthcare-license-certificate/src/forms/HealthcareLicenseCertificateForm/personalSection.ts
libs/application/templates/healthcare-work-permit/src/forms/HealthcareWorkPermitForm/personalSection.ts
libs/application/templates/id-card/src/forms/IdCardForm/IdInformation/ChosenApplicantsSubSection.ts
libs/application/templates/parental-leave/src/lib/answerValidators.spec.ts
libs/judicial-system/formatters/src/lib/formatters.spec.ts
libs/portals/admin/petition/src/components/ExportList/downloadCSV.ts
libs/service-portal/finance/src/utils/filesHousingBenefits.ts
libs/service-portal/health/src/utils/FileBreakdown/filesStructure.ts
libs/service-portal/petitions/src/screens/PetitionsTable/ExportPetition/downloadCSV.ts
Please review and update these instances to ensure consistent date formatting.
Analysis chain
LGTM! But verify the function usage in the codebase.
The code changes are approved.
However, ensure that all function calls to
formatDate
match the intended default format.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `formatDate` match the intended default format. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts -A 5 $'formatDate('Length of output: 106
Script:
#!/bin/bash # Description: Verify all function calls to `formatDate` match the intended default format. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts 'formatDate(' -A 5Length of output: 106
Script:
#!/bin/bash # Description: Verify all function calls to `formatDate` match the intended default format. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts 'formatDate('Length of output: 101
Script:
#!/bin/bash # Description: Verify all function calls to `formatDate` match the intended default format. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type ts "formatDate("Length of output: 101
Script:
#!/bin/bash # Description: Verify all function calls to `formatDate` match the intended default format. # Test: Search for the function usage. Expect: Only occurrences of the new signature. grep -r "formatDate(" --include \*.tsLength of output: 15235
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (14)
- apps/judicial-system/backend/src/app/formatters/caseFilesRecordPdf.ts (2 hunks)
- apps/judicial-system/backend/src/app/formatters/confirmedIndictmentPdf.ts (1 hunks)
- apps/judicial-system/backend/src/app/formatters/formatters.ts (2 hunks)
- apps/judicial-system/backend/src/app/formatters/pdfHelpers.ts (1 hunks)
- apps/judicial-system/web/src/components/AccordionItems/IndictmentsCaseFilesAccordionItem/IndictmentsCaseFilesAccordionItem.tsx (4 hunks)
- apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts (2 hunks)
- apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (1 hunks)
- apps/judicial-system/web/src/components/SignedDocument/SignedDocument.tsx (1 hunks)
- apps/judicial-system/web/src/components/Table/PastCasesTable/PastCases.spec.ts (2 hunks)
- apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (1 hunks)
- apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx (1 hunks)
- apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx (1 hunks)
- apps/judicial-system/web/src/routes/PublicProsecutor/components/ReviewDecision/ReviewDecision.tsx (1 hunks)
- libs/judicial-system/formatters/src/lib/formatters.ts (1 hunks)
Files skipped from review due to trivial changes (1)
- apps/judicial-system/web/src/components/Table/PastCasesTable/PastCases.spec.ts
Additional context used
Path-based instructions (13)
apps/judicial-system/web/src/components/SignedDocument/SignedDocument.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/components/InfoCard/DefendantInfo/DefendantInfo.spec.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/routes/PublicProsecutor/components/ReviewDecision/ReviewDecision.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/PublicProsecutor/Tables/CasesAwaitingReview.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/PublicProsecutor/Tables/CasesForReview.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/components/InfoCard/DefendantInfo/DefendantInfo.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/backend/src/app/formatters/confirmedIndictmentPdf.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/formatters/caseFilesRecordPdf.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/routes/PublicProsecutor/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."
apps/judicial-system/backend/src/app/formatters/pdfHelpers.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/formatters/src/lib/formatters.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."
apps/judicial-system/web/src/components/AccordionItems/IndictmentsCaseFilesAccordionItem/IndictmentsCaseFilesAccordionItem.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/backend/src/app/formatters/formatters.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."
Learnings (5)
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts (3)
Learnt from: oddsson PR: island-is/island.is#15461 File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:36-62 Timestamp: 2024-07-08T13:30:58.001Z Learning: The user prefers readability over optimization in the `getAppealExpirationInfo` function within `DefendantInfo.tsx`.
Learnt from: unakb PR: island-is/island.is#14922 File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:43-49 Timestamp: 2024-05-27T10:53:40.687Z Learning: The `getAppealExpirationInfo` function in `DefendantInfo.tsx` correctly uses `today < expiryDate` to determine if the current date is before the appeal expiration date.
Learnt from: gudjong PR: island-is/island.is#15241 File: apps/judicial-system/backend/src/app/modules/defendant/dto/updateDefendant.dto.ts:87-90 Timestamp: 2024-06-14T15:09:02.068Z Learning: In some parts of the codebase, `verdictViewDate` is treated as a string, not a Date object, specifically in `updateDefendant.input.ts`, `defendant.model.ts`, and `case.transformer.ts`.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx (1)
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.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx (1)
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.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (2)
Learnt from: oddsson PR: island-is/island.is#15461 File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:36-62 Timestamp: 2024-07-08T13:30:58.001Z Learning: The user prefers readability over optimization in the `getAppealExpirationInfo` function within `DefendantInfo.tsx`.
Learnt from: unakb PR: island-is/island.is#14922 File: apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx:43-49 Timestamp: 2024-05-27T10:53:40.687Z Learning: The `getAppealExpirationInfo` function in `DefendantInfo.tsx` correctly uses `today < expiryDate` to determine if the current date is before the appeal expiration date.
apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (1)
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.
Additional comments not posted (16)
apps/judicial-system/web/src/components/SignedDocument/SignedDocument.tsx (1)
24-25
: Verify the default date format.Ensure that the
formatDate
function applies the default date format ('dd.MM.yyyy') consistently across the application.apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts (1)
58-58
: Verify the updated test cases.Ensure that the updated test cases correctly verify the date format with leading zeros for single-digit days and months.
Also applies to: 70-70
Verification successful
The updated test cases correctly verify the date format with leading zeros for single-digit days and months.
- Line 58: The test case checks if the date format is '05.08.2024' when the appeal expiration date is in the future.
- Line 70: The test case checks if the date format is '07.07.2024' when the appeal expiration date is in the past.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correctness of the updated test cases for `getAppealExpirationInfo`. # Test: Run the test cases in `DefendantInfo.spec.ts`. Expect: All tests should pass. npx jest apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.tsLength of output: 166
Script:
#!/bin/bash # Description: Search for test cases related to `getAppealExpirationInfo` in `DefendantInfo.spec.ts` to verify the date format. # Search for test cases in `DefendantInfo.spec.ts` rg 'getAppealExpirationInfo' -A 10 apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.tsLength of output: 2495
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx (1)
90-90
: Verify the default date format.Ensure that the
formatDate
function applies the default date format ('dd.MM.yyyy') consistently across the application.apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx (1)
98-98
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
formatDate
match the intended default format.apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx (1)
61-61
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
formatDate
match the intended default format.apps/judicial-system/backend/src/app/formatters/caseFilesRecordPdf.ts (2)
160-160
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
formatDate
match the intended default format.
217-222
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
formatDate
match the intended default format.apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx (1)
Line range hint
14-14
:
Verify the default date format.Ensure that the
formatDate
function defaults to 'dd.MM.yyyy' when no format specifier is provided. This change should maintain consistent date formatting across the application.apps/judicial-system/backend/src/app/formatters/pdfHelpers.ts (1)
249-251
: Verify the default date format.Ensure that the
formatDate
function defaults to 'dd.MM.yyyy' when no format specifier is provided. This change should maintain consistent date formatting in the generated PDF.libs/judicial-system/formatters/src/lib/formatters.ts (1)
28-30
: LGTM!The default format pattern 'dd.MM.yyyy' ensures consistent date formatting across the application.
apps/judicial-system/web/src/components/AccordionItems/IndictmentsCaseFilesAccordionItem/IndictmentsCaseFilesAccordionItem.tsx (4)
190-190
: LGTM!The removal of the
DDMMYYYY
constant and the use of the default format pattern informatDate
ensures consistent date formatting.
200-200
: LGTM!The removal of the
DDMMYYYY
constant and the use of the default format pattern informatDate
ensures consistent date formatting.
207-209
: LGTM!The removal of the
DDMMYYYY
constant and the use of the default format pattern informatDate
ensures consistent date formatting.
309-311
: LGTM!The removal of the
DDMMYYYY
constant and the use of the default format pattern informatDate
ensures consistent date formatting.apps/judicial-system/backend/src/app/formatters/formatters.ts (2)
520-520
: Verify the correctness of date formatting.Ensure that the
formatDate
function correctly formats the date without the format specifier'P'
.Verification successful
Verified: The
formatDate
function correctly formats dates without the format specifier 'P'.The
formatDate
function directly formats the date into a string with the day of the week, date, month, year, and time, ensuring correct formatting without the need for the specifier.
apps/judicial-system/backend/migrations/20210831141153-update-case.js
apps/judicial-system/backend/migrations/20210608081018-update-case.js
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `formatDate` function correctly formats dates without the format specifier 'P'. # Test: Search for the `formatDate` function implementation. Expect: Correct default format handling. rg --type python -A 5 $'def formatDate'Length of output: 71
Script:
#!/bin/bash # Description: Verify the `formatDate` function correctly formats dates without the format specifier 'P'. # Test: Search for the `formatDate` function implementation. Expect: Correct default format handling. rg --type js -A 5 $'function formatDate'Length of output: 1352
108-108
: Verify the correctness of date formatting.Ensure that the
formatDate
function correctly formats the date without the format specifier'P'
.Verification successful
Verified the correctness of date formatting.
The
formatDate
function inlibs/judicial-system/formatters/src/lib/formatters.ts
correctly handles date formatting with a default pattern of 'dd.MM.yyyy'. The removal of the format specifier'P'
does not affect its functionality.
libs/judicial-system/formatters/src/lib/formatters.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `formatDate` function correctly formats dates without the format specifier 'P'. # Test: Search for the `formatDate` function implementation. Expect: Correct default format handling. rg --type python -A 5 $'def formatDate'Length of output: 71
Script:
#!/bin/bash # Description: Verify the `formatDate` function correctly formats dates without the format specifier 'P'. # Test: Search for the `formatDate` function implementation. Expect: Correct default format handling. rg --type ts -A 5 'function formatDate'Length of output: 524
Script:
#!/bin/bash # Description: Verify the `formatDate` function correctly formats dates without the format specifier 'P'. # Test: Search for the `formatDate` function definition or import. Expect: Correct default format handling. rg --type ts 'formatDate'Length of output: 84717
Script:
#!/bin/bash # Description: Extract the implementation of the `formatDate` function from the relevant file. # Extract the implementation of the `formatDate` function. rg --type ts -A 10 'export const formatDate' apps/judicial-system/formatters/src/lib/formatters.tsLength of output: 194
Script:
#!/bin/bash # Description: Extract the implementation of the `formatDate` function from the entire repository. # Extract the implementation of the `formatDate` function. rg --type ts -A 10 'export const formatDate'Length of output: 12543
Datadog ReportAll test runs ❌ 5 Total Test Services: 1 Failed, 4 Passed Test Services
❌ Failed Tests (2)
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15537 /- ##
=======================================
Coverage 37.02% 37.02%
=======================================
Files 6558 6558
Lines 134045 134038 -7
Branches 38349 38347 -2
=======================================
- Hits 49628 49627 -1
Misses 84417 84411 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
Format á dagsetningum
What
Fix the format of dates so they place a 0 in front of one digit days and months (4.3.2024 -> 04.03.2024)
Why
So that all our dates of this type are displayed in the same fashion
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor