Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add Student CSFA Accomodation Section to Student Application Endpoint Response #31

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/api/models/accommodation_type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// TODO: question whether this should be in the database at all.
// And if so, why is it its own table?
enum AccommodationTypes {
LIVING_AT_PARENTS = 1,
LIVING_ON_OWN = 2,
BOTH = 3,
}

export default class AccommodationType {
id: number
description: string
isActive: boolean

constructor({
id,
description,
isActive,
}: {
id: number
description: string
isActive: boolean
}) {
this.id = id
this.description = description
this.isActive = isActive
}

// not in database
static readonly Types = AccommodationTypes
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default class StudentApplicationsSerializer {
studentDependants: this.#studentDependantsSection(
this.#application.student?.dependents || ([] as Dependent[])
),
csfaAccommodation: this.#csfaAccomodationSection(this.#application),
}
}

Expand Down Expand Up @@ -339,4 +340,39 @@ export default class StudentApplicationsSerializer {
dependants: serializedDependents,
}
}

#csfaAccomodationSection(application: Application) {
const accommodations = []
if (!isNil(application.prestudyAccomCode)) {
accommodations.push({
living: application.prestudyAccomCode,
ownHome: application.prestudyOwnHome,
rentToParents: application.prestudyBoardAmount,
cityId: application.prestudyCityId,
city: application.prestudyCityId,
provinceId: application.prestudyProvinceId,
province: application.prestudyProvinceId,
busService: application.prestudyBus,
distanceFromSchool: application.prestudyDistance, // NOTE: spelling updated from distinct_from_school used in front-end
})
}

if (!isNil(application.studyAccomCode)) {
accommodations.push({
living: application.studyAccomCode,
ownHome: application.studyOwnHome,
rentToParents: application.studyBoardAmount,
cityId: application.studyCityId,
city: application.studyCityId,
provinceId: application.studyProvinceId,
province: application.studyProvinceId,
busService: application.studyBus,
distanceFromSchool: application.studyDistance, // NOTE: spelling updated from distinct_from_school used in front-end
})
}

return {
accommodations // NOTE: spelling updated from accomodations (one m) used in front-end
}
}
}