Skip to content

Commit

Permalink
code modification 3
Browse files Browse the repository at this point in the history
  • Loading branch information
RuoxuanPengBC committed Nov 28, 2023
1 parent b07d2e2 commit f2eb88b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions ppr-ui/src/components/unitNotes/UnitNoteHeaderInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { defineComponent, reactive, computed, toRefs } from 'vue-demi'
import { MhUIStatusTypes, UnitNoteDocTypes, UnitNoteStatusTypes } from '@/enums'
import { UnitNotesInfo, cancelledWithRedemptionNote } from '@/resources'
import { UnitNoteIF } from '@/interfaces/unit-note-interfaces/unit-note-interface'
import { pacificDate } from '@/utils'
import { localTodayDate, pacificDate } from '@/utils'
import { useMhrUnitNote } from '@/composables'
export default defineComponent({
Expand All @@ -39,14 +39,15 @@ export default defineComponent({
} = useMhrUnitNote()
const localState = reactive({
today: computed(() : string => localTodayDate()),
noteHeader: computed(() : string => {
let header =
[UnitNoteDocTypes.CONTINUED_NOTE_OF_CAUTION, UnitNoteDocTypes.EXTENSION_TO_NOTICE_OF_CAUTION]
.includes(props.note.documentType)
? UnitNotesInfo[props.note.documentType].panelHeader
: UnitNotesInfo[props.note.documentType].header
if (isExpiryDatePassed(props.note)) {
if (isExpiryDatePassed(props.note, localState.today)) {
header += ` (Expired)`
} else if (props.note.status === UnitNoteStatusTypes.CANCELLED &&
props.note.documentType === UnitNoteDocTypes.NOTICE_OF_TAX_SALE) {
Expand Down
9 changes: 5 additions & 4 deletions ppr-ui/src/composables/mhrInformation/useMhrUnitNote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { UnitNoteDocTypes, UnitNoteStatusTypes } from '@/enums/unitNoteDocTypes'
import { CancelUnitNoteIF, PartyIF, UnitNoteIF, UnitNotePanelIF, UnitNoteRegistrationIF } from '@/interfaces'
import { useStore } from '@/store/store'
import { deleteEmptyProperties, localTodayDate, submitMhrUnitNote } from '@/utils'
import { deleteEmptyProperties, submitMhrUnitNote } from '@/utils'
import { storeToRefs } from 'pinia'
import { cloneDeep } from 'lodash'
import { computed } from 'vue-demi'
Expand Down Expand Up @@ -114,12 +114,13 @@ export const useMhrUnitNote = () => {

const isCancelUnitNote = computed((): boolean => getMhrUnitNoteType.value === UnitNoteDocTypes.NOTE_CANCELLATION)

const isExpiryDatePassed = (note: UnitNoteIF): boolean => {
// Check if the provided Unit Note's Expiry date passed today or not
// parameter 'today' need to be in the format of 'YYYY-MM-DD'
const isExpiryDatePassed = (note: UnitNoteIF, today: string): boolean => {
if ((note.documentType === UnitNoteDocTypes.CONTINUED_NOTE_OF_CAUTION ||
note.documentType === UnitNoteDocTypes.EXTENSION_TO_NOTICE_OF_CAUTION) &&
note.expiryDateTime != null && note.expiryDateTime !== '') {
!!note.expiryDateTime) {
const expiryDate = note.expiryDateTime.substring(0, 10)
const today = localTodayDate()
return new Date(expiryDate) < new Date(today)
}
return false
Expand Down
6 changes: 3 additions & 3 deletions ppr-ui/tests/unit/UnitNotePanels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
mockedUnitNotesCancelled
} from './test-data'
import { BaseAddress } from '@/composables/address'
import { pacificDate, shortPacificDate } from '@/utils'
import { localTodayDate, pacificDate, shortPacificDate } from '@/utils'
import {
ResidentialExemptionQSDropDown,
ResidentialExemptionStaffDropDown,
Expand Down Expand Up @@ -58,10 +58,10 @@ function createComponent (otherMockNotes?: Array<UnitNoteIF | CancelUnitNoteIF>)
const verifyHeaderContent = (note: UnitNotePanelIF, header: Wrapper<any>) => {
// Check the unit note type
const typeText = header.find('h3').text()

const today = localTodayDate()
let statusText = ''
if (note.status === UnitNoteStatusTypes.EXPIRED ||
useMhrUnitNote().isExpiryDatePassed(note)) {
useMhrUnitNote().isExpiryDatePassed(note, today)) {
statusText = ' (Expired)'
} else if (note.status === UnitNoteStatusTypes.CANCELLED) {
statusText = ' (Cancelled)'
Expand Down

0 comments on commit f2eb88b

Please sign in to comment.