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

[Signalement] Lors de l'écriture d'un signalement, le raffraichissement de l'app efface les données saisies dans le formulaire #3002

Merged
merged 7 commits into from
Mar 5, 2024

Conversation

louptheron
Copy link
Collaborator

@louptheron louptheron commented Mar 4, 2024

Linked issues


  • Tests E2E (Cypress)

Summary by CodeRabbit

  • New Features

    • Introduced a new ReportingForm component for creating or editing vessel reporting data.
    • Added visibility and layout adjustments for the VesselSidebar.
    • Enhanced vessel reporting by supporting EditableReporting and EditedReporting types.
    • Implemented a new useGetInLocalStorage hook for retrieving data from local storage.
  • Bug Fixes

    • Fixed incorrect type usage in various reporting components and utility functions.
    • Adjusted styling for BeaconMalfunctionDetails and VesselStatusSelect for improved specificity.
  • Refactor

    • Refactored EditReporting component for better prop handling and styling.
    • Optimized useEffect hooks in VesselReportings for dispatch calls.
    • Updated import paths to use module aliases for enhanced code readability.
  • Style

    • Updated VesselCardOverlay styling based on the number of warnings.
    • Removed unused BackofficeSecondaryButton styled component.
  • Documentation

    • No visible changes to end-users.
  • Tests

    • No visible changes to end-users.
  • Chores

    • No visible changes to end-users.
  • Revert

    • No visible changes to end-users.

Copy link
Contributor

coderabbitai bot commented Mar 4, 2024

Walkthrough

The updates focus on enhancing the reporting functionality within the frontend, specifically around creating and editing reports related to vessel activities. Changes include the introduction of new types for editable and edited reporting, improvements in form validation and state management, adjustments to UI components for better usability, and the implementation of local storage to preserve form data during app refreshes. These adjustments aim to streamline the reporting process, making it more efficient and user-friendly.

Changes

File Path Change Summary
.../types/reporting.ts, .../Reporting/slice.ts, .../Reporting/useCases/updateReporting.ts Introduced EditableReporting and EditedReporting types; updated reporting-related types and imports.
.../MainWindow.tsx, .../VesselSidebar/..., .../map/overlays/VesselCardOverlay/... Adjusted UI components and styling for better layout and visibility.
.../Reporting/components/... Enhanced reporting forms and lists with new components, utility functions, schemas, and styling adjustments.
.../hooks/useSaveInLocalStorage.tsx Added a custom hook for retrieving data from local storage.

Assessment against linked issues

Objective Addressed Explanation
Signalement - Lors de l'écriture d'un signalement, le raffraichissement de l'app efface les données saisies dans le formulaire (#2941)

🐰✨

In the land of code where the rabbits hop,
A change was made, not a single flop.
Reports now safe, through refreshes they stay,
No more lost data, it's a brighter day.
With every tweak and adjustment made,
Our rabbit's work, in solid gold is weighed.
🚀🌟

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-tests 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 tests 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 tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

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

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b11301c and 2340ef1.
Files selected for processing (24)
  • frontend/src/api/reporting.ts (2 hunks)
  • frontend/src/domain/types/reporting.ts (1 hunks)
  • frontend/src/features/MainWindow.tsx (1 hunks)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx (1 hunks)
  • frontend/src/features/Reporting/components/ReportingForm/schemas.ts (1 hunks)
  • frontend/src/features/Reporting/components/ReportingForm/utils.ts (1 hunks)
  • frontend/src/features/Reporting/components/ReportingList/constants.ts (4 hunks)
  • frontend/src/features/Reporting/components/ReportingList/index.tsx (8 hunks)
  • frontend/src/features/Reporting/components/VesselReportings/Current/CreateOrEditReporting.tsx (2 hunks)
  • frontend/src/features/Reporting/components/VesselReportings/Current/utils.ts (1 hunks)
  • frontend/src/features/Reporting/components/VesselReportings/ReportingCard.tsx (2 hunks)
  • frontend/src/features/Reporting/components/VesselReportings/index.tsx (4 hunks)
  • frontend/src/features/Reporting/components/VesselReportings/utils.ts (1 hunks)
  • frontend/src/features/Reporting/slice.ts (2 hunks)
  • frontend/src/features/Reporting/useCases/updateReporting.ts (2 hunks)
  • frontend/src/features/SideWindow/Alert/AlertListAndReportingList/EditReporting.tsx (2 hunks)
  • frontend/src/features/SideWindow/BeaconMalfunctionBoard/BeaconMalfunctionDetails.tsx (1 hunks)
  • frontend/src/features/SideWindow/BeaconMalfunctionBoard/VesselStatusSelect.tsx (1 hunks)
  • frontend/src/features/VesselSidebar/beacon_malfunctions/resume/CurrentBeaconMalfunctionBody.tsx (1 hunks)
  • frontend/src/features/commonStyles/Buttons.style.jsx (1 hunks)
  • frontend/src/features/map/overlays/VesselCardOverlay/VesselCard.tsx (6 hunks)
  • frontend/src/features/map/overlays/VesselCardOverlay/constants.ts (1 hunks)
  • frontend/src/features/map/overlays/VesselCardOverlay/index.tsx (2 hunks)
  • frontend/src/hooks/useSaveInLocalStorage.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • frontend/src/features/commonStyles/Buttons.style.jsx
Additional comments: 40
frontend/src/hooks/useSaveInLocalStorage.tsx (1)
  • 1-3: The implementation of useGetInLocalStorage custom hook looks good and aligns with the PR's objectives. Ensure that the getLocalStorageState utility function robustly handles exceptions related to local storage access, such as quota limits or user privacy settings that might block local storage.
frontend/src/features/Reporting/components/VesselReportings/utils.ts (1)
  • 7-7: The change from null to undefined for the unit parameter in getReportingActor aligns with standardizing optional value representation. Ensure that all related logic and function calls are updated to handle the undefined value correctly.
frontend/src/features/map/overlays/VesselCardOverlay/constants.ts (1)
  • 27-34: The addition of marginsWithThreeWarning constant is a good enhancement for accommodating different UI states. Ensure that these new margin values are tested across various screen sizes and resolutions to maintain a consistent and responsive UI.
frontend/src/features/Reporting/components/VesselReportings/Current/utils.ts (1)
  • 4-4: The updates to imports and types, along with the addition of the mapControlUnitsToUniqueSortedIdsAsOptions function, enhance the application's architecture and improve code maintainability. Ensure the correctness of the sorting and mapping logic in the new utility function.
frontend/src/features/Reporting/components/ReportingList/constants.ts (1)
  • 4-4: The update to the import path for TableOptions and adjustments to column widths in REPORTING_LIST_TABLE_OPTIONS are positive changes for code readability and UI enhancement. Verify the visual impact of these adjustments on the table layout across different screen sizes to ensure a balanced and readable presentation.
frontend/src/features/Reporting/components/ReportingForm/schemas.ts (1)
  • 8-37: The CreateOrEditReportingSchema validation schema is well-defined, using yup for clear validation rules and conditional validation. Review all validation messages for user-friendliness and ensure comprehensive coverage of validation cases to enhance form usability.
frontend/src/features/Reporting/components/VesselReportings/Current/CreateOrEditReporting.tsx (1)
  • 1-68: The refactoring and updates in the CreateOrEditReporting component improve maintainability and user experience. Ensure that styling adjustments are consistent with the application's overall design and that event handling logic is robust to enhance usability.
frontend/src/features/SideWindow/BeaconMalfunctionBoard/VesselStatusSelect.tsx (1)
  • 32-41: The use of setProperty with important for style specificity in VesselStatusSelect is practical for ensuring correct style application. Review the necessity of using important to ensure it does not negatively impact CSS maintainability or introduce style inconsistencies.
frontend/src/features/Reporting/components/ReportingForm/utils.ts (1)
  • 7-68: The getFormFields and updateReportingActor utility functions enhance form state management and user interaction handling. Ensure thorough testing of these functions, particularly the conditional logic in updateReportingActor, to maintain form usability and relevance.
frontend/src/domain/types/reporting.ts (1)
  • 62-100: The introduction of EditableReporting and EditedReporting types, along with updates to existing types, enhances type safety and code maintainability. Verify the consistent application of these new types and the use of undefined for optional fields across the codebase.
frontend/src/features/Reporting/useCases/updateReporting.ts (3)
  • 1-1: The use of module aliases (@api/reporting) improves code readability and maintainability by making import paths clearer and more concise.
  • 14-14: Changing the type reference from ReportingUpdate to EditedReporting aligns with the PR's objective to enhance reporting functionality. This change ensures that the correct type is used throughout the application, improving type safety and code clarity.
  • 15-15: Utilizing a module alias for MainAppThunk is consistent with the approach of improving code readability and maintainability. This change makes it easier to understand where the type is coming from and reduces the complexity of import paths.
frontend/src/features/Reporting/components/VesselReportings/index.tsx (4)
  • 1-2: Updating imports to use custom hooks (useMainAppDispatch and useMainAppSelector) enhances modularity and encapsulation. This change promotes the use of custom hooks that abstract away the Redux store logic, making the component more maintainable and easier to understand.
  • 31-33: Refactoring the useEffect hook to optimize dispatch calls based on vessel changes is a good practice. This optimization prevents unnecessary dispatch calls when the selected vessel identity has not changed, improving the component's performance.
  • 65-65: Replacing COLORS.charcoal with THEME.color.charcoal for the spinner color aligns with the approach of centralizing theme-related values. This change ensures consistency in color usage across the application and facilitates easier theme adjustments in the future.
  • 92-92: The slight decrease in max-height for the Body styled component may impact the layout and visibility of the VesselReportings component. Ensure that this change does not adversely affect the user interface, especially on devices with different screen sizes or resolutions.
frontend/src/api/reporting.ts (1)
  • 98-98: Changing the type of the nextReporting parameter in the updateReportingFromAPI function to EditedReporting is consistent with the PR's objective to refine the reporting functionality. This change ensures that the function expects the correct type, enhancing type safety and clarity in the reporting update process.
frontend/src/features/MainWindow.tsx (1)
  • 71-71: Moving the rendering of VesselSidebar outside of LegacyRsuiteComponentsWrapper and making it conditional on the isVesselSidebarOpen flag is a significant change. This adjustment likely aims to improve the layout and visibility of the sidebar component. Ensure that this change does not introduce any layout shifts or affect the overall user experience negatively.
frontend/src/features/map/overlays/VesselCardOverlay/index.tsx (1)
  • 95-97: Adding the marginsWithThreeWarning constant and utilizing it based on the number of warnings for a vessel is a thoughtful approach to dynamically adjust the overlay's margins. This change ensures that the overlay's layout adapts to the content, improving the user interface for cases with multiple warnings.
frontend/src/features/VesselSidebar/beacon_malfunctions/resume/CurrentBeaconMalfunctionBody.tsx (1)
  • 32-39: Adjusting the selectors for setting background color and text color to target specific child elements within .rs-picker-select and .rs-picker-toggle-value respectively, ensures that the styling is applied correctly. This change improves the visual representation of the vessel status, making it clearer and more consistent with the intended design.
frontend/src/features/SideWindow/Alert/AlertListAndReportingList/EditReporting.tsx (3)
  • 1-10: Refactoring imports to use custom hooks and module aliases enhances the modularity and readability of the code. This change aligns with best practices for organizing imports and using custom hooks for Redux store logic.
  • 23-55: The restructuring of the EditReporting component, including the use of styled-components for styling and adjustments to component props handling, improves the component's readability and maintainability. The use of data-cy attributes also facilitates easier testing. Ensure that these changes have been tested thoroughly to confirm that the component's functionality remains intact and the user experience is not adversely affected.
  • 64-142: The extensive use of styled-components for defining the component's styling is a good practice, as it enhances the separation of concerns and allows for more maintainable and scalable styling. Ensure that the styles are consistent with the application's design system and that there are no unintended side effects on the layout or appearance.
frontend/src/features/Reporting/slice.ts (2)
  • 16-17: The update of editedReporting and editedReportingInSideWindow types to EditableReporting is a positive change for consistency and flexibility. It allows for a more generic handling of reporting entities, potentially accommodating future extensions or variations in reporting types.
  • 129-129: The action setEditedReportingInSideWindow correctly accepts EditableReporting | undefined as its payload. This change aligns with the updated state types and ensures that the application can handle both setting and clearing the edited reporting in the side window context.
frontend/src/features/Reporting/components/VesselReportings/ReportingCard.tsx (2)
  • 96-96: The change from isAlert to $isAlert for the ArchiveButton styled component is a good practice in styled-components to indicate that isAlert is a prop used exclusively for styling purposes and not meant to be passed to the DOM element as an attribute. This prevents unnecessary warnings and keeps the DOM cleaner.
  • 201-201: The dynamic styling based on the $isAlert prop ensures that the ArchiveButton's margin-top is adjusted according to whether there are any alerts. This is a neat way to conditionally style components based on props.
frontend/src/features/Reporting/components/ReportingForm/index.tsx (3)
  • 1-28: The imports have been updated to include necessary hooks, utilities, and components for the reporting form. It's good to see that the code is organized and imports are grouped logically. Ensure that all imported entities are used within the component to avoid unnecessary imports.
  • 68-108: The createOrEditReporting function is well-structured and handles both the creation and updating of reportings. It makes good use of the useCallback hook for memoization. However, ensure that previousReportingType.current is correctly managed and updated as needed, as its value seems to be used but not set within this component. This could potentially lead to incorrect behavior when updating reportings.
  • 110-234: The form structure and field definitions are clear and well-organized. Using Formik for form management is a good choice for handling form state and validation. The dynamic rendering of form fields based on the reporting type and actor is a nice touch that enhances the user experience. Ensure that all form fields are correctly validated according to the CreateOrEditReportingSchema.
frontend/src/features/Reporting/components/ReportingList/index.tsx (4)
  • 32-36: The addition of ObservationReporting to the imported types suggests an expansion in the types of reportings the component can handle. Ensure that the component's logic and UI correctly accommodate this new type, reflecting the application's domain logic.
  • 107-107: The change in the parameter type of the edit function to include ObservationReporting is a logical extension to accommodate new reporting types. Ensure that the editing functionality is fully compatible with ObservationReporting, including any necessary UI adjustments or validations.
  • 175-175: Adjusting the width of the table to 1195px may improve the layout and user experience by ensuring better alignment and spacing of content. Verify this change in the context of the entire application to maintain a consistent design language.
  • 363-363: Modifying the padding of the Content styled component to 20px 0px 40px 10px could enhance the visual appeal and readability of the content. Ensure this adjustment aligns with the overall design and spacing conventions of the application.
frontend/src/features/map/overlays/VesselCardOverlay/VesselCard.tsx (5)
  • 6-6: The import marginsWithThreeWarning has been added to VesselCard.tsx. Ensure that this constant is used appropriately within the file and that its values are correctly calculated based on the design requirements.
  • 337-351: The dynamic styling for BottomTriangleShadow correctly adjusts the margin-left based on the numberOfWarnings. This approach ensures that the visual representation of warnings is consistent with the design requirements. However, ensure that the constants used (marginsWithOneWarning, marginsWithTwoWarning, marginsWithThreeWarning, marginsWithoutAlert) are defined with accurate values to maintain visual consistency.
  • 366-395: The TopTriangleShadow component's dynamic styling for margin-left and margin-top is well-implemented, allowing for adjustments based on the numberOfWarnings. This method of handling styling ensures that the component's appearance is dynamically adjusted to reflect the current state accurately. As with the BottomTriangleShadow, verify that the constants used for margins are correctly defined.
  • 409-438: The RightTriangleShadow component's styling logic, which adjusts both margin-left and margin-top based on the numberOfWarnings, is correctly implemented. This dynamic adjustment is crucial for maintaining the visual integrity of the component based on the state. Continue to ensure that the constants defining the margins are accurate and reflect the intended design.
  • 454-468: The LeftTriangleShadow component's dynamic margin-top adjustment based on the numberOfWarnings is implemented correctly. This approach ensures that the component's visual representation is consistent with the application's design requirements. As with other triangle shadow components, it's important to verify the accuracy of the constants used for margin calculations.

Comment on lines +51 to +53
const selectElement = vesselStatusRef.current.querySelector('.rs-picker-select > div') as HTMLElement | null
if (selectElement?.style) {
selectElement.style.background = vesselStatus.color
selectElement.style.setProperty('background', vesselStatus.color, 'important')
Copy link
Contributor

Choose a reason for hiding this comment

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

Direct manipulation of DOM element styles, especially using setProperty with the 'important' flag, is generally discouraged in React applications. It's recommended to use styled-components or CSS classes for styling. This approach enhances maintainability and avoids potential specificity conflicts that can arise from the use of 'important'. Consider refactoring this to use a styled-component or a CSS class.

frontend/src/features/Reporting/slice.ts Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2340ef1 and 2ecfa00.
Files selected for processing (3)
  • frontend/cypress/e2e/side_window/reporting_list.spec.ts (1 hunks)
  • frontend/cypress/e2e/vessel_sidebar/reporting.spec.ts (2 hunks)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx
Additional comments: 5
frontend/cypress/e2e/vessel_sidebar/reporting.spec.ts (4)
  • 66-73: The use of custom Cypress commands like cy.clickButton and cy.fill significantly improves the readability and maintainability of the test script by abstracting repetitive actions into reusable functions. This change aligns well with best practices for writing clean and maintainable test code.
  • 75-75: It's good practice to use cy.intercept to mock network requests and responses. This ensures that the tests are not dependent on the actual network environment, which can lead to flakiness. However, ensure that the mocked responses closely mimic the real API responses to maintain test accuracy.
  • 81-82: The modification of a reporting to an infraction suspicion is well tested here, demonstrating the flexibility of the test suite to cover different user scenarios. This is crucial for ensuring that the application behaves as expected under various conditions.
  • 158-169: The createReporting function encapsulates the steps to create a new reporting, making the test cases more concise and focused on the test logic rather than the setup. This is a good example of DRY (Don't Repeat Yourself) principle in test automation.
frontend/cypress/e2e/side_window/reporting_list.spec.ts (1)
  • 185-187: The use of custom Cypress commands such as cy.fill and cy.clickButton in the modifyReportingToObservation function is a great way to improve the readability and maintainability of the test script. These commands abstract away the details of interacting with the UI, allowing the test logic to be more easily understood.

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2ecfa00 and b4513a2.
Files selected for processing (2)
  • frontend/cypress/e2e/side_window/reporting_list.spec.ts (2 hunks)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • frontend/cypress/e2e/side_window/reporting_list.spec.ts
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b4513a2 and 71911b0.
Files selected for processing (3)
  • frontend/src/domain/shared_slices/Vessel.ts (1 hunks)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx (1 hunks)
  • frontend/src/features/Reporting/useCases/updateReporting.ts (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx
  • frontend/src/features/Reporting/useCases/updateReporting.ts
Additional comments: 1
frontend/src/domain/shared_slices/Vessel.ts (1)
  • 137-140: The addition of a condition to check state.selectedVesselIdentity before comparing it with action.payload.vesselFeatureId is a logical improvement. This ensures that operations are only performed if a vessel is selected, which can prevent potential errors or unintended behavior when no vessel is selected. However, it's important to ensure that all related components and state management logic that depend on selectedVesselIdentity are aware of and properly handle cases where selectedVesselIdentity might be null or undefined.

Copy link
Member

@ivangabriele ivangabriele left a comment

Choose a reason for hiding this comment

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

Je ne suis pas sûr d'avoir compris si le besoin est une sauvegarde en live du formulaire. Là j'ai l'impression de ne voir qu'une sauvegarde standard via le backend seulement une fois qu'on clique sur le submit button. Il n'y a pas de redux-persist ou de test de rechargement de page à moins que j'ai raté quelques chose ?

}: ReportingFormProps) {
const dispatch = useMainAppDispatch()
const infractions = useMainAppSelector(state => state.infraction.infractions)
const controlUnitsQuery = useGetLegacyControlUnitsQuery(undefined)
Copy link
Member

Choose a reason for hiding this comment

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

Pourquoi utiliser les unités legacy ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

+1, utilisation des nouvelles unités

frontend/src/hooks/useSaveInLocalStorage.tsx Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Mar 5, 2024

Quality Gate Passed Quality Gate passed

Issues
6 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 71911b0 and 5c2f60e.
Files selected for processing (2)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx (1 hunks)
  • frontend/src/features/Reporting/components/VesselReportings/Current/utils.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • frontend/src/features/Reporting/components/ReportingForm/index.tsx
Additional comments: 2
frontend/src/features/Reporting/components/VesselReportings/Current/utils.ts (2)
  • 1-3: Ensure that the updated imports and types (Reporting and ControlUnit) are correctly used throughout this file. Given the removal of getReportingValueErrors, verify that the updated types still meet all necessary validation and functionality requirements within the reporting feature.
  • 1-13: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [12-20]

The sortByValidationOrCreationDateDesc function provides a clear and logical way to sort reports. However, ensure that all Reporting objects have either a validationDate or a creationDate to avoid unexpected behavior when either date is missing or invalid.

Comment on lines +6 to +10
export const mapControlUnitsToUniqueSortedIdsAsOptions = (controlUnits: ControlUnit.ControlUnit[]): Option<number>[] =>
Array.from(controlUnits)
.sort((a, b) => Number(b.name) - Number(a.name))
.map(controlUnit => ({
label: `${controlUnit.name} (${controlUnit.administration})`,
label: `${controlUnit.name} (${controlUnit.administration.name})`,
Copy link
Contributor

Choose a reason for hiding this comment

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

The mapControlUnitsToUniqueSortedIdsAsOptions function correctly maps and sorts control units. However, the sorting logic seems to sort by name in descending order, which might not be intuitive for user selection. Consider if ascending order (Number(a.name) - Number(b.name)) would be more user-friendly.

@louptheron louptheron merged commit baff9ff into master Mar 5, 2024
25 checks passed
@louptheron louptheron deleted the loup/do-not-erase-reporting-when-app-refresh branch March 5, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants