import { Divider, Tooltip } from '@mui/material' import { formatTimestamp, fromUnixTimestamp, hexToNpub, npubToHex, SigitStatus, SignStatus } from '../../utils' import { useSigitMeta } from '../../hooks/useSigitMeta' import { UserAvatarGroup } from '../UserAvatarGroup' import styles from './style.module.scss' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faCalendar, faCalendarCheck, faCalendarPlus, faCheck, faClock, faEye, faFile, faFileCircleExclamation } from '@fortawesome/free-solid-svg-icons' import { getExtensionIconLabel } from '../getExtensionIconLabel' import { useAppSelector } from '../../hooks/store' import { DisplaySigner } from '../DisplaySigner' import { Meta, OpenTimestamp } from '../../types' import { extractFileExtensions } from '../../utils/file' import { UserAvatar } from '../UserAvatar' interface UsersDetailsProps { meta: Meta } export const UsersDetails = ({ meta }: UsersDetailsProps) => { const { submittedBy, exportedBy, signers, viewers, fileHashes, signersStatus, createdAt, completedAt, parsedSignatureEvents, signedStatus, isValid, id, timestamps } = useSigitMeta(meta) const { usersPubkey } = useAppSelector((state) => state.auth) const userCanSign = typeof usersPubkey !== 'undefined' && signers.includes(hexToNpub(usersPubkey)) const { extensions, isSame } = extractFileExtensions(Object.keys(fileHashes)) const isTimestampVerified = ( timestamps: OpenTimestamp[], nostrId: string ): boolean => { const matched = timestamps.find((t) => t.nostrId === nostrId) return !!(matched && matched.verification) } const getOpenTimestampsInfo = ( timestamps: OpenTimestamp[], nostrId: string ) => { if (isTimestampVerified(timestamps, nostrId)) { return } else { return } } const getCompletedOpenTimestampsInfo = (timestamp: OpenTimestamp) => { if (timestamp.verification) { return } else { return } } const getTimestampTooltipTitle = (label: string, isVerified: boolean) => { return `${label} / Open Timestamp ${isVerified ? 'Verified' : 'Pending'}` } const isUserSignatureTimestampVerified = () => { if ( userCanSign && hexToNpub(usersPubkey) in parsedSignatureEvents && timestamps && timestamps.length > 0 ) { const nostrId = parsedSignatureEvents[hexToNpub(usersPubkey)].id return isTimestampVerified(timestamps, nostrId) } return false } return submittedBy ? (

Signers

{submittedBy && ( )} {submittedBy && signers.length ? ( ) : null} {signers.map((signer) => { const pubkey = npubToHex(signer)! return ( ) })}
{viewers.length > 0 && ( <>

Viewers

{viewers.map((signer) => { const pubkey = npubToHex(signer)! return ( ) })}
)} {exportedBy && ( <>

Exported By

)}

Details

{' '} {createdAt ? formatTimestamp(createdAt) : <>—}{' '} {timestamps && timestamps.length > 0 && id && ( {getOpenTimestampsInfo(timestamps, id)} )} 0 && timestamps[timestamps.length - 1].verification ) )} placement="top" arrow disableInteractive > {' '} {completedAt ? formatTimestamp(completedAt) : <>—} {signedStatus === SigitStatus.Complete && completedAt && timestamps && timestamps.length > 0 && ( {getCompletedOpenTimestampsInfo( timestamps[timestamps.length - 1] )} )} {/* User signed date */} {userCanSign ? ( {' '} {hexToNpub(usersPubkey) in parsedSignatureEvents ? ( parsedSignatureEvents[hexToNpub(usersPubkey)].created_at ? ( formatTimestamp( fromUnixTimestamp( parsedSignatureEvents[hexToNpub(usersPubkey)].created_at ) ) ) : ( <>— ) ) : ( <>— )} {hexToNpub(usersPubkey) in parsedSignatureEvents && timestamps && timestamps.length > 0 && ( {getOpenTimestampsInfo( timestamps, parsedSignatureEvents[hexToNpub(usersPubkey)].id )} )} ) : null} {signedStatus} {extensions.length > 0 ? ( {!isSame ? ( <> Multiple File Types ) : ( getExtensionIconLabel(extensions[0]) )} ) : ( <> — )}
) : undefined }