diff --git a/apps/remix/app/components/general/document/document-history-sheet.tsx b/apps/remix/app/components/general/document/document-history-sheet.tsx deleted file mode 100644 index 5320967b0..000000000 --- a/apps/remix/app/components/general/document/document-history-sheet.tsx +++ /dev/null @@ -1,429 +0,0 @@ -import { useMemo, useState } from 'react'; - -import { useLingui } from '@lingui/react'; -import { Trans } from '@lingui/react/macro'; -import { ArrowRightIcon, Loader } from 'lucide-react'; -import { DateTime } from 'luxon'; -import { match } from 'ts-pattern'; -import { UAParser } from 'ua-parser-js'; - -import { DOCUMENT_AUDIT_LOG_EMAIL_FORMAT } from '@documenso/lib/constants/document-audit-logs'; -import { DOCUMENT_AUTH_TYPES } from '@documenso/lib/constants/document-auth'; -import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs'; -import { formatDocumentAuditLogAction } from '@documenso/lib/utils/document-audit-logs'; -import { trpc } from '@documenso/trpc/react'; -import { cn } from '@documenso/ui/lib/utils'; -import { Avatar, AvatarFallback } from '@documenso/ui/primitives/avatar'; -import { Badge } from '@documenso/ui/primitives/badge'; -import { Button } from '@documenso/ui/primitives/button'; -import { Sheet, SheetContent, SheetTrigger } from '@documenso/ui/primitives/sheet'; - -import { DocumentHistorySheetChanges } from './document-history-sheet-changes'; - -export type DocumentHistorySheetProps = { - documentId: number; - userId: number; - isMenuOpen?: boolean; - onMenuOpenChange?: (_value: boolean) => void; - children?: React.ReactNode; -}; - -export const DocumentHistorySheet = ({ - documentId, - userId, - isMenuOpen, - onMenuOpenChange, - children, -}: DocumentHistorySheetProps) => { - const { _, i18n } = useLingui(); - - const [isUserDetailsVisible, setIsUserDetailsVisible] = useState(false); - - const { - data, - isLoading, - isLoadingError, - refetch, - hasNextPage, - fetchNextPage, - isFetchingNextPage, - } = trpc.document.findDocumentAuditLogs.useInfiniteQuery( - { - documentId, - }, - { - getNextPageParam: (lastPage) => lastPage.nextCursor, - placeholderData: (previousData) => previousData, - }, - ); - - const documentAuditLogs = useMemo(() => (data?.pages ?? []).flatMap((page) => page.data), [data]); - - const extractBrowser = (userAgent?: string | null) => { - if (!userAgent) { - return 'Unknown'; - } - - const parser = new UAParser(userAgent); - - parser.setUA(userAgent); - - const result = parser.getResult(); - - return result.browser.name; - }; - - /** - * Applies the following formatting for a given text: - * - Uppercase first lower, lowercase rest - * - Replace _ with spaces - * - * @param text The text to format - * @returns The formatted text - */ - const formatGenericText = (text?: string | string[] | null): string => { - if (!text) { - return ''; - } - - if (Array.isArray(text)) { - return text.map((t) => formatGenericText(t)).join(', '); - } - - return (text.charAt(0).toUpperCase() + text.slice(1).toLowerCase()).replaceAll('_', ' '); - }; - - return ( - - {children && {children}} - - -
-

- Document history -

- -
- - {isLoading && ( -
- -
- )} - - {isLoadingError && ( -
-

- Unable to load document history -

- -
- )} - - {data && ( - - )} -
-
- ); -};