Skip to content

Commit

Permalink
Merge pull request #6372 from espoon-voltti/starters-fix
Browse files Browse the repository at this point in the history
Näytä aloittavien ryhmä viimeisenä mobiilin vastaanottajavalinnassa
  • Loading branch information
terolaakso authored Feb 11, 2025
2 parents 0d1c320 + f540eb7 commit c68992b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ describe('Sending and receiving messages', () => {
testDaycareGroup.name,
`${testChild.lastName} ${testChild.firstName}`,
`${testChild2.lastName} ${testChild2.firstName}`,
`${testPreschool.name} (aloittavat)`,
`${preschoolGroup.name} (aloittavat)`,
`${testPreschool.name} (aloittavat lapset)`,
`${preschoolGroup.name} (aloittavat lapset)`,
starterChildLabel
]
expect(labels.sort()).toEqual(expectedReceiverNames.sort())
expect(labels).toEqual(expectedReceiverNames)

// Send a message to a starter child -> selects the whole unit
await receiverSelector.optionByLabel(starterChildLabel).click()
Expand Down Expand Up @@ -327,7 +327,7 @@ describe('Sending and receiving messages', () => {
}).save()
await createMessageAccounts()

// Verify that available recipients contain current placements and starters
// Verify that available recipients contain the starters
staffPage = await Page.open({ mockedTime: mockedDateAt10 })
await employeeLogin(staffPage, futureStaff)
await staffPage.goto(`${config.employeeUrl}/messages`)
Expand All @@ -338,15 +338,15 @@ describe('Sending and receiving messages', () => {
await receiverSelector.expandAll()
const labels = await receiverSelector.labels.allTexts()
const expectedReceiverNames = [
`${secondGroup.name} (aloittavat)`,
`${secondGroup.name} (aloittavat lapset)`,
`${testChild.lastName} ${testChild.firstName} (${mockedDate.addYears(1).addDays(1).format()})`,
`${testChild2.lastName} ${testChild2.firstName} (${mockedDate.addYears(1).addDays(1).format()})`
]
expect(labels.sort()).toEqual(expectedReceiverNames.sort())
expect(labels).toEqual(expectedReceiverNames)

// Send a message to a starter group (contains 2 children)
await receiverSelector
.optionByLabel(`${secondGroup.name} (aloittavat)`)
.optionByLabel(`${secondGroup.name} (aloittavat lapset)`)
.click()
await receiverSelector.close()
await messageEditor.inputTitle.fill('Aloittavalle otsikko')
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/employee-mobile-frontend/messages/MessageEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import isEqual from 'lodash/isEqual'
import React, { useEffect, useMemo, useState } from 'react'
import styled from 'styled-components'

import { sortReceivers } from 'lib-common/api-types/messaging'
import { boolean, string } from 'lib-common/form/fields'
import { array, mapped, object, recursive, value } from 'lib-common/form/form'
import { useForm, useFormFields } from 'lib-common/form/hooks'
Expand Down Expand Up @@ -152,7 +153,10 @@ export default React.memo(function MessageEditor({
? {
recipients: receiversAsSelectorNode(
accountId,
availableRecipients,
availableRecipients.map((r) => ({
...r,
receivers: sortReceivers(r.receivers)
})),
i18n.messages.messageEditor.starters,
draft.recipients
),
Expand All @@ -163,7 +167,10 @@ export default React.memo(function MessageEditor({
: {
recipients: receiversAsSelectorNode(
accountId,
availableRecipients,
availableRecipients.map((r) => ({
...r,
receivers: sortReceivers(r.receivers)
})),
i18n.messages.messageEditor.starters
),
urgent: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export const fi = {
sender: 'Lähettäjä',
receivers: 'Vastaanottajat',
recipientsPlaceholder: 'Valitse...',
starters: 'aloittavat',
starters: 'aloittavat lapset',
subject: {
heading: 'Otsikko',
placeholder: 'Kirjoita...'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4609,7 +4609,7 @@ export const fi = {
childDob: 'Syntymäaika',
receivers: 'Vastaanottajat',
confirmText: 'Lähetä viesti valituille',
starters: 'aloittavat'
starters: 'aloittavat lapset'
},
noTitle: 'Ei otsikkoa',
notSent: 'Ei lähetetty',
Expand Down

0 comments on commit c68992b

Please sign in to comment.