Skip to content

Commit 305ed01

Browse files
committed
Merge branch 'master' into Nekku_meal_integration
2 parents a1b1429 + d642bed commit 305ed01

File tree

71 files changed

+2490
-1473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2490
-1473
lines changed

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"concurrently": "^9.1.0",
103103
"css-loader": "^7.1.1",
104104
"csstype": "^3.1.2",
105-
"esbuild": "^0.24.0",
105+
"esbuild": "^0.25.0",
106106
"eslint": "^9.20.0",
107107
"eslint-config-prettier": "^10.0.1",
108108
"eslint-plugin-import": "^2.31.0",

frontend/src/citizen-frontend/applications/editor/service-need/PreferredStartSubSection.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import LocalDate from 'lib-common/local-date'
1010
import { useIdRouteParam } from 'lib-common/useRouteParams'
1111
import { useUniqueId } from 'lib-common/utils/useUniqueId'
1212
import Checkbox from 'lib-components/atoms/form/Checkbox'
13+
import AdaptiveFlex from 'lib-components/layout/AdaptiveFlex'
1314
import ExpandingInfo from 'lib-components/molecules/ExpandingInfo'
1415
import FileUpload from 'lib-components/molecules/FileUpload'
1516
import { AlertBox } from 'lib-components/molecules/MessageBoxes'
@@ -127,12 +128,25 @@ export default React.memo(function PreferredStartSubSection({
127128
<>
128129
<Gap size="s" />
129130

130-
<strong>
131-
{
132-
t.applications.editor.serviceNeed.urgent.attachmentsMessage
133-
.subtitle
134-
}
135-
</strong>
131+
<AdaptiveFlex>
132+
<strong>
133+
{
134+
t.applications.editor.serviceNeed.urgent
135+
.attachmentsMessage.subtitle
136+
}
137+
</strong>
138+
{verificationRequested &&
139+
errors.urgencyAttachments?.arrayErrors && (
140+
<AlertBox
141+
message={
142+
t.validationErrors[
143+
errors.urgencyAttachments.arrayErrors
144+
]
145+
}
146+
thin
147+
/>
148+
)}
149+
</AdaptiveFlex>
136150

137151
<Gap size="s" />
138152

frontend/src/citizen-frontend/applications/editor/service-need/ServiceTimeSubSectionDaycare.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useIdRouteParam } from 'lib-common/useRouteParams'
1212
import Checkbox from 'lib-components/atoms/form/Checkbox'
1313
import Radio from 'lib-components/atoms/form/Radio'
1414
import TimeInput from 'lib-components/atoms/form/TimeInput'
15+
import AdaptiveFlex from 'lib-components/layout/AdaptiveFlex'
1516
import {
1617
FixedSpaceColumn,
1718
FixedSpaceRow
@@ -296,9 +297,20 @@ export default React.memo(function ServiceTimeSubSectionDaycare({
296297

297298
<Gap size="s" />
298299

299-
<strong>
300-
{t.applications.editor.serviceNeed.shiftCare.attachmentsSubtitle}
301-
</strong>
300+
<AdaptiveFlex>
301+
<strong>
302+
{t.applications.editor.serviceNeed.shiftCare.attachmentsSubtitle}
303+
</strong>
304+
{verificationRequested &&
305+
errors.shiftCareAttachments?.arrayErrors && (
306+
<AlertBox
307+
message={
308+
t.validationErrors[errors.shiftCareAttachments.arrayErrors]
309+
}
310+
thin
311+
/>
312+
)}
313+
</AdaptiveFlex>
302314

303315
<Gap size="s" />
304316

frontend/src/citizen-frontend/applications/editor/validations.ts

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import {
1818
TIME_REGEXP,
1919
validate
2020
} from 'lib-common/form-validation'
21-
import { ApplicationDetails as ApplicationDetailsGen } from 'lib-common/generated/api-types/application'
21+
import {
22+
ApplicationAttachment,
23+
ApplicationDetails as ApplicationDetailsGen
24+
} from 'lib-common/generated/api-types/application'
2225
import LocalDate from 'lib-common/local-date'
2326
import { featureFlags } from 'lib-customizations/citizen'
2427

@@ -67,6 +70,26 @@ const preferredStartDateValidator =
6770
? undefined
6871
: err
6972

73+
export const getUrgencyAttachmentValidStatus = (
74+
urgent: boolean,
75+
urgencyAttachments: ApplicationAttachment[]
76+
) =>
77+
urgent && urgencyAttachments.length === 0 && featureFlags.urgencyAttachments
78+
? featureFlags.requireAttachments
79+
? 'require'
80+
: 'notify'
81+
: undefined
82+
83+
export const getShiftCareAttachmentsValidStatus = (
84+
shiftCare: boolean,
85+
shiftCareAttachments: ApplicationAttachment[]
86+
) =>
87+
shiftCare && shiftCareAttachments.length === 0
88+
? featureFlags.requireAttachments
89+
? 'require'
90+
: 'notify'
91+
: undefined
92+
7093
export const validateApplication = (
7194
apiData: ApplicationDetailsGen,
7295
form: ApplicationFormData,
@@ -125,7 +148,36 @@ export const validateApplication = (
125148
: undefined,
126149
assistanceDescription: form.serviceNeed.assistanceNeeded
127150
? required(form.serviceNeed.assistanceDescription)
128-
: undefined
151+
: undefined,
152+
urgencyAttachments:
153+
getUrgencyAttachmentValidStatus(
154+
form.serviceNeed.urgent,
155+
form.serviceNeed.urgencyAttachments
156+
) === 'require'
157+
? {
158+
arrayErrors: 'required',
159+
itemErrors: form.serviceNeed.urgencyAttachments.map(() => ({
160+
id: undefined,
161+
name: undefined
162+
}))
163+
}
164+
: undefined,
165+
shiftCareAttachments:
166+
getShiftCareAttachmentsValidStatus(
167+
form.serviceNeed.shiftCare,
168+
form.serviceNeed.shiftCareAttachments
169+
) === 'require'
170+
? {
171+
arrayErrors:
172+
form.serviceNeed.shiftCareAttachments.length === 0
173+
? 'required'
174+
: undefined,
175+
itemErrors: form.serviceNeed.shiftCareAttachments.map(() => ({
176+
id: undefined,
177+
name: undefined
178+
}))
179+
}
180+
: undefined
129181
},
130182
unitPreference: {
131183
siblingName:

frontend/src/citizen-frontend/applications/editor/verification/ApplicationVerificationView.tsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ import RoundIcon from 'lib-components/atoms/RoundIcon'
1515
import Container, { ContentArea } from 'lib-components/layout/Container'
1616
import { H1, P } from 'lib-components/typography'
1717
import { defaultMargins, Gap } from 'lib-components/white-space'
18-
import { featureFlags } from 'lib-customizations/citizen'
1918
import colors from 'lib-customizations/common'
2019
import { faInfo } from 'lib-icons'
2120

2221
import BasicsSection from '../../../applications/editor/verification/BasicsSection'
2322
import UnitPreferenceSection from '../../../applications/editor/verification/UnitPreferenceSection'
2423
import { useTranslation } from '../../../localization'
24+
import {
25+
getShiftCareAttachmentsValidStatus,
26+
getUrgencyAttachmentValidStatus
27+
} from '../validations'
2528

2629
import AdditionalDetailsSection from './AdditionalDetailsSection'
2730
import ContactInfoSection from './ContactInfoSection'
@@ -52,14 +55,18 @@ export default React.memo(function ApplicationVerificationViewDaycare({
5255
}: DaycareApplicationVerificationViewProps) {
5356
const t = useTranslation()
5457
const missingUrgencyAttachments =
55-
formData.serviceNeed.urgent &&
56-
formData.serviceNeed.urgencyAttachments.length === 0 &&
57-
featureFlags.urgencyAttachments
58+
getUrgencyAttachmentValidStatus(
59+
formData.serviceNeed.urgent,
60+
formData.serviceNeed.urgencyAttachments
61+
) === 'notify'
62+
const missingShiftCareAttachments =
63+
getShiftCareAttachmentsValidStatus(
64+
formData.serviceNeed.shiftCare,
65+
formData.serviceNeed.shiftCareAttachments
66+
) === 'notify'
5867

5968
const missingAttachments =
60-
missingUrgencyAttachments ||
61-
(formData.serviceNeed.shiftCare &&
62-
formData.serviceNeed.shiftCareAttachments.length === 0)
69+
missingUrgencyAttachments || missingShiftCareAttachments
6370
return (
6471
<Container>
6572
<ContentArea opaque>
@@ -83,15 +90,11 @@ export default React.memo(function ApplicationVerificationViewDaycare({
8390
{t.applications.editor.verification.attachmentBox.urgency}
8491
</li>
8592
)}
86-
{formData.serviceNeed.shiftCare &&
87-
formData.serviceNeed.shiftCareAttachments.length === 0 && (
88-
<li>
89-
{
90-
t.applications.editor.verification.attachmentBox
91-
.shiftCare
92-
}
93-
</li>
94-
)}
93+
{missingShiftCareAttachments && (
94+
<li>
95+
{t.applications.editor.verification.attachmentBox.shiftCare}
96+
</li>
97+
)}
9598
</ul>
9699
<P>
97100
<a href="#" onClick={closeVerification} role="button">

frontend/src/citizen-frontend/attachments.ts

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// SPDX-License-Identifier: LGPL-2.1-or-later
44

55
import { Failure, Success, wrapResult } from 'lib-common/api'
6-
import { AttachmentType } from 'lib-common/generated/api-types/attachment'
6+
import { ApplicationAttachmentType } from 'lib-common/generated/api-types/application'
7+
import { IncomeStatementAttachmentType } from 'lib-common/generated/api-types/incomestatement'
78
import {
89
ApplicationId,
910
AttachmentId,
@@ -14,22 +15,30 @@ import { UploadHandler } from 'lib-components/molecules/FileUpload'
1415
import { API_URL, client } from './api-client'
1516
import { deleteAttachment } from './generated/api-clients/attachment'
1617

17-
function uploadHandler(url: string): UploadHandler {
18+
function uploadHandler(config: {
19+
path: string
20+
params?: unknown
21+
}): UploadHandler {
1822
return {
1923
upload: async (file, onUploadProgress) => {
2024
const formData = new FormData()
2125
formData.append('file', file)
2226

2327
try {
24-
const { data } = await client.post<AttachmentId>(url, formData, {
25-
headers: { 'Content-Type': 'multipart/form-data' },
26-
onUploadProgress: ({ loaded, total }) =>
27-
onUploadProgress(
28-
total !== undefined && total !== 0
29-
? Math.round((loaded / total) * 100)
30-
: 0
31-
)
32-
})
28+
const { data } = await client.post<AttachmentId>(
29+
config.path,
30+
formData,
31+
{
32+
headers: { 'Content-Type': 'multipart/form-data' },
33+
params: config.params,
34+
onUploadProgress: ({ loaded, total }) =>
35+
onUploadProgress(
36+
total !== undefined && total !== 0
37+
? Math.round((loaded * 100) / total)
38+
: 0
39+
)
40+
}
41+
)
3342
return Success.of(data)
3443
} catch (e) {
3544
return Failure.fromError(e)
@@ -42,24 +51,28 @@ function uploadHandler(url: string): UploadHandler {
4251
const deleteAttachmentResult = wrapResult(deleteAttachment)
4352

4453
export function incomeStatementAttachment(
45-
incomeStatementId: IncomeStatementId | undefined
54+
incomeStatementId: IncomeStatementId | undefined,
55+
attachmentType: IncomeStatementAttachmentType | null
4656
): UploadHandler {
47-
return uploadHandler(
48-
incomeStatementId
57+
return uploadHandler({
58+
path: incomeStatementId
4959
? `/citizen/attachments/income-statements/${incomeStatementId}`
50-
: '/citizen/attachments/income-statements'
51-
)
60+
: '/citizen/attachments/income-statements',
61+
params: { attachmentType }
62+
})
5263
}
5364

54-
export const messageAttachment = uploadHandler('/citizen/attachments/messages')
65+
export const messageAttachment = uploadHandler({
66+
path: '/citizen/attachments/messages'
67+
})
5568

5669
export function applicationAttachment(
5770
applicationId: ApplicationId,
58-
attachmentType: AttachmentType
71+
attachmentType: ApplicationAttachmentType
5972
): UploadHandler {
60-
return uploadHandler(
61-
`/citizen/attachments/applications/${applicationId}?type=${attachmentType}`
62-
)
73+
return uploadHandler({
74+
path: `/citizen/attachments/applications/${applicationId}?type=${attachmentType}`
75+
})
6376
}
6477

6578
export function getAttachmentUrl(

0 commit comments

Comments
 (0)