Complete operational map result workflow
This commit is contained in:
@@ -97,14 +97,27 @@ export function useMapThemeSelectionInsights<TThemeId extends string>(
|
||||
})),
|
||||
)
|
||||
const successful = settled.flatMap((item) => (item.status === 'fulfilled' ? [item.value] : []))
|
||||
const failureCount = settled.length - successful.length
|
||||
const failures = settled.flatMap((item, index) => (
|
||||
item.status === 'rejected'
|
||||
? [{
|
||||
dataset: queries[index]?.dataset.name ?? queries[index]?.themeId ?? 'Onbekende bron',
|
||||
reason: formatError(item.reason, 'Bron kon niet worden bevraagd.'),
|
||||
}]
|
||||
: []
|
||||
))
|
||||
const failureCount = failures.length
|
||||
if (requestSequence.current !== sequence) {
|
||||
return []
|
||||
}
|
||||
setThemeInsights(successful)
|
||||
if (failureCount > 0) {
|
||||
const details = failures
|
||||
.slice(0, 4)
|
||||
.map((failure) => `${failure.dataset}: ${failure.reason}`)
|
||||
.join(' · ')
|
||||
const remainder = failureCount > 4 ? ` · en ${failureCount - 4} andere` : ''
|
||||
setThemeInsightsError(
|
||||
`${failureCount} beschikbare databron${failureCount === 1 ? '' : 'nen'} kon niet worden bevraagd.`,
|
||||
`${failureCount} beschikbare databron${failureCount === 1 ? '' : 'nen'} kon niet worden bevraagd. ${details}${remainder}`,
|
||||
)
|
||||
}
|
||||
return successful
|
||||
|
||||
Reference in New Issue
Block a user