Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jxio committed Oct 29, 2024
1 parent 4ccc807 commit ddf08c5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
19 changes: 15 additions & 4 deletions src/components/ViewRoutingSlip/RefundRequestForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
close-on-content-click
offset-y
v-model="isExpanded"
v-if="!canEdit && currentRefundStatusLabel !== RoutingSlipRefundCodes.PROCESSING"
v-if="!canEdit && currentRefundStatusLabel && currentRefundStatusLabel !== RoutingSlipRefundCodes.PROCESSING"
>
<template v-slot:activator="{ on, attrs }">
<v-btn
Expand Down Expand Up @@ -125,7 +125,7 @@ import { computed, defineComponent, reactive, toRefs } from '@vue/composition-ap
import { useRefundRequestForm, useRoutingSlipInfo } from '@/composables/ViewRoutingSlip'
import AddressForm from '@/components/common/AddressForm.vue'
import { GetRoutingSlipRequestPayload, RefundRequestDetails } from '@/models/RoutingSlip'
import { RoutingSlipRefundCodes, RoutingSlipRefundStatus } from '@/util/constants'
import { RoutingSlipRefundCodes, RoutingSlipRefundStatus, SlipStatus } from '@/util/constants'
import { useRoutingSlip } from '@/composables/useRoutingSlip'
import { useSearch } from '@/composables/Dashboard/useSearch'
Expand Down Expand Up @@ -156,11 +156,22 @@ export default defineComponent({
const state = reactive({
currentRefundStatus: routingSlipState.routingSlipDetails.value?.refundStatus,
currentStatus: routingSlipState.routingSlipDetails.value?.status,
isExpanded: false,
...refundRequestFormState
})
const currentRefundStatusLabel = computed(() => searchState.getRefundStatusText(state.currentRefundStatus))
const currentRefundStatusLabel = computed(() => {
const refundInProgress = [SlipStatus.REFUNDAUTHORIZED, SlipStatus.REFUNDREQUEST, SlipStatus.REFUNDUPLOADED].includes(state.currentStatus as SlipStatus)
const refundComplete = [SlipStatus.REFUNDPROCESSED].includes(state.currentStatus as SlipStatus)
if (refundInProgress) {
return RoutingSlipRefundCodes.PROCESSING
} else if (refundComplete) {
return searchState.getRefundStatusText(state.currentRefundStatus)
} else {
return null
}
})
const expendStatus = () => {
state.isExpanded = !state.isExpanded
Expand All @@ -174,12 +185,12 @@ export default defineComponent({
await routingSlipOperations.updateRoutingSlipRefundStatus(status)
const comment = `Refund status updated from ${searchState.getRefundStatusText(state.currentRefundStatus)} to ${searchState.getRefundStatusText(status)}`
await routingSlipOperations.updateRoutingSlipComments(comment)
context.emit('commentsUpdated')
state.currentRefundStatus = status
if (routingSlipOperations.routingSlip.value?.number) {
const getRoutingSlipRequestPayload: GetRoutingSlipRequestPayload = { routingSlipNumber: routingSlipOperations.routingSlip.value?.number }
await routingSlipOperations.getRoutingSlip(getRoutingSlipRequestPayload)
}
context.emit('commentsUpdated')
}
return {
Expand Down
4 changes: 2 additions & 2 deletions src/composables/Dashboard/useSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ export function useSearch (props, context) {
}, 100) // Adjust the wait time as needed

function getRefundStatusText (statusCode: string | undefined): string {
const status = RoutingSlipRefundStatus.find(item => item.code === statusCode)
return status ? status.text : RoutingSlipRefundCodes.PROCESSING
const refundStatus = RoutingSlipRefundStatus.find(item => item.code === statusCode)
return refundStatus.text ? refundStatus.text : RoutingSlipRefundCodes.PROCESSING
}

function getStatusFromRefundStatus (statusCode: string): SlipStatus {
Expand Down
1 change: 1 addition & 0 deletions src/composables/useRoutingSlip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const useRoutingSlip = () => {

const getRoutingSlip = async (getRoutingSlipRequestPayload: GetRoutingSlipRequestPayload) => {
try {
routingSlip.value = null
const response = await RoutingSlipService.getRoutingSlip(
getRoutingSlipRequestPayload.routingSlipNumber,
getRoutingSlipRequestPayload?.showGlobalLoader
Expand Down

0 comments on commit ddf08c5

Please sign in to comment.