Skip to content

Commit

Permalink
Implement attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
birkirkristmunds committed Jan 10, 2024
1 parent dc1d165 commit a415f8a
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,13 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
): Promise<Attachment[]> {
const {
additionalAttachments,
schoolConfirmationAttachments,
leaseAgreementAttachments,
householdSupplementChildren,
householdSupplementHousing,
} = getHSApplicationAnswers(application.answers)
assistedCareAtHomeAttachments,
houseRentAttachments,
houseRentAllowanceAttachments,
assistedLivingAttachments,
purchaseOfHearingAidsAttachments,
halfwayHouseAttachments,
} = getPSApplicationAnswers(application.answers)

const attachments: Attachment[] = []

Expand All @@ -269,29 +271,70 @@ export class SocialInsuranceAdministrationService extends BaseTemplateApiService
}

if (
schoolConfirmationAttachments &&
schoolConfirmationAttachments.length > 0 &&
householdSupplementChildren === YES
assistedCareAtHomeAttachments &&
assistedCareAtHomeAttachments.length > 0
) {
attachments.push(
...(await this.initAttachments(
application,
AttachmentTypeEnum.SchoolConfirmation,
schoolConfirmationAttachments,
AttachmentTypeEnum.AssistedCareAtHome,
assistedCareAtHomeAttachments,
)),
)
}

if (houseRentAttachments && houseRentAttachments.length > 0) {
attachments.push(
...(await this.initAttachments(
application,
AttachmentTypeEnum.HouseRentAgreement,
houseRentAttachments,
)),
)
}

if (
leaseAgreementAttachments &&
leaseAgreementAttachments.length > 0 &&
householdSupplementHousing === HouseholdSupplementHousing.RENTER
houseRentAllowanceAttachments &&
houseRentAllowanceAttachments.length > 0
) {
attachments.push(
...(await this.initAttachments(
application,
AttachmentTypeEnum.RentalAgreement,
leaseAgreementAttachments,
AttachmentTypeEnum.HouseRentAllowance,
houseRentAllowanceAttachments,
)),
)
}

if (assistedLivingAttachments && assistedLivingAttachments.length > 0) {
attachments.push(
...(await this.initAttachments(
application,
AttachmentTypeEnum.AssistedLiving,
assistedLivingAttachments,
)),
)
}

if (
purchaseOfHearingAidsAttachments &&
purchaseOfHearingAidsAttachments.length > 0
) {
attachments.push(
...(await this.initAttachments(
application,
AttachmentTypeEnum.PurchaseOfHearingAids,
purchaseOfHearingAidsAttachments,
)),
)
}

if (halfwayHouseAttachments && halfwayHouseAttachments.length > 0) {
attachments.push(
...(await this.initAttachments(
application,
AttachmentTypeEnum.HalfwayHouse,
halfwayHouseAttachments,
)),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export const PensionSupplementForm: Form = buildForm({

const reasons = [
ApplicationReason.ASSISTED_CARE_AT_HOME,
ApplicationReason.PURCHASE_OF_HEARING_AIDS,
ApplicationReason.HELPING_EQUIPMENT,
ApplicationReason.ASSISTED_LIVING,
ApplicationReason.HALFWAY_HOUSE,
ApplicationReason.HOUSE_RENT,
Expand Down Expand Up @@ -406,9 +406,7 @@ export const PensionSupplementForm: Form = buildForm({

return (
applicationReason &&
applicationReason.includes(
ApplicationReason.PURCHASE_OF_HEARING_AIDS,
)
applicationReason.includes(ApplicationReason.HELPING_EQUIPMENT)
)
},
children: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const fileUploadValidationSection = (
}

if (
applicationReason.includes(ApplicationReason.PURCHASE_OF_HEARING_AIDS) &&
applicationReason.includes(ApplicationReason.HELPING_EQUIPMENT) &&
obj.purchaseOfHearingAids
) {
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export enum ApplicationReason {
HOUSE_RENT = 'houseRent', // Húsaleiga sem fellur utan húsaleigubóta frá sveitafélagi
ASSISTED_CARE_AT_HOME = 'assistedCareAtHome', // Umönnun í heimahúsi
ASSISTED_LIVING = 'assistedLiving', // Dvöl á sambýli eða áfangaheimili
PURCHASE_OF_HEARING_AIDS = 'purchaseOfHearingAids', // Kaup á heyrnartækjum
OXYGEN_FILTER_COST = 'oxygenFilterCost', // Rafmagn á súrefnissíu
HELPING_EQUIPMENT = 'helpingEquipment', // Kaup á heyrnartækjum
OXYGEN_FILTER_ELECTRICITY_COST = 'oxygenFilterElectricityCost', // Rafmagn á súrefnissíu
HALFWAY_HOUSE = 'halfwayHouse', // Dvöl á áfangaheimili
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export const dataSchema = z.object({
z.enum([
ApplicationReason.MEDICINE_COST,
ApplicationReason.ASSISTED_CARE_AT_HOME,
ApplicationReason.OXYGEN_FILTER_COST,
ApplicationReason.PURCHASE_OF_HEARING_AIDS,
ApplicationReason.OXYGEN_FILTER_ELECTRICITY_COST,
ApplicationReason.HELPING_EQUIPMENT,
ApplicationReason.ASSISTED_LIVING,
ApplicationReason.HALFWAY_HOUSE,
ApplicationReason.HOUSE_RENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,36 @@ export function getApplicationAnswers(answers: Application['answers']) {
'tempAnswers',
) as Application['answers']

const assistedCareAtHomeAttachments = getValueViaPath(
answers,
'fileUpload.assistedCareAtHome',
) as FileType[]

const houseRentAttachments = getValueViaPath(
answers,
'fileUpload.houseRentAgreement',
) as FileType[]

const houseRentAllowanceAttachments = getValueViaPath(
answers,
'fileUpload.houseRentAllowance',
) as FileType[]

const assistedLivingAttachments = getValueViaPath(
answers,
'fileUpload.assistedLiving',
) as FileType[]

const purchaseOfHearingAidsAttachments = getValueViaPath(
answers,
'fileUpload.purchaseOfHearingAids',
) as FileType[]

const halfwayHouseAttachments = getValueViaPath(
answers,
'fileUpload.halfwayHouse',
) as FileType[]

return {
applicantPhonenumber,
applicationReason,
Expand All @@ -87,6 +117,12 @@ export function getApplicationAnswers(answers: Application['answers']) {
bankAddress,
currency,
tempAnswers,
assistedCareAtHomeAttachments,
houseRentAttachments,
houseRentAllowanceAttachments,
assistedLivingAttachments,
purchaseOfHearingAidsAttachments,
halfwayHouseAttachments,
}
}

Expand Down Expand Up @@ -163,11 +199,11 @@ export function getApplicationReasonOptions() {
label: pensionSupplementFormMessage.applicationReason.assistedCareAtHome,
},
{
value: ApplicationReason.OXYGEN_FILTER_COST,
value: ApplicationReason.OXYGEN_FILTER_ELECTRICITY_COST,
label: pensionSupplementFormMessage.applicationReason.oxygenFilterCost,
},
{
value: ApplicationReason.PURCHASE_OF_HEARING_AIDS,
value: ApplicationReason.HELPING_EQUIPMENT,
label:
pensionSupplementFormMessage.applicationReason.purchaseOfHearingAids,
},
Expand Down Expand Up @@ -240,7 +276,7 @@ export function getAttachments(application: Application) {
AttachmentTypes.ASSISTED_LIVING,
)
}
if (reason === ApplicationReason.PURCHASE_OF_HEARING_AIDS) {
if (reason === ApplicationReason.HELPING_EQUIPMENT) {
getAttachmentDetails(
pensionSupplementAttachments?.purchaseOfHearingAids,
AttachmentTypes.PURCHASE_OF_HEARING_AIDS,
Expand Down

0 comments on commit a415f8a

Please sign in to comment.