Skip to content

Commit f622c6f

Browse files
committed
refactor(types): share visible element service types
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 84cfc6d commit f622c6f

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/services/visibleElementsService.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
interface Coordinates {
6+
export interface Coordinates {
77
page?: number | string
88
left?: number | string
99
top?: number | string
1010
}
1111

12-
interface VisibleElement {
12+
export interface VisibleElement {
1313
elementId?: number | string
1414
fileId?: number | string
1515
signRequestId?: number | string
@@ -18,23 +18,23 @@ interface VisibleElement {
1818
[key: string]: unknown
1919
}
2020

21-
interface Signer {
21+
export interface Signer {
2222
visibleElements?: VisibleElement[]
2323
me?: boolean
2424
signRequestId?: number | string
2525
[key: string]: unknown
2626
}
2727

28-
interface FileData {
28+
export interface FileData {
2929
id?: number | string
30-
file?: string
31-
files?: Array<{ file?: string; signers?: Signer[] }>
30+
file?: unknown
31+
files?: Array<{ file?: unknown; signers?: Signer[] }>
3232
visibleElements?: VisibleElement[]
3333
signers?: Signer[]
3434
[key: string]: unknown
3535
}
3636

37-
interface DocumentData {
37+
export interface DocumentData {
3838
visibleElements?: VisibleElement[]
3939
signers?: Signer[]
4040
files?: FileData[]
@@ -85,7 +85,11 @@ const collectSignerVisibleElements = (signers: unknown): VisibleElement[] => {
8585
export const idsMatch = (left: unknown, right: unknown): boolean => keyOf(left) === keyOf(right)
8686

8787
export const getFileUrl = (file: FileData | null | undefined): string | null =>
88-
file?.file || file?.files?.[0]?.file || null
88+
typeof file?.file === 'string'
89+
? file.file
90+
: typeof file?.files?.[0]?.file === 'string'
91+
? file.files[0].file
92+
: null
8993

9094
export const getFileSigners = (file: FileData): Signer[] => {
9195
if (Array.isArray(file?.signers) && file.signers.length > 0) {

0 commit comments

Comments
 (0)