@@ -4,6 +4,7 @@ import { toast } from 'react-toastify';
44import { useMutation , useQueryClient } from '@tanstack/react-query' ;
55
66import { ContextNotProvided } from 'src/core/contexts/context' ;
7+ import { useDisplayError } from 'src/core/errorHandling/DisplayErrorProvider' ;
78import { useApplicationMetadata } from 'src/features/applicationMetadata/ApplicationMetadataProvider' ;
89import { useHasPendingScans } from 'src/features/attachments/useHasPendingScans' ;
910import { invalidateFormDataQueries } from 'src/features/formData/useFormDataQuery' ;
@@ -39,6 +40,7 @@ export function useProcessNext() {
3940 const onSubmitFormValidation = useOnFormSubmitValidation ( ) ;
4041 const applicationMetadata = useApplicationMetadata ( ) ;
4142 const queryClient = useQueryClient ( ) ;
43+ const displayError = useDisplayError ( ) ;
4244 const hasPendingScans = useHasPendingScans ( ) ;
4345
4446 const mutation = useMutation ( {
@@ -65,7 +67,7 @@ export function useProcessNext() {
6567 } else if (
6668 error . response ?. status === 500 &&
6769 error . response ?. data ?. [ 'detail' ] === 'Pdf generation failed' &&
68- appUnlocksOnPDFFailure ( applicationMetadata )
70+ appSupportsUnlockingOnProcessNextFailure ( applicationMetadata )
6971 ) {
7072 // If process next fails due to the PDF generator failing, don't show unknown error if the app unlocks data elements
7173 toast ( < Lang id = 'process_error.submit_error_please_retry' /> , { type : 'error' , autoClose : false } ) ;
@@ -96,6 +98,11 @@ export function useProcessNext() {
9698 const { data : newProcess } = await refetchProcessData ( ) ;
9799 const newCurrentTask = newProcess ?. currentTask ;
98100
101+ if ( ! appSupportsUnlockingOnProcessNextFailure ( applicationMetadata ) ) {
102+ displayError ( error ) ;
103+ return ;
104+ }
105+
99106 if ( newCurrentTask ?. elementId && newCurrentTask ?. elementId !== process ?. currentTask ?. elementId ) {
100107 await reFetchInstanceData ( ) ;
101108 navigateToTask ( newCurrentTask . elementId ) ;
@@ -134,6 +141,6 @@ export function useProcessConfirm() {
134141 } ;
135142}
136143
137- function appUnlocksOnPDFFailure ( { altinnNugetVersion } : ApplicationMetadata ) {
144+ function appSupportsUnlockingOnProcessNextFailure ( { altinnNugetVersion } : ApplicationMetadata ) {
138145 return ! altinnNugetVersion || isAtLeastVersion ( { actualVersion : altinnNugetVersion , minimumVersion : '8.1.0.115' } ) ;
139146}
0 commit comments