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

feat: address visibility settings #1305

Merged
merged 16 commits into from
Jun 25, 2024
Merged

feat: address visibility settings #1305

merged 16 commits into from
Jun 25, 2024

Conversation

JoeKarow
Copy link
Collaborator

@JoeKarow JoeKarow commented Jun 25, 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-984

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Enhanced address visibility options with new addressVisibility property.
    • Address visibility can now be set to 'FULL', 'PARTIAL', or 'HIDDEN'.
    • Added dropdown for address visibility selection in the Address Drawer UI component.
  • Bug Fixes

    • Improved accuracy of displayed address data based on visibility settings.
  • Refactor

    • Replaced notVisitable with addressVisibility across multiple components and handlers.
    • Updated form handling and state management logic in LocationDrawer component.
  • Chores

    • Updated autogenerated Next.js routes version from 2.2.0 to 2.2.1.
    • Introduced a new exclusion pattern for the _queries directory in workspace settings.

Copy link

vercel bot commented Jun 25, 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 Jun 25, 2024 4:23pm

Copy link
Contributor

coderabbitai bot commented Jun 25, 2024

Walkthrough

This update brings widespread changes across several modules in the project, focusing on enhancing the address handling system. Key alterations include renaming the notVisitable property to addressVisibility, ensuring compliance with new visibility settings, and introducing enums for address visibility. These modifications enhance the consistency and control over how addresses are displayed throughout the application. Additionally, several UI components, schemas, and handlers are updated to reflect these changes, ensuring seamless integration and functionality.

Changes

File(s) Change Summary
InReach.code-workspace Introduced exclusion pattern for _queries directory in workspace settings.
apps/app/src/types/nextjs-routes.d.ts Updated version number from 2.2.0 to 2.2.1.
packages/api/router/location/lib.formatAddressVisibility.ts Added lib.formatAddressVisibility.ts with a function for formatting addresses based on visibility settings.
packages/api/router/location/mutation.create.schema.ts, mutation.update.schema.ts Updated schemas to include city as required and replaced notVisitable with addressVisibility.
packages/api/router/location/query.*.handler.ts Renamed notVisitable to addressVisibility and integrated formatAddressVisibility function across various query handlers.
packages/api/router/organization/query.forOrgPage.handler.ts, query.forOrgPageEdits.handler.ts Updated organization query handlers to replace notVisitable with addressVisibility.
packages/db/client/index.ts Exported $Enums as PrismaEnums alongside existing Prisma export.
packages/db/prisma/data-migrations/index.ts Updated exports and introduced new modules for data migrations.
packages/db/prisma/migrations/.../migration.sql Updated OrgLocation table schema, adding addressVisibility and removing irrelevant columns.
packages/db/prisma/schema.prisma Modified OrgLocation model and introduced AddressVisibility enum for address control.
packages/ui/components/core/Toolbar.stories.tsx Simplified initialization of constants NotSaved and Saved.
packages/ui/components/data-portal/AddressDrawer.tsx, LocationDrawer/index.tsx Updated UI components to handle new addressVisibility settings and removed notVisitable.
packages/ui/components/sections/ListingBasicInfo.tsx, LocationCard.tsx Adjusted address display logic based on addressVisibility.
packages/ui/mockData/... Updated mock data to replace notVisitable with addressVisibility.
packages/ui/modals/MoreFilter.stories.tsx Added state management wrapper to MoreFilter component.
packages/ui/modals/MoreFilter.tsx Made MoreFilterProps interface publicly exportable.

The changes enhance address visibility control across the application, ensuring consistent display and handling of address information via updated schemas and UI components.


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

@JoeKarow JoeKarow added the new-feature New features or options. label Jun 25, 2024
Copy link

Copy link

relativeci bot commented Jun 25, 2024

#713 Bundle Size — 3.54MiB (+3.77%).

96a4d6d(current) vs 15ed769 dev#704(baseline)

Warning

Bundle contains 6 duplicate packages – View duplicate packages

Warning

Bundle introduced 6 new packages: prisma-query-log, @prisma/client, slugify and 3 more – View changed packages

Bundle metrics  Change 8 changes Regression 2 regressions Improvement 1 improvement
                 Current
#713
     Baseline
#704
Regression  Initial JS 3.14MiB(+4.25%) 3.01MiB
No change  Initial CSS 9.54KiB 9.54KiB
Change  Cache Invalidation 39.94% 54.45%
Change  Chunks 70(+4.48%) 67
Change  Assets 83(+3.75%) 80
Change  Modules 2043(+1.79%) 2007
Improvement  Duplicate Modules 267(-1.11%) 270
Change  Duplicate Code 7.4%(-5.49%) 7.83%
Regression  Packages 217(+2.84%) 211
No change  Duplicate Packages 6 6
Bundle size by type  Change 1 change Regression 1 regression
                 Current
#713
     Baseline
#704
Regression  JS 3.42MiB (+3.9%) 3.29MiB
No change  Fonts 94.54KiB 94.54KiB
No change  Other 9.58KiB 9.58KiB
No change  CSS 9.54KiB 9.54KiB
No change  IMG 8.57KiB 8.57KiB

Bundle analysis reportBranch IN-984-re-require-cityProject dashboard

Copy link
Contributor

github-actions bot commented Jun 25, 2024

📦 Next.js Bundle Analysis for @weareinreach/app

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

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (575 KB)
/org/[slug] 323.7 KB 735.37 KB 127.89% (🟡 +0.17%)
/org/[slug]/edit 324.73 KB 736.41 KB 128.07% (🟡 +8.20%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

Copy link

alwaysmeticulous bot commented Jun 25, 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 96a4d6d. This comment will update as new commits are pushed.

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: 2

Outside diff range and nitpick comments (2)
packages/db/client/index.ts (1)

Line range hint 55-55: Potential issue with variable redeclaration.

The static analysis tool has flagged a potential redeclaration of the prisma variable. It's important to ensure that this does not cause any unexpected behavior or conflicts in the global scope, especially in development environments where conditional assignments are used.

packages/ui/components/data-portal/AddressDrawer.tsx (1)

Line range hint 84-95: Schema updates align well with PR objectives.

The changes to make city a required field and introduce addressVisibility are consistent with the PR's goals to enhance visibility settings. However, consider using z.string().nonempty() for city to ensure that it is not only present but also non-empty.

- city: z.string(),
+ city: z.string().nonempty(),
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e705e93 and 96a4d6d.

Files selected for processing (27)
  • InReach.code-workspace (1 hunks)
  • apps/app/src/types/nextjs-routes.d.ts (1 hunks)
  • packages/api/router/location/lib.formatAddressVisibility.ts (1 hunks)
  • packages/api/router/location/mutation.create.schema.ts (2 hunks)
  • packages/api/router/location/mutation.update.schema.ts (3 hunks)
  • packages/api/router/location/query.forGoogleMaps.handler.ts (2 hunks)
  • packages/api/router/location/query.forLocationCard.handler.ts (3 hunks)
  • packages/api/router/location/query.forLocationPage.handler.ts (2 hunks)
  • packages/api/router/location/query.forLocationPageEdits.handler.ts (1 hunks)
  • packages/api/router/location/query.forVisitCard.handler.ts (4 hunks)
  • packages/api/router/location/query.getAddress.handler.ts (1 hunks)
  • packages/api/router/organization/query.forOrgPage.handler.ts (1 hunks)
  • packages/api/router/organization/query.forOrgPageEdits.handler.ts (1 hunks)
  • packages/db/client/index.ts (1 hunks)
  • packages/db/prisma/data-migrations/index.ts (1 hunks)
  • packages/db/prisma/migrations/20240614194612_address_visibility/migration.sql (1 hunks)
  • packages/db/prisma/schema.prisma (2 hunks)
  • packages/ui/components/core/Toolbar.stories.tsx (1 hunks)
  • packages/ui/components/data-portal/AddressDrawer.tsx (4 hunks)
  • packages/ui/components/data-portal/LocationDrawer/index.tsx (5 hunks)
  • packages/ui/components/sections/ListingBasicInfo.tsx (1 hunks)
  • packages/ui/components/sections/LocationCard.tsx (2 hunks)
  • packages/ui/mockData/json/location.forLocationCard.json (1 hunks)
  • packages/ui/mockData/location.ts (1 hunks)
  • packages/ui/mockData/service.ts (1 hunks)
  • packages/ui/modals/MoreFilter.stories.tsx (2 hunks)
  • packages/ui/modals/MoreFilter.tsx (1 hunks)
Files skipped from review due to trivial changes (6)
  • InReach.code-workspace
  • apps/app/src/types/nextjs-routes.d.ts
  • packages/api/router/location/query.getAddress.handler.ts
  • packages/ui/components/core/Toolbar.stories.tsx
  • packages/ui/mockData/json/location.forLocationCard.json
  • packages/ui/mockData/location.ts
Additional context used
Biome
packages/api/router/location/lib.formatAddressVisibility.ts

[error] 22-22: Useless case clause. (lint/complexity/noUselessSwitchCase)

because the default clause is present:

Unsafe fix: Remove the useless case.

packages/db/client/index.ts

[error] 55-55: Shouldn't redeclare 'prisma'. Consider to delete it or rename it. (lint/suspicious/noRedeclare)

'prisma' is defined here:

packages/ui/components/data-portal/LocationDrawer/index.tsx

[error] 60-62: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

packages/ui/components/sections/ListingBasicInfo.tsx

[error] 134-141: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (24)
packages/db/prisma/data-migrations/index.ts (1)

Line range hint 1-6: Verify the new data migration exports.

The newly added exports for data migration scripts should be verified to ensure they are correctly implemented and match the intended functionality changes described in the PR.

Verification successful

Verify the new data migration exports.

The newly added export statements in packages/db/prisma/data-migrations/index.ts have been verified. All the referenced files exist and their initial lines indicate that they are correctly implemented.

  • packages/db/prisma/data-migrations/2024-03-21_attribute-supplement-schemas.ts
  • packages/db/prisma/data-migrations/2024-04-03_access-instruction-schemas.ts
  • packages/db/prisma/data-migrations/2024-04-24_update-crowdin-ids.ts
  • packages/db/prisma/data-migrations/2024-04-25_translation-activation-flag.ts
  • packages/db/prisma/data-migrations/2024-06-14_update-baltimore-to-reflect-city-and-county-options.ts
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the new data migration exports are correctly implemented.

# Test: List all export statements and manually verify if they match the intended functionality changes.
cat packages/db/prisma/data-migrations/index.ts | grep 'export'

Length of output: 363



Script:

#!/bin/bash
# Verify the existence of each exported file

files=(
  "packages/db/prisma/data-migrations/2024-03-21_attribute-supplement-schemas.ts"
  "packages/db/prisma/data-migrations/2024-04-03_access-instruction-schemas.ts"
  "packages/db/prisma/data-migrations/2024-04-24_update-crowdin-ids.ts"
  "packages/db/prisma/data-migrations/2024-04-25_translation-activation-flag.ts"
  "packages/db/prisma/data-migrations/2024-06-14_update-baltimore-to-reflect-city-and-county-options.ts"
)

for file in "${files[@]}"; do
  if [[ -f "$file" ]]; then
    echo "$file exists."
  else
    echo "$file is missing."
  fi
done

Length of output: 1939



Script:

#!/bin/bash
# Display the first few lines of each exported file to verify their contents

files=(
  "packages/db/prisma/data-migrations/2024-03-21_attribute-supplement-schemas.ts"
  "packages/db/prisma/data-migrations/2024-04-03_access-instruction-schemas.ts"
  "packages/db/prisma/data-migrations/2024-04-24_update-crowdin-ids.ts"
  "packages/db/prisma/data-migrations/2024-04-25_translation-activation-flag.ts"
  "packages/db/prisma/data-migrations/2024-06-14_update-baltimore-to-reflect-city-and-county-options.ts"
)

for file in "${files[@]}"; do
  echo "Contents of $file:"
  head -n 10 "$file"
  echo "-----------------------------------"
done

Length of output: 4148

packages/db/prisma/migrations/20240614194612_address_visibility/migration.sql (1)

1-29: Review SQL migration script for address visibility changes.

The SQL script properly handles the migration for the new AddressVisibility enum and updates the OrgLocation table accordingly. However, ensure that the script is tested on a backup of the production database to catch any potential issues with existing data, especially concerning the city column's requirement change.

packages/api/router/location/mutation.create.schema.ts (1)

Line range hint 1-24: Review the Zod schema for creating a location entity.

The Zod schema correctly enforces the new addressVisibility field using PrismaEnums. This aligns with the PR's objectives to handle address visibility settings. Ensure that all dependent systems are updated to handle these schema changes.

packages/api/router/location/query.forLocationPage.handler.ts (1)

Line range hint 1-37: Review the API handler for the location page.

The handler function correctly integrates the new addressVisibility field and utilizes the formatAddressVisibility function to format the address data. This change aligns with the PR's objectives to enhance address visibility handling.

packages/api/router/organization/query.forOrgPageEdits.handler.ts (1)

Line range hint 1-34: Review the API handler for organization page edits.

The handler function correctly integrates the new addressVisibility field and ensures it is included in the data fetched for organization page edits. This change aligns with the PR's objectives to enhance address visibility handling.

packages/ui/modals/MoreFilter.stories.tsx (1)

8-8: Ensure consistent export of MoreFilter component.

The code change reflects a change in how MoreFilter is exported and used, which aligns with the alterations mentioned in the summary. Ensure that this new export pattern is consistently applied across the project, especially in places where MoreFilter is imported.

packages/api/router/organization/query.forOrgPage.handler.ts (1)

39-39: Approved addition of addressVisibility in API handler.

The inclusion of addressVisibility in the select query aligns with the database schema changes and the PR's objectives to handle visibility settings. This change is necessary to ensure the frontend receives the correct data based on the new visibility rules.

packages/api/router/location/query.forVisitCard.handler.ts (1)

6-6: Integration of formatAddressVisibility and updates to address visibility handling.

The changes here integrate the new formatAddressVisibility function and update the visibility filtering logic. This is crucial for maintaining consistency in how address visibility is handled across different parts of the application.

Ensure that the formatAddressVisibility function is thoroughly tested to handle all expected input variations effectively.

Also applies to: 15-15, 32-32, 41-41

packages/ui/mockData/service.ts (1)

9-9: Ensure correct typing for API output.

The casting of data as ApiOutput['service']['forServiceInfoCard'] is a good practice to ensure type safety. This change helps maintain consistency in how data types are handled and ensures that the components consuming this data can rely on its structure.

packages/db/client/index.ts (1)

62-62: Ensure proper export of PrismaEnums for address visibility.

The addition of PrismaEnums export is crucial for handling the new addressVisibility field consistently across the application. This change appears to be correctly implemented.

packages/api/router/location/query.forLocationCard.handler.ts (2)

6-6: Good integration of address formatting utility.

Importing formatAddressVisibility is essential for applying the new address visibility rules within the location card context. This change supports the feature's requirements effectively.


53-53: Proper application of address visibility formatting.

The application of formatAddressVisibility to the query result ensures that the address data is correctly transformed according to the visibility settings before being sent to the client.

packages/api/router/location/query.forGoogleMaps.handler.ts (1)

33-41: Enhanced query logic for address visibility in maps.

The modification to include addressVisibility in the query conditions is crucial for ensuring that only appropriately visible locations are processed for map displays. This change aligns well with the privacy and visibility requirements of the feature.

packages/api/router/location/mutation.update.schema.ts (2)

3-3: Updated import to support address visibility in update operations.

Importing PrismaEnums is necessary for defining the addressVisibility field in the update schema. This change is correctly implemented to support the feature.


33-33: Enhanced schema logic for address visibility in updates.

The inclusion of addressVisibility in the update schema is crucial for ensuring that updates to location data adhere to the new visibility rules. This change aligns well with the privacy and visibility requirements of the feature.

packages/api/router/location/query.forLocationPageEdits.handler.ts (1)

27-27: Correct integration of address visibility in edit page queries.

The inclusion of addressVisibility in the query conditions is crucial for ensuring that the edit page for locations respects the new visibility rules. This change aligns well with the privacy and visibility requirements of the feature.

packages/ui/components/data-portal/LocationDrawer/index.tsx (2)

64-68: Add a clarifying comment for address visibility options.

It would be beneficial to include a comment explaining the purpose of the addressVisibilityOptions array, especially for future maintainability and understanding of how these options are used within the UI.

+ // Options for user to select how their address is displayed on the platform
  const addressVisibilityOptions: Record<'value' | 'label', string>[] = [
    { value: 'FULL', label: 'Show full address' },
    { value: 'PARTIAL', label: 'Show city & state/province' },
    { value: 'HIDDEN', label: 'Hide address' },
  ]

94-99: Ensure proper handling of the Select component for address visibility.

The integration of the Select component for address visibility is correctly implemented. It uses the addressVisibilityOptions for user selection, which aligns with the PR's objectives to manage address visibility settings. Ensure that the Select component's behavior is thoroughly tested, especially its interaction with the form's state and the backend.

packages/ui/components/sections/ListingBasicInfo.tsx (1)

30-33: Address visibility logic correctly implemented in UI display.

The conditional rendering based on the addressVisibility property is implemented correctly. This checks if the address should be hidden and, if not, displays it. This change is consistent with the new address visibility feature introduced in the PR.

packages/ui/components/sections/LocationCard.tsx (1)

324-326: Correct implementation of conditional rendering based on address visibility.

The logic to conditionally render address details based on the addressVisibility field is implemented correctly. This ensures that the address is displayed only when it is not set to 'HIDDEN', which is a crucial part of the feature being added in this PR.

[APROVED]

packages/ui/modals/MoreFilter.tsx (1)

518-518: Interface definition for MoreFilterProps is clear and concise.

The MoreFilterProps interface is well-defined, providing clear type definitions for props used in the MoreFilter component. This ensures type safety and improves the maintainability of the code.

packages/ui/components/data-portal/AddressDrawer.tsx (2)

163-167: Good addition of addressVisibilityOptions for UI consistency.

This change introduces a clear and user-friendly way to handle address visibility settings in the UI, aligning with the feature's requirements.


471-475: Proper integration of addressVisibility selection in the form.

Adding a Select component for addressVisibility with a default value of 'FULL' is a good practice, ensuring that there's always a valid state for this field.

packages/db/prisma/schema.prisma (1)

691-695: Approval of the AddressVisibility enum definition

The new AddressVisibility enum with values FULL, PARTIAL, and HIDDEN is well-defined. This enum provides clear options for setting the visibility of addresses, which can be utilized across different parts of the application to conditionally display address information based on this setting.

  • Usage: Ensure that the application logic that consumes this enum handles all three cases correctly, especially in UI components where address visibility is critical.
  • Integration: Check integration points where this enum replaces previous boolean flags or other visibility indicators to ensure seamless transition and correct behavior across the application.

The definition and default usage of the AddressVisibility enum are appropriate and follow best practices for handling conditional visibility in a scalable and maintainable way.

@kodiakhq kodiakhq bot merged commit 2447dd7 into dev Jun 25, 2024
59 of 62 checks passed
@kodiakhq kodiakhq bot deleted the IN-984-re-require-city branch June 25, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 api 📦 app automerge Enable Kodiak auto-merge 📦 db kodiak: merge.method = 'squash' Kodiak will squash merge this PR. new-feature New features or options. 📦 ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants