mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-30 14:57:59 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import React, { useRef } from 'react';
|
|
|
|
import type { MessageDescriptor } from '@lingui/core';
|
|
import { Trans, useLingui } from '@lingui/react/macro';
|
|
|
|
import { useCurrentEnvelopeRender } from '@hanzo/esign-lib/client-only/providers/envelope-render-provider';
|
|
import { PDF_VIEWER_ERROR_MESSAGES } from '@hanzo/esign-lib/constants/pdf-viewer-i18n';
|
|
import { cn } from '@hanzo/esign-ui/lib/utils';
|
|
import { Alert, AlertDescription, AlertTitle } from '@hanzo/esign-ui/primitives/alert';
|
|
|
|
import { PDFViewer, type PDFViewerProps } from './pdf-viewer';
|
|
|
|
export type EnvelopePdfViewerProps = {
|
|
/**
|
|
* The error message to render when there is an error.
|
|
*/
|
|
errorMessage: { title: MessageDescriptor; description: MessageDescriptor } | null;
|
|
} & Omit<PDFViewerProps, 'data'>;
|
|
|
|
export const EnvelopePdfViewer = ({
|
|
errorMessage,
|
|
className,
|
|
...props
|
|
}: EnvelopePdfViewerProps) => {
|
|
const { t } = useLingui();
|
|
|
|
const $el = useRef<HTMLDivElement>(null);
|
|
|
|
const { currentEnvelopeItem, renderError } = useCurrentEnvelopeRender();
|
|
|
|
if (renderError || !currentEnvelopeItem) {
|
|
return (
|
|
<div ref={$el} className={cn('h-full w-full max-w-[800px]', className)} {...props}>
|
|
{renderError ? (
|
|
<Alert variant="destructive" className="mb-4 max-w-[800px]">
|
|
<AlertTitle>
|
|
{t(errorMessage?.title || PDF_VIEWER_ERROR_MESSAGES.default.title)}
|
|
</AlertTitle>
|
|
<AlertDescription>
|
|
{t(errorMessage?.description || PDF_VIEWER_ERROR_MESSAGES.default.description)}
|
|
</AlertDescription>
|
|
</Alert>
|
|
) : (
|
|
<div className="flex h-[80vh] max-h-[60rem] w-full flex-col items-center justify-center overflow-hidden rounded">
|
|
<p className="text-sm text-muted-foreground">
|
|
<Trans>No document found</Trans>
|
|
</p>
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<PDFViewer
|
|
{...props}
|
|
className={cn('h-full w-full max-w-[800px]', className)}
|
|
data={currentEnvelopeItem.data}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default EnvelopePdfViewer;
|