feature: Core Digitization Workstation (Entry, Verification, Approval)
This commit is contained in:
@@ -6,6 +6,7 @@ export function usePresignedUrl(batchId: Ref<string | undefined>) {
|
||||
const batchStore = useBatchStore()
|
||||
const documentUrl = ref<string | null>(null)
|
||||
const documentError = ref<string | null>(null)
|
||||
const documentLoading = ref(false)
|
||||
|
||||
let currentBlobUrl: string | null = null
|
||||
|
||||
@@ -21,8 +22,12 @@ export function usePresignedUrl(batchId: Ref<string | undefined>) {
|
||||
documentUrl.value = null
|
||||
documentError.value = null
|
||||
|
||||
if (!batchId.value) return
|
||||
if (!batchId.value) {
|
||||
documentLoading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
documentLoading.value = true
|
||||
try {
|
||||
await batchStore.getBatch(batchId.value)
|
||||
const blob = await getBlob(`digitization-batches/${batchId.value}/document`)
|
||||
@@ -33,6 +38,8 @@ export function usePresignedUrl(batchId: Ref<string | undefined>) {
|
||||
documentUrl.value = currentBlobUrl
|
||||
} catch (e: unknown) {
|
||||
documentError.value = e instanceof Error ? e.message : 'Failed to load document'
|
||||
} finally {
|
||||
documentLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +52,7 @@ export function usePresignedUrl(batchId: Ref<string | undefined>) {
|
||||
revokeBlobUrl()
|
||||
documentUrl.value = null
|
||||
documentError.value = null
|
||||
documentLoading.value = false
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
@@ -52,5 +60,5 @@ export function usePresignedUrl(batchId: Ref<string | undefined>) {
|
||||
|
||||
onUnmounted(revokeBlobUrl)
|
||||
|
||||
return { documentUrl, documentError, refreshUrl }
|
||||
return { documentUrl, documentError, documentLoading, refreshUrl }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user