Skip to content

Commit

Permalink
✨ Add CSFA accommodations section to student application blob.
Browse files Browse the repository at this point in the history
Decide to standardize spelling in back end, because I don't want to propagate the typos. I'd rather require the front-end be fixed to match.
  • Loading branch information
klondikemarlen committed Aug 14, 2023
1 parent dad3023 commit 8f28861
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
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
}
}
}

0 comments on commit 8f28861

Please sign in to comment.