Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: access instruction editing #1338

Merged
merged 12 commits into from
Jul 26, 2024
Merged

Conversation

JoeKarow
Copy link
Collaborator

@JoeKarow JoeKarow commented Jul 19, 2024

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: IN-1000

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Introduced an edit mode for email, phone number, and website entries, allowing users to edit their details directly within the interface.
    • Added new components for managing attributes and service areas within the edit drawer.
  • Bug Fixes

    • Enhanced handling of undefined data in the Coverage Area modal.
  • Improvements

    • Updated data structures to streamline the handling of active properties across multiple components and processors, improving data accuracy and user experience.

Copy link

vercel bot commented Jul 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
inreach-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 26, 2024 5:46pm

Copy link
Contributor

coderabbitai bot commented Jul 19, 2024

Walkthrough

The recent updates introduce enhanced interactivity to several components related to contact information, including email, phone numbers, and websites, by integrating an edit mode. This allows users to modify entries directly within the UI. Additionally, new components like AttributeEditWrapper and ServiceAreaItem have been added to streamline attribute management and service area interactions, coupled with improvements in data handling across various processing functions.

Changes

File Path Change Summary
packages/ui/components/data-display/ContactInfo/{Emails,PhoneNumbers,Websites}.tsx Integrated useEditMode for editing capabilities; modified rendering logic to conditionally wrap elements in AttributeEditWrapper. Updated data queries to exclude the active property.
packages/ui/components/data-display/ContactInfo/types.ts Modified PassedData type to reflect passedData as an array, incorporating an optional active property.
packages/ui/components/data-portal/ServiceEditDrawer/{AttributeEditWrapper,ServiceAreaItem}.tsx Introduced new components for managing attribute editing and service areas, utilizing Mantine UI and TRPC for backend integration.
packages/ui/components/data-portal/ServiceEditDrawer/index.tsx Removed ServiceAreaItem and AttributeEditWrapper along with associated logic; refactored state management.
packages/ui/modals/CoverageArea/index.tsx Enhanced CoverageAreaModal by modifying reduceDistType to return an array, improving data handling.
packages/ui/modals/Service/processors/{emailAccess,linkAccess,phoneAccess}.ts Updated processing functions to include an active property in the returned objects, improving data output integrity.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EmailsDisplay
    participant AttributeEditWrapper

    User->>EmailsDisplay: Toggle Edit Mode
    EmailsDisplay->>AttributeEditWrapper: Render Emails in Edit Mode
    AttributeEditWrapper->>User: Show Editable Fields
    User->>AttributeEditWrapper: Edit Email
    AttributeEditWrapper->>EmailsDisplay: Update Email Data
Loading

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

@github-actions github-actions bot added automerge Enable Kodiak auto-merge kodiak: merge.method = 'squash' Kodiak will squash merge this PR. 📦 ui labels Jul 19, 2024
@JoeKarow JoeKarow added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label Jul 19, 2024
Copy link

relativeci bot commented Jul 19, 2024

#1028 Bundle Size — 3.5MiB (+0.04%).

23cf15c(current) vs 3c00bb2 dev#1026(baseline)

Warning

Bundle contains 5 duplicate packages – View duplicate packages

Bundle metrics  Change 4 changes Regression 1 regression
                 Current
#1028
     Baseline
#1026
Regression  Initial JS 3.07MiB(+0.04%) 3.07MiB
No change  Initial CSS 9.54KiB 9.54KiB
Change  Cache Invalidation 45.76% 32.22%
No change  Chunks 64 64
No change  Assets 77 77
Change  Modules 2056(+0.1%) 2054
No change  Duplicate Modules 340 340
Change  Duplicate Code 9.43%(-0.11%) 9.44%
No change  Packages 209 209
No change  Duplicate Packages 5 5
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#1028
     Baseline
#1026
Regression  JS 3.39MiB (+0.04%) 3.38MiB
No change  Fonts 94.54KiB 94.54KiB
No change  CSS 9.54KiB 9.54KiB
No change  Other 9.09KiB 9.09KiB
No change  IMG 8.57KiB 8.57KiB

Bundle analysis reportBranch IN-1000-access-instructions-allo...Project dashboard

Copy link
Contributor

github-actions bot commented Jul 19, 2024

📦 Next.js Bundle Analysis for @weareinreach/app

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link

alwaysmeticulous bot commented Jul 19, 2024

🤖 No test run has been triggered as your Meticulous project has been deactivated (since you haven't viewed any test results in a while). Click here to reactivate.

Last updated for commit 23cf15c. This comment will update as new commits are pushed.

Copy link

sonarqubecloud bot commented Jul 26, 2024

Quality Gate Passed Quality Gate passed

Issues
2 New issues
3 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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3c00bb2 and 23cf15c.

Files selected for processing (11)
  • packages/ui/components/data-display/ContactInfo/Emails.tsx (3 hunks)
  • packages/ui/components/data-display/ContactInfo/PhoneNumbers.tsx (3 hunks)
  • packages/ui/components/data-display/ContactInfo/Websites.tsx (4 hunks)
  • packages/ui/components/data-display/ContactInfo/types.ts (1 hunks)
  • packages/ui/components/data-portal/ServiceEditDrawer/AttributeEditWrapper.tsx (1 hunks)
  • packages/ui/components/data-portal/ServiceEditDrawer/ServiceAreaItem.tsx (1 hunks)
  • packages/ui/components/data-portal/ServiceEditDrawer/index.tsx (5 hunks)
  • packages/ui/modals/CoverageArea/index.tsx (5 hunks)
  • packages/ui/modals/Service/processors/emailAccess.ts (2 hunks)
  • packages/ui/modals/Service/processors/linkAccess.ts (2 hunks)
  • packages/ui/modals/Service/processors/phoneAccess.ts (2 hunks)
Additional comments not posted (38)
packages/ui/modals/Service/processors/linkAccess.ts (2)

29-29: LGTM! The addition of the active property is correct.

The active property has been correctly added to the LinkAccessOutput interface.


10-14: LGTM! Ensure the active property is correctly used.

The addition of the active property is straightforward and aligns with the updated interface.

However, ensure that the active property is correctly used wherever processLinkAccess is called.

packages/ui/modals/Service/processors/emailAccess.ts (2)

35-35: LGTM! The addition of the active property is correct.

The active property has been correctly added to the EmailAccessOutput interface.


10-14: LGTM! Ensure the active property is correctly used.

The addition of the active property is straightforward and aligns with the updated interface.

However, ensure that the active property is correctly used wherever processEmailAccess is called.

packages/ui/modals/Service/processors/phoneAccess.ts (2)

38-38: LGTM! The addition of the active property is correct.

The active property has been correctly added to the PhoneAccessOutput interface.


14-18: LGTM! Ensure the active property is correctly used.

The addition of the active property is straightforward and aligns with the updated interface.

However, ensure that the active property is correctly used wherever processPhoneAccess is called.

packages/ui/components/data-portal/ServiceEditDrawer/ServiceAreaItem.tsx (5)

1-6: Imports look good.

The imports from @mantine/core, react, and custom modules are appropriate for the functionality of this component.


7-13: Component definition and props look good.

The props are well-defined and necessary for the component's functionality.


14-17: API utility and mutation setup look good.

The API utility and mutation setup are appropriate for the intended functionality.


19-27: Action handler and conditional rendering logic look good.

The useCallback hook is used efficiently for the actionHandler function, and the conditional rendering logic is appropriate.


29-47: JSX structure and props interface look good.

The JSX structure is clear, and the props interface is well-defined.

packages/ui/components/data-display/ContactInfo/types.ts (4)

Line range hint 1-17:
Imports and type definitions look good.

The imports and type definitions for contact sections, contact map, and contact info props are appropriate.


Line range hint 18-30:
Common props and specific props look good.

The common props and specific props for phone numbers, websites, emails, and social media are well-defined and necessary for the component's functionality.


31-33: Modification of PassedData type definition looks good.

The modification enhances the flexibility of the data structure to handle multiple entries with an optional active property.


Line range hint 34-48:
PassedDataObject and ApiData type definitions look good.

The type definitions are well-defined and necessary for the component's functionality.

packages/ui/components/data-portal/ServiceEditDrawer/AttributeEditWrapper.tsx (5)

1-8: Imports look good.

The imports from @mantine/core, @mantine/hooks, react, and custom modules are appropriate for the functionality of this component.


9-13: Component definition and props look good.

The props are well-defined and necessary for the component's functionality.


14-15: API utility and mutation setup look good.

The API utility and mutation setup are appropriate for the intended functionality.


16-63: Event handlers and memoized icons look good.

The event handlers for toggling, deleting, and editing attributes are well-implemented. The memoized icons for edit and toggle actions are efficient.


64-93: JSX structure and props interface look good.

The JSX structure is clear, and the props interface is well-defined.

packages/ui/modals/CoverageArea/index.tsx (2)

22-24: LGTM! Improved robustness by returning an array.

Returning an array instead of a string ensures more predictable and easier handling of the function's return value.


Line range hint 113-126: LGTM! Performance optimization with useCallback.

Using useCallback with appropriate dependencies optimizes performance by memoizing the function.

packages/ui/components/data-display/ContactInfo/Websites.tsx (3)

8-11: LGTM! Necessary imports for edit mode functionality.

The new imports AttributeEditWrapper and useEditMode are necessary for implementing the edit mode functionality.


36-36: LGTM! Essential addition of useEditMode hook.

The useEditMode hook is necessary for determining whether the component is in edit mode, enabling conditional rendering.


Line range hint 72-91: LGTM! Enhanced functionality with conditional rendering for edit mode.

The updated rendering logic wraps website links in AttributeEditWrapper when isEditMode is true, enabling direct editing of website entries.

packages/ui/components/data-display/ContactInfo/Emails.tsx (3)

10-12: LGTM! Necessary imports for edit mode functionality.

The new imports AttributeEditWrapper and useEditMode are necessary for implementing the edit mode functionality.


39-39: LGTM! Essential addition of useEditMode hook.

The useEditMode hook is necessary for determining whether the component is in edit mode, enabling conditional rendering.


82-91: LGTM! Enhanced functionality with conditional rendering for edit mode.

The updated rendering logic wraps email links in AttributeEditWrapper when isEditMode is true, enabling direct editing of email entries.

packages/ui/components/data-display/ContactInfo/PhoneNumbers.tsx (5)

8-10: LGTM! New imports are necessary and correctly used.

The imports AttributeEditWrapper and useEditMode are essential for the new functionality.


28-28: LGTM! Correct usage of useEditMode.

The useEditMode hook is used appropriately to determine the edit mode state.


32-35: LGTM! Query modification is correct.

The query now removes the active property from each phone record, which is correctly implemented.


68-81: LGTM! Conditional rendering logic is correct.

The phone number display is correctly wrapped in an AttributeEditWrapper when in edit mode.


Line range hint 15-81:
LGTM! Overall function logic is correct.

The PhoneNumbersDisplay function is well-implemented and enhances the user experience by providing an editable view.

packages/ui/components/data-portal/ServiceEditDrawer/index.tsx (5)

53-53: LGTM! Refactoring of serviceId state variable is correct.

The refactoring from a state hook (useState) to a memoized value (useMemo) is correctly implemented and improves performance.


126-126: LGTM! Simplification of mutation calls is correct.

The mutation calls related to API interactions have been simplified correctly.


Line range hint 18-287:
LGTM! Overall changes to the ServiceEditDrawer component are correct.

The changes improve the component's functionality and performance by removing unnecessary components and refactoring state variables.


Line range hint 1-287:
LGTM! Overall component logic is correct.

The ServiceEditDrawer component is well-implemented and enhances the user experience and performance.


41-43: Verify the removal of AttributeEditWrapper and ServiceAreaItem components.

Ensure that the removal of these components is intentional and doesn't break any functionality.

@JoeKarow JoeKarow requested a review from InReach-svc July 26, 2024 19:15
@kodiakhq kodiakhq bot merged commit 36f6277 into dev Jul 26, 2024
34 of 35 checks passed
@kodiakhq kodiakhq bot deleted the IN-1000-access-instructions-allow branch July 26, 2024 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Enable Kodiak auto-merge bugfix Inconsistencies or issues which will cause a problem for users or implementors. kodiak: merge.method = 'squash' Kodiak will squash merge this PR. 📦 ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants