staging #223
@ -24,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
color: black
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left {
|
.left {
|
||||||
@ -51,7 +51,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.image-placeholder {
|
.image-placeholder {
|
||||||
width: 150px;
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
|
@ -804,7 +804,7 @@ export const SignPage = () => {
|
|||||||
navigate(appPublicRoutes.verify)
|
navigate(appPublicRoutes.verify)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleExportSigit = async () => {
|
const handleEncryptedExport = async () => {
|
||||||
if (Object.entries(files).length === 0 || !meta) return
|
if (Object.entries(files).length === 0 || !meta) return
|
||||||
|
|
||||||
const zip = new JSZip()
|
const zip = new JSZip()
|
||||||
@ -943,7 +943,7 @@ export const SignPage = () => {
|
|||||||
{signedStatus === SignedStatus.Fully_Signed && (
|
{signedStatus === SignedStatus.Fully_Signed && (
|
||||||
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
||||||
<Button onClick={handleExport} variant="contained">
|
<Button onClick={handleExport} variant="contained">
|
||||||
Export
|
Export Sigit
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
@ -958,8 +958,8 @@ export const SignPage = () => {
|
|||||||
|
|
||||||
{isSignerOrCreator && (
|
{isSignerOrCreator && (
|
||||||
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
||||||
<Button onClick={handleExportSigit} variant="contained">
|
<Button onClick={handleEncryptedExport} variant="contained">
|
||||||
Export Sigit
|
Export Encrypted Sigit
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
@ -8,7 +8,6 @@ import { NostrController } from '../../controllers'
|
|||||||
import { DocSignatureEvent, Meta } from '../../types'
|
import { DocSignatureEvent, Meta } from '../../types'
|
||||||
import {
|
import {
|
||||||
decryptArrayBuffer,
|
decryptArrayBuffer,
|
||||||
extractMarksFromSignedMeta,
|
|
||||||
getHash,
|
getHash,
|
||||||
hexToNpub,
|
hexToNpub,
|
||||||
unixNow,
|
unixNow,
|
||||||
@ -20,13 +19,7 @@ import {
|
|||||||
import styles from './style.module.scss'
|
import styles from './style.module.scss'
|
||||||
import { useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import {
|
import { FONT_SIZE, FONT_TYPE, inPx } from '../../utils/pdf.ts'
|
||||||
addMarks,
|
|
||||||
FONT_SIZE,
|
|
||||||
FONT_TYPE,
|
|
||||||
groupMarksByFileNamePage,
|
|
||||||
inPx
|
|
||||||
} from '../../utils/pdf.ts'
|
|
||||||
import { useAppSelector } from '../../hooks/store'
|
import { useAppSelector } from '../../hooks/store'
|
||||||
import { getLastSignersSig } from '../../utils/sign.ts'
|
import { getLastSignersSig } from '../../utils/sign.ts'
|
||||||
import { saveAs } from 'file-saver'
|
import { saveAs } from 'file-saver'
|
||||||
@ -38,7 +31,11 @@ import FileList from '../../components/FileList'
|
|||||||
import { CurrentUserFile } from '../../types/file.ts'
|
import { CurrentUserFile } from '../../types/file.ts'
|
||||||
import { Mark } from '../../types/mark.ts'
|
import { Mark } from '../../types/mark.ts'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { convertToSigitFile, SigitFile } from '../../utils/file.ts'
|
import {
|
||||||
|
convertToSigitFile,
|
||||||
|
getZipWithFiles,
|
||||||
|
SigitFile
|
||||||
|
} from '../../utils/file.ts'
|
||||||
import { FileDivider } from '../../components/FileDivider.tsx'
|
import { FileDivider } from '../../components/FileDivider.tsx'
|
||||||
import { ExtensionFileBox } from '../../components/ExtensionFileBox.tsx'
|
import { ExtensionFileBox } from '../../components/ExtensionFileBox.tsx'
|
||||||
import { useScale } from '../../hooks/useScale.tsx'
|
import { useScale } from '../../hooks/useScale.tsx'
|
||||||
@ -358,7 +355,7 @@ export const VerifyPage = () => {
|
|||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleExport = async () => {
|
const handleMarkedExport = async () => {
|
||||||
if (Object.entries(files).length === 0 || !meta || !usersPubkey) return
|
if (Object.entries(files).length === 0 || !meta || !usersPubkey) return
|
||||||
|
|
||||||
const usersNpub = hexToNpub(usersPubkey)
|
const usersNpub = hexToNpub(usersPubkey)
|
||||||
@ -388,22 +385,9 @@ export const VerifyPage = () => {
|
|||||||
const updatedMeta = { ...meta, exportSignature }
|
const updatedMeta = { ...meta, exportSignature }
|
||||||
const stringifiedMeta = JSON.stringify(updatedMeta, null, 2)
|
const stringifiedMeta = JSON.stringify(updatedMeta, null, 2)
|
||||||
|
|
||||||
const zip = new JSZip()
|
const zip = await getZipWithFiles(updatedMeta, files)
|
||||||
zip.file('meta.json', stringifiedMeta)
|
zip.file('meta.json', stringifiedMeta)
|
||||||
|
|
||||||
const marks = extractMarksFromSignedMeta(updatedMeta)
|
|
||||||
const marksByPage = groupMarksByFileNamePage(marks)
|
|
||||||
|
|
||||||
for (const [fileName, file] of Object.entries(files)) {
|
|
||||||
if (file.isPdf) {
|
|
||||||
// Draw marks into PDF file and generate a brand new blob
|
|
||||||
const blob = await addMarks(file, marksByPage[fileName])
|
|
||||||
zip.file(`files/${fileName}`, blob)
|
|
||||||
} else {
|
|
||||||
zip.file(`files/${fileName}`, file)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const arrayBuffer = await zip
|
const arrayBuffer = await zip
|
||||||
.generateAsync({
|
.generateAsync({
|
||||||
type: 'arraybuffer',
|
type: 'arraybuffer',
|
||||||
@ -470,7 +454,7 @@ export const VerifyPage = () => {
|
|||||||
)}
|
)}
|
||||||
currentFile={currentFile}
|
currentFile={currentFile}
|
||||||
setCurrentFile={setCurrentFile}
|
setCurrentFile={setCurrentFile}
|
||||||
handleDownload={handleExport}
|
handleDownload={handleMarkedExport}
|
||||||
downloadLabel="Download Sigit"
|
downloadLabel="Download Sigit"
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
@ -19,14 +19,14 @@ export const getZipWithFiles = async (
|
|||||||
const marksByFileNamePage = groupMarksByFileNamePage(marks)
|
const marksByFileNamePage = groupMarksByFileNamePage(marks)
|
||||||
|
|
||||||
for (const [fileName, file] of Object.entries(files)) {
|
for (const [fileName, file] of Object.entries(files)) {
|
||||||
|
// Handle PDF Files, add marks
|
||||||
if (file.isPdf) {
|
if (file.isPdf) {
|
||||||
// Handle PDF Files
|
|
||||||
const blob = await addMarks(file, marksByFileNamePage[fileName])
|
const blob = await addMarks(file, marksByFileNamePage[fileName])
|
||||||
zip.file(`files/${fileName}`, blob)
|
zip.file(`marked/${fileName}`, blob)
|
||||||
} else {
|
|
||||||
// Handle other files
|
|
||||||
zip.file(`files/${fileName}`, file)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save original files
|
||||||
|
zip.file(`files/${fileName}`, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
return zip
|
return zip
|
||||||
|
Loading…
Reference in New Issue
Block a user