Skip to content

Commit 0940b12

Browse files
committed
applies qa suggested changes
1 parent b69c718 commit 0940b12

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/features/instance/useProcessNext.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,15 @@ export function useProcessNext({ action }: ProcessNextProps = {}) {
105105
},
106106
onError: async (error: HttpClientError<ProblemDetails | undefined>) => {
107107
window.logError('Process next failed:\n', error);
108-
const { data: newProcess } = await refetchProcessData();
109-
const newCurrentTask = newProcess?.currentTask;
110108

111109
if (!appSupportsUnlockingOnProcessNextFailure(applicationMetadata)) {
112110
displayError(error);
113111
return;
114112
}
115113

114+
const { data: newProcess } = await refetchProcessData();
115+
const newCurrentTask = newProcess?.currentTask;
116+
116117
if (newCurrentTask?.elementId && newCurrentTask?.elementId !== process?.currentTask?.elementId) {
117118
await reFetchInstanceData();
118119
navigateToTask(newCurrentTask.elementId);

src/layout/Button/ButtonComponent.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from 'react';
33
import { Button } from 'src/app-components/Button/Button';
44
import { useAttachmentState } from 'src/features/attachments/hooks';
55
import { useSetReturnToView } from 'src/features/form/layout/PageNavigationContext';
6+
import { useLayoutSets } from 'src/features/form/layoutSets/LayoutSetsProvider';
67
import { useProcessNext } from 'src/features/instance/useProcessNext';
78
import { useProcessQuery, useTaskTypeFromBackend } from 'src/features/instance/useProcessQuery';
89
import { Lang } from 'src/features/language/Lang';
@@ -12,7 +13,7 @@ import { getComponentFromMode } from 'src/layout/Button/getComponentFromMode';
1213
import { ComponentStructureWrapper } from 'src/layout/ComponentStructureWrapper';
1314
import { alignStyle } from 'src/layout/RepeatingGroup/Container/RepeatingGroupContainer';
1415
import { ProcessTaskType } from 'src/types';
15-
import { ELEMENT_TYPE } from 'src/types/shared';
16+
import { behavesLikeDataTask } from 'src/utils/formLayout';
1617
import { useItemWhenType } from 'src/utils/layout/useNodeItem';
1718
import type { PropsFromGenericComponent } from 'src/layout';
1819
import type { CompInternal } from 'src/layout/layout';
@@ -30,10 +31,11 @@ export const ButtonComponent = ({ baseComponentId, ...componentProps }: PropsFro
3031
const currentTaskType = useTaskTypeFromBackend();
3132
const { data: process } = useProcessQuery();
3233
const currentTask = process?.currentTask;
33-
const { actions, write, elementType: currentElementType } = currentTask ?? {};
34+
const { actions, write } = currentTask ?? {};
3435
const attachmentState = useAttachmentState();
3536
const { mutate: processNext, isPending: isProcessingNext } = useProcessNext();
3637
const { mutate: processConfirm, isPending: isConfirming } = useProcessNext({ action: 'confirm' });
38+
const layoutSets = useLayoutSets();
3739

3840
const setReturnToView = useSetReturnToView();
3941

@@ -55,10 +57,8 @@ export const ButtonComponent = ({ baseComponentId, ...componentProps }: PropsFro
5557
}
5658

5759
function submitTask() {
58-
const isServiceTask = currentElementType === ELEMENT_TYPE.SERVICE_TASK;
59-
6060
setReturnToView?.(undefined);
61-
if (currentTaskType === ProcessTaskType.Data || isServiceTask) {
61+
if (currentTaskType === ProcessTaskType.Data || behavesLikeDataTask(currentTask?.elementId, layoutSets)) {
6262
processNext();
6363
} else if (currentTaskType === ProcessTaskType.Confirm) {
6464
processConfirm();

src/types/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ export type ITask = {
241241
flow: number;
242242
started: string;
243243
elementId: string;
244-
elementType: ElementType;
245244
name: string;
246245
altinnTaskType: string;
246+
elementType?: ElementType;
247247
ended?: string | null;
248248
validated?: IValidated | null;
249249

src/utils/formLayout.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { ILayoutSet } from 'src/layout/common.generated';
22

33
/**
44
* Some tasks other than data (for instance confirm, or other in the future) can be configured to behave like data steps
5-
* @param task the task
5+
* @param taskId the task element id
66
* @param layoutSets the layout sets
77
*/
8-
export function behavesLikeDataTask(task: string | null | undefined, layoutSets: ILayoutSet[] | null): boolean {
9-
if (!task) {
8+
export function behavesLikeDataTask(taskId: string | null | undefined, layoutSets: ILayoutSet[] | null): boolean {
9+
if (!taskId) {
1010
return false;
1111
}
1212

13-
return !!layoutSets?.some((set) => set.tasks?.includes(task));
13+
return !!layoutSets?.some((set) => set.tasks?.includes(taskId));
1414
}

0 commit comments

Comments
 (0)