Compare commits

..

2 Commits

Author SHA1 Message Date
b22f577cc2 fix: marking 2024-08-15 12:25:37 +03:00
2becab9f79 feat(pdf-marking): integrates UserDetails 2024-08-15 12:23:35 +03:00
3 changed files with 13 additions and 7 deletions

View File

@ -14,6 +14,8 @@ import styles from './style.module.scss'
import { CurrentUserFile } from '../../types/file.ts' import { CurrentUserFile } from '../../types/file.ts'
import FileList from '../FileList' import FileList from '../FileList'
import { StickySideColumns } from '../../layouts/StickySideColumns.tsx' import { StickySideColumns } from '../../layouts/StickySideColumns.tsx'
import { UsersDetails } from '../UsersDetails.tsx'
import { Meta } from '../../types'
interface PdfMarkingProps { interface PdfMarkingProps {
files: CurrentUserFile[] files: CurrentUserFile[]
@ -22,6 +24,7 @@ interface PdfMarkingProps {
setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void
setUpdatedMarks: (markToUpdate: Mark) => void setUpdatedMarks: (markToUpdate: Mark) => void
handleDownload: () => void handleDownload: () => void
meta: Meta | null
} }
/** /**
@ -37,7 +40,8 @@ const PdfMarking = (props: PdfMarkingProps) => {
setIsReadyToSign, setIsReadyToSign,
setCurrentUserMarks, setCurrentUserMarks,
setUpdatedMarks, setUpdatedMarks,
handleDownload handleDownload,
meta
} = props } = props
const [selectedMark, setSelectedMark] = useState<CurrentUserMark | null>(null) const [selectedMark, setSelectedMark] = useState<CurrentUserMark | null>(null)
const [selectedMarkValue, setSelectedMarkValue] = useState<string>('') const [selectedMarkValue, setSelectedMarkValue] = useState<string>('')
@ -81,8 +85,8 @@ const PdfMarking = (props: PdfMarkingProps) => {
} }
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => { const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault(); event.preventDefault()
if (!selectedMarkValue || !selectedMark) return; if (!selectedMarkValue || !selectedMark) return
const updatedMark: CurrentUserMark = getUpdatedMark( const updatedMark: CurrentUserMark = getUpdatedMark(
selectedMark, selectedMark,
@ -126,6 +130,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
)} )}
</div> </div>
} }
right={meta !== null && <UsersDetails meta={meta} />}
> >
<div className={styles.container}> <div className={styles.container}>
{currentUserMarks?.length > 0 && ( {currentUserMarks?.length > 0 && (

View File

@ -35,10 +35,10 @@ const PdfView = ({
}, [currentFile]) }, [currentFile])
const filterByFile = ( const filterByFile = (
currentUserMarks: CurrentUserMark[], currentUserMarks: CurrentUserMark[],
fileName: string hash: string
): CurrentUserMark[] => { ): CurrentUserMark[] => {
return currentUserMarks.filter( return currentUserMarks.filter(
(currentUserMark) => currentUserMark.mark.fileName === fileName (currentUserMark) => currentUserMark.mark.pdfFileHash === hash
) )
} }
const isNotLastPdfFile = (index: number, files: CurrentUserFile[]): boolean => const isNotLastPdfFile = (index: number, files: CurrentUserFile[]): boolean =>
@ -46,7 +46,7 @@ const PdfView = ({
return ( return (
<> <>
{files.map((currentUserFile, index, arr) => { {files.map((currentUserFile, index, arr) => {
const { hash, pdfFile, filename, id } = currentUserFile const { hash, pdfFile, id } = currentUserFile
if (!hash) return if (!hash) return
return ( return (
<div <div
@ -56,7 +56,7 @@ const PdfView = ({
> >
<PdfItem <PdfItem
pdfFile={pdfFile} pdfFile={pdfFile}
currentUserMarks={filterByFile(currentUserMarks, filename)} currentUserMarks={filterByFile(currentUserMarks, hash)}
selectedMark={selectedMark} selectedMark={selectedMark}
handleMarkClick={handleMarkClick} handleMarkClick={handleMarkClick}
selectedMarkValue={selectedMarkValue} selectedMarkValue={selectedMarkValue}

View File

@ -958,6 +958,7 @@ export const SignPage = () => {
setCurrentUserMarks={setCurrentUserMarks} setCurrentUserMarks={setCurrentUserMarks}
setUpdatedMarks={setUpdatedMarks} setUpdatedMarks={setUpdatedMarks}
handleDownload={handleDownload} handleDownload={handleDownload}
meta={meta}
/> />
) )
} }