Skip to content

Commit

Permalink
M2-6044: Submit take now params
Browse files Browse the repository at this point in the history
  • Loading branch information
sultanofcardio committed Apr 24, 2024
1 parent cb14d82 commit ace3725
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/shared/api/types/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export type AnswerPayload = {
localEndDate: string;
localEndTime: string;
};
sourceSubjectId?: ID | null;
targetSubjectId?: ID | null;
};

export type AlertDTO = {
Expand Down
13 changes: 13 additions & 0 deletions src/widgets/ActivityDetails/model/hooks/useAnswers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -154,6 +166,7 @@ export const useAnswer = (props: Props) => {
props.eventId,
props.eventsRawData,
props.flowId,
getMultiInformantState,
],
);

Expand Down

0 comments on commit ace3725

Please sign in to comment.