From d1271c6c2a5020cdb191a0f75fa9bcca99838d98 Mon Sep 17 00:00:00 2001 From: sultanofcardio Date: Mon, 22 Apr 2024 15:26:50 -0500 Subject: [PATCH] M2-6044: Submit take now params --- src/shared/api/types/activity.ts | 2 ++ .../ActivityDetails/model/hooks/useAnswers.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/shared/api/types/activity.ts b/src/shared/api/types/activity.ts index bdd166d28..f1ac7db7b 100644 --- a/src/shared/api/types/activity.ts +++ b/src/shared/api/types/activity.ts @@ -92,6 +92,8 @@ export type AnswerPayload = { localEndDate: string; localEndTime: string; }; + sourceSubjectId?: ID | null; + targetSubjectId?: ID | null; }; export type AlertDTO = { diff --git a/src/widgets/ActivityDetails/model/hooks/useAnswers.ts b/src/widgets/ActivityDetails/model/hooks/useAnswers.ts index 05a3e13f4..0ea38fae8 100644 --- a/src/widgets/ActivityDetails/model/hooks/useAnswers.ts +++ b/src/widgets/ActivityDetails/model/hooks/useAnswers.ts @@ -14,6 +14,7 @@ import { appletModel } from '~/entities/applet'; import { userModel } from '~/entities/user'; import { AnswerPayload, AppletDetailsDTO, AppletEventsResponse } from '~/shared/api'; import { formatToDtoDate, formatToDtoTime, useEncryption } from '~/shared/utils'; +import { useLaunchDarkly } from '~/shared/utils/hooks/useLaunchDarkly'; type Props = { applet: AppletDetailsDTO; @@ -36,6 +37,9 @@ export const useAnswer = (props: Props) => { const { encryptPayload } = useEncryptPayload(); const { getGroupProgress } = appletModel.hooks.useGroupProgressState(); + const { getMultiInformantState, isInMultiInformantFlow } = + appletModel.hooks.useMultiInformantState(); + const { flags: featureFlags } = useLaunchDarkly(); const getSubmitId = (groupInProgress: GroupProgress): string => { const isFlow = groupInProgress.type === ActivityPipelineType.Flow; @@ -135,6 +139,14 @@ export const useAnswer = (props: Props) => { }, }; + if (featureFlags.enableMultiInformant) { + const multiInformantState = getMultiInformantState(); + if (isInMultiInformantFlow()) { + answer.sourceSubjectId = multiInformantState.sourceSubjectId; + answer.targetSubjectId = multiInformantState.targetSubjectId; + } + } + const scheduledTime = getScheduledTimeFromEvents(props.eventsRawData, props.activityId); if (scheduledTime) { answer.answer.scheduledTime = scheduledTime; @@ -154,6 +166,7 @@ export const useAnswer = (props: Props) => { props.eventId, props.eventsRawData, props.flowId, + getMultiInformantState, ], );