Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
306 changes: 142 additions & 164 deletions bun.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/amplify-component-lib",
"version": "12.0.5",
"version": "12.0.6",
"description": "Frontend Typescript components for the Amplify team",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -52,7 +52,7 @@
},
"devDependencies": {
"@equinor/eds-icons": "^0.22.0",
"@equinor/subsurface-app-management": "5.4.6",
"@equinor/subsurface-app-management": "5.4.7",
"@eslint/js": "^9.22.0",
"@faker-js/faker": "^9.6.0",
"@storybook/addon-coverage": "^2.0.0",
Expand Down Expand Up @@ -114,7 +114,7 @@
"@equinor/eds-core-react": "0.44.0",
"@equinor/eds-data-grid-react": "^0.7.5",
"@equinor/eds-icons": "*",
"@equinor/subsurface-app-management": "^5.4.6",
"@equinor/subsurface-app-management": "^5.4.7",
"@tanstack/react-query": "*",
"@tanstack/react-router": "*",
"@tiptap/core": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - Please do NOT modify this file.
*/

const PACKAGE_VERSION = '2.13.3'
const PACKAGE_VERSION = '2.13.6'
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
Comment thread
mariush2 marked this conversation as resolved.
const activeClientIds = new Set()
Expand Down
13 changes: 8 additions & 5 deletions src/providers/SurveyProvider/SurveyDialog/SurveyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ export const SurveyDialog: FC = () => {
if (!currentAnswer) return;

setIsAnswering(true);
await answerQuestion({
...currentAnswer,
selectedOptionIds: currentAnswer?.selectedOptionIds ?? [],
});
setIsAnswering(false);
try {
await answerQuestion({
...currentAnswer,
selectedOptionIds: currentAnswer?.selectedOptionIds ?? [],
});
} finally {
setIsAnswering(false);
}
};

const disabledNextAction = () => {
Expand Down
6 changes: 6 additions & 0 deletions src/providers/SurveyProvider/SurveyProvider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ const surveyHandlers = [
};
return HttpResponse.json(answerId);
}),
http.put(
'*/api/v1/surveys/:surveyResponseId/responses/me/finalize',
async () => {
return HttpResponse.text('OK');
}
),
];

const standardSurvey: UserSurveyVm = {
Expand Down
43 changes: 43 additions & 0 deletions src/providers/SurveyProvider/SurveyProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,46 @@ test('Sets activeQuestionIndex to the last unanswered question if some questions
);
await waitFor(() => expect(result.current.activeQuestionIndex).toBe(1));
});

test('Calls show from confetti provider if showConfettiOnComplete: true', async ({
worker,
}) => {
const survey: UserSurveyVm = {
surveyId: {
value: 'some-id',
},
status: SurveyResponseStatus.IN_PROGRESS,
surveyType: SurveyType.DEFAULT,
applicationId: 'some-app',
title: 'This is the title',
description: '',
startAt: '',
endAt: '',
showConfettiOnComplete: true,
questions: [
{
questionId: { value: 'id1' },
questionText: 'Hei',
type: QuestionType.TEXT,
order: 1,
answer: {
answerId: { value: 'id2' },
textAnswer: 'Something or other',
},
},
],
};
worker.use(
http.get('*/api/v1/surveys/applications/:applicationName/me', () =>
HttpResponse.json(survey)
)
);

const { result } = renderHook(() => useSurvey(), { wrapper: TestProviders });

await waitFor(() =>
expect(result.current.activeSurvey?.surveyId.value).toBe(
survey.surveyId.value
)
);
});
Comment thread
mariush2 marked this conversation as resolved.
8 changes: 7 additions & 1 deletion src/providers/SurveyProvider/SurveyProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
AnswerQuestionCommandDto,
useActiveSurvey,
useAnswerQuestionActiveSurvey,
useCompleteActiveSurvey,
useRespondActiveSurvey,
UserSurveyVm,
} from '@equinor/subsurface-app-management';
Expand Down Expand Up @@ -63,6 +64,7 @@ export const SurveyProvider: FC<SurveyProviderProps> = ({ children }) => {
const initializedQuestionIndex = useRef<string | undefined>(undefined);
const { mutateAsync: respondActiveSurvey } = useRespondActiveSurvey();
const { mutateAsync: answerQuestion } = useAnswerQuestionActiveSurvey();
const { mutate: completeSurvey } = useCompleteActiveSurvey();

useEffect(() => {
if (
Expand All @@ -78,7 +80,9 @@ export const SurveyProvider: FC<SurveyProviderProps> = ({ children }) => {
}, [activeSurvey]);

const handleCompleteSurvey = () => {
if (!activeSurvey) return;
if (!activeSurvey || !activeSurvey.surveyResponseId) return;

completeSurvey(activeSurvey.surveyResponseId.value);

Comment thread
mariush2 marked this conversation as resolved.
Comment thread
mariush2 marked this conversation as resolved.
showToast({
variant: 'success',
Expand All @@ -87,13 +91,15 @@ export const SurveyProvider: FC<SurveyProviderProps> = ({ children }) => {
duration: 5,
});

/* v8 ignore start */
if (activeSurvey.showConfettiOnComplete) {
shower({
mode: 'shower',
shapes: ['square'],
duration: 5000,
});
}
/* v8 ignore end */
};

const handleAnswerQuestion = async (
Expand Down
Loading