@@ -11,7 +11,7 @@ import { SøkeboksOppgaveDto } from 'saksbehandler/sokeboks/SøkeboksOppgaveDto'
11
11
import EndreOppgaveType from 'types/EndreOppgaveType' ;
12
12
import { OppgaveNøkkel } from 'types/OppgaveNøkkel' ;
13
13
import OppgaveV3 from 'types/OppgaveV3' ;
14
- import { OppgavekøV3 , OppgavekøV3Enkel } from 'types/OppgavekøV3Type' ;
14
+ import { OppgavekøV3 } from 'types/OppgavekøV3Type' ;
15
15
import { axiosInstance } from 'utils/reactQueryConfig' ;
16
16
17
17
export const useInnloggetSaksbehandler = ( options ?: Omit < UseQueryOptions < NavAnsatt , Error > , 'queryKey' > ) =>
@@ -96,16 +96,18 @@ export const useEndreReservasjoner = (onSuccess?: () => void) => {
96
96
} ,
97
97
} ) ;
98
98
} ;
99
- export const usePlukkOppgaveMutation = ( callback ?: ( oppgave : ReservasjonV3FraKøDto ) => void ) => {
99
+ export const usePlukkOppgaveMutation = ( callback ?: ( oppgave : ReservasjonV3FraKøDto [ ] ) => void ) => {
100
100
const queryClient = useQueryClient ( ) ;
101
101
102
102
return useMutation ( {
103
- mutationFn : ( data : { oppgaveKøId : string } ) : Promise < ReservasjonV3FraKøDto > =>
103
+ mutationFn : ( data : { oppgaveKøId : string } ) : Promise < ReservasjonV3FraKøDto [ ] > =>
104
104
axiosInstance . post ( `${ apiPaths . hentOppgaveFraKoV3 ( data . oppgaveKøId ) } ` , data ) . then ( ( response ) => response . data ) ,
105
- onSuccess : ( data : ReservasjonV3FraKøDto ) => {
106
- queryClient . refetchQueries ( { queryKey : [ apiPaths . saksbehandlerReservasjoner ] } ) . then ( ( ) => {
107
- if ( callback ) callback ( data ) ;
108
- } ) ;
105
+ onSuccess : async ( data : ReservasjonV3FraKøDto [ ] | ReservasjonV3FraKøDto ) => {
106
+ const array = Array . isArray ( data ) ? data : [ data ] ; // Midlertidig, for å slippe å deploye backend og frontend helt samtidig
107
+ if ( callback ) callback ( array ) ;
108
+ if ( array . length > 0 ) {
109
+ await queryClient . refetchQueries ( { queryKey : [ apiPaths . saksbehandlerReservasjoner ] } ) ;
110
+ }
109
111
} ,
110
112
} ) ;
111
113
} ;
0 commit comments