Skip to content

Commit

Permalink
fix(samgongustofa): Small cleanup in applications (#16946)
Browse files Browse the repository at this point in the history
* Make fields forPaymentLabel and totalLabel in PaymentChargeOverview optional (it has default value in buildFormPaymentChargeOverviewSection)

* Add mockable payment to MortgageCertificate

* Return recipientList on addReview action for TransferOfVehicleOwnership

* Add validation to plateSize field to make sure either front or rear is selected

* Make sure to clear the plateSize field when switching vehicle value

* Cleanup

* Cleanup check for oldEntry

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
johannaagma and kodiakhq[bot] authored Nov 21, 2024
1 parent 0885426 commit 2e6ef49
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class TransferOfVehicleOwnershipService extends BaseTemplateApiService {
async addReview({
application,
auth,
}: TemplateApiModuleActionProps): Promise<void> {
}: TemplateApiModuleActionProps): Promise<Array<EmailRecipient>> {
const answers = application.answers as TransferOfVehicleOwnershipAnswers

// 1. Make sure review comes from buyer, he is the only one that can add more reviewers
Expand All @@ -342,7 +342,7 @@ export class TransferOfVehicleOwnershipService extends BaseTemplateApiService {
!answers.buyer.nationalId ||
auth.nationalId !== answers.buyer.nationalId
) {
return
return []
}

// 2. Notify users that were added that need to review
Expand All @@ -365,10 +365,11 @@ export class TransferOfVehicleOwnershipService extends BaseTemplateApiService {
)
if (buyerCoOwners) {
for (let i = 0; i < buyerCoOwners.length; i++) {
const oldEntry = oldRecipientList.find((x) => {
x.role === EmailRole.buyerCoOwner &&
x.ssn === buyerCoOwners[i].nationalId
})
const oldEntry = oldRecipientList.find(
(x) =>
x.role === EmailRole.buyerCoOwner &&
x.ssn === buyerCoOwners[i].nationalId,
)
const emailChanged = oldEntry
? oldEntry.email !== buyerCoOwners[i].email
: true
Expand All @@ -393,10 +394,11 @@ export class TransferOfVehicleOwnershipService extends BaseTemplateApiService {
)
if (buyerOperators) {
for (let i = 0; i < buyerOperators.length; i++) {
const oldEntry = oldRecipientList.find((x) => {
x.role === EmailRole.buyerOperator &&
x.ssn === buyerOperators[i].nationalId
})
const oldEntry = oldRecipientList.find(
(x) =>
x.role === EmailRole.buyerOperator &&
x.ssn === buyerOperators[i].nationalId,
)
const emailChanged = oldEntry
? oldEntry.email !== buyerOperators[i].email
: true
Expand Down Expand Up @@ -453,6 +455,8 @@ export class TransferOfVehicleOwnershipService extends BaseTemplateApiService {
})
}
}

return newlyAddedRecipientList
}

async rejectApplication(props: TemplateApiModuleActionProps): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ export const payment = {
},
}),
paymentChargeOverview: defineMessages({
forPayment: {
id: 'aosh.tmo.application:payment.paymentChargeOverview.forPayment',
defaultMessage: 'Til greiðslu',
description: 'For payment label',
},
total: {
id: 'aosh.tmo.application:payment.paymentChargeOverview.total',
defaultMessage: 'Samtals',
description: 'Total amount label',
},
alertTitle: {
id: 'aosh.tmo.application:payment.paymentChargeOverview.alertTitle',
defaultMessage: 'Til athugunar!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ export const payment = {
description: 'Payment page title',
},
}),
paymentChargeOverview: defineMessages({
forPayment: {
id: 'doi.cs.application:payment.paymentChargeOverview.forPayment',
defaultMessage: 'Til greiðslu',
description: 'For payment label',
},
total: {
id: 'doi.cs.application:payment.paymentChargeOverview.total',
defaultMessage: 'Samtals',
description: 'Total amount label',
},
}),
confirmation: defineMessages({
confirm: {
id: 'doi.cs.application:payment.confirmation.confirm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ export const payment = {
description: 'Payment page title',
},
}),
paymentChargeOverview: defineMessages({
forPayment: {
id: 'hlc.application:payment.paymentChargeOverview.forPayment',
defaultMessage: 'Til greiðslu',
description: 'For payment label',
},
total: {
id: 'hlc.application:payment.paymentChargeOverview.total',
defaultMessage: 'Samtals',
description: 'Total amount label',
},
}),
confirmation: defineMessages({
confirm: {
id: 'hlc.application:payment.confirmation.confirm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@ export const payment = {
description: 'Payment page title',
},
}),
paymentChargeOverview: defineMessages({
forPayment: {
id: 'hwp.application:payment.paymentChargeOverview.forPayment',
defaultMessage: 'Til greiðslu',
description: 'For payment label',
},
total: {
id: 'hwp.application:payment.paymentChargeOverview.total',
defaultMessage: 'Samtals',
description: 'Total amount label',
},
}),

confirmation: defineMessages({
confirm: {
id: 'hwp.application:payment.confirmation.confirm',
Expand Down
12 changes: 0 additions & 12 deletions libs/application/templates/id-card/src/lib/messages/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ export const payment = {
description: 'Payment page title',
},
}),
paymentChargeOverview: defineMessages({
forPayment: {
id: 'id.application:payment.paymentChargeOverview.forPayment',
defaultMessage: 'Til greiðslu',
description: 'For payment label',
},
total: {
id: 'id.application:payment.paymentChargeOverview.total',
defaultMessage: 'Samtals',
description: 'Total amount label',
},
}),
confirmation: defineMessages({
confirm: {
id: 'id.application:payment.confirmation.confirm',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
InstitutionNationalIds,
MockablePaymentCatalogApi,
PaymentCatalogApi,
} from '@island.is/application/types'

Expand All @@ -11,3 +12,11 @@ export const SyslumadurPaymentCatalogApi = PaymentCatalogApi.configure({
},
externalDataId: 'payment',
})

export const MockableSyslumadurPaymentCatalogApi =
MockablePaymentCatalogApi.configure({
params: {
organizationId: InstitutionNationalIds.SYSLUMENN,
},
externalDataId: 'payment',
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
confirmation,
externalData,
overview,
payment,
property,
propertySearch,
} from '../lib/messages'
Expand Down Expand Up @@ -83,8 +82,6 @@ export const MortgageCertificateForm = (
],
}),
buildFormPaymentChargeOverviewSection({
sectionTitle: payment.general.sectionTitle,
forPaymentLabel: payment.labels.forPayment,
getSelectedChargeItems: (application) =>
getChargeItemCodesAndExtraLabel(application),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
IdentityApi,
UserProfileApi,
SyslumadurPaymentCatalogApi,
MockableSyslumadurPaymentCatalogApi,
} from '../dataProviders'
import { confirmation, externalData, payment, property } from '../lib/messages'
import Logo from '../assets/Logo'
Expand Down Expand Up @@ -60,6 +61,10 @@ export const PrerequisitesForm: Form = buildForm({
provider: SyslumadurPaymentCatalogApi,
title: '',
}),
buildDataProviderItem({
provider: MockableSyslumadurPaymentCatalogApi,
title: '',
}),
],
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@ export const payment = {
description: 'Payment section title',
},
}),
labels: defineMessages({
forPayment: {
id: 'mc.application:payment.labels.forPayment',
defaultMessage: 'Til greiðslu',
description: 'Payment for payment label',
},
}),
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
IdentityApi,
UserProfileApi,
SyslumadurPaymentCatalogApi,
MockableSyslumadurPaymentCatalogApi,
} from '../dataProviders'
import { AuthDelegationType } from '@island.is/shared/types'
import { buildPaymentState } from '@island.is/application/utils'
Expand Down Expand Up @@ -84,7 +85,12 @@ const template: ApplicationTemplate<
write: 'all',
read: 'all',
delete: true,
api: [IdentityApi, UserProfileApi, SyslumadurPaymentCatalogApi],
api: [
IdentityApi,
UserProfileApi,
SyslumadurPaymentCatalogApi,
MockableSyslumadurPaymentCatalogApi,
],
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ export const VehicleSelectField: FC<
const disabled =
!!response?.vehiclePlateOrderChecksByPermno?.validationErrorMessages
?.length
setPlate(disabled ? '' : currentVehicle.permno || '')
setValue(
'pickVehicle.plate',
disabled ? '' : currentVehicle.permno || '',
)

const permno = disabled ? '' : currentVehicle.permno || ''

setPlate(permno)

setValue('pickVehicle.plate', permno)

setValue('plateSize.frontPlateSize', [])
setValue('plateSize.rearPlateSize', [])

setIsLoading(false)
})
.catch((error) => console.error(error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ export const OrderVehicleLicensePlateSchema = z.object({
plate: z.string(),
type: z.string(),
}),
plateSize: z.object({
frontPlateSize: z.array(z.string()),
rearPlateSize: z.array(z.string()),
}),
plateSize: z
.object({
frontPlateSize: z.array(z.string()),
rearPlateSize: z.array(z.string()),
})
.refine(({ frontPlateSize, rearPlateSize }) => {
return frontPlateSize.length !== 0 || rearPlateSize.length !== 0
}),
plateDelivery: z.object({
deliveryMethodIsDeliveryStation: z.enum([YES, NO]),
deliveryStationTypeCode: z.string().optional(),
Expand Down
12 changes: 0 additions & 12 deletions libs/application/templates/university/src/lib/messages/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@ export const payment = {
description: 'Payment page title',
},
}),
paymentChargeOverview: defineMessages({
forPayment: {
id: 'uni.application:payment.paymentChargeOverview.forPayment',
defaultMessage: 'Til greiðslu',
description: 'For payment label',
},
total: {
id: 'uni.application:payment.paymentChargeOverview.total',
defaultMessage: 'Samtals',
description: 'Total amount label',
},
}),
confirmation: defineMessages({
confirm: {
id: 'uni.application:payment.confirmation.confirm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ export const FindVehicleFormField: FC<React.PropsWithChildren<Props>> = ({
setValue('vehicleMileage.requireMileage', vehicleDetails?.requireMileage)
setValue('vehicleMileage.mileageReading', vehicleDetails?.mileageReading)

setValue('plateSize.frontPlateSize', [])
setValue('plateSize.rearPlateSize', [])

if (permno) setValue('vehicleInfo.plate', permno)
if (permno) setValue('vehicleInfo.type', vehicleDetails.make)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export const VehicleRadioFormField: FC<React.PropsWithChildren<Props>> = ({
setValue('vehicleMileage.requireMileage', currentVehicle?.requireMileage)
setValue('vehicleMileage.mileageReading', currentVehicle?.mileageReading)

setValue('plateSize.frontPlateSize', [])
setValue('plateSize.rearPlateSize', [])

if (permno) setValue('vehicleInfo.plate', permno)
if (permno) setValue('vehicleInfo.type', currentVehicle?.make)
} else if (field.itemType === 'PLATE') {
Expand Down

0 comments on commit 2e6ef49

Please sign in to comment.