Skip to content

Commit

Permalink
Merge branch 'develop' into service-units-2
Browse files Browse the repository at this point in the history
  • Loading branch information
NC-jsAhonen committed Sep 20, 2023
2 parents 92d404c + 8249df6 commit 9158156
Show file tree
Hide file tree
Showing 87 changed files with 3,425 additions and 1,593 deletions.
64 changes: 64 additions & 0 deletions src/application/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,41 @@ import {createAction} from 'redux-actions';

import type {
ApplicantInfoCheckAttributesNotFoundAction,
ApplicationRelatedAttachmentsNotFoundAction,
AttachmentAttributesNotFoundAction,
AttributesNotFoundAction,
DeleteUploadAction,
FetchApplicantInfoCheckAttributesAction,
FetchApplicationRelatedAttachmentsAction,
FetchAttachmentAttributesAction,
FetchAttributesAction,
FetchFormAttributesAction,
FetchPendingUploadsAction,
FormAttributesNotFoundAction,
PendingUploadsNotFoundAction,
ReceiveApplicantInfoCheckAttributesAction,
ReceiveApplicationRelatedAttachmentsAction,
ReceiveAttachmentAttributesAction,
ReceiveAttachmentMethodsAction,
ReceiveAttributesAction,
ReceiveFileOperationFinishedAction,
ReceiveFormAttributesAction,
ReceiveMethodsAction,
ReceivePendingUploadsAction,
ReceiveUpdatedApplicantInfoCheckItemAction,
ReceiveUpdatedTargetInfoCheckItemAction,
UploadFileAction,
} from '$src/application/types';
import type {Attributes, Methods} from '$src/types';

export const fetchAttributes = (): FetchAttributesAction =>
createAction('mvj/application/FETCH_ATTRIBUTES')();
export const receiveMethods = (methods: Methods): ReceiveMethodsAction =>
createAction('mvj/application/RECEIVE_METHODS')(methods);
export const attributesNotFound = (): AttributesNotFoundAction =>
createAction('mvj/application/ATTRIBUTES_NOT_FOUND')();
export const receiveAttributes = (attributes: Attributes): ReceiveAttributesAction =>
createAction('mvj/application/RECEIVE_ATTRIBUTES')(attributes);
export const fetchApplicantInfoCheckAttributes = (): FetchApplicantInfoCheckAttributesAction =>
createAction('mvj/application/FETCH_APPLICANT_INFO_CHECK_ATTRIBUTES')();
export const receiveApplicantInfoCheckAttributes = (payload: Object): ReceiveApplicantInfoCheckAttributesAction =>
Expand All @@ -16,3 +46,37 @@ export const applicantInfoCheckAttributesNotFound = (): ApplicantInfoCheckAttrib
createAction('mvj/application/APPLICANT_INFO_CHECK_ATTRIBUTES_NOT_FOUND')();
export const receiveUpdatedApplicantInfoCheckItem = (payload: Object): ReceiveUpdatedApplicantInfoCheckItemAction =>
createAction('mvj/application/RECEIVE_UPDATED_APPLICANT_INFO_CHECK_ITEM')(payload);
export const receiveUpdatedTargetInfoCheckItem = (payload: Object): ReceiveUpdatedTargetInfoCheckItemAction =>
createAction('mvj/application/RECEIVE_UPDATED_TARGET_INFO_CHECK_ITEM')(payload);
export const fetchFormAttributes = (payload: Object): FetchFormAttributesAction =>
createAction('mvj/application/FETCH_FORM_ATTRIBUTES')(payload);
export const formAttributesNotFound = (): FormAttributesNotFoundAction =>
createAction('mvj/application/FORM_ATTRIBUTES_NOT_FOUND')();
export const receiveFormAttributes = (attributes: Attributes): ReceiveFormAttributesAction =>
createAction('mvj/application/RECEIVE_FORM_ATTRIBUTES')(attributes);
export const fetchAttachmentAttributes = (): FetchAttachmentAttributesAction =>
createAction('mvj/application/FETCH_ATTACHMENT_ATTRIBUTES')();
export const receiveAttachmentAttributes = (payload: Object): ReceiveAttachmentAttributesAction =>
createAction('mvj/application/RECEIVE_ATTACHMENT_ATTRIBUTES')(payload);
export const receiveAttachmentMethods = (payload: Object): ReceiveAttachmentMethodsAction =>
createAction('mvj/application/RECEIVE_ATTACHMENT_METHODS')(payload);
export const attachmentAttributesNotFound = (): AttachmentAttributesNotFoundAction =>
createAction('mvj/application/ATTACHMENT_ATTRIBUTES_NOT_FOUND')();
export const fetchApplicationRelatedAttachments = (payload: Object): FetchApplicationRelatedAttachmentsAction =>
createAction('mvj/application/FETCH_ATTACHMENTS')(payload);
export const receiveApplicationRelatedAttachments = (payload: Object): ReceiveApplicationRelatedAttachmentsAction =>
createAction('mvj/application/RECEIVE_ATTACHMENTS')(payload);
export const applicationRelatedAttachmentsNotFound = (payload: Object): ApplicationRelatedAttachmentsNotFoundAction =>
createAction('mvj/application/ATTACHMENTS_NOT_FOUND')(payload);
export const deleteUploadedAttachment = (payload: Object): DeleteUploadAction =>
createAction('mvj/application/DELETE_UPLOAD')(payload);
export const uploadAttachment = (payload: Object): UploadFileAction =>
createAction('mvj/application/UPLOAD_FILE')(payload);
export const fetchPendingUploads = (): FetchPendingUploadsAction =>
createAction('mvj/application/FETCH_PENDING_UPLOADS')();
export const receivePendingUploads = (payload: Object): ReceivePendingUploadsAction =>
createAction('mvj/application/RECEIVE_PENDING_UPLOADS')(payload);
export const pendingUploadsNotFound = (): PendingUploadsNotFoundAction =>
createAction('mvj/application/PENDING_UPLOADS_NOT_FOUND')();
export const receiveFileOperationFinished = (): ReceiveFileOperationFinishedAction =>
createAction('mvj/application/RECEIVE_FILE_OPERATION_FINISHED')();
26 changes: 15 additions & 11 deletions src/application/components/ApplicationAnswersField.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
// @flow

import React from 'react';
import type {FormSection} from '$src/plotSearch/types';
import type {SavedApplicationFormSection, UploadedFileMeta} from '$src/plotApplications/types';
import type {SectionExtraComponentProps} from '$src/application/types';
import {Column, Row} from 'react-foundation';

import FileDownloadLink from '$components/file/FileDownloadLink';
import {getApplicationAttachmentDownloadLink} from '$src/plotApplications/helpers';
import FormTextTitle from '$components/form/FormTextTitle';
import FormText from '$components/form/FormText';
import ApplicationAnswersSection from '$src/application/components/ApplicationAnswersSection';
import {getApplicationAttachmentDownloadLink} from '$src/application/helpers';

import type {
FormSection,
SavedApplicationFormSection,
SectionExtraComponentProps,
UploadedFileMeta,
} from '$src/application/types';

type Props = {
section: FormSection,
Expand All @@ -34,6 +39,11 @@ const ApplicationAnswersField = ({
<Row>
{section.fields.filter((field) => field.enabled).map((field) => {
const fieldAnswer = answer.fields[field.identifier];
const fieldType = fieldTypes?.find((fieldType) => fieldType.value === field.type)?.display_name;

if (fieldType === 'hidden') {
return null;
}

const getChoiceName = (id) => {
if (!id) {
Expand All @@ -52,7 +62,7 @@ const ApplicationAnswersField = ({

let displayValue = fieldAnswer?.value;
if (displayValue !== undefined && displayValue !== null) {
switch (fieldTypes?.find((fieldType) => fieldType.value === field.type)?.display_name) {
switch (fieldType) {
case 'radiobutton':
case 'radiobuttoninline':
displayValue = getChoiceName(displayValue);
Expand Down Expand Up @@ -80,12 +90,6 @@ const ApplicationAnswersField = ({
</li>)}</ul> : null;
break;
case 'hidden':
if(!field.choices) {
displayValue = field.default_value;
break;
}

displayValue = field.choices.find(choice => choice.value === field.default_value)?.text;
break;
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/application/components/ApplicationAnswersSection.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// @flow

import React from 'react';
import type {FormSection} from '$src/plotSearch/types';
import type {SavedApplicationFormSection} from '$src/plotApplications/types';

import Collapse from '$components/collapse/Collapse';
import SubTitle from '$components/content/SubTitle';
import type {SectionExtraComponentProps} from '$src/application/types';
import ApplicationAnswersField from '$src/application/components/ApplicationAnswersField';

import type {
FormSection,
SavedApplicationFormSection,
SectionExtraComponentProps,
} from '$src/application/types';

type Props = {
section: FormSection,
answer: SavedApplicationFormSection | Array<SavedApplicationFormSection>,
Expand Down
Loading

0 comments on commit 9158156

Please sign in to comment.