Skip to content

Commit

Permalink
send all relevant payload for both medportalen and mimer.nu until fur…
Browse files Browse the repository at this point in the history
…ther notice
  • Loading branch information
momentiris committed Dec 17, 2024
1 parent 1443cdd commit 44300ee
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 81 deletions.
6 changes: 6 additions & 0 deletions src/adapters/tests/leasing-adapter/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ describe('leasing-adapter', () => {
housingType: 'RENTAL',
housingTypeDescription: null,
landlord: null,
housingReference:
factory.applicationProfileHousingReference.build(),
}
)

Expand All @@ -259,6 +261,8 @@ describe('leasing-adapter', () => {
housingType: 'RENTAL',
housingTypeDescription: null,
landlord: null,
housingReference:
factory.applicationProfileHousingReference.build(),
}
)

Expand All @@ -282,6 +286,8 @@ describe('leasing-adapter', () => {
housingType: 'RENTAL',
housingTypeDescription: null,
landlord: null,
housingReference:
factory.applicationProfileHousingReference.build(),
}
)

Expand Down
53 changes: 16 additions & 37 deletions src/services/lease-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1587,49 +1587,28 @@ export const routes = (router: KoaRouter) => {
}

const expiresAt = dayjs(new Date()).add(6, 'months').toDate()
const housingReferenceParams: leasingAdapter.CreateOrUpdateApplicationProfileRequestParams['housingReference'] =
body.housingReference
? {
email: body.housingReference.email,
expiresAt,
phone: body.housingReference.phone,
...(getApplicationProfile.ok &&
getApplicationProfile.data.housingReference
? {
reviewStatus:
getApplicationProfile.data.housingReference.reviewStatus,
comment:
getApplicationProfile.data.housingReference.comment,
lastAdminUpdatedAt:
getApplicationProfile.data.housingReference
.lastAdminUpdatedAt,
lastApplicantUpdatedAt:
getApplicationProfile.data.housingReference
.lastApplicantUpdatedAt,
lastAdminUpdatedBy: 'foo',
reasonRejected:
getApplicationProfile.data.housingReference
.reasonRejected,
}
: {
reviewStatus: 'PENDING',
comment: null,
lastAdminUpdatedAt: null,
lastAdminUpdatedBy: null,
lastApplicantUpdatedAt: null,
reasonRejected: null,
reviewedAt: null,
}),
}
: undefined

const createOrUpdate =
await leasingAdapter.createOrUpdateApplicationProfileByContactCode(
ctx.params.contactCode,
{
...body,
expiresAt,
housingReference: housingReferenceParams,
numChildren: body.numChildren,
numAdults: body.numAdults,
housingType: body.housingType,
landlord: body.landlord,
housingTypeDescription: body.housingTypeDescription,
housingReference: {
comment: body.housingReference.comment,
email: body.housingReference.email,
phone: body.housingReference.phone,
lastAdminUpdatedAt: body.housingReference.lastAdminUpdatedAt,
lastApplicantUpdatedAt:
body.housingReference.lastApplicantUpdatedAt,
reasonRejected: body.housingReference.reasonRejected,
reviewStatus: body.housingReference.reviewStatus,
expiresAt: body.housingReference.expiresAt,
},
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,22 @@ export const UpdateApplicationProfileRequestParams =
housingTypeDescription: true,
}).extend({
housingReference:
leasing.CreateOrUpdateApplicationProfileRequestParamsSchema.shape.housingReference
.unwrap()
.pick({ email: true, phone: true })
.optional(),
})

export const UpdateApplicationProfileResponseData =
leasing.CreateOrUpdateApplicationProfileResponseDataSchema.pick({
id: true,
contactCode: true,
expiresAt: true,
housingTypeDescription: true,
housingType: true,
landlord: true,
numAdults: true,
numChildren: true,
}).extend({
housingReference:
leasing.CreateOrUpdateApplicationProfileResponseDataSchema.shape.housingReference
.unwrap()
.pick({
leasing.CreateOrUpdateApplicationProfileResponseDataSchema.shape.housingReference.pick(
{
email: true,
phone: true,
reviewStatus: true,
comment: true,
lastAdminUpdatedAt: true,
lastApplicantUpdatedAt: true,
reasonRejected: true,
expiresAt: true,
})
.nullable(),
}
),
})

export const UpdateApplicationProfileResponseData =
leasing.CreateOrUpdateApplicationProfileResponseDataSchema

export const GetApplicationProfileResponseData =
leasing.GetApplicationProfileResponseDataSchema.pick({
contactCode: true,
createdAt: true,
expiresAt: true,
housingType: true,
housingTypeDescription: true,
id: true,
landlord: true,
numAdults: true,
numChildren: true,
}).extend({
housingReference:
leasing.GetApplicationProfileResponseDataSchema.shape.housingReference
.unwrap()
.pick({
email: true,
phone: true,
expiresAt: true,
})
.nullable(),
})
leasing.GetApplicationProfileResponseDataSchema
10 changes: 10 additions & 0 deletions src/services/lease-service/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,16 @@ describe('lease-service', () => {
housingType: 'RENTAL',
housingTypeDescription: 'bar',
landlord: null,
housingReference: {
email: null,
phone: null,
reviewStatus: 'PENDING',
comment: null,
lastApplicantUpdatedAt: null,
lastAdminUpdatedAt: null,
expiresAt: new Date(),
reasonRejected: null,
},
})

expect(res.status).toBe(200)
Expand Down

0 comments on commit 44300ee

Please sign in to comment.