Skip to content

Commit 84cfc6d

Browse files
committed
fix(types): refine identify signer typing
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 7b9b7c8 commit 84cfc6d

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

src/components/Request/IdentifySigner.vue

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ const iconMap = {
9595
svgXmpp,
9696
}
9797
98+
const methodIconMap: Record<string, keyof typeof iconMap> = {
99+
account: 'svgAccount',
100+
email: 'svgEmail',
101+
signal: 'svgSignal',
102+
sms: 'svgSms',
103+
telegram: 'svgTelegram',
104+
whatsapp: 'svgWhatsapp',
105+
xmpp: 'svgXmpp',
106+
}
107+
98108
defineOptions({
99109
name: 'IdentifySigner',
100110
})
@@ -124,6 +134,12 @@ type SelectedSigner = {
124134
acceptsEmailNotifications?: boolean
125135
}
126136
137+
type FilesStore = {
138+
getFile: () => { signers?: Array<Record<string, unknown>> } | null | undefined
139+
saveOrUpdateSignatureRequest: (payload: { signers: Array<Record<string, unknown>> }) => Promise<{ success?: boolean; message?: string }>
140+
disableIdentifySigner: () => void
141+
}
142+
127143
const props = withDefaults(defineProps<{
128144
signerToEdit?: SignerToEdit
129145
method?: string
@@ -142,7 +158,7 @@ const props = withDefaults(defineProps<{
142158
disabled: false,
143159
})
144160
145-
const filesStore = useFilesStore()
161+
const filesStore = useFilesStore() as unknown as FilesStore
146162
147163
const id = ref<string | null>(null)
148164
const nameHelperText = ref('')
@@ -178,7 +194,8 @@ function getMethodIcon() {
178194
if (!method) {
179195
return iconMap.svgAccount
180196
}
181-
return iconMap[`svg${method.charAt(0).toUpperCase() + method.slice(1)}`] || iconMap.svgAccount
197+
const iconKey = methodIconMap[method] || 'svgAccount'
198+
return iconMap[iconKey]
182199
}
183200
184201
function updateSigner(nextSigner: SelectedSigner | null) {
@@ -213,7 +230,7 @@ async function saveSigner() {
213230
try {
214231
const response = await filesStore.saveOrUpdateSignatureRequest({ signers })
215232
if (response?.success === false) {
216-
showError(response.message)
233+
showError(response.message ?? t('libresign', 'Failed to save or update signature request'))
217234
return
218235
}
219236
} catch {

0 commit comments

Comments
 (0)