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

chore(j-s): Fix date and set default format #15537

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

chore(j-s): Fix date and set default format #15537

wants to merge 3 commits into from

Conversation

unakb
Copy link
Member

@unakb unakb commented Jul 18, 2024

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:

  • 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

    • Implemented default date formatting to 'dd.MM.yyyy' across various components and functions.
  • Bug Fixes

    • Improved consistency in date display by removing hard-coded date format specifiers.
    • Fixed test cases to ensure correct date format with leading zeros for days and months.
  • Refactor

    • Simplified date formatting logic by applying a default date format, reducing code redundancy.

@unakb unakb requested a review from a team as a code owner July 18, 2024 20:19
Copy link
Contributor

coderabbitai bot commented Jul 18, 2024

Walkthrough

The recent changes across several files mainly focus on standardizing date formatting within the judicial system application's backend and frontend components. The formatDate function has been updated to use a default format pattern ('dd.MM.yyyy') if no specific format is provided. This simplification removes redundant format specifiers throughout the codebase and ensures consistency in date representation across different components and outputs, such as PDFs, notifications, and UI elements.

Changes

Files Change Summary
apps/judicial-system/backend/src/app/formatters/caseFilesRecordPdf.ts Simplified date formatting by removing explicit date format specifications.
apps/judicial-system/backend/src/app/formatters/confirmedIndictmentPdf.ts Removed the format specifier from formatDate function call in createConfirmedIndictment function.
apps/judicial-system/backend/src/app/formatters/formatters.ts Updated formatDate function calls to remove the format specifier 'P'.
apps/judicial-system/backend/src/app/formatters/pdfHelpers.ts Modified addIndictmentConfirmation to format dates without the 'P' specifier.
apps/judicial-system/web/src/components/AccordionItems/IndictmentsCaseFilesAccordionItem/IndictmentsCaseFilesAccordionItem.tsx Streamlined date handling by using default format in CaseFile component.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.spec.ts Updated test cases to ensure correct date formats with leading zeros.
apps/judicial-system/web/src/components/InfoCard/DefendantInfo/DefendantInfo.tsx Removed format specifier 'P' in getAppealExpirationInfo function.
apps/judicial-system/web/src/components/SignedDocument/SignedDocument.tsx Altered formatMessage call to include only signingDate without specific format.
apps/judicial-system/web/src/components/Table/PastCasesTable/PastCases.spec.ts Adjusted date strings in tests to include leading zeros for consistency.
apps/judicial-system/web/src/routes/PublicProsecutor/Indictments/Overview/Overview.tsx Removed date formatting parameter ('P') for indictmentAppealDeadline display.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesAwaitingReview.tsx Simplified date formatting by removing the 'P' argument from formatDate call.
apps/judicial-system/web/src/routes/PublicProsecutor/Tables/CasesForReview.tsx Modified formatDate by removing the 'P' argument, affecting indictmentAppealDeadline display.
apps/judicial-system/web/src/routes/PublicProsecutor/components/ReviewDecision/ReviewDecision.tsx Removed the 'P' format specifier from the formatDate function call for date formatting.
libs/judicial-system/formatters/src/lib/formatters.ts Set a default format pattern ('dd.MM.yyyy') for formatDate function to standardize date formatting across the application.

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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: 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 in formatDate 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: Inconsistent formatDate Function Calls Detected

The 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 5

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('

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 \*.ts

Length of output: 15235

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between aba1949 and 0fedc24.

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.ts

Length 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.ts

Length 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 in formatDate ensures consistent date formatting.


200-200: LGTM!

The removal of the DDMMYYYY constant and the use of the default format pattern in formatDate ensures consistent date formatting.


207-209: LGTM!

The removal of the DDMMYYYY constant and the use of the default format pattern in formatDate ensures consistent date formatting.


309-311: LGTM!

The removal of the DDMMYYYY constant and the use of the default format pattern in formatDate 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 in libs/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.ts

Length 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-island-is
Copy link

Datadog Report

All test runs 6e7366a 🔗

5 Total Test Services: 1 Failed, 4 Passed
➡️ Test Sessions change in coverage: 6 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
judicial-system-web 2 0 0 324 0 1m 14.35s 1 no change Link
judicial-system-api 0 0 0 54 0 6.87s 1 no change Link
judicial-system-backend 0 0 0 20039 0 19m 5.62s 1 no change Link
judicial-system-formatters 0 0 0 36 0 6.12s 1 no change Link
judicial-system-xrd-api 0 0 0 6 0 5.63s 1 no change Link

❌ Failed Tests (2)

  • getDurationDate should use initial ruling date if it is set - apps/judicial-system/web/src/components/Table/PastCasesTable/PastCases.spec.ts - Details

    Expand for error
     expect(received).toBe(expected) // Object.is equality
     
     Expected: "04.08.2022 - 04.09.2022"
     Received: "4.8.2022 - 4.9.2022"
    
  • getDurationDate should use ruling date if initialRulingDate is not set - apps/judicial-system/web/src/components/Table/PastCasesTable/PastCases.spec.ts - Details

    Expand for error
     expect(received).toBe(expected) // Object.is equality
     
     Expected: "04.09.2022 - 13.09.2022"
     Received: "4.9.2022 - 13.9.2022"
    

Copy link

codecov bot commented Jul 18, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 37.02%. Comparing base (aba1949) to head (0fedc24).

Additional details and impacted files

Impacted file tree graph

@@           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     
Flag Coverage Δ
judicial-system-backend 55.98% <20.00%> ( <0.01%) ⬆️

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

Files Coverage Δ
...al-system/backend/src/app/formatters/formatters.ts 97.85% <ø> (ø)
...ccordionItem/IndictmentsCaseFilesAccordionItem.tsx 20.00% <ø> (-0.12%) ⬇️
...omponents/InfoCard/DefendantInfo/DefendantInfo.tsx 73.68% <ø> (-0.68%) ⬇️
...b/src/components/SignedDocument/SignedDocument.tsx 25.00% <ø> (ø)
...PublicProsecutor/Indictments/Overview/Overview.tsx 11.11% <ø> (ø)
...es/PublicProsecutor/Tables/CasesAwaitingReview.tsx 6.66% <ø> ( 0.41%) ⬆️
.../routes/PublicProsecutor/Tables/CasesForReview.tsx 0.00% <ø> (ø)
...cutor/components/ReviewDecision/ReviewDecision.tsx 0.00% <ø> (ø)
...s/judicial-system/formatters/src/lib/formatters.ts 81.46% <100.00%> ( 0.10%) ⬆️
...ckend/src/app/formatters/confirmedIndictmentPdf.ts 9.43% <0.00%> (ø)
... and 2 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 aba1949...0fedc24. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant