From f8a4480994085b56bbda28b72f2a6d75b0c555d7 Mon Sep 17 00:00:00 2001 From: enes Date: Tue, 17 Sep 2024 15:04:54 +0200 Subject: [PATCH 01/15] refactor(toolbox): reduce number of mark types Closes #201 --- src/utils/mark.ts | 178 +++++++++++++++++++++------------------------- 1 file changed, 83 insertions(+), 95 deletions(-) diff --git a/src/utils/mark.ts b/src/utils/mark.ts index ac80623..258dc51 100644 --- a/src/utils/mark.ts +++ b/src/utils/mark.ts @@ -9,20 +9,8 @@ import { faSignature, faBriefcase, faIdCard, - faHeading, faClock, - faCalendarDays, - fa1, - faImage, - faSquareCheck, - faCheckDouble, - faPaperclip, - faCircleDot, - faSquareCaretDown, - faTableCellsLarge, - faStamp, - faCreditCard, - faPhone + fa1 } from '@fortawesome/free-solid-svg-icons' /** @@ -154,15 +142,9 @@ const findOtherUserMarks = (marks: Mark[], pubkey: string): Mark[] => { export const DEFAULT_TOOLBOX = [ { - identifier: MarkType.TEXT, - icon: faT, - label: 'Text', - active: true - }, - { - identifier: MarkType.SIGNATURE, - icon: faSignature, - label: 'Signature', + identifier: MarkType.FULLNAME, + icon: faIdCard, + label: 'Full Name', active: false }, { @@ -172,15 +154,9 @@ export const DEFAULT_TOOLBOX = [ active: false }, { - identifier: MarkType.FULLNAME, - icon: faIdCard, - label: 'Full Name', - active: false - }, - { - identifier: MarkType.INITIALS, - icon: faHeading, - label: 'Initials', + identifier: MarkType.SIGNATURE, + icon: faSignature, + label: 'Signature', active: false }, { @@ -190,77 +166,89 @@ export const DEFAULT_TOOLBOX = [ active: false }, { - identifier: MarkType.DATE, - icon: faCalendarDays, - label: 'Date', - active: false + identifier: MarkType.TEXT, + icon: faT, + label: 'Text', + active: true }, { identifier: MarkType.NUMBER, icon: fa1, label: 'Number', active: false - }, - { - identifier: MarkType.IMAGES, - icon: faImage, - label: 'Images', - active: false - }, - { - identifier: MarkType.CHECKBOX, - icon: faSquareCheck, - label: 'Checkbox', - active: false - }, - { - identifier: MarkType.MULTIPLE, - icon: faCheckDouble, - label: 'Multiple', - active: false - }, - { - identifier: MarkType.FILE, - icon: faPaperclip, - label: 'File', - active: false - }, - { - identifier: MarkType.RADIO, - icon: faCircleDot, - label: 'Radio', - active: false - }, - { - identifier: MarkType.SELECT, - icon: faSquareCaretDown, - label: 'Select', - active: false - }, - { - identifier: MarkType.CELLS, - icon: faTableCellsLarge, - label: 'Cells', - active: false - }, - { - identifier: MarkType.STAMP, - icon: faStamp, - label: 'Stamp', - active: false - }, - { - identifier: MarkType.PAYMENT, - icon: faCreditCard, - label: 'Payment', - active: false - }, - { - identifier: MarkType.PHONE, - icon: faPhone, - label: 'Phone', - active: false } + // { + // identifier: MarkType.INITIALS, + // icon: faHeading, + // label: 'Initials', + // active: false + // }, + // { + // identifier: MarkType.DATE, + // icon: faCalendarDays, + // label: 'Date', + // active: false + // }, + // { + // identifier: MarkType.IMAGES, + // icon: faImage, + // label: 'Images', + // active: false + // }, + // { + // identifier: MarkType.CHECKBOX, + // icon: faSquareCheck, + // label: 'Checkbox', + // active: false + // }, + // { + // identifier: MarkType.MULTIPLE, + // icon: faCheckDouble, + // label: 'Multiple', + // active: false + // }, + // { + // identifier: MarkType.FILE, + // icon: faPaperclip, + // label: 'File', + // active: false + // }, + // { + // identifier: MarkType.RADIO, + // icon: faCircleDot, + // label: 'Radio', + // active: false + // }, + // { + // identifier: MarkType.SELECT, + // icon: faSquareCaretDown, + // label: 'Select', + // active: false + // }, + // { + // identifier: MarkType.CELLS, + // icon: faTableCellsLarge, + // label: 'Cells', + // active: false + // }, + // { + // identifier: MarkType.STAMP, + // icon: faStamp, + // label: 'Stamp', + // active: false + // }, + // { + // identifier: MarkType.PAYMENT, + // icon: faCreditCard, + // label: 'Payment', + // active: false + // }, + // { + // identifier: MarkType.PHONE, + // icon: faPhone, + // label: 'Phone', + // active: false + // } ] export const getToolboxLabelByMarkType = (markType: MarkType) => { -- 2.34.1 From dfdcb8419d5b3c8ca34c6f9590107ce120a53174 Mon Sep 17 00:00:00 2001 From: enes Date: Tue, 17 Sep 2024 17:21:30 +0200 Subject: [PATCH 02/15] fix(marks): add default signer --- src/components/DrawPDFFields/index.tsx | 113 ++++++++++++------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/src/components/DrawPDFFields/index.tsx b/src/components/DrawPDFFields/index.tsx index 7c1227d..aa6b0e5 100644 --- a/src/components/DrawPDFFields/index.tsx +++ b/src/components/DrawPDFFields/index.tsx @@ -37,6 +37,8 @@ interface Props { export const DrawPDFFields = (props: Props) => { const { selectedFiles, selectedTool, onDrawFieldsChange, users } = props + const signers = users.filter((u) => u.role === UserRole.signer) + const defaultSignerNpub = signers.length ? hexToNpub(signers[0].pubkey) : '' const { to, from } = useScale() const [sigitFiles, setSigitFiles] = useState([]) @@ -115,7 +117,7 @@ export const DrawPDFFields = (props: Props) => { top: to(page.width, y), width: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.width, height: event.pointerType === 'mouse' ? 0 : DEFAULT_START_SIZE.height, - counterpart: '', + counterpart: defaultSignerNpub, type: selectedTool.identifier } @@ -453,7 +455,9 @@ export const DrawPDFFields = (props: Props) => { Counterpart @@ -524,28 +523,28 @@ export const DrawPDFFields = (props: Props) => { ) } - const renderCounterpartValue = (value: string) => { - const user = users.find((u) => u.pubkey === npubToHex(value)) - if (user) { - let displayValue = truncate(value, { - length: 16 - }) - - const metadata = props.metadata[user.pubkey] + const renderCounterpartValue = (npub: string) => { + let displayValue = truncate(npub, { + length: 16 + }) + const signer = signers.find((u) => u.pubkey === npubToHex(npub)) + if (signer) { + const metadata = props.metadata[signer.pubkey] if (metadata) { displayValue = truncate( - metadata.name || metadata.display_name || metadata.username || value, + metadata.display_name || metadata.name || npub, { length: 16 } ) } + return ( <> { ) } - return value + return displayValue } if (parsingPdf) { -- 2.34.1 From 6d78d9ed643296b6dfa6ab3ffd0ae5295a46243a Mon Sep 17 00:00:00 2001 From: enes Date: Tue, 17 Sep 2024 17:56:53 +0200 Subject: [PATCH 03/15] fix(create): uploading file adds to the existing file list, dedupe file list Closes #184 --- src/pages/create/index.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index dd17450..7f39b11 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -301,7 +301,15 @@ export const CreatePage = () => { const handleSelectFiles = (event: React.ChangeEvent) => { if (event.target.files) { - setSelectedFiles(Array.from(event.target.files)) + // Get the uploaded files + const files = Array.from(event.target.files) + + // Remove duplicates based on the file.name + setSelectedFiles((p) => + [...p, ...files].filter( + (file, i, array) => i === array.findIndex((t) => t.name === file.name) + ) + ) } } -- 2.34.1 From ebd59471c79335555ddf43748b3dd3457b65eb42 Mon Sep 17 00:00:00 2001 From: enes Date: Thu, 19 Sep 2024 09:53:16 +0200 Subject: [PATCH 04/15] fix: footer portal on relays --- src/pages/settings/relays/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/relays/index.tsx b/src/pages/settings/relays/index.tsx index 4ed5d62..a1f5223 100644 --- a/src/pages/settings/relays/index.tsx +++ b/src/pages/settings/relays/index.tsx @@ -233,6 +233,7 @@ export const RelaysPage = () => { ))} )} +