Files
sign/apps/web/src/components/document/document-read-only-fields.tsx

140 lines
6.0 KiB
TypeScript
Raw Normal View History

2024-04-18 21:56:31 +07:00
'use client';
import { useState } from 'react';
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
import { EyeOffIcon } from 'lucide-react';
2024-04-18 21:56:31 +07:00
import { P, match } from 'ts-pattern';
import {
DEFAULT_DOCUMENT_DATE_FORMAT,
convertToLocalSystemFormat,
} from '@documenso/lib/constants/date-formats';
import { PDF_VIEWER_PAGE_SELECTOR } from '@documenso/lib/constants/pdf-viewer';
import { DEFAULT_DOCUMENT_TIME_ZONE } from '@documenso/lib/constants/time-zones';
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
import type { DocumentField } from '@documenso/lib/server-only/field/get-fields-for-document';
2024-04-18 21:56:31 +07:00
import { extractInitials } from '@documenso/lib/utils/recipient-formatter';
import type { DocumentMeta } from '@documenso/prisma/client';
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
import { FieldType, SigningStatus } from '@documenso/prisma/client';
2024-04-18 21:56:31 +07:00
import { FieldRootContainer } from '@documenso/ui/components/field/field';
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
import { cn } from '@documenso/ui/lib/utils';
2024-04-18 21:56:31 +07:00
import { Avatar, AvatarFallback } from '@documenso/ui/primitives/avatar';
import { FRIENDLY_FIELD_TYPE } from '@documenso/ui/primitives/document-flow/types';
import { ElementVisible } from '@documenso/ui/primitives/element-visible';
import { PopoverHover } from '@documenso/ui/primitives/popover';
export type DocumentReadOnlyFieldsProps = {
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
fields: DocumentField[];
2024-04-18 21:56:31 +07:00
documentMeta?: DocumentMeta;
};
export const DocumentReadOnlyFields = ({ documentMeta, fields }: DocumentReadOnlyFieldsProps) => {
const [hiddenFieldIds, setHiddenFieldIds] = useState<Record<string, boolean>>({});
const handleHideField = (fieldId: string) => {
setHiddenFieldIds((prev) => ({ ...prev, [fieldId]: true }));
};
return (
<ElementVisible target={PDF_VIEWER_PAGE_SELECTOR}>
{fields.map(
(field) =>
!hiddenFieldIds[field.secondaryId] && (
<FieldRootContainer
field={field}
key={field.id}
cardClassName="border-gray-300/50 !shadow-none backdrop-blur-[1px] bg-gray-50 ring-0 ring-offset-0"
2024-04-18 21:56:31 +07:00
>
<div className="absolute -right-3 -top-3">
<PopoverHover
trigger={
<Avatar className="dark:border-foreground h-8 w-8 border-2 border-solid border-gray-200/50 transition-colors hover:border-gray-200">
2024-04-18 21:56:31 +07:00
<AvatarFallback className="bg-neutral-50 text-xs text-gray-400">
{extractInitials(field.Recipient.name || field.Recipient.email)}
</AvatarFallback>
</Avatar>
}
contentProps={{
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
className: 'relative flex w-fit flex-col p-2.5 text-sm',
2024-04-18 21:56:31 +07:00
}}
>
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
<p className="font-semibold">
{field.Recipient.signingStatus === SigningStatus.SIGNED ? 'Signed' : 'Pending'}{' '}
{FRIENDLY_FIELD_TYPE[field.type].toLowerCase()} field
2024-04-18 21:56:31 +07:00
</p>
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
<p className="text-muted-foreground text-xs">
{field.Recipient.name
? `${field.Recipient.name} (${field.Recipient.email})`
: field.Recipient.email}{' '}
</p>
<button
className="absolute right-0 top-0 my-1 p-2 focus:outline-none focus-visible:ring-0"
2024-04-18 21:56:31 +07:00
onClick={() => handleHideField(field.secondaryId)}
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
title="Hide field"
2024-04-18 21:56:31 +07:00
>
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
<EyeOffIcon className="h-3 w-3" />
</button>
2024-04-18 21:56:31 +07:00
</PopoverHover>
</div>
<div className="text-muted-foreground dark:text-background/70 break-all text-sm">
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
{field.Recipient.signingStatus === SigningStatus.SIGNED &&
match(field)
.with({ type: FieldType.SIGNATURE }, (field) =>
field.Signature?.signatureImageAsBase64 ? (
<img
src={field.Signature.signatureImageAsBase64}
alt="Signature"
className="h-full w-full object-contain dark:invert"
/>
) : (
<p className="font-signature text-muted-foreground text-lg duration-200 sm:text-xl md:text-2xl lg:text-3xl">
{field.Signature?.typedSignature}
</p>
),
)
.with(
{
type: P.union(
FieldType.NAME,
FieldType.INITIALS,
FieldType.EMAIL,
FieldType.NUMBER,
FieldType.RADIO,
FieldType.CHECKBOX,
FieldType.DROPDOWN,
),
},
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
() => field.customText,
)
.with({ type: FieldType.TEXT }, () => field.customText.substring(0, 20) + '...')
fix: show field on pending document (#1158) ## 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](https://github.com/documenso/documenso/assets/55143799/ffea0b29-d251-4dd5-9742-5416ac8262ad) ## 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 - [x] I have tested these changes locally and they work as expected. - [x] I have added/updated tests that prove the effectiveness of these changes. - [x] I have updated the documentation to reflect these changes, if applicable. - [x] 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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: David Nguyen <davidngu28@gmail.com>
2024-06-24 06:08:06 +00:00
.with({ type: FieldType.DATE }, () =>
convertToLocalSystemFormat(
field.customText,
documentMeta?.dateFormat ?? DEFAULT_DOCUMENT_DATE_FORMAT,
documentMeta?.timezone ?? DEFAULT_DOCUMENT_TIME_ZONE,
),
)
.with({ type: FieldType.FREE_SIGNATURE }, () => null)
.exhaustive()}
{field.Recipient.signingStatus === SigningStatus.NOT_SIGNED && (
<p
className={cn('text-muted-foreground text-lg duration-200', {
'font-signature sm:text-xl md:text-2xl lg:text-3xl':
field.type === FieldType.SIGNATURE ||
field.type === FieldType.FREE_SIGNATURE,
})}
>
{FRIENDLY_FIELD_TYPE[field.type]}
</p>
)}
2024-04-18 21:56:31 +07:00
</div>
</FieldRootContainer>
),
)}
</ElementVisible>
);
};