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

174 lines
7.1 KiB
TypeScript
Raw Normal View History

2024-04-18 21:56:31 +07:00
'use client';
import { useState } from 'react';
import { Trans } from '@lingui/macro';
import { useLingui } from '@lingui/react';
import { Clock, 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';
import { parseMessageDescriptor } from '@documenso/lib/utils/i18n';
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';
import { SignatureIcon } from '@documenso/ui/icons/signature';
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 { Badge } from '@documenso/ui/primitives/badge';
2024-04-18 21:56:31 +07:00
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;
showFieldStatus?: boolean;
2024-04-18 21:56:31 +07:00
};
export const DocumentReadOnlyFields = ({
documentMeta,
fields,
showFieldStatus = true,
}: DocumentReadOnlyFieldsProps) => {
const { _ } = useLingui();
2024-04-18 21:56:31 +07:00
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">
2025-01-13 13:41:53 +11:00
{extractInitials(field.recipient.name || field.recipient.email)}
2024-04-18 21:56:31 +07:00
</AvatarFallback>
</Avatar>
}
contentProps={{
className: 'relative flex w-fit flex-col p-4 text-sm',
2024-04-18 21:56:31 +07:00
}}
>
{showFieldStatus && (
<Badge
className="mx-auto mb-1 py-0.5"
variant={
2025-01-13 13:41:53 +11:00
field.recipient.signingStatus === SigningStatus.SIGNED
? 'default'
: 'secondary'
}
>
2025-01-13 13:41:53 +11:00
{field.recipient.signingStatus === SigningStatus.SIGNED ? (
<>
<SignatureIcon className="mr-1 h-3 w-3" />
<Trans>Signed</Trans>
</>
) : (
<>
<Clock className="mr-1 h-3 w-3" />
<Trans>Pending</Trans>
</>
)}
</Badge>
)}
<p className="text-center font-semibold">
<span>{parseMessageDescriptor(_, FRIENDLY_FIELD_TYPE[field.type])} field</span>
2024-04-18 21:56:31 +07:00
</p>
<p className="text-muted-foreground mt-1 text-center text-xs">
2025-01-13 13:41:53 +11:00
{field.recipient.name
? `${field.recipient.name} (${field.recipient.email})`
: field.recipient.email}{' '}
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>
<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">
2025-01-13 13:41:53 +11:00
{field.recipient.signingStatus === SigningStatus.SIGNED &&
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
match(field)
.with({ type: FieldType.SIGNATURE }, (field) =>
2025-01-13 13:41:53 +11:00
field.signature?.signatureImageAsBase64 ? (
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
<img
2025-01-13 13:41:53 +11:00
src={field.signature.signatureImageAsBase64}
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
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">
2025-01-13 13:41:53 +11:00
{field.signature?.typedSignature}
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>
),
)
.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()}
2025-01-13 13:41:53 +11:00
{field.recipient.signingStatus === SigningStatus.NOT_SIGNED && (
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={cn('text-muted-foreground text-lg duration-200', {
'font-signature sm:text-xl md:text-2xl':
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.type === FieldType.SIGNATURE ||
field.type === FieldType.FREE_SIGNATURE,
})}
>
{parseMessageDescriptor(_, FRIENDLY_FIELD_TYPE[field.type])}
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>
)}
2024-04-18 21:56:31 +07:00
</div>
</FieldRootContainer>
),
)}
</ElementVisible>
);
};