Skip to content

Commit

Permalink
Merge pull request #6253 from espoon-voltti/preschool-manager
Browse files Browse the repository at this point in the history
Esiopetuksen johtajan tiedot
  • Loading branch information
akheron authored Jan 17, 2025
2 parents f3dbb24 + 259b65f commit 0cc0dd2
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
DaycareCareArea,
DaycareFields,
Language,
ProviderType
ProviderType,
UnitManager
} from 'lib-common/generated/api-types/daycare'
import {
AreaId,
Expand Down Expand Up @@ -104,6 +105,7 @@ type FormData = {
location: string
mailingAddress: Address
unitManager: UnitManager
preschoolManager: UnitManager
decisionCustomization: UnitDecisionCustomization
ophUnitOid: string
ophOrganizerOid: string
Expand All @@ -123,12 +125,6 @@ interface UnitDecisionCustomization {
handlerAddress: string
}

interface UnitManager {
name: string
phone: string
email: string
}

interface Address {
streetAddress: string
postalCode: string
Expand Down Expand Up @@ -410,6 +406,11 @@ function validateForm(
email: form.unitManager.email.trim(),
phone: form.unitManager.phone.trim()
}
const preschoolManager = {
name: form.preschoolManager.name.trim(),
email: form.preschoolManager.email.trim(),
phone: form.preschoolManager.phone.trim()
}
const decisionCustomization = {
daycareName: form.decisionCustomization.daycareName.trim(),
preschoolName: form.decisionCustomization.preschoolName.trim(),
Expand Down Expand Up @@ -730,6 +731,7 @@ function validateForm(
location,
mailingAddress,
unitManager,
preschoolManager,
decisionCustomization: {
daycareName: decisionCustomization.daycareName,
preschoolName: decisionCustomization.preschoolName,
Expand Down Expand Up @@ -855,6 +857,11 @@ function toFormData(unit: Daycare | undefined): FormData {
phone: unit?.unitManager?.phone ?? '',
email: unit?.unitManager?.email ?? ''
},
preschoolManager: {
name: unit?.preschoolManager?.name ?? '',
phone: unit?.preschoolManager?.phone ?? '',
email: unit?.preschoolManager?.email ?? ''
},
providesShiftCare: !!unit?.shiftCareOperationTimes,
operationTimes: (unit?.operationTimes ?? emptyOperationWeek).map((range) =>
range ? { start: range.formatStart(), end: range.formatEnd() } : null
Expand Down Expand Up @@ -923,7 +930,8 @@ export default function UnitEditor(props: Props) {
},
formErrors: []
})
const { careTypes, decisionCustomization, unitManager } = form
const { careTypes, decisionCustomization, unitManager, preschoolManager } =
form

const canApplyTypes = [
{
Expand Down Expand Up @@ -966,6 +974,8 @@ export default function UnitEditor(props: Props) {
})
const updateUnitManager: UpdateStateFn<UnitManager> = (updates) =>
updateForm({ unitManager: { ...form.unitManager, ...updates } })
const updatePreschoolManager: UpdateStateFn<UnitManager> = (updates) =>
updateForm({ preschoolManager: { ...form.preschoolManager, ...updates } })

const selectedFinanceDecisionManager = useMemo(
() =>
Expand Down Expand Up @@ -1826,7 +1836,7 @@ export default function UnitEditor(props: Props) {
{props.editable ? (
<InputField
id="unit-manager-name"
placeholder={i18n.unitEditor.placeholder.unitManager.name}
placeholder={i18n.unitEditor.placeholder.manager.name}
value={unitManager.name}
onChange={(value) => updateUnitManager({ name: value })}
width="L"
Expand Down Expand Up @@ -1869,6 +1879,57 @@ export default function UnitEditor(props: Props) {
<div data-qa="unit-manager-email">{unitManager.email}</div>
)}
</FormPart>
<H3>{i18n.unitEditor.title.preschoolManager}</H3>
<FormPart>
<label htmlFor="preschool-manager-name">
{i18n.unitEditor.label.preschoolManager.name}
</label>
{props.editable ? (
<InputField
id="preschool-manager-name"
placeholder={i18n.unitEditor.placeholder.manager.name}
value={preschoolManager.name}
onChange={(value) => updatePreschoolManager({ name: value })}
width="L"
data-qa="preschool-manager-name-input"
/>
) : (
<div data-qa="preschool-manager-name">{preschoolManager.name}</div>
)}
</FormPart>
<FormPart>
<label htmlFor="preschool-manager-phone">
{i18n.unitEditor.label.preschoolManager.phone}
</label>
{props.editable ? (
<InputField
id="preschool-manager-phone"
placeholder={i18n.unitEditor.placeholder.phone}
value={preschoolManager.phone}
onChange={(value) => updatePreschoolManager({ phone: value })}
data-qa="qa-preschool-manager-phone-input-field"
/>
) : (
<div data-qa="preschool-manager-phone">{preschoolManager.phone}</div>
)}
</FormPart>
<FormPart>
<label htmlFor="preschool-manager-email">
{i18n.unitEditor.label.preschoolManager.email}
</label>
{props.editable ? (
<InputField
id="preschool-manager-email"
placeholder={i18n.unitEditor.placeholder.email}
value={preschoolManager.email}
onChange={(value) => updatePreschoolManager({ email: value })}
width="L"
data-qa="qa-preschool-manager-email-input-field"
/>
) : (
<div data-qa="preschool-manager-email">{preschoolManager.email}</div>
)}
</FormPart>
<H3>{i18n.unitEditor.title.decisionCustomization}</H3>
<FormPart>
<label htmlFor="unit-daycare-name">
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib-common/generated/api-types/daycare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export interface Daycare {
ophUnitOid: string | null
phone: string | null
preschoolApplyPeriod: DateRange | null
preschoolManager: UnitManager
providerId: string
providerType: ProviderType
shiftCareOpenOnHolidays: boolean
Expand Down Expand Up @@ -280,6 +281,7 @@ export interface DaycareFields {
ophUnitOid: string | null
phone: string | null
preschoolApplyPeriod: DateRange | null
preschoolManager: UnitManager
providerId: string
providerType: ProviderType
shiftCareOpenOnHolidays: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4340,6 +4340,7 @@ export const fi = {
title: {
contact: 'Yksikön yhteystiedot',
unitManager: 'Varhaiskasvatusyksikön johtajan yhteystiedot',
preschoolManager: 'Esiopetuksen johtajan yhteystiedot',
decisionCustomization:
'Yksikön nimi päätöksellä ja ilmoitus paikan vastaanottamisesta',
mealOrderIntegration: 'Ruokatilausintegraatio',
Expand Down Expand Up @@ -4389,6 +4390,11 @@ export const fi = {
phone: 'Johtajan puhelinnumero',
email: 'Johtajan sähköpostiosoite'
},
preschoolManager: {
name: 'Esiopetuksen johtajan nimi',
phone: 'Esiopetuksen johtajan puhelinnumero',
email: 'Esiopetuksen johtajan sähköpostiosoite'
},
decisionCustomization: {
daycareName: 'Yksikön nimi varhaiskasvatuspäätöksellä',
preschoolName: 'Yksikön nimi esiopetuspäätöksellä',
Expand Down Expand Up @@ -4448,7 +4454,7 @@ export const fi = {
postalCode: 'Postinumero',
postOffice: 'Toimipaikka',
location: 'esim. 60.223038, 24.692637',
unitManager: {
manager: {
name: 'Etunimi Sukunimi'
},
decisionCustomization: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class DaycareEditIntegrationTest : FullApplicationTest(resetDbBeforeEach = true)
email = "joh.taja@example.com",
phone = "000-0000000",
),
preschoolManager =
UnitManager(
name = "Essi Opetus",
email = "essi.opetus@example.com",
phone = "001-0000000",
),
decisionCustomization =
DaycareDecisionCustomization(
daycareName = "Uusi päiväkoti (vaka)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ private fun DaycareFields.Companion.fromDaycare(daycare: Daycare): DaycareFields
location = daycare.location,
mailingAddress = daycare.mailingAddress,
unitManager = daycare.unitManager,
preschoolManager = daycare.preschoolManager,
decisionCustomization = daycare.decisionCustomization,
ophUnitOid = daycare.ophUnitOid,
ophOrganizerOid = daycare.ophOrganizerOid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
package fi.espoo.evaka.pdfgen

import fi.espoo.evaka.application.ServiceNeed
import fi.espoo.evaka.daycare.UnitManager
import fi.espoo.evaka.daycare.domain.ProviderType
import fi.espoo.evaka.daycare.service.DaycareManager
import fi.espoo.evaka.decision.Decision
import fi.espoo.evaka.decision.DecisionStatus
import fi.espoo.evaka.decision.DecisionType
Expand Down Expand Up @@ -146,7 +146,7 @@ private val guardian =
"",
)
private val manager =
DaycareManager("Pirkko Päiväkodinjohtaja", "pirkko.paivakodinjohtaja@example.com", "0401231234")
UnitManager("Pirkko Päiväkodinjohtaja", "pirkko.paivakodinjohtaja@example.com", "0401231234")

@TestConfiguration
class PdfGeneratorTestConfiguration {
Expand Down Expand Up @@ -441,6 +441,7 @@ class PdfGeneratorTest {
serviceNeed,
lang,
manager,
manager,
)

val file = File.createTempFile("decision_", ".pdf")
Expand Down
5 changes: 3 additions & 2 deletions service/src/main/kotlin/fi/espoo/evaka/daycare/CareArea.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ data class Daycare(
val location: Coordinate?,
@Nested("mailing_") val mailingAddress: MailingAddress,
@Nested("unit_manager_") val unitManager: UnitManager,
@Nested("preschool_manager_") val preschoolManager: UnitManager,
@Nested("decision_") val decisionCustomization: DaycareDecisionCustomization,
val ophUnitOid: String?,
val ophOrganizerOid: String?,
Expand All @@ -79,6 +80,8 @@ data class Daycare(
@Nested("mealtime_") override val mealTimes: DaycareMealtimes,
) : DaycareInfo

data class UnitManager(val name: String, val email: String, val phone: String)

interface DaycareInfo {
val name: String
val operationDays: Set<Int>
Expand Down Expand Up @@ -120,8 +123,6 @@ data class FinanceDecisionHandler(
val lastName: String,
)

data class UnitManager(val name: String, val email: String, val phone: String)

data class DaycareDecisionCustomization(
val daycareName: String,
val preschoolName: String,
Expand Down
35 changes: 8 additions & 27 deletions service/src/main/kotlin/fi/espoo/evaka/daycare/DaycareQueries.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import fi.espoo.evaka.daycare.controllers.ApplicationUnitType
import fi.espoo.evaka.daycare.controllers.PublicUnit
import fi.espoo.evaka.daycare.domain.Language
import fi.espoo.evaka.daycare.domain.ProviderType
import fi.espoo.evaka.daycare.service.DaycareManager
import fi.espoo.evaka.shared.AreaId
import fi.espoo.evaka.shared.DaycareId
import fi.espoo.evaka.shared.EmployeeId
Expand Down Expand Up @@ -59,6 +58,7 @@ data class DaycareFields(
val location: Coordinate?,
val mailingAddress: MailingAddress,
val unitManager: UnitManager,
val preschoolManager: UnitManager,
val decisionCustomization: DaycareDecisionCustomization,
val ophUnitOid: String?,
val ophOrganizerOid: String?,
Expand Down Expand Up @@ -163,6 +163,7 @@ SELECT
finance_decision_handler.last_name AS finance_decision_handler_last_name,
finance_decision_handler.created AS finance_decision_handler_created,
unit_manager_name, unit_manager_email, unit_manager_phone,
preschool_manager_name, preschool_manager_email, preschool_manager_phone,
ca.name AS care_area_name, ca.short_name AS care_area_short_name,
daycare.operation_times,
daycare.shift_care_operation_times,
Expand Down Expand Up @@ -264,20 +265,6 @@ SELECT ${bind(name)}, ${bind(areaId)}
.executeAndReturnGeneratedKeys()
.exactlyOne()

fun Database.Transaction.updateDaycareManager(daycareId: DaycareId, manager: UnitManager) =
execute {
sql(
"""
UPDATE daycare
SET
unit_manager_name = ${bind(manager.name)},
unit_manager_email = ${bind(manager.email)},
unit_manager_phone = ${bind(manager.phone)}
WHERE id = ${bind(daycareId)}
"""
)
}

fun Database.Transaction.updateDaycare(id: DaycareId, fields: DaycareFields) = execute {
sql(
"""
Expand Down Expand Up @@ -327,6 +314,12 @@ SET
iban = ${bind(fields.iban)},
provider_id = ${bind(fields.providerId)},
operation_times = ${bind(fields.operationTimes)},
unit_manager_name = ${bind(fields.unitManager.name)},
unit_manager_phone = ${bind(fields.unitManager.phone)},
unit_manager_email = ${bind(fields.unitManager.email)},
preschool_manager_name = ${bind(fields.preschoolManager.name)},
preschool_manager_phone = ${bind(fields.preschoolManager.phone)},
preschool_manager_email = ${bind(fields.preschoolManager.email)},
shift_care_operation_times = ${bind(fields.shiftCareOperationTimes)},
shift_care_open_on_holidays = ${bind(fields.shiftCareOpenOnHolidays)},
mealtime_breakfast = ${bind(fields.mealtimes.breakfast)},
Expand Down Expand Up @@ -428,18 +421,6 @@ ORDER BY name
.toList()
}

fun Database.Read.getUnitManager(unitId: DaycareId): DaycareManager? =
createQuery {
sql(
"""
SELECT unit_manager_name AS name, unit_manager_phone AS phone, unit_manager_email AS email
FROM daycare
WHERE id = ${bind(unitId)}
"""
)
}
.exactlyOneOrNull()

fun Database.Read.getDaycareGroupSummaries(daycareId: DaycareId): List<DaycareGroupSummary> =
createQuery {
sql(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import fi.espoo.evaka.daycare.service.DaycareGroup
import fi.espoo.evaka.daycare.service.DaycareService
import fi.espoo.evaka.daycare.updateCaretakers
import fi.espoo.evaka.daycare.updateDaycare
import fi.espoo.evaka.daycare.updateDaycareManager
import fi.espoo.evaka.daycare.updateGroup
import fi.espoo.evaka.daycare.updateUnitClosingDate
import fi.espoo.evaka.daycare.validateUnitClosingDate
Expand Down Expand Up @@ -441,7 +440,6 @@ class DaycareController(
daycareId,
)
fields.closingDate?.also { validateUnitClosingDate(tx, daycareId, it) }
tx.updateDaycareManager(daycareId, fields.unitManager)
tx.updateDaycare(daycareId, fields)
}
}
Expand Down Expand Up @@ -484,7 +482,6 @@ class DaycareController(
Action.Global.CREATE_UNIT,
)
val id = it.createDaycare(fields.areaId, fields.name)
it.updateDaycareManager(id, fields.unitManager)
it.updateDaycare(id, fields)
id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class DaycareService {
}
}

data class DaycareManager(val name: String, val email: String, val phone: String)

data class DaycareGroup(
val id: GroupId,
val daycareId: DaycareId,
Expand Down
Loading

0 comments on commit 0cc0dd2

Please sign in to comment.