Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: amend date of certification for verifying certificate #7098

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/client/src/i18n/messages/views/verifyCertificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface IVerifyCertificateMessages
registar: MessageDescriptor
brn: MessageDescriptor
drn: MessageDescriptor
createdAt: MessageDescriptor
certifiedAt: MessageDescriptor
toastMessage: MessageDescriptor
}

Expand Down Expand Up @@ -110,7 +110,7 @@ const messagesToDefine: IVerifyCertificateMessages = {
defaultMessage: 'Name of registar',
description: 'Label for name of registar center'
},
createdAt: {
certifiedAt: {
id: 'verifyCertificate.createdAt',
Nil20 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Date of certification',
description: 'Label for date of certification'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { compact } from 'lodash'
import { useVerificationRecordDetails } from './useVerificationRecordDetails'
import { useLocationIntl } from '@client/hooks/useLocationIntl'
import { generateFullAddress } from '@client/utils/locationUtils'
import { SUBMISSION_STATUS } from '@client/declarations'

const Container = styled.div<{ size: string; checking: boolean }>`
position: relative;
Expand Down Expand Up @@ -246,6 +247,21 @@ export function VerifyCertificatePage() {
if (isDeathRegistration(data)) return data.deceased?.gender
}

const getLastCertifiedDate = (data: RecordDetails) => {
// find when declaration was certified
return (
data.history &&
data.history.find(
(h, index, allHistory) =>
index - 1 &&
allHistory[index]?.regStatus?.toString() ===
SUBMISSION_STATUS.CERTIFIED &&
allHistory[index + 1]?.regStatus?.toString() !==
SUBMISSION_STATUS.CERTIFIED
)
)?.date
}
Nil20 marked this conversation as resolved.
Show resolved Hide resolved

// This function currently supports upto two location levels
const getLocation = (data: RecordDetails) => {
const location = data.eventLocation
Expand Down Expand Up @@ -477,12 +493,15 @@ export function VerifyCertificatePage() {
<ListViewItemSimplified
label={
<Text variant={'bold16'} element={'span'}>
{intl.formatMessage(messageToDefine.createdAt)}
{intl.formatMessage(messageToDefine.certifiedAt)}
</Text>
}
value={
<Text variant={'reg16'} element={'span'}>
{formatDate(new Date(data.createdAt), 'dd MMMM yyyy')}
{formatDate(
new Date(getLastCertifiedDate(data)),
'dd MMMM yyyy'
)}
</Text>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const FETCH_RECORD_DETAILS_FOR_VERIFICATION = gql`
history {
action
regStatus
date
user {
primaryOffice {
hierarchy {
Expand Down
Loading