diff --git a/app/package.json b/app/package.json index a8ee0c168..2b0f4c53b 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "name-request", - "version": "5.8.1", + "version": "5.8.2", "private": true, "appName": "Name Request UI", "sbcName": "SBC Common Components", diff --git a/app/src/interfaces/payment-models.ts b/app/src/interfaces/payment-models.ts index 80f4bb11a..690c15bbc 100644 --- a/app/src/interfaces/payment-models.ts +++ b/app/src/interfaces/payment-models.ts @@ -1,7 +1,8 @@ -import { FilingTypes, Jurisdictions } from '@/enums' +import { FilingTypes, Jurisdictions, PaymentAction } from '@/enums' import { ErrorI } from '@/interfaces' export interface NameRequestPaymentResponse { + action: PaymentAction id: number nrId: string nrNum: string diff --git a/app/src/mixins/payment-mixin.ts b/app/src/mixins/payment-mixin.ts index 38e74f023..102e62571 100644 --- a/app/src/mixins/payment-mixin.ts +++ b/app/src/mixins/payment-mixin.ts @@ -4,7 +4,7 @@ import { useErrorStore, usePaymentStore, useStore } from '@/store' import { AxiosRequestConfig } from 'axios' import { ACCEPTED, CREATED, NO_CONTENT, OK, PAYMENT_REQUIRED } from 'http-status-codes' import { SessionStorageKeys } from 'sbc-common-components/src/util/constants' -import { PaymentStatus, StaffPaymentOptions, NrState, PaymentMethod, SbcPaymentStatus } from '@/enums' +import { PaymentStatus, StaffPaymentOptions, NrState, PaymentMethod, SbcPaymentStatus, PaymentAction } from '@/enums' import { ActionMixin } from '@/mixins' import { StaffPaymentIF, RefundParamsIF, NameRequestI, ErrorI, CreatePaymentParams, FetchFeesParams, NameRequestPaymentResponse } from '@/interfaces' @@ -22,6 +22,7 @@ export class PaymentMixin extends Mixins(ActionMixin) { @Action(usePaymentStore) setPaymentReceipt!: (receipt: any) => void @Action(usePaymentStore) setPaymentRequest!: (req: any) => void @Action(usePaymentStore) setSbcPayment!: (payment: any) => void + @Action(useStore) setFolioNumber!: (folioNumber: string) => void @Action(useStore) setRefundParams!: (refundParams: RefundParamsIF) => void @Action(useErrorStore) setAppError!: (err: ErrorI) => void @@ -582,6 +583,17 @@ export class PaymentMixin extends Mixins(ActionMixin) { if (!paymentsResponse) throw new Error('Got error from getNameRequestPayments()') this.setPayments(paymentsResponse) + + // find the first payment in the returned array that has action = CREATE and has sbcPayment.folioNumber set + const paymentWithFolio = paymentsResponse?.find( + payment => + payment?.action === PaymentAction.CREATE && + payment?.sbcPayment?.folioNumber + ) + if (paymentWithFolio?.sbcPayment?.folioNumber) { + this.setFolioNumber(paymentWithFolio.sbcPayment.folioNumber) + } + return true } catch (err) { // don't console.error - getNameRequestPayments() already did that