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: show field on pending document #1158

Merged
merged 9 commits into from
Jun 24, 2024
Merged

fix: show field on pending document #1158

merged 9 commits into from
Jun 24, 2024

Conversation

ephraimduncan
Copy link
Contributor

@ephraimduncan ephraimduncan commented May 14, 2024

Description

This pull request introduces the functionality to display pending fields on the document page view. This enhancement allows users to see which fields are pending and need to be completed.

CleanShot 2024-05-14 at 23 31 29@2x

Changes Made

  • Added getPendingFieldsForDocument function in packages/lib/server-only/field/get-pending-fields-for-document.ts to fetch pending fields for a document.
  • Created a new component DocumentPendingFields in document-pending-fields.tsx to display the pending fields with options to hide individual fields.

Testing Performed

  • Tested the new feature by creating documents with pending fields and verifying their display on the document page view.
  • Verified that the pending fields are correctly hidden when the "Hide field" button is clicked.
  • Ran unit tests for the new functionality and existing components to ensure no regressions.

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Additional Notes

No additional notes.

Summary by CodeRabbit

  • New Features

    • Introduced logic for handling pending and completed document fields based on signing status.
  • Refactor

    • Replaced getCompletedFieldsForDocument with getFieldsForDocument.
    • Updated DocumentReadOnlyFields component to DocumentPendingFields.
  • Bug Fixes

    • Improved field retrieval accuracy and display based on recipient signing status.
  • Style

    • Enhanced UI elements with new icons and button adjustments for better user interaction.

Copy link

vercel bot commented May 14, 2024

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

Name Status Preview Comments Updated (UTC)
stg-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 6:05am
stg-docs ❌ Failed (Inspect) Jun 24, 2024 6:05am
stg-marketing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 24, 2024 6:05am
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
prd-app ⬜️ Ignored (Inspect) Jun 24, 2024 6:05am
prd-marketing ⬜️ Ignored (Inspect) Jun 24, 2024 6:05am

Copy link
Contributor

coderabbitai bot commented May 14, 2024

Walkthrough

The updates in this codebase primarily involve refactoring field retrieval functions and adjusting related components. The getCompletedFieldsForDocument function is now getFieldsForDocument, bringing a more inclusive approach to field data. Similarly, DocumentReadOnlyFields has been switched to DocumentPendingFields, allowing for a distinction between pending and completed fields based on signing status.

Changes

Files/Paths Change Summary
apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx Replaced getCompletedFieldsForDocument with getFieldsForDocument. Switched to DocumentPendingFields for field rendering logic based on signing status.
apps/web/src/components/document/document-read-only-fields.tsx Updated imports and type declarations. Replaced CompletedField with DocumentField. Adjustments to rendering logic based on signingStatus.
packages/lib/server-only/field/get-fields-for-document.ts Updated to include additional recipient details when retrieving document fields.
packages/lib/server-only/field/get-completed-fields-for-token.ts Added signingStatus to the fields selected in the getCompletedFieldsForToken function.

Poem

In the meadow of code, fields anew do grow,
From pending to signed, their statuses show.
A tweak here and there, functions aligned,
Now documents flourish, perfectly designed.
With type-safe grace and logic refined,
Our web app shines, a marvel defined. 🌸📝


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.

@github-actions github-actions bot added the apps: web Issues related to the webapp label May 14, 2024
Copy link

🚨 @ephraimduncan has 4 pull requests awaiting review. Please consider reviewing them when possible. 🚨

@ephraimduncan ephraimduncan requested a review from dguyen May 14, 2024 23:32
@github-actions github-actions bot added the apps: marketing Issues related to website or marketing app label Jun 18, 2024
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 9a48da5 and 3f81603.

Files selected for processing (3)
  • apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx (4 hunks)
  • apps/web/src/components/document/document-pending-readonly-fields.tsx (1 hunks)
  • packages/lib/server-only/field/get-fields-for-document.ts (1 hunks)
Additional comments not posted (3)
packages/lib/server-only/field/get-fields-for-document.ts (1)

29-38: Well-implemented query inclusion for recipient details in document fields.

The inclusion of Signature and detailed recipient information (name, email, signingStatus) in the getFieldsForDocument function is well-aligned with the PR's objectives to enhance handling of document fields. This change supports the frontend's ability to filter and display fields based on signing status, which is crucial for the new functionality.

apps/web/src/components/document/document-pending-readonly-fields.tsx (1)

19-78: Excellent implementation of the DocumentPendingFields component.

The component is well-designed with clear separation of concerns. The use of useState to manage the visibility of fields and the handleHideField method to update this state are appropriate. The rendering logic inside ElementVisible is clean, and the use of PopoverHover and Avatar components enhances the user interface. This implementation aligns well with the PR's objective to allow users to interact with pending fields effectively.

apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx (1)

Line range hint 89-174: Effective integration of field handling in the document page view.

The integration of DocumentPendingFields for displaying pending fields based on the document status is well executed. The use of Promise.all to fetch recipients and fields concurrently is efficient and improves page load performance. The filtering logic to separate pending and completed fields based on the SigningStatus is clear and functional. This setup ensures that the UI components receive the correct data subset to work with, which is crucial for maintaining a responsive and accurate user interface.
[APROVED]

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3f81603 and efbe60b.

Files selected for processing (4)
  • apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx (3 hunks)
  • apps/web/src/components/document/document-read-only-fields.tsx (3 hunks)
  • packages/lib/server-only/field/get-completed-fields-for-token.ts (1 hunks)
  • packages/lib/server-only/field/get-fields-for-document.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx
  • packages/lib/server-only/field/get-fields-for-document.ts
Additional context used
Biome
apps/web/src/components/document/document-read-only-fields.tsx

[error] 71-75: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

Additional comments not posted (4)
packages/lib/server-only/field/get-completed-fields-for-token.ts (1)

29-29: Approved addition of signingStatus in the selection object.

This change enhances the data retrieved by including the signing status, which is crucial for the new functionality related to handling document fields based on their signing status.

apps/web/src/components/document/document-read-only-fields.tsx (3)

5-5: Approved new imports for UI enhancements.

The addition of EyeOffIcon and match supports new UI functionalities, such as hiding fields and matching field types for rendering, which aligns with the PR objectives.


14-14: Approved update of type from CompletedField to DocumentField.

This change aligns with the updated data handling strategy across the application, ensuring consistency in how document fields are managed.


17-17: Approved addition of FieldType and SigningStatus for enhanced field handling.

Incorporating these types from prisma/client directly into the component allows for more precise control over the rendering based on the field's type and signing status.

Comment on lines +71 to 75
<button
className="absolute right-0 top-0 my-1 p-2 focus:outline-none focus-visible:ring-0"
onClick={() => handleHideField(field.secondaryId)}
title="Hide field"
>
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an explicit type attribute to the button to prevent form submission issues.

The button used to hide fields should have an explicit type='button' to ensure it does not inadvertently submit forms if nested within one.

- <button
+ <button type="button"

Committable suggestion was skipped due to low confidence.

Tools
Biome

[error] 71-75: Provide an explicit type prop for the button element. (lint/a11y/useButtonType)

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

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 efbe60b and f45d42c.

Files selected for processing (1)
  • apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/app/(dashboard)/documents/[id]/document-page-view.tsx

@dguyen dguyen merged commit 16c6d4a into main Jun 24, 2024
14 of 15 checks passed
@dguyen dguyen deleted the feat/show-fields branch June 24, 2024 06:08
@coderabbitai coderabbitai bot mentioned this pull request Sep 8, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apps: marketing Issues related to website or marketing app apps: web Issues related to the webapp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants