From cd6670f9714a18b389122374188134bef33b04a2 Mon Sep 17 00:00:00 2001 From: Riku Rouvila Date: Mon, 13 May 2024 09:56:42 +0300 Subject: [PATCH 001/108] Code freeze 1.5.0 release --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ca3be238e6..98000d3fbf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.5.0 (TBD) +## 1.5.0 ## Breaking changes @@ -43,7 +43,6 @@ - Fix search result declaration record audit unassign issue [#5781](https://github.com/opencrvs/opencrvs-core/issues/5781) - In review page, Eliminating the 'No supporting documents' and 'upload' prompts when documents are already uploaded [#6231] (https://github.com/opencrvs/opencrvs-core/issues/6231) - ## Refactor - Remove dependency on openhim. The openhim db is kept for backwards compatibility reasons and will be removed in v1.6. It has brought some major changes From 1e12cea5b14d21c53b0fa7611a5dad05531afcf8 Mon Sep 17 00:00:00 2001 From: Tahmid Rahman <42269993+tahmidrahman-dsi@users.noreply.github.com> Date: Tue, 14 May 2024 14:27:09 +0600 Subject: [PATCH 002/108] [OCRVS-6228] Remove record corrected action from history (#6976) * Add a util function to exclude record corrected history from fhir bundle response * Implement the util method to remove record corrected history from root resolvers * Revert "Implement the util method to remove record corrected history from root resolvers" This reverts commit fe1d6f5360393892a142ded9c8f3f33db1413f57. * Refactor exclude record corrected history * Revert "Refactor exclude record corrected history" This reverts commit 588f9c8a3d8b6b98ad1b56930341b5035f7ea976. * Create and implement a custom filtering predicate to remove corrected history * Remove unused utils * Remove unused imports * Remove check for rejected action as there would be no corrected task after rejection --------- Co-authored-by: Riku Rouvila --- packages/commons/src/fhir/task.ts | 18 ++++++++++++++++++ .../features/registration/type-resolvers.ts | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/commons/src/fhir/task.ts b/packages/commons/src/fhir/task.ts index faaf0dc9fe9..4daf8b022e0 100644 --- a/packages/commons/src/fhir/task.ts +++ b/packages/commons/src/fhir/task.ts @@ -457,3 +457,21 @@ function updateTaskTemplate( } return task } + +export function notCorrectedHistory( + task: Task, + index: number, + allTasks: Task[] +): boolean { + const currentAction = getActionFromTask(task) + if (currentAction === TaskAction.CORRECTED) { + const pastTasks = allTasks + .slice(0, index) + .filter((task) => getActionFromTask(task) !== TaskAction.ASSIGNED) + const lastAction = getActionFromTask(pastTasks[pastTasks.length - 1]) + if (lastAction === TaskAction.APPROVED_CORRECTION) { + return false + } + } + return true +} diff --git a/packages/gateway/src/features/registration/type-resolvers.ts b/packages/gateway/src/features/registration/type-resolvers.ts index 21db1bd9063..1ffd2d84b86 100644 --- a/packages/gateway/src/features/registration/type-resolvers.ts +++ b/packages/gateway/src/features/registration/type-resolvers.ts @@ -82,7 +82,8 @@ import { isQuestionnaireResponse, isTaskOrTaskHistory, resourceIdentifierToUUID, - Address + Address, + notCorrectedHistory } from '@opencrvs/commons/types' import { GQLQuestionnaireQuestion, GQLResolver } from '@gateway/graphql/schema' @@ -1821,6 +1822,7 @@ export const typeResolvers: GQLResolver = { return record.entry .map(({ resource }) => resource) .filter(isTaskOrTaskHistory) + .filter(notCorrectedHistory) .sort(sortDescending) } }, @@ -1980,6 +1982,7 @@ export const typeResolvers: GQLResolver = { return record.entry .map(({ resource }) => resource) .filter(isTaskOrTaskHistory) + .filter(notCorrectedHistory) .sort(sortDescending) } }, @@ -2117,6 +2120,7 @@ export const typeResolvers: GQLResolver = { return record.entry .map(({ resource }) => resource) .filter(isTaskOrTaskHistory) + .filter(notCorrectedHistory) .sort(sortDescending) } } From 7192fcbad41b8ef8aec940a56ab03602149df0a6 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 14 May 2024 14:49:11 +0600 Subject: [PATCH 003/108] Update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98000d3fbf8..8b2868e0a19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,8 @@ - Fix certificate templates not getting populated for health facility event locations & ADMIN_LEVEL > 2 - Fix download failure for incomplete (without date of death) death declarations [#6807](https://github.com/opencrvs/opencrvs-core/issues/6807) - Fix search result declaration record audit unassign issue [#5781](https://github.com/opencrvs/opencrvs-core/issues/5781) -- In review page, Eliminating the 'No supporting documents' and 'upload' prompts when documents are already uploaded [#6231] (https://github.com/opencrvs/opencrvs-core/issues/6231) +- In review page, Eliminating the 'No supporting documents' and 'upload' prompts when documents are already uploaded [#6231](https://github.com/opencrvs/opencrvs-core/issues/6231) +- In record audit page, after 'Correction request approved' the “record corrected” action is removed from history [#6228](https://github.com/opencrvs/opencrvs-core/issues/6228) ## Refactor From 5ac4a52cbc23fa5de8f556a524c10f0892d7cbd4 Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Tue, 14 May 2024 19:12:28 +0600 Subject: [PATCH 004/108] Fix: Ocrvs 6247 Registrar of any location should be able to review a correction request (#6981) * review button role status updated for national registrar * updated changelog.md * In search result page, navigate to review correction page if registration status is `CORRECTION_REQUESTED` * Update CHANGELOG.md --------- Co-authored-by: tahmidrahman-dsi Co-authored-by: Tahmid Rahman <42269993+tahmidrahman-dsi@users.noreply.github.com> --- CHANGELOG.md | 1 + packages/client/src/views/RecordAudit/ActionButtons.tsx | 6 +++++- packages/client/src/views/SearchResult/SearchResult.tsx | 9 +++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b2868e0a19..b5b8100e3af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ - Fix search result declaration record audit unassign issue [#5781](https://github.com/opencrvs/opencrvs-core/issues/5781) - In review page, Eliminating the 'No supporting documents' and 'upload' prompts when documents are already uploaded [#6231](https://github.com/opencrvs/opencrvs-core/issues/6231) - In record audit page, after 'Correction request approved' the “record corrected” action is removed from history [#6228](https://github.com/opencrvs/opencrvs-core/issues/6228) +- Fix Registrar of any location should be able to review a correction request [#6247](https://github.com/opencrvs/opencrvs-core/issues/6247) ## Refactor diff --git a/packages/client/src/views/RecordAudit/ActionButtons.tsx b/packages/client/src/views/RecordAudit/ActionButtons.tsx index 439dc001881..e01353e2e45 100644 --- a/packages/client/src/views/RecordAudit/ActionButtons.tsx +++ b/packages/client/src/views/RecordAudit/ActionButtons.tsx @@ -394,7 +394,11 @@ export const ShowReviewButton = ({ EVENT_STATUS.DECLARED, EVENT_STATUS.CORRECTION_REQUESTED ], - NATIONAL_REGISTRAR: [EVENT_STATUS.VALIDATED, EVENT_STATUS.DECLARED] + NATIONAL_REGISTRAR: [ + EVENT_STATUS.VALIDATED, + EVENT_STATUS.DECLARED, + EVENT_STATUS.CORRECTION_REQUESTED + ] } if ( diff --git a/packages/client/src/views/SearchResult/SearchResult.tsx b/packages/client/src/views/SearchResult/SearchResult.tsx index d6a0cdec931..9cc6eedac09 100644 --- a/packages/client/src/views/SearchResult/SearchResult.tsx +++ b/packages/client/src/views/SearchResult/SearchResult.tsx @@ -34,7 +34,10 @@ import { goToPage as goToPageAction, goToPrintCertificate as goToPrintCertificateAction } from '@client/navigation' -import { REVIEW_EVENT_PARENT_FORM_PAGE } from '@client/navigation/routes' +import { + REVIEW_CORRECTION, + REVIEW_EVENT_PARENT_FORM_PAGE +} from '@client/navigation/routes' import { getScope, getUserDetails } from '@client/profile/profileSelectors' import { SEARCH_EVENTS } from '@client/search/queries' import { transformData } from '@client/search/transformer' @@ -319,7 +322,9 @@ class SearchResultView extends React.Component< : this.props.intl.formatMessage(constantsMessages.review), handler: () => this.props.goToPage( - REVIEW_EVENT_PARENT_FORM_PAGE, + reg.declarationStatus === 'CORRECTION_REQUESTED' + ? REVIEW_CORRECTION + : REVIEW_EVENT_PARENT_FORM_PAGE, reg.id, 'review', reg.event.toLowerCase() From 5dd2bd0c45d7ae948c6373e7448257a61aa105e4 Mon Sep 17 00:00:00 2001 From: Tahmid Rahman <42269993+tahmidrahman-dsi@users.noreply.github.com> Date: Mon, 20 May 2024 18:40:05 +0600 Subject: [PATCH 005/108] [OCRVS-6163] Fix login config load issue (#7010) * Rename component file names according to the current convention * Rename PhoneNumberVerificationForm -> AuthDetailsVerificationForm - as we also verify email if the user notification method is set 'email' * Fetch config before rendering react app * Amend withRetry function implementation Co-authored-by: Riku Rouvila * Update CHANGELOG.md --------- Co-authored-by: Riku Rouvila --- CHANGELOG.md | 1 + packages/login/src/App.tsx | 14 ++++++------- packages/login/src/Page.tsx | 8 ++----- packages/login/src/index.tsx | 21 ++++++++++++++++++- .../AuthDetailsVerificationForm.test.tsx} | 0 .../AuthDetailsVerificationForm.tsx} | 6 +++--- .../Commons.tsx} | 0 .../ForgottenItemForm.test.tsx} | 2 +- .../ForgottenItemForm.tsx} | 0 .../RecoveryCodeEntryForm.tsx} | 0 .../ResetCredentialsSuccessPage.test.tsx} | 0 .../ResetCredentialsSuccessPage.tsx} | 2 +- .../SecurityQuestionForm.tsx} | 0 .../UpdatePasswordForm.test.tsx} | 0 .../UpdatePasswordForm.tsx} | 0 15 files changed, 35 insertions(+), 19 deletions(-) rename packages/login/src/views/{resetCredentialsForm/phoneNumberVerificationForm.test.tsx => ResetCredentialsForm/AuthDetailsVerificationForm.test.tsx} (100%) rename packages/login/src/views/{resetCredentialsForm/phoneNumberVerificationForm.tsx => ResetCredentialsForm/AuthDetailsVerificationForm.tsx} (98%) rename packages/login/src/views/{resetCredentialsForm/commons.tsx => ResetCredentialsForm/Commons.tsx} (100%) rename packages/login/src/views/{resetCredentialsForm/forgottenItemForm.test.tsx => ResetCredentialsForm/ForgottenItemForm.test.tsx} (96%) rename packages/login/src/views/{resetCredentialsForm/forgottenItemForm.tsx => ResetCredentialsForm/ForgottenItemForm.tsx} (100%) rename packages/login/src/views/{resetCredentialsForm/recoveryCodeEntryForm.tsx => ResetCredentialsForm/RecoveryCodeEntryForm.tsx} (100%) rename packages/login/src/views/{resetCredentialsForm/resetCredentialsSuccessPage.test.tsx => ResetCredentialsForm/ResetCredentialsSuccessPage.test.tsx} (100%) rename packages/login/src/views/{resetCredentialsForm/resetCredentialsSuccessPage.tsx => ResetCredentialsForm/ResetCredentialsSuccessPage.tsx} (98%) rename packages/login/src/views/{resetCredentialsForm/securityQuestionForm.tsx => ResetCredentialsForm/SecurityQuestionForm.tsx} (100%) rename packages/login/src/views/{resetCredentialsForm/updatePasswordForm.test.tsx => ResetCredentialsForm/UpdatePasswordForm.test.tsx} (100%) rename packages/login/src/views/{resetCredentialsForm/updatePasswordForm.tsx => ResetCredentialsForm/UpdatePasswordForm.tsx} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5b8100e3af..1f06957dcbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ - In review page, Eliminating the 'No supporting documents' and 'upload' prompts when documents are already uploaded [#6231](https://github.com/opencrvs/opencrvs-core/issues/6231) - In record audit page, after 'Correction request approved' the “record corrected” action is removed from history [#6228](https://github.com/opencrvs/opencrvs-core/issues/6228) - Fix Registrar of any location should be able to review a correction request [#6247](https://github.com/opencrvs/opencrvs-core/issues/6247) +- Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) ## Refactor diff --git a/packages/login/src/App.tsx b/packages/login/src/App.tsx index 035e8b4c9a5..958d2f8e0a6 100644 --- a/packages/login/src/App.tsx +++ b/packages/login/src/App.tsx @@ -21,12 +21,12 @@ import { Provider } from 'react-redux' import { Route, Switch } from 'react-router' import { ConnectedRouter } from 'connected-react-router' import { createGlobalStyle, ThemeProvider } from 'styled-components' -import { ForgottenItem } from './views/resetCredentialsForm/forgottenItemForm' -import { ResetCredentialsSuccessPage } from './views/resetCredentialsForm/resetCredentialsSuccessPage' -import { PhoneNumberVerification } from './views/resetCredentialsForm/phoneNumberVerificationForm' -import { RecoveryCodeEntry } from './views/resetCredentialsForm/recoveryCodeEntryForm' -import { SecurityQuestion } from './views/resetCredentialsForm/securityQuestionForm' -import { UpdatePassword } from './views/resetCredentialsForm/updatePasswordForm' +import { ForgottenItem } from './views/ResetCredentialsForm/ForgottenItemForm' +import { ResetCredentialsSuccessPage } from './views/ResetCredentialsForm/ResetCredentialsSuccessPage' +import { AuthDetailsVerification } from './views/ResetCredentialsForm/AuthDetailsVerificationForm' +import { RecoveryCodeEntry } from './views/ResetCredentialsForm/RecoveryCodeEntryForm' +import { SecurityQuestion } from './views/ResetCredentialsForm/SecurityQuestionForm' +import { UpdatePassword } from './views/ResetCredentialsForm/UpdatePasswordForm' import { Page } from './Page' import { LoginBackgroundWrapper } from '@login/common/LoginBackgroundWrapper' import { StepTwoContainer } from '@login/views/StepTwo/StepTwoContainer' @@ -72,7 +72,7 @@ export const App = ({ store, history }: IAppProps) => ( - + diff --git a/packages/login/src/Page.tsx b/packages/login/src/Page.tsx index e7177329775..f17824e437a 100644 --- a/packages/login/src/Page.tsx +++ b/packages/login/src/Page.tsx @@ -10,10 +10,7 @@ */ import * as React from 'react' import { useDispatch, useSelector } from 'react-redux' -import { - applicationConfigLoadAction, - storeClientRedirectRoute -} from './login/actions' +import { storeClientRedirectRoute } from './login/actions' import { changeLanguage, loadLanguages } from './i18n/actions' import { getDefaultLanguage, @@ -39,7 +36,6 @@ function useLoadConfigurations() { const dispatch = useDispatch() React.useEffect(() => { dispatch(loadLanguages()) - dispatch(applicationConfigLoadAction()) }, [dispatch]) } @@ -50,7 +46,7 @@ function useStoreClientRedirectRoute() { if (!!paramRedirectTo) { dispatch(storeClientRedirectRoute(paramRedirectTo)) } - }, [dispatch]) + }, [dispatch, paramRedirectTo]) } function useSyncLanguage() { diff --git a/packages/login/src/index.tsx b/packages/login/src/index.tsx index a6884793144..b5d70fb8c7e 100644 --- a/packages/login/src/index.tsx +++ b/packages/login/src/index.tsx @@ -19,6 +19,11 @@ import { BrowserTracing } from '@sentry/tracing' // eslint-disable-next-line import/no-unassigned-import import 'focus-visible/dist/focus-visible.js' import WebFont from 'webfontloader' +import { authApi } from './utils/authApi' +import { delay } from 'lodash' +import { applicationConfigLoadedAction } from './login/actions' + +const RETRY_TIMEOUT = 5000 WebFont.load({ google: { @@ -44,4 +49,18 @@ const { store, history } = createStore() const container = document.getElementById('root') const root = createRoot(container!) -root.render() + +async function renderAppWithConfig() { + return authApi.getApplicationConfig().then((res) => { + store.dispatch(applicationConfigLoadedAction(res)) + root.render() + }) +} + +function withRetry(render: () => Promise) { + render().catch(() => { + delay(() => withRetry(render), RETRY_TIMEOUT) + }) +} + +withRetry(renderAppWithConfig) diff --git a/packages/login/src/views/resetCredentialsForm/phoneNumberVerificationForm.test.tsx b/packages/login/src/views/ResetCredentialsForm/AuthDetailsVerificationForm.test.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/phoneNumberVerificationForm.test.tsx rename to packages/login/src/views/ResetCredentialsForm/AuthDetailsVerificationForm.test.tsx diff --git a/packages/login/src/views/resetCredentialsForm/phoneNumberVerificationForm.tsx b/packages/login/src/views/ResetCredentialsForm/AuthDetailsVerificationForm.tsx similarity index 98% rename from packages/login/src/views/resetCredentialsForm/phoneNumberVerificationForm.tsx rename to packages/login/src/views/ResetCredentialsForm/AuthDetailsVerificationForm.tsx index 1bbde1130e7..accd32c701b 100644 --- a/packages/login/src/views/resetCredentialsForm/phoneNumberVerificationForm.tsx +++ b/packages/login/src/views/ResetCredentialsForm/AuthDetailsVerificationForm.tsx @@ -58,7 +58,7 @@ type Props = BaseProps & RouteComponentProps<{}, {}, { forgottenItem: FORGOTTEN_ITEMS }> & WrappedComponentProps -class PhoneNumberVerificationComponent extends React.Component { +class AuthDetailsVerificationComponent extends React.Component { constructor(props: Props) { super(props) this.state = { @@ -298,8 +298,8 @@ class PhoneNumberVerificationComponent extends React.Component { } } -export const PhoneNumberVerification = connect(null, { +export const AuthDetailsVerification = connect(null, { goToForgottenItemForm, goToRecoveryCodeEntryForm, goToSecurityQuestionForm -})(withRouter(injectIntl(PhoneNumberVerificationComponent))) +})(withRouter(injectIntl(AuthDetailsVerificationComponent))) diff --git a/packages/login/src/views/resetCredentialsForm/commons.tsx b/packages/login/src/views/ResetCredentialsForm/Commons.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/commons.tsx rename to packages/login/src/views/ResetCredentialsForm/Commons.tsx diff --git a/packages/login/src/views/resetCredentialsForm/forgottenItemForm.test.tsx b/packages/login/src/views/ResetCredentialsForm/ForgottenItemForm.test.tsx similarity index 96% rename from packages/login/src/views/resetCredentialsForm/forgottenItemForm.test.tsx rename to packages/login/src/views/ResetCredentialsForm/ForgottenItemForm.test.tsx index 8d28c06e796..25915bdcb6d 100644 --- a/packages/login/src/views/resetCredentialsForm/forgottenItemForm.test.tsx +++ b/packages/login/src/views/ResetCredentialsForm/ForgottenItemForm.test.tsx @@ -11,7 +11,7 @@ import { createTestComponent, wait } from '@login/tests/util' import { ReactWrapper } from 'enzyme' import * as React from 'react' -import { ForgottenItem } from './forgottenItemForm' +import { ForgottenItem } from './ForgottenItemForm' describe('Test forgotten item form', () => { let component: ReactWrapper diff --git a/packages/login/src/views/resetCredentialsForm/forgottenItemForm.tsx b/packages/login/src/views/ResetCredentialsForm/ForgottenItemForm.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/forgottenItemForm.tsx rename to packages/login/src/views/ResetCredentialsForm/ForgottenItemForm.tsx diff --git a/packages/login/src/views/resetCredentialsForm/recoveryCodeEntryForm.tsx b/packages/login/src/views/ResetCredentialsForm/RecoveryCodeEntryForm.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/recoveryCodeEntryForm.tsx rename to packages/login/src/views/ResetCredentialsForm/RecoveryCodeEntryForm.tsx diff --git a/packages/login/src/views/resetCredentialsForm/resetCredentialsSuccessPage.test.tsx b/packages/login/src/views/ResetCredentialsForm/ResetCredentialsSuccessPage.test.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/resetCredentialsSuccessPage.test.tsx rename to packages/login/src/views/ResetCredentialsForm/ResetCredentialsSuccessPage.test.tsx diff --git a/packages/login/src/views/resetCredentialsForm/resetCredentialsSuccessPage.tsx b/packages/login/src/views/ResetCredentialsForm/ResetCredentialsSuccessPage.tsx similarity index 98% rename from packages/login/src/views/resetCredentialsForm/resetCredentialsSuccessPage.tsx rename to packages/login/src/views/ResetCredentialsForm/ResetCredentialsSuccessPage.tsx index 96b30e4ff5e..7995f10a213 100644 --- a/packages/login/src/views/resetCredentialsForm/resetCredentialsSuccessPage.tsx +++ b/packages/login/src/views/ResetCredentialsForm/ResetCredentialsSuccessPage.tsx @@ -17,7 +17,7 @@ import { Box } from '@opencrvs/components/lib/Box' import { Stack } from '@opencrvs/components/lib/Stack' import { Text } from '@opencrvs/components/lib/Text' import { CountryLogo } from '@opencrvs/components/lib/icons' -import { LogoContainer } from '@login/views/resetCredentialsForm/commons' +import { LogoContainer } from '@login/views/ResetCredentialsForm/Commons' import React, { useEffect } from 'react' import { injectIntl, WrappedComponentProps as IntlShapeProps } from 'react-intl' import { connect } from 'react-redux' diff --git a/packages/login/src/views/resetCredentialsForm/securityQuestionForm.tsx b/packages/login/src/views/ResetCredentialsForm/SecurityQuestionForm.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/securityQuestionForm.tsx rename to packages/login/src/views/ResetCredentialsForm/SecurityQuestionForm.tsx diff --git a/packages/login/src/views/resetCredentialsForm/updatePasswordForm.test.tsx b/packages/login/src/views/ResetCredentialsForm/UpdatePasswordForm.test.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/updatePasswordForm.test.tsx rename to packages/login/src/views/ResetCredentialsForm/UpdatePasswordForm.test.tsx diff --git a/packages/login/src/views/resetCredentialsForm/updatePasswordForm.tsx b/packages/login/src/views/ResetCredentialsForm/UpdatePasswordForm.tsx similarity index 100% rename from packages/login/src/views/resetCredentialsForm/updatePasswordForm.tsx rename to packages/login/src/views/ResetCredentialsForm/UpdatePasswordForm.tsx From 65a5bb2e31bedee76daaceecab5ce27751d9cfc2 Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Mon, 27 May 2024 13:31:58 +0600 Subject: [PATCH 006/108] fix: handle informant change (#7039) * fix: amend updated record type * chore: add comment and change function name * fix: handle no informant info for in-progress declaration --- .../workflow/src/records/handler/update.ts | 59 ++++++++++++++++++- .../workflow/src/records/state-transitions.ts | 4 +- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/packages/workflow/src/records/handler/update.ts b/packages/workflow/src/records/handler/update.ts index e930d44f8cf..718a507c3ed 100644 --- a/packages/workflow/src/records/handler/update.ts +++ b/packages/workflow/src/records/handler/update.ts @@ -16,7 +16,13 @@ import { MarriageRegistration as GQLMarriageRegistration, EVENT_TYPE, updateFHIRBundle, - Registration + Registration, + InProgressRecord, + ReadyForReviewRecord, + getComposition, + findCompositionSection, + findEntryFromBundle, + RelatedPerson } from '@opencrvs/commons/types' import { z } from 'zod' import { indexBundle } from '@workflow/records/search' @@ -43,6 +49,47 @@ const requestSchema = z.object({ >() }) +function filterInformantSectionFromComposition< + T extends InProgressRecord | ReadyForReviewRecord +>(record: T): T { + const composition = getComposition(record) + + const filteredComposition = composition.section.filter( + (sec) => sec.code.coding[0].code !== 'informant-details' + ) + + return { + ...record, + entry: [ + { + fullUrl: record.entry.find( + (e) => e.resource.resourceType === 'Composition' + )!.fullUrl, + resource: { + ...composition, + section: filteredComposition + } + }, + ...record.entry.filter((e) => e.resource.resourceType !== 'Composition') + ] + } +} + +function getInformantType(record: InProgressRecord | ReadyForReviewRecord) { + const compositionSection = findCompositionSection( + 'informant-details', + getComposition(record) + ) + if (!compositionSection) return undefined + const personSectionEntry = compositionSection.entry[0] + const personEntry = findEntryFromBundle( + record, + personSectionEntry.reference + ) + + return personEntry?.resource.relationship?.coding?.[0].code +} + export const updateRoute = createRoute({ method: 'POST', path: '/records/{recordId}/update', @@ -52,6 +99,16 @@ export const updateRoute = createRoute({ const token = getToken(request) const payload = validateRequest(requestSchema, request.payload) + const informantTypeOfBundle = getInformantType(record) + const payloadInformantType = payload.details.registration.informantType + + // When new informant details are provided, we should create a patient entry + // by removing the composition section from the bundle. + // If the section is not found, the builders from updateFhirBundle + // create a new patient resource from scratch. + if (informantTypeOfBundle && informantTypeOfBundle !== payloadInformantType) + record = filterInformantSectionFromComposition(record) + const { details, event } = payload const { registration: registrationWithChangedValues, diff --git a/packages/workflow/src/records/state-transitions.ts b/packages/workflow/src/records/state-transitions.ts index 20f7da89c9c..1ba122c25da 100644 --- a/packages/workflow/src/records/state-transitions.ts +++ b/packages/workflow/src/records/state-transitions.ts @@ -240,7 +240,7 @@ export async function toUpdated( record: InProgressRecord | ReadyForReviewRecord, token: string, updatedDetails: ChangedValuesInput -): Promise { +): Promise { const previousTask = getTaskFromSavedBundle(record) const updatedTaskWithoutPractitionerExtensions = createUpdatedTask( @@ -275,7 +275,7 @@ export async function toUpdated( recordWithUpdatedTask, practitionerResourcesBundle ), - ['IN_PROGRESS', 'READY_FOR_REVIEW'] + 'READY_FOR_REVIEW' ) } From 370775cdd9454c43900ee1480322384c62d6ffde Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Mon, 27 May 2024 13:44:47 +0600 Subject: [PATCH 007/108] fix: open print record page in the current tab (#7042) * fix: update print record page to open in the same tab * chore: add X icon in the print record page * docs: update changelog --- CHANGELOG.md | 1 + packages/client/src/navigation/index.ts | 9 +- .../src/views/PrintRecord/PrintRecord.tsx | 86 ++++++++++++------- 3 files changed, 62 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f06957dcbf..6ec36eb3f50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ - In record audit page, after 'Correction request approved' the “record corrected” action is removed from history [#6228](https://github.com/opencrvs/opencrvs-core/issues/6228) - Fix Registrar of any location should be able to review a correction request [#6247](https://github.com/opencrvs/opencrvs-core/issues/6247) - Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) +- Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) ## Refactor diff --git a/packages/client/src/navigation/index.ts b/packages/client/src/navigation/index.ts index ce0b003a3cd..89a7d701a48 100644 --- a/packages/client/src/navigation/index.ts +++ b/packages/client/src/navigation/index.ts @@ -58,7 +58,8 @@ import { ISSUE_CERTIFICATE_PAYMENT, DRAFT_BIRTH_PARENT_FORM, DRAFT_MARRIAGE_FORM, - ALL_USER_EMAIL + ALL_USER_EMAIL, + PRINT_RECORD } from '@client/navigation/routes' import { NATL_ADMIN_ROLES, @@ -691,7 +692,11 @@ export function goToOrganisationView(userDetails: UserDetails) { } export function goToPrintRecordView(declarationId: string) { - window.open(`/print-record/${declarationId}`, '_blank') + return push( + formatUrl(PRINT_RECORD, { + declarationId + }) + ) } export type INavigationState = undefined diff --git a/packages/client/src/views/PrintRecord/PrintRecord.tsx b/packages/client/src/views/PrintRecord/PrintRecord.tsx index dafceabadc6..69f58fe5a9d 100644 --- a/packages/client/src/views/PrintRecord/PrintRecord.tsx +++ b/packages/client/src/views/PrintRecord/PrintRecord.tsx @@ -11,10 +11,10 @@ import React from 'react' import { PrintRecordHeader as Header } from '@client/views/PrintRecord/Header' import { WORKQUEUE_TABS } from '@client/components/interface/Navigation' -import { formatUrl } from '@client/navigation' +import { formatUrl, goBack } from '@client/navigation' import { REGISTRAR_HOME_TAB } from '@client/navigation/routes' import { IStoreState } from '@client/store' -import { useSelector } from 'react-redux' +import { useSelector, useDispatch } from 'react-redux' import { useParams, Redirect } from 'react-router' import { IDeclaration } from '@client/declarations' import styled from 'styled-components' @@ -30,6 +30,7 @@ import { getOfflineData } from '@client/offline/selectors' import { messages as reviewMessages } from '@client/i18n/messages/views/review' import { printRecordMessages } from '@client/i18n/messages/views/printRecord' import { constantsMessages } from '@client/i18n/messages' +import { AppBar, Button, Icon } from '@opencrvs/components/lib' const Container = styled.div` padding: 16px; @@ -46,7 +47,14 @@ const AvoidBreak = styled.div` page-break-after: avoid; } ` +const StyledAppBar = styled(AppBar)` + @media print { + display: none; + } +` + export function PrintRecord() { + const dispatch = useDispatch() const languages = useSelector(getLanguages) const offlineData = useSelector(getOfflineData) const cache = createIntlCache() @@ -72,36 +80,50 @@ export function PrintRecord() { } return ( - - - -
+ dispatch(goBack())}> + + + } + mobileRight={ + + } + /> + + + +
- - - - + subjectColor={getEventwiseSubjectColor(declaration.event)} + /> + + + + + ) } From d2995e6acb8bd42c4c4dc2ce87c0b9c0cbdf8b44 Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Mon, 27 May 2024 13:47:20 +0600 Subject: [PATCH 008/108] fix: set correction requested declaration to be retreived (#7040) * fix: set correction requested declaration to be retreived * chore: improve condition readability --- .../components/interface/DownloadButton.tsx | 23 +++++++++++++------ .../workflow/src/records/handler/download.ts | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/client/src/components/interface/DownloadButton.tsx b/packages/client/src/components/interface/DownloadButton.tsx index 46fd1bbc9d9..304395ac037 100644 --- a/packages/client/src/components/interface/DownloadButton.tsx +++ b/packages/client/src/components/interface/DownloadButton.tsx @@ -256,15 +256,23 @@ function DownloadButtonComponent(props: DownloadButtonProps & HOCProps) { status === DOWNLOAD_STATUS.FAILED_NETWORK, [status] ) + const isSentForApprovalDeclaration = + downloadConfigs.declarationStatus && + ['VALIDATED', 'CORRECTION_REQUESTED'].includes( + downloadConfigs.declarationStatus + ) + + // user roles of users who can not retrieve a declaration + const nonRetrievalUserRoles = + userRole !== ROLE_REGISTRATION_AGENT && + !FIELD_AGENT_ROLES.includes(String(userRole)) const onClickDownload = useCallback( (e: React.MouseEvent) => { if ( (assignment?.userId !== userId || status === DOWNLOAD_STATUS.DOWNLOADED) && - (downloadConfigs.declarationStatus !== 'VALIDATED' || - userRole !== ROLE_REGISTRATION_AGENT) && - !FIELD_AGENT_ROLES.includes(String(userRole)) + (!isSentForApprovalDeclaration || nonRetrievalUserRoles) ) { setAssignModal( getAssignModalOptions( @@ -291,13 +299,14 @@ function DownloadButtonComponent(props: DownloadButtonProps & HOCProps) { }, [ assignment, - userRole, - download, userId, status, - unassign, + isSentForApprovalDeclaration, + nonRetrievalUserRoles, + userRole, hideModal, - downloadConfigs + download, + unassign ] ) diff --git a/packages/workflow/src/records/handler/download.ts b/packages/workflow/src/records/handler/download.ts index 9443e825680..3e8dcc5a2e0 100644 --- a/packages/workflow/src/records/handler/download.ts +++ b/packages/workflow/src/records/handler/download.ts @@ -33,7 +33,8 @@ function getDownloadedOrAssignedExtension( ) { if ( inScope(authHeader, ['declare', 'recordsearch']) || - (hasScope(authHeader, 'validate') && status === 'VALIDATED') + (hasScope(authHeader, 'validate') && + ['CORRECTION_REQUESTED', 'VALIDATED'].includes(status)) ) { return `http://opencrvs.org/specs/extension/regDownloaded` as const } From d4ea536ea7702da395e2083d474c7680d0717419 Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Mon, 27 May 2024 13:48:39 +0600 Subject: [PATCH 009/108] chore: handle configuration option restructure (#7041) --- packages/client/src/tests/forms.json | 16 ++++++++-------- packages/client/src/tests/mock-offline-data.ts | 6 +++--- packages/client/src/utils/referenceApi.ts | 4 ++-- .../views/RegisterForm/review/ReviewSection.tsx | 5 +++-- packages/client/typings/window.d.ts | 4 ++-- .../application/applicationConfigHandler.ts | 6 +++--- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/packages/client/src/tests/forms.json b/packages/client/src/tests/forms.json index fcd0cb032a4..59d18a6163c 100644 --- a/packages/client/src/tests/forms.json +++ b/packages/client/src/tests/forms.json @@ -975,7 +975,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" } ], "mapping": { @@ -2372,7 +2372,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN || (!values.detailsExist)" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN || (!values.detailsExist)" } ], "mapping": { @@ -2903,7 +2903,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN || (!values.detailsExist)" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN || (!values.detailsExist)" } ], "mapping": { @@ -3737,7 +3737,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN" } ], "mapping": { @@ -4714,7 +4714,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" } ], "mapping": { @@ -6588,7 +6588,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" } ], "mapping": { @@ -7958,7 +7958,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" } ], "mapping": { @@ -9211,7 +9211,7 @@ "conditionals": [ { "action": "hide", - "expression": "!window.config.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" + "expression": "!window.config.FEATURES.DATE_OF_BIRTH_UNKNOWN || !values.detailsExist" } ], "mapping": { diff --git a/packages/client/src/tests/mock-offline-data.ts b/packages/client/src/tests/mock-offline-data.ts index 6c197ae88a6..25da8514b92 100644 --- a/packages/client/src/tests/mock-offline-data.ts +++ b/packages/client/src/tests/mock-offline-data.ts @@ -454,7 +454,9 @@ export const mockOfflineData = { MARRIAGE_REGISTRATION: true, EXTERNAL_VALIDATION_WORKQUEUE: true, INFORMANT_SIGNATURE: false, - PRINT_DECLARATION: true + PRINT_DECLARATION: true, + DATE_OF_BIRTH_UNKNOWN: true, + INFORMANT_SIGNATURE_REQUIRED: false }, HEALTH_FACILITY_FILTER: 'DISTRICT', LANGUAGES: 'en,bn', @@ -481,8 +483,6 @@ export const mockOfflineData = { DEATH_REGISTRATION_TARGET: 45, NID_NUMBER_PATTERN: /^[0-9]{9}$/, SENTRY: 'https://sentry.com', - DATE_OF_BIRTH_UNKNOWN: true, - INFORMANT_SIGNATURE_REQUIRED: false, USER_NOTIFICATION_DELIVERY_METHOD: 'email', INFORMANT_NOTIFICATION_DELIVERY_METHOD: 'email', SIGNATURE_REQUIRED_FOR_ROLES: ['LOCAL_REGISTRAR', 'NATIONAL_REGISTRAR'] diff --git a/packages/client/src/utils/referenceApi.ts b/packages/client/src/utils/referenceApi.ts index 2b51c36e653..3617e5df5fb 100644 --- a/packages/client/src/utils/referenceApi.ts +++ b/packages/client/src/utils/referenceApi.ts @@ -123,13 +123,13 @@ export interface IApplicationConfig { EXTERNAL_VALIDATION_WORKQUEUE: boolean INFORMANT_SIGNATURE: boolean PRINT_DECLARATION: boolean + DATE_OF_BIRTH_UNKNOWN: boolean + INFORMANT_SIGNATURE_REQUIRED: boolean } FIELD_AGENT_AUDIT_LOCATIONS: string DECLARATION_AUDIT_LOCATIONS: string PHONE_NUMBER_PATTERN: RegExp NID_NUMBER_PATTERN: RegExp - DATE_OF_BIRTH_UNKNOWN: boolean - INFORMANT_SIGNATURE_REQUIRED: boolean LOGIN_BACKGROUND: ILoginBackground USER_NOTIFICATION_DELIVERY_METHOD: string INFORMANT_NOTIFICATION_DELIVERY_METHOD: string diff --git a/packages/client/src/views/RegisterForm/review/ReviewSection.tsx b/packages/client/src/views/RegisterForm/review/ReviewSection.tsx index a4a1442f85d..6b8f2b5476b 100644 --- a/packages/client/src/views/RegisterForm/review/ReviewSection.tsx +++ b/packages/client/src/views/RegisterForm/review/ReviewSection.tsx @@ -1678,7 +1678,8 @@ class ReviewSectionComp extends React.Component { } else { if (event === Event.Birth || event === Event.Death) { return ( - offlineCountryConfiguration.config.INFORMANT_SIGNATURE_REQUIRED && + offlineCountryConfiguration.config.FEATURES + .INFORMANT_SIGNATURE_REQUIRED && !declaration.data.registration?.informantsSignature ) } else if (event === Event.Marriage) { @@ -1767,7 +1768,7 @@ class ReviewSectionComp extends React.Component { 'informants_signature', declaration.data.registration?.informantsSignature as string, intl.formatMessage(messages.informantsSignature), - window.config.INFORMANT_SIGNATURE_REQUIRED + window.config.FEATURES.INFORMANT_SIGNATURE_REQUIRED ) return ( <> diff --git a/packages/client/typings/window.d.ts b/packages/client/typings/window.d.ts index 4ec83b69179..c67120df95b 100644 --- a/packages/client/typings/window.d.ts +++ b/packages/client/typings/window.d.ts @@ -55,6 +55,8 @@ interface Window { INFORMANT_SIGNATURE: boolean EXTERNAL_VALIDATION_WORKQUEUE: boolean PRINT_DECLARATION: boolean + DATE_OF_BIRTH_UNKNOWN: boolean + INFORMANT_SIGNATURE_REQUIRED: boolean } LANGUAGES: string LOGIN_URL: string @@ -69,8 +71,6 @@ interface Window { NID_NUMBER_PATTERN: RegExp DECLARATION_AUDIT_LOCATIONS: string SENTRY: string - DATE_OF_BIRTH_UNKNOWN: boolean - INFORMANT_SIGNATURE_REQUIRED: boolean REGISTRATIONS_DASHBOARD_URL: string STATISTICS_DASHBOARD_URL: string LEADERBOARDS_DASHBOARD_URL: string diff --git a/packages/config/src/handlers/application/applicationConfigHandler.ts b/packages/config/src/handlers/application/applicationConfigHandler.ts index 1b24ab614fd..8a4c94b97a3 100644 --- a/packages/config/src/handlers/application/applicationConfigHandler.ts +++ b/packages/config/src/handlers/application/applicationConfigHandler.ts @@ -281,10 +281,10 @@ const applicationConfigResponseValidation = Joi.object({ MARRIAGE_REGISTRATION: Joi.boolean().required(), EXTERNAL_VALIDATION_WORKQUEUE: Joi.boolean().required(), INFORMANT_SIGNATURE: Joi.boolean().required(), - PRINT_DECLARATION: Joi.boolean().required() + PRINT_DECLARATION: Joi.boolean().required(), + DATE_OF_BIRTH_UNKNOWN: Joi.boolean().required(), + INFORMANT_SIGNATURE_REQUIRED: Joi.boolean().required() }, - DATE_OF_BIRTH_UNKNOWN: Joi.boolean().required(), - INFORMANT_SIGNATURE_REQUIRED: Joi.boolean().required(), USER_NOTIFICATION_DELIVERY_METHOD: Joi.string().allow('').optional(), INFORMANT_NOTIFICATION_DELIVERY_METHOD: Joi.string().allow('').optional(), SIGNATURE_REQUIRED_FOR_ROLES: Joi.array().items( From e69c23fc7f861116162c8eac07c23a56cee7a835 Mon Sep 17 00:00:00 2001 From: Tahmid Rahman <42269993+tahmidrahman-dsi@users.noreply.github.com> Date: Mon, 27 May 2024 15:57:17 +0600 Subject: [PATCH 010/108] fix: dashboard cron job not working (#7027) * Remove authentication from dashboard queries api endpoints * Update CHANGELOG.md --- CHANGELOG.md | 1 + packages/config/src/config/routes.ts | 1 + .../handlers/dashboardQueries/dashboardQueries.ts | 10 +--------- packages/metrics/src/config/routes.ts | 2 +- packages/metrics/src/configApi.ts | 10 ++++------ .../src/features/performance/viewRefresher.ts | 15 ++++++--------- 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec36eb3f50..ee86657cbd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ - Fix Registrar of any location should be able to review a correction request [#6247](https://github.com/opencrvs/opencrvs-core/issues/6247) - Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) +- Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) ## Refactor diff --git a/packages/config/src/config/routes.ts b/packages/config/src/config/routes.ts index c0e08da89e3..2965fac730c 100644 --- a/packages/config/src/config/routes.ts +++ b/packages/config/src/config/routes.ts @@ -279,6 +279,7 @@ export default function getRoutes(): ServerRoute[] { handler: getDashboardQueries, options: { tags: ['api'], + auth: false, description: 'Fetch dashboard queries from country config' } } diff --git a/packages/config/src/handlers/dashboardQueries/dashboardQueries.ts b/packages/config/src/handlers/dashboardQueries/dashboardQueries.ts index 51c315bdf0c..1a10c880f49 100644 --- a/packages/config/src/handlers/dashboardQueries/dashboardQueries.ts +++ b/packages/config/src/handlers/dashboardQueries/dashboardQueries.ts @@ -17,15 +17,7 @@ export default async function getDashboardQueries( request: Hapi.Request, h: Hapi.ResponseToolkit ) { - const token = request.headers.authorization - const response = await fetch( - `${COUNTRY_CONFIG_URL}/dashboards/queries.json`, - { - headers: { - Authorization: token - } - } - ) + const response = await fetch(`${COUNTRY_CONFIG_URL}/dashboards/queries.json`) if (response.status === 404) { return defaultQueries() diff --git a/packages/metrics/src/config/routes.ts b/packages/metrics/src/config/routes.ts index 78b1a7a2284..c243eb679ba 100644 --- a/packages/metrics/src/config/routes.ts +++ b/packages/metrics/src/config/routes.ts @@ -102,7 +102,7 @@ function analyticsDataRefreshingRoute< // Consider triggering this a task that will be left to be run in the background. return (request: Request, response: Response) => { if (!PRODUCTION || QA_ENV) { - refresh(request.headers.authorization) + refresh() } return handler(request, response) } diff --git a/packages/metrics/src/configApi.ts b/packages/metrics/src/configApi.ts index 961222187e3..0d3f6d50269 100644 --- a/packages/metrics/src/configApi.ts +++ b/packages/metrics/src/configApi.ts @@ -91,15 +91,13 @@ export async function getApplicationConfig( }) } -export async function getDashboardQueries( - authorization: string -): Promise> { - const token = authorization.replace('Bearer ', '') +export async function getDashboardQueries(): Promise< + Array<{ collection: string; aggregate: Document[] }> +> { return fetch(`${CONFIG_API_URL}/dashboardQueries`, { method: 'GET', headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${token}` + 'Content-Type': 'application/json' } }) .then((response) => { diff --git a/packages/metrics/src/features/performance/viewRefresher.ts b/packages/metrics/src/features/performance/viewRefresher.ts index 6bdde683cb1..7cd8f9a6ea0 100644 --- a/packages/metrics/src/features/performance/viewRefresher.ts +++ b/packages/metrics/src/features/performance/viewRefresher.ts @@ -34,7 +34,7 @@ export async function performanceDataRefreshHandler( request: Hapi.Request, h: Hapi.ResponseToolkit ) { - refresh(request.headers.authorization).catch((error) => { + refresh().catch((error) => { logger.error(`Error on performance data refresh triggered: ${error}`) }) return h.response({ @@ -43,7 +43,7 @@ export async function performanceDataRefreshHandler( }) } -export async function refresh(authorization: string) { +export async function refresh() { if (updateInProgress) { logger.info('Performance materialised views already being refreshed') nextUpdateRequested = true @@ -54,7 +54,7 @@ export async function refresh(authorization: string) { try { updateInProgress = true const connectedClient = await client.connect() - await refreshPerformanceMaterialisedViews(connectedClient, authorization) + await refreshPerformanceMaterialisedViews(connectedClient) logger.info('Performance materialised views refreshed') } catch (error) { logger.error(`Error refreshing performances materialised views ${error}`) @@ -64,17 +64,14 @@ export async function refresh(authorization: string) { updateInProgress = false if (nextUpdateRequested) { nextUpdateRequested = false - refresh(authorization) + refresh() } } } -async function refreshPerformanceMaterialisedViews( - client: MongoClient, - authorization: string -) { +async function refreshPerformanceMaterialisedViews(client: MongoClient) { const db = client.db() - const queries = await getDashboardQueries(authorization) + const queries = await getDashboardQueries() for (const { collection, aggregate } of queries) { await db From 9d1733a8c2e4b976eb3d77aab0097702c18d0cb4 Mon Sep 17 00:00:00 2001 From: Tahmid Rahman <42269993+tahmidrahman-dsi@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:38:40 +0600 Subject: [PATCH 011/108] fix(ocrvs-7068): show requester, reason, comment, id verfied sections in action modal for action CORRECTED (#7094) --- .../src/views/RecordAudit/ActionDetailsModal.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx b/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx index 9af524ac78f..8dade4616ed 100644 --- a/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx +++ b/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx @@ -107,7 +107,8 @@ function prepareComments( if ( !draft || (actionDetailsData.action && - actionDetailsData.action !== RegAction.RequestedCorrection) + actionDetailsData.action !== RegAction.RequestedCorrection && + actionDetailsData.action !== RegAction.Corrected) ) { return [] } @@ -447,7 +448,8 @@ const ActionDetailsModalListTable = ({ {/* Correction Requester */} {actionDetailsData.requester && - actionDetailsData.action === RegAction.RequestedCorrection && ( + (actionDetailsData.action === RegAction.RequestedCorrection || + actionDetailsData.action === RegAction.Corrected) && ( Date: Tue, 4 Jun 2024 13:10:37 +0600 Subject: [PATCH 012/108] fix: show correction rejection reason in history --- .../src/views/RecordAudit/ActionDetailsModal.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx b/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx index 8dade4616ed..df9de1f6105 100644 --- a/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx +++ b/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx @@ -457,14 +457,13 @@ const ActionDetailsModalListTable = ({ /> )} {/* Correction rejected */} - {actionDetailsData.requester && - actionDetailsData.action === RegAction.RejectedCorrection && ( -
- )} + {actionDetailsData.action === RegAction.RejectedCorrection && ( +
+ )} {/* Correction Requester Id Verified */} {(actionDetailsData.action === RegAction.RequestedCorrection || From 21244468f007d26ebe5681c96ead8e8907e77adf Mon Sep 17 00:00:00 2001 From: "Md. Ashikul Alam" <32668488+Nil20@users.noreply.github.com> Date: Fri, 7 Jun 2024 13:03:43 +0600 Subject: [PATCH 013/108] fix: update correction request task (#7106) * fix: update correction request task * fix: update snapshot for task output * fix: set correction changes to read from output * fix: amend correction values and type in client --- .../views/ReviewCorrection/ReviewCorrection.tsx | 14 ++++++++++---- .../__snapshots__/state-transitions.test.ts.snap | 1 + packages/workflow/src/records/fhir.ts | 13 +++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/client/src/views/ReviewCorrection/ReviewCorrection.tsx b/packages/client/src/views/ReviewCorrection/ReviewCorrection.tsx index 101f5de3b6b..ee6c586f751 100644 --- a/packages/client/src/views/ReviewCorrection/ReviewCorrection.tsx +++ b/packages/client/src/views/ReviewCorrection/ReviewCorrection.tsx @@ -615,7 +615,13 @@ function applyCorrectionToData(record: IDeclaration) { ) } - const proposedChangesPatch = correctionRequestTask.input.reduce( + if (!correctionRequestTask.output) { + throw new Error( + 'Correction request task did not have an output field. Should never happen' + ) + } + + const proposedChangesPatch = correctionRequestTask.output.reduce( (acc: Record>, curr: any) => { acc[curr.valueCode] = acc[curr.valueCode] || {} @@ -647,11 +653,11 @@ function applyCorrectionToData(record: IDeclaration) { }, reason: correctionRequestTask.reason!, requester: correctionRequestTask.requester!, - values: correctionRequestTask.input.map((input) => ({ + values: correctionRequestTask.input.map((input, index) => ({ fieldName: input!.valueId, - newValue: input!.value!, + newValue: correctionRequestTask.output![index]?.value, section: input!.valueCode, - oldValue: (record.data[input!.valueCode][input!.valueId] || '').toString() + oldValue: input!.value! })) } diff --git a/packages/workflow/src/records/__snapshots__/state-transitions.test.ts.snap b/packages/workflow/src/records/__snapshots__/state-transitions.test.ts.snap index 5c59125a116..f7f25cf584a 100644 --- a/packages/workflow/src/records/__snapshots__/state-transitions.test.ts.snap +++ b/packages/workflow/src/records/__snapshots__/state-transitions.test.ts.snap @@ -103,6 +103,7 @@ Array [ "text": "Note", }, ], + "output": Array [], "reason": Object { "extension": Array [ Object { diff --git a/packages/workflow/src/records/fhir.ts b/packages/workflow/src/records/fhir.ts index 90e81859b17..30bbe914767 100644 --- a/packages/workflow/src/records/fhir.ts +++ b/packages/workflow/src/records/fhir.ts @@ -1034,6 +1034,19 @@ export function createCorrectionRequestTask( } ], input: correctionDetails.values.map((update) => ({ + valueCode: update.section, + valueId: update.fieldName, + type: { + coding: [ + { + system: 'http://terminology.hl7.org/CodeSystem/action-type', + code: 'update' + } + ] + }, + ...getFHIRValueField(update.oldValue) + })), + output: correctionDetails.values.map((update) => ({ valueCode: update.section, valueId: update.fieldName, type: { From 43e8b1afa59b20ee8aa79bab945827db0bfe1d50 Mon Sep 17 00:00:00 2001 From: Tameem Bin Haider Date: Wed, 15 May 2024 13:18:41 +0600 Subject: [PATCH 014/108] feat: add new handlebars (#6914) * feat: add new handlebars * docs: update CHANGELOG * test: add registered history entry to mock data --- CHANGELOG.md | 2 + .../ReviewCertificateAction.test.tsx | 30 ++++++------- .../usePrintableCertificate.ts | 44 +++++++++++++++---- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee86657cbd5..79e47e140ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ - Add loading spinners before JavaScript bundle has loaded for both login and client - Support for landscape certificate templates - Allow defining maxLength attribute for number type fields [#6356](https://github.com/opencrvs/opencrvs-core/issues/6356) +- Certificate handlebar for registration fees `registrationFees` [#6817](https://github.com/opencrvs/opencrvs-core/issues/6817) +- Logged in user details handlebar `loggedInUser` [#6529](https://github.com/opencrvs/opencrvs-core/issues/6529) ## Bug fixes diff --git a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx index da50d66d3c6..8a07f5b7384 100644 --- a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx +++ b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.test.tsx @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { vi, Mock } from 'vitest' +import { Mock } from 'vitest' import * as React from 'react' import { createStore } from '@client/store' import { storeDeclaration, IDeclaration } from '@client/declarations' @@ -28,7 +28,6 @@ import { Event } from '@client/utils/gateway' import { cloneDeep } from 'lodash' import { waitForElement } from '@client/tests/wait-for-element' import { push } from 'connected-react-router' -import * as pdfRender from '@client/pdfRenderer' import { useParams } from 'react-router' const deathDeclaration = { @@ -47,8 +46,6 @@ const deathDeclaration = { } describe('when user wants to review death certificate', () => { - const spy = vi.spyOn(pdfRender, 'printPDF').mockImplementation(() => {}) - it('displays the "Confirm & Print" button', async () => { const { history, match } = createRouterProps( '/', @@ -87,7 +84,16 @@ describe('when user wants to review death certificate', () => { describe('back button behavior tests of review certificate action', () => { let component: ReactWrapper - const mockBirthDeclarationData = cloneDeep(mockDeclarationData) + const mockBirthDeclarationData = { + ...cloneDeep(mockDeclarationData), + history: [ + { + date: '2022-03-21T08:16:24.467+00:00', + regStatus: 'REGISTERED', + reinstated: false + } + ] + } mockBirthDeclarationData.registration.certificates[0] = { collector: { type: 'PRINT_IN_ADVANCE' @@ -114,16 +120,7 @@ describe('back button behavior tests of review certificate action', () => { loginAsFieldAgent(store) const birthDeclaration = { id: 'asdhdqe2472487jsdfsdf', - data: { - ...mockBirthDeclarationData, - history: [ - { - date: '2022-03-21T08:16:24.467+00:00', - regStatus: 'REGISTERED', - reinstated: false - } - ] - }, + data: mockBirthDeclarationData, event: Event.Birth } store.dispatch( @@ -155,6 +152,7 @@ describe('back button behavior tests of review certificate action', () => { loginAsFieldAgent(store) store.dispatch( + // @ts-ignore storeDeclaration({ id: 'asdhdqe2472487jsdfsdf', data: mockBirthDeclarationData, @@ -256,7 +254,7 @@ describe('when user wants to review marriage certificate', () => { let component: ReactWrapper<{}, {}> beforeEach(async () => { - const { history, location, match } = createRouterProps( + const { history, match } = createRouterProps( '/', { isNavigatedInsideApp: false }, { diff --git a/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts b/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts index c7a1f41d025..3447fc37d83 100644 --- a/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts +++ b/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts @@ -16,7 +16,11 @@ import { writeDeclaration } from '@client/declarations' import { useDeclaration } from '@client/declarations/selectors' -import { CorrectionSection, SubmissionAction } from '@client/forms' +import { + CorrectionSection, + IFormSectionData, + SubmissionAction +} from '@client/forms' import { goToCertificateCorrection, goToHomeTab } from '@client/navigation' import { getOfflineData } from '@client/offline/selectors' import { getScope, getUserDetails } from '@client/profile/profileSelectors' @@ -44,22 +48,44 @@ import { getCountryTranslations } from './utils' import { Event } from '@client/utils/gateway' +import { getUserName, UserDetails } from '@client/utils/userUtils' +import { formatLongDate } from '@client/utils/date-formatting' +import { IOfflineData } from '@client/offline/reducer' const withEnhancedTemplateVariables = ( - declaration: IPrintableDeclaration | undefined + declaration: IPrintableDeclaration | undefined, + userDetails: UserDetails | null, + offlineData: IOfflineData ) => { - if (!declaration || !isCertificateForPrintInAdvance(declaration)) { + if (!declaration) { return declaration } + const registeredDate = getRegisteredDate(declaration.data) + const eventDate = getEventDate(declaration.data, declaration.event) + const registrationFees = calculatePrice( + declaration.event, + eventDate, + registeredDate, + offlineData + ) return { ...declaration, data: { ...declaration.data, template: { ...declaration.data.template, - printInAdvance: true - } + printInAdvance: isCertificateForPrintInAdvance(declaration), + certificateDate: formatLongDate(new Date().toISOString()), + registrationFees, + ...(userDetails && { + loggedInUser: { + name: getUserName(userDetails), + officeId: userDetails.primaryOffice?.id, + signature: userDetails.localRegistrar?.signature + } + }) + } as IFormSectionData } } } @@ -68,11 +94,14 @@ export const usePrintableCertificate = (declarationId: string) => { const declarationWithoutAllTemplateVariables = useDeclaration< IPrintableDeclaration | undefined >(declarationId) + const userDetails = useSelector(getUserDetails) + const offlineData = useSelector(getOfflineData) const declaration = withEnhancedTemplateVariables( - declarationWithoutAllTemplateVariables + declarationWithoutAllTemplateVariables, + userDetails, + offlineData ) - const offlineData = useSelector(getOfflineData) const state = useSelector((store: IStoreState) => store) const [svg, setSvg] = useState() const isPrintInAdvance = isCertificateForPrintInAdvance(declaration) @@ -85,7 +114,6 @@ export const usePrintableCertificate = (declarationId: string) => { const canUserEditRecord = declaration?.event !== Event.Marriage && (hasRegisterScope(scope) || hasRegistrationClerkScope(scope)) - const userDetails = useSelector(getUserDetails) useEffect(() => { if (declaration) From e3fdfbb485adc9e4904f1aac7969d448e53c8b8d Mon Sep 17 00:00:00 2001 From: Anamul Haque Date: Wed, 29 May 2024 16:03:05 +0600 Subject: [PATCH 015/108] fix: client modal glitches on Integrations-page (#7056) * ocrvs-7002 * replaced 'auto' with 'scroll' * changelog.md updated * fix: react issue with exhaustive deps --------- Co-authored-by: Pyry --- CHANGELOG.md | 1 + .../components/src/ResponsiveModal/ResponsiveModal.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79e47e140ff..3503dd04c4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ - Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) +- Fix client modal glitches on integrations page [#7002] (https://github.com/opencrvs/opencrvs-core/issues/7002) ## Refactor diff --git a/packages/components/src/ResponsiveModal/ResponsiveModal.tsx b/packages/components/src/ResponsiveModal/ResponsiveModal.tsx index 285527676ec..b5aafbbdd78 100644 --- a/packages/components/src/ResponsiveModal/ResponsiveModal.tsx +++ b/packages/components/src/ResponsiveModal/ResponsiveModal.tsx @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import React, { useEffect } from 'react' +import React, { useCallback, useEffect } from 'react' import styled from 'styled-components' import { Cross } from '../icons' import { CircleButton } from '../buttons' @@ -110,7 +110,7 @@ const Body = styled.div<{ height ? `${height}px` : autoHeight ? `auto` : `250px`}; max-height: calc(100vh - 180px); color: ${({ theme }) => theme.colors.supportingCopy}; - overflow-y: ${({ scrollableY }) => (scrollableY ? 'visible' : 'auto')}; + overflow-y: ${({ scrollableY }) => (scrollableY ? 'visible' : 'scroll')}; padding: 0 24px 16px; display: flex; flex-direction: column; @@ -186,13 +186,13 @@ export const ResponsiveModal = ({ showHeaderBorder, children }: IProps) => { - const toggleScroll = () => { + const toggleScroll = useCallback(() => { const body = document.querySelector('body') as HTMLBodyElement if (show) { return (body.style.overflow = 'hidden') } return body.style.removeProperty('overflow') - } + }, [show]) useEffect(() => { toggleScroll() @@ -201,7 +201,7 @@ export const ResponsiveModal = ({ const body = document.querySelector('body') as HTMLBodyElement body.style.removeProperty('overflow') } - }, [show]) + }, [show, toggleScroll]) if (!show) { return null From 4e26db5d092503912a476c0c40bf1cda3ae22046 Mon Sep 17 00:00:00 2001 From: Anamul Haque Date: Thu, 30 May 2024 12:30:32 +0600 Subject: [PATCH 016/108] fix: french translation missing for relationship to informant when trying to correct, print or issue record (#7061) * failed tests fixed * removeing labelformat for informant * failed test fixed, removeing labelformat for informant * remove labelformatterForInformant * removed labelformatter for requesterLabelMapper in ActionDetailsModal.tsx --- CHANGELOG.md | 1 + .../forms/certificate/fieldDefinitions/collectorSection.ts | 5 ++--- packages/client/src/forms/correction/corrector.ts | 4 +--- .../client/src/views/CorrectionForm/CorrectorForm.test.tsx | 2 +- .../PrintCertificate/collectorForm/CollectorForm.test.tsx | 6 +++--- .../client/src/views/RecordAudit/ActionDetailsModal.tsx | 3 +-- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3503dd04c4f..023498de077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ - In record audit page, after 'Correction request approved' the “record corrected” action is removed from history [#6228](https://github.com/opencrvs/opencrvs-core/issues/6228) - Fix Registrar of any location should be able to review a correction request [#6247](https://github.com/opencrvs/opencrvs-core/issues/6247) - Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) +- Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) - Fix client modal glitches on integrations page [#7002] (https://github.com/opencrvs/opencrvs-core/issues/7002) diff --git a/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts b/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts index 6cf3639eec9..328906fdc0a 100644 --- a/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts +++ b/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts @@ -36,7 +36,6 @@ import { identityHelperTextMapper, identityNameMapper } from './messages' import { Event } from '@client/utils/gateway' import { IDeclaration } from '@client/declarations' import { issueMessages } from '@client/i18n/messages/issueCertificate' -import { labelFormatterForInformant } from '@client/views/CorrectionForm/utils' interface INameField { firstNamesField: string @@ -1023,7 +1022,7 @@ function getCertCollectorGroupForEvent( value: 'INFORMANT', label: formMessages.certifyRecordToInformant, param: { - informant: labelFormatterForInformant(informant) + informant: informant } }, { value: 'OTHER', label: formMessages.someoneElseCollector }, @@ -1088,7 +1087,7 @@ export function getIssueCertCollectorGroupForEvent( value: 'INFORMANT', label: issueMessages.issueToInformant, param: { - informant: labelFormatterForInformant(informant) + informant: informant } }, { value: 'OTHER', label: issueMessages.issueToSomeoneElse } diff --git a/packages/client/src/forms/correction/corrector.ts b/packages/client/src/forms/correction/corrector.ts index 8d661efc309..d3a1bf4e1a7 100644 --- a/packages/client/src/forms/correction/corrector.ts +++ b/packages/client/src/forms/correction/corrector.ts @@ -22,7 +22,6 @@ import { messages } from '@client/i18n/messages/views/correction' import { Event } from '@client/utils/gateway' import { RadioSize } from '@opencrvs/components/lib/Radio' import { getFilteredRadioOptions } from '@client/forms/certificate/fieldDefinitions/collectorSection' -import { labelFormatterForInformant } from '@client/views/CorrectionForm/utils' export enum CorrectorRelationship { //death @@ -108,13 +107,12 @@ export const getCorrectorSection = ( ): IFormSection => { const informant = (declaration.data.informant.otherInformantType || declaration.data.informant.informantType) as string - const initialOptions: IRadioOption[] = [ { value: CorrectorRelationship.INFORMANT, label: messages.informant, param: { - informant: labelFormatterForInformant(informant) + informant: informant } }, { diff --git a/packages/client/src/views/CorrectionForm/CorrectorForm.test.tsx b/packages/client/src/views/CorrectionForm/CorrectorForm.test.tsx index 8be8261f19c..a667ebc6710 100644 --- a/packages/client/src/views/CorrectionForm/CorrectorForm.test.tsx +++ b/packages/client/src/views/CorrectionForm/CorrectorForm.test.tsx @@ -176,7 +176,7 @@ describe('Corrector form', () => { it('should not disable the continue button if an option is selected', () => { wrapper - .find('#relationship_INFORMANT_Spouse') + .find('#relationship_INFORMANT_SPOUSE') .hostNodes() .simulate('change', { target: { checked: true } }) wrapper.update() diff --git a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx index a4ad5e07f6c..5ef66cf40c1 100644 --- a/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx +++ b/packages/client/src/views/PrintCertificate/collectorForm/CollectorForm.test.tsx @@ -559,7 +559,7 @@ describe('Certificate collector test for a death registration', () => { }) it('informant will be spouse', async () => { - const element = await waitForElement(component, '#type_INFORMANT_Spouse') + const element = await waitForElement(component, '#type_INFORMANT_SPOUSE') expect(element.hostNodes()).toHaveLength(1) }) @@ -611,7 +611,7 @@ describe('Certificate collector test for a marriage registration', () => { }) it('informant will be grrom', async () => { - const element = await waitForElement(component, '#type_INFORMANT_Groom') + const element = await waitForElement(component, '#type_INFORMANT_GROOM') expect(element.hostNodes()).toHaveLength(1) }) @@ -669,7 +669,7 @@ describe('Certificate collector test for a birth registration without father and }) it('informant will be mother', () => { - expect(component.find('#type_INFORMANT_Mother').hostNodes()).toHaveLength( + expect(component.find('#type_INFORMANT_MOTHER').hostNodes()).toHaveLength( 1 ) }) diff --git a/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx b/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx index df9de1f6105..07417d47ba7 100644 --- a/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx +++ b/packages/client/src/views/RecordAudit/ActionDetailsModal.tsx @@ -44,7 +44,6 @@ import { Pill } from '@opencrvs/components/lib/Pill' import { recordAuditMessages } from '@client/i18n/messages/views/recordAudit' import { formatLongDate } from '@client/utils/date-formatting' import { EMPTY_STRING } from '@client/utils/constants' -import { labelFormatterForInformant } from '@client/views/CorrectionForm/utils' interface IActionDetailsModalListTable { actionDetailsData: History @@ -154,7 +153,7 @@ const requesterLabelMapper = ( // informant info added for corrector being informant return requesterIndividual?.label ? intl.formatMessage(requesterIndividual.label, { - informant: labelFormatterForInformant(informant) + informant }) : '' } From 848f064ba32923d45d4842b13c75efc8cf56d3eb Mon Sep 17 00:00:00 2001 From: Anamul Haque Date: Mon, 3 Jun 2024 12:32:41 +0600 Subject: [PATCH 017/108] fix: remove upload button when no supporting docs are configured (#7006) * initial fix * updated changelog.md * updated changelog * filtered with isVisibleField * isUploadButtonVisible now boolean --- CHANGELOG.md | 1 + .../client/src/views/RegisterForm/review/ReviewSection.tsx | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 023498de077..d18cd952705 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ - In review page, Eliminating the 'No supporting documents' and 'upload' prompts when documents are already uploaded [#6231](https://github.com/opencrvs/opencrvs-core/issues/6231) - In record audit page, after 'Correction request approved' the “record corrected” action is removed from history [#6228](https://github.com/opencrvs/opencrvs-core/issues/6228) - Fix Registrar of any location should be able to review a correction request [#6247](https://github.com/opencrvs/opencrvs-core/issues/6247) +- remove upload button when no supporting docs are configured [#5944](https://github.com/opencrvs/opencrvs-core/issues/5944) - Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) - Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) diff --git a/packages/client/src/views/RegisterForm/review/ReviewSection.tsx b/packages/client/src/views/RegisterForm/review/ReviewSection.tsx index 6b8f2b5476b..17e059030ec 100644 --- a/packages/client/src/views/RegisterForm/review/ReviewSection.tsx +++ b/packages/client/src/views/RegisterForm/review/ReviewSection.tsx @@ -1834,6 +1834,12 @@ class ReviewSectionComp extends React.Component { } const options = this.prepSectionDocOptions(declaration) + const isUploadButtonVisible = Boolean( + documentsSection.groups[0].fields.filter((field) => + this.isVisibleField(field, documentsSection) + ).length + ) + return ( @@ -2047,6 +2053,7 @@ class ReviewSectionComp extends React.Component { )} {viewRecord || isDuplicate || + !isUploadButtonVisible || declaration.registrationStatus === SUBMISSION_STATUS.CORRECTION_REQUESTED ? null : ( Date: Thu, 6 Jun 2024 16:07:54 +0600 Subject: [PATCH 018/108] fix: place of certification showing wrong location in certificates (#7084) --- CHANGELOG.md | 2 ++ .../usePrintableCertificate.ts | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d18cd952705..7a18e32b185 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ - Fix Registrar of any location should be able to review a correction request [#6247](https://github.com/opencrvs/opencrvs-core/issues/6247) - remove upload button when no supporting docs are configured [#5944](https://github.com/opencrvs/opencrvs-core/issues/5944) - Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) +- Remove leading slash from `resendAuthenticationCode` in login to fix resend email button [#6987](https://github.com/opencrvs/opencrvs-core/issues/6987) [#7037](https://github.com/opencrvs/opencrvs-core/issues/7037) +- Fix 'Place of Certification' is showing wrong in certificate [#7060] (https://github.com/opencrvs/opencrvs-core/issues/7060) - Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) diff --git a/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts b/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts index 3447fc37d83..1cbe40b6095 100644 --- a/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts +++ b/packages/client/src/views/PrintCertificate/usePrintableCertificate.ts @@ -50,7 +50,8 @@ import { import { Event } from '@client/utils/gateway' import { getUserName, UserDetails } from '@client/utils/userUtils' import { formatLongDate } from '@client/utils/date-formatting' -import { IOfflineData } from '@client/offline/reducer' +import { AdminStructure, IOfflineData } from '@client/offline/reducer' +import { getLocationHierarchy } from '@client/utils/locationUtils' const withEnhancedTemplateVariables = ( declaration: IPrintableDeclaration | undefined, @@ -69,6 +70,22 @@ const withEnhancedTemplateVariables = ( registeredDate, offlineData ) + + const locationKey = userDetails?.primaryOffice?.id + ? offlineData.offices[userDetails.primaryOffice.id].partOf.split('/')[1] + : '' + const { country, ...locationHierarchyIds } = getLocationHierarchy( + locationKey, + offlineData.locations + ) + + const locationHierarchy: Record = + { country } + + for (const [key, value] of Object.entries(locationHierarchyIds)) { + locationHierarchy[`${key}Id`] = value + } + return { ...declaration, data: { @@ -82,7 +99,8 @@ const withEnhancedTemplateVariables = ( loggedInUser: { name: getUserName(userDetails), officeId: userDetails.primaryOffice?.id, - signature: userDetails.localRegistrar?.signature + signature: userDetails.localRegistrar?.signature, + ...locationHierarchy } }) } as IFormSectionData From 2a213676fd16d112bfca752b40a42a5696e37e79 Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Wed, 5 Jun 2024 12:59:35 +0600 Subject: [PATCH 019/108] Fix "Print and issue to groom|bride" is added to a different variable (#7066) * Fix "Print and issue to groom|bride" is added to a different variable * groom and bride default name fix --------- Co-authored-by: Tameem Bin Haider --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a18e32b185..4a3288a12cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,10 @@ - Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) -- Fix client modal glitches on integrations page [#7002] (https://github.com/opencrvs/opencrvs-core/issues/7002) +- Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481) +- Fix client modal glitches on integrations page [#7002](https://github.com/opencrvs/opencrvs-core/issues/7002) +- Fix "Print and issue to groom|bride" is added to a different variable [#7066](https://github.com/opencrvs/opencrvs-core/pull/7066) +- Fix Removed duplicateTrackingId check in createDuplicateTask method [#7081](https://github.com/opencrvs/opencrvs-core/pull/7081) ## Refactor From 18d5e2f99153cb012bc52cfd8506cac493ba0cd9 Mon Sep 17 00:00:00 2001 From: Tareq Date: Fri, 7 Jun 2024 18:35:30 +0600 Subject: [PATCH 020/108] fix: remove leading slash to make it relative (#7036) * Fix URL path by removing leading slash This change ensures that the constructed URL uses a relative path instead of an absolute path, appending 'resendAuthenticationCode' correctly to the base URL 'https://gateway.farajaland-qa.opencrvs.org/auth/'. * chore(changelog) --------- Co-authored-by: naftis --- CHANGELOG.md | 2 ++ packages/login/src/utils/authApi.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3288a12cb..c33b2e0d265 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ - Fix issues of invisible inputs when navigating from can't login link in login page [#6163](https://github.com/opencrvs/opencrvs-core/issues/6163) - Remove leading slash from `resendAuthenticationCode` in login to fix resend email button [#6987](https://github.com/opencrvs/opencrvs-core/issues/6987) [#7037](https://github.com/opencrvs/opencrvs-core/issues/7037) - Fix 'Place of Certification' is showing wrong in certificate [#7060] (https://github.com/opencrvs/opencrvs-core/issues/7060) +- Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) +- Fix Check for valid date to handle incomplete marriage declarations [#7017](https://github.com/opencrvs/opencrvs-core/issues/7017) - Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) diff --git a/packages/login/src/utils/authApi.ts b/packages/login/src/utils/authApi.ts index 33e6290985d..0cbdc629e9b 100644 --- a/packages/login/src/utils/authApi.ts +++ b/packages/login/src/utils/authApi.ts @@ -117,7 +117,7 @@ const resendAuthenticationCode = ( ) => { return request({ url: new URL( - '/resendAuthenticationCode', + 'resendAuthenticationCode', window.config.AUTH_API_URL ).toString(), method: 'POST', From 0a025e1a3fc81557e280abae6b3237fb6ea8d3c3 Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Tue, 4 Jun 2024 15:41:16 +0600 Subject: [PATCH 021/108] fix: remove duplicateTrackingId check in createDuplicateTask method (#7081) * Removed duplicateTrackingId check in createDuplicateTask method * changelog updated --- packages/commons/src/fhir/extension.ts | 2 +- packages/workflow/src/records/fhir.ts | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/commons/src/fhir/extension.ts b/packages/commons/src/fhir/extension.ts index 8fa4b1c1fd2..9948f03f220 100644 --- a/packages/commons/src/fhir/extension.ts +++ b/packages/commons/src/fhir/extension.ts @@ -17,7 +17,7 @@ export type StringExtensionType = { } 'http://opencrvs.org/specs/extension/markedAsDuplicate': { url: 'http://opencrvs.org/specs/extension/markedAsDuplicate' - valueString: string + valueString?: string } 'http://opencrvs.org/specs/extension/educational-attainment': { url: 'http://opencrvs.org/specs/extension/educational-attainment' diff --git a/packages/workflow/src/records/fhir.ts b/packages/workflow/src/records/fhir.ts index 30bbe914767..0aa5103ac73 100644 --- a/packages/workflow/src/records/fhir.ts +++ b/packages/workflow/src/records/fhir.ts @@ -873,12 +873,10 @@ export function createDuplicateTask( duplicateTrackingId?: string ): SavedTask { const newExtensions: Extension[] = [] - if (duplicateTrackingId) { - newExtensions.push({ - url: 'http://opencrvs.org/specs/extension/markedAsDuplicate', - valueString: duplicateTrackingId - }) - } + newExtensions.push({ + url: 'http://opencrvs.org/specs/extension/markedAsDuplicate', + valueString: duplicateTrackingId + }) const duplicateTask = createNewTaskResource(previousTask, newExtensions) From 2b7449216f438bb5b4e2965112b9cf217521c647 Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Thu, 30 May 2024 12:54:07 +0600 Subject: [PATCH 022/108] fix: check for valid date to handle incomplete marriage declarations (#7038) * Fix issue #7017: Check for valid date to handle incomplete marriage declarations Updated logic to use isValidPlainDate function to check date values, ensuring that null or invalid date values do not cause issues. This change allows the retrieval of incomplete marriage declarations even when the date of marriage is missing. * changelog updated --- .../marriage/query/event-mappings.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/event-mappings.ts b/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/event-mappings.ts index 241a33a35ca..271f9491948 100644 --- a/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/event-mappings.ts +++ b/packages/client/src/forms/register/mappings/event-specific-fields/marriage/query/event-mappings.ts @@ -9,7 +9,10 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { IFormField, IFormData } from '@client/forms' -import { formatPlainDate } from '@client/utils/date-formatting' +import { + formatPlainDate, + isValidPlainDate +} from '@client/utils/date-formatting' export const marriageDateToFieldTransformation = (alternativeSectionIds?: string[]) => @@ -67,8 +70,7 @@ export const marriageDateFormatTransformation = queryValue = queryData[fromSectionIds].dateOfMarriage } - const date = new Date(queryValue) - if (!Number.isNaN(date.getTime())) { + if (isValidPlainDate(queryValue)) { const prevLocale = window.__localeId__ window.__localeId__ = locale From 44cfcf3e8c28a40aa0afce734c79b534cbf5371e Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Wed, 29 May 2024 17:44:32 +0600 Subject: [PATCH 023/108] fix: reset pagination to page 1 when location changes (#7043) * Fix: Reset pagination to page 1 when location changes Ensure the currentPageNumber is reset to 1 whenever the location parameter changes to avoid issues where no data is found and the table and pagination components disappear. * changelog updated --- CHANGELOG.md | 5 +++-- packages/client/src/views/SysAdmin/Team/user/UserList.tsx | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c33b2e0d265..cfe26288079 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,12 +53,13 @@ - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) - Fix Check for valid date to handle incomplete marriage declarations [#7017](https://github.com/opencrvs/opencrvs-core/issues/7017) - Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341) -- Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) -- Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481) - Fix client modal glitches on integrations page [#7002](https://github.com/opencrvs/opencrvs-core/issues/7002) - Fix "Print and issue to groom|bride" is added to a different variable [#7066](https://github.com/opencrvs/opencrvs-core/pull/7066) - Fix Removed duplicateTrackingId check in createDuplicateTask method [#7081](https://github.com/opencrvs/opencrvs-core/pull/7081) +- Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) +- Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481) +- Fix client modal glitches on integrations page [#7002] (https://github.com/opencrvs/opencrvs-core/issues/7002) ## Refactor diff --git a/packages/client/src/views/SysAdmin/Team/user/UserList.tsx b/packages/client/src/views/SysAdmin/Team/user/UserList.tsx index 8a9e5ac7d00..34a7659c9ab 100644 --- a/packages/client/src/views/SysAdmin/Team/user/UserList.tsx +++ b/packages/client/src/views/SysAdmin/Team/user/UserList.tsx @@ -84,6 +84,8 @@ import { getLocalizedLocationName } from '@client/utils/locationUtils' import { HOME } from '@client/navigation/routes' const DEFAULT_FIELD_AGENT_LIST_SIZE = 10 +const DEFAULT_PAGE_NUMBER = 1 + const { useState } = React const UserTable = styled(BodyContent)` @@ -269,7 +271,8 @@ function UserListComponent(props: IProps) { selectedUser: null }) - const [currentPageNumber, setCurrentPageNumber] = useState(1) + const [currentPageNumber, setCurrentPageNumber] = + useState(DEFAULT_PAGE_NUMBER) const recordCount = DEFAULT_FIELD_AGENT_LIST_SIZE * currentPageNumber const searchedLocation: ILocation | undefined = offlineOffices.find( ({ id }) => locationId === id @@ -633,6 +636,7 @@ function UserListComponent(props: IProps) { selectedLocationId={locationId} onChangeLocation={(locationId) => { props.goToTeamUserList(locationId) + setCurrentPageNumber(DEFAULT_PAGE_NUMBER) }} requiredLocationTypes={'CRVS_OFFICE'} /> From 4edbd563bdc5b20de399afa804432cd24355c149 Mon Sep 17 00:00:00 2001 From: Tareq Date: Fri, 7 Jun 2024 19:28:08 +0600 Subject: [PATCH 024/108] changelog edited --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfe26288079..ed19983dd6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,6 @@ - Fix Removed duplicateTrackingId check in createDuplicateTask method [#7081](https://github.com/opencrvs/opencrvs-core/pull/7081) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481) -- Fix client modal glitches on integrations page [#7002] (https://github.com/opencrvs/opencrvs-core/issues/7002) ## Refactor From 082edb1b181c30c99d4cfbedc1fbcb4cbefa09a4 Mon Sep 17 00:00:00 2001 From: Tareq Date: Fri, 7 Jun 2024 19:30:38 +0600 Subject: [PATCH 025/108] changelog edited --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed19983dd6d..81cbd097d41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,6 @@ - Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) - Fix Check for valid date to handle incomplete marriage declarations [#7017](https://github.com/opencrvs/opencrvs-core/issues/7017) - Fix French translation missing for relationship to informant when trying to correct record, print and issue record [#6341] (https://github.com/opencrvs/opencrvs-core/issues/6341) -- Fix dashboard cron jobs not working [#7016](https://github.com/opencrvs/opencrvs-core/issues/7016) - Fix client modal glitches on integrations page [#7002](https://github.com/opencrvs/opencrvs-core/issues/7002) - Fix "Print and issue to groom|bride" is added to a different variable [#7066](https://github.com/opencrvs/opencrvs-core/pull/7066) - Fix Removed duplicateTrackingId check in createDuplicateTask method [#7081](https://github.com/opencrvs/opencrvs-core/pull/7081) From 4ef8fa6b3cc3be9b786f7887eb90a745230d3e7a Mon Sep 17 00:00:00 2001 From: tahmidrahman-dsi Date: Mon, 10 Jun 2024 20:15:06 +0600 Subject: [PATCH 026/108] feat: configurable image compression options (#7019) * Covert DocumentUploaderWithOption to functional component * Introduce a prop compressImagesToSizeMB to define maximum size of compressed file * Minor refactor * Add a maxSize prop to prevent uploading document bigger than a defined size * Updates to the messages having variable maximum sizes * Update FormFieldGenerator to make document uploader with options configurable from country config forms * Fix typo * Apply suggestions from code review Co-authored-by: Tameem Bin Haider * Update CHANGELOG.md --- CHANGELOG.md | 3 + .../DocumentUploaderWithOption.tsx | 347 +++++++++--------- .../components/form/FormFieldGenerator.tsx | 2 + packages/client/src/forms/index.ts | 4 + .../src/i18n/messages/views/imageUpload.ts | 10 +- packages/client/src/utils/imageUtils.ts | 7 +- .../client/src/views/Settings/ImageLoader.tsx | 20 +- .../Config/Certificates/Certificates.tsx | 9 +- 8 files changed, 210 insertions(+), 192 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81cbd097d41..0864d2ee8bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,9 @@ - Allow defining maxLength attribute for number type fields [#6356](https://github.com/opencrvs/opencrvs-core/issues/6356) - Certificate handlebar for registration fees `registrationFees` [#6817](https://github.com/opencrvs/opencrvs-core/issues/6817) - Logged in user details handlebar `loggedInUser` [#6529](https://github.com/opencrvs/opencrvs-core/issues/6529) +- Introduce two new properties to the form field `DOCUMENT_UPLOADER_WITH_OPTION` + - `compressImagesToSizeMB` : An optional prop of number type to define a compressed size. Compression is ignored when the input file is already smaller or equal of the given value or a falsy given value. + - `maxSizeMB`: An optional validation prop to prevent input of a file bigger than a defined value. ## Bug fixes diff --git a/packages/client/src/components/form/DocumentUploadfield/DocumentUploaderWithOption.tsx b/packages/client/src/components/form/DocumentUploadfield/DocumentUploaderWithOption.tsx index b5a929c0314..96ce3d6ec62 100644 --- a/packages/client/src/components/form/DocumentUploadfield/DocumentUploaderWithOption.tsx +++ b/packages/client/src/components/form/DocumentUploadfield/DocumentUploaderWithOption.tsx @@ -14,20 +14,19 @@ import { ErrorText } from '@opencrvs/components/lib/ErrorText' import { DocumentPreview } from '@client/components/form/DocumentUploadfield/DocumentPreview' import { IFileValue, IFormFieldValue, IAttachmentValue } from '@client/forms' import { ALLOWED_IMAGE_TYPE, EMPTY_STRING } from '@client/utils/constants' -import * as React from 'react' -import { - WrappedComponentProps as IntlShapeProps, - injectIntl, - MessageDescriptor -} from 'react-intl' +import React, { useState } from 'react' +import { MessageDescriptor, useIntl } from 'react-intl' import styled from 'styled-components' import { DocumentListPreview } from './DocumentListPreview' import { remove, clone } from 'lodash' -import { buttonMessages, formMessages } from '@client/i18n/messages' +import { formMessages } from '@client/i18n/messages' import { messages } from '@client/i18n/messages/views/imageUpload' import imageCompression from 'browser-image-compression' +import { bytesToMB } from '@client/utils/imageUtils' -const options = { +const DEFAULT_MAX_SIZE_MB = 5 + +const defaultOptions = { maxSizeMB: 0.4, maxWidthOrHeight: 1920, useWebWorker: true @@ -67,21 +66,15 @@ type IFullProps = { touched?: boolean onUploadingStateChanged?: (isUploading: boolean) => void requiredErrorMessage?: MessageDescriptor -} & IntlShapeProps + compressImagesToSizeMB?: number + maxSizeMB?: number +} type DocumentFields = { documentType: string documentData: string } -type IState = { - errorMessage: string - fields: DocumentFields - previewImage: IFileValue | null - filesBeingProcessed: Array<{ label: string }> - dropDownOptions: ISelectOption[] -} - export const getBase64String = (file: File) => { return new Promise((resolve, reject) => { const reader = new FileReader() @@ -95,72 +88,74 @@ export const getBase64String = (file: File) => { }) } -class DocumentUploaderWithOptionComp extends React.Component< - IFullProps, - IState -> { - constructor(props: IFullProps) { - super(props) - this.state = { - errorMessage: EMPTY_STRING, - previewImage: null, - dropDownOptions: this.initializeDropDownOption(), - filesBeingProcessed: [], - fields: { - documentType: EMPTY_STRING, - documentData: EMPTY_STRING - } - } - } +const initializeDropDownOption = ( + options: ISelectOption[], + files: IFileValue[] +): ISelectOption[] => { + const outputOptions = clone(options) + files && + files.forEach((element: IFileValue) => { + remove( + outputOptions, + (option: ISelectOption) => option.value === element.optionValues[1] + ) + }) - initializeDropDownOption = (): ISelectOption[] => { - const options = clone(this.props.options) - this.props.files && - this.props.files.forEach((element: IFileValue) => { - remove( - options, - (option: ISelectOption) => option.value === element.optionValues[1] - ) - }) + return outputOptions +} - return options - } +export const DocumentUploaderWithOption = (props: IFullProps) => { + const intl = useIntl() + const [errorMessage, setErrorMessage] = useState(EMPTY_STRING) + const [previewImage, setPreviewImage] = useState(null) + const [dropdownOptions, setDropdownOptions] = useState( + initializeDropDownOption(props.options, props.files) + ) + const [filesBeingProcessed, setFilesBeingProcessed] = useState< + Array<{ label: string }> + >([]) + const [fields, setFields] = useState({ + documentType: EMPTY_STRING, + documentData: EMPTY_STRING + }) + const maxSize = props.maxSizeMB ?? DEFAULT_MAX_SIZE_MB - onChange = (documentType: string) => { - const currentState = this.state - currentState.fields.documentType = documentType - this.setState(currentState) + const onChange = (documentType: string) => { + setFields((currentFields) => ({ + ...currentFields, + documentType + })) } - isValid = (): boolean => { - const isValid = !!this.state.fields.documentType + const isValid = (): boolean => { + const isValid = !!fields.documentType - this.setState({ - errorMessage: isValid - ? EMPTY_STRING - : this.props.intl.formatMessage(messages.documentTypeRequired) - }) + setErrorMessage( + isValid ? EMPTY_STRING : intl.formatMessage(messages.documentTypeRequired) + ) return isValid } - processImage = async (uploadedImage: File) => { + const processImage = async (uploadedImage: File) => { + const options = { ...defaultOptions } if (!ALLOWED_IMAGE_TYPE.includes(uploadedImage.type)) { - this.setState({ - errorMessage: this.props.intl.formatMessage(messages.uploadError) - }) + setErrorMessage(intl.formatMessage(messages.uploadError, { maxSize })) throw new Error('File type not supported') } - if (uploadedImage.size > 5242880) { - this.setState({ - errorMessage: this.props.intl.formatMessage(messages.overSized) - }) - throw new Error(this.props.intl.formatMessage(messages.overSized)) + if (bytesToMB(uploadedImage.size) > maxSize) { + setErrorMessage(intl.formatMessage(messages.overSized, { maxSize })) + throw new Error(intl.formatMessage(messages.overSized, { maxSize })) } + if (props.compressImagesToSizeMB !== undefined) { + options.maxSizeMB = props.compressImagesToSizeMB + } + // disable compression with a falsy value const resized = - uploadedImage.size > 512000 && + Boolean(options.maxSizeMB) && + bytesToMB(uploadedImage.size) > options.maxSizeMB && (await imageCompression(uploadedImage, options)) const fileAsBase64 = await getBase64String(resized || uploadedImage) @@ -168,28 +163,27 @@ class DocumentUploaderWithOptionComp extends React.Component< return fileAsBase64.toString() } - handleFileChange = async (uploadedImage: File) => { + const handleFileChange = async (uploadedImage: File) => { if (!uploadedImage) { return } let fileAsBase64: string const optionValues: [IFormFieldValue, string] = [ - this.props.extraValue, - this.state.fields.documentType + props.extraValue, + fields.documentType ] - this.setState((state) => ({ - filesBeingProcessed: [ - ...state.filesBeingProcessed, - { - label: optionValues[1] - } - ] - })) + setFilesBeingProcessed((filesCurrentlyBeingProcessed) => [ + ...filesCurrentlyBeingProcessed, + { + label: optionValues[1] + } + ]) - this.props.onUploadingStateChanged && - this.props.onUploadingStateChanged(true) + if (props.onUploadingStateChanged) { + props.onUploadingStateChanged(true) + } const minimumProcessingTime = new Promise((resolve) => setTimeout(resolve, 2000) @@ -198,30 +192,30 @@ class DocumentUploaderWithOptionComp extends React.Component< try { // Start processing ;[fileAsBase64] = await Promise.all([ - this.processImage(uploadedImage), + processImage(uploadedImage), minimumProcessingTime ]) } catch (error) { - this.props.onUploadingStateChanged && - this.props.onUploadingStateChanged(false) - - this.setState({ - errorMessage: - this.state.errorMessage || - this.props.intl.formatMessage(messages.uploadError), - // Remove from processing files - filesBeingProcessed: this.state.filesBeingProcessed.filter( + if (props.onUploadingStateChanged) { + props.onUploadingStateChanged(false) + } + + setErrorMessage( + (msg) => msg || intl.formatMessage(messages.uploadError, { maxSize }) + ) + setFilesBeingProcessed((filesCurrentlyBeingProcessed) => + filesCurrentlyBeingProcessed.filter( ({ label }) => label !== optionValues[1] ) - }) + ) return } - const tempOptions = this.state.dropDownOptions + const tempOptions = dropdownOptions remove( tempOptions, - (option: ISelectOption) => option.value === this.state.fields.documentType + (option: ISelectOption) => option.value === fields.documentType ) const newDocument: IFileValue = { @@ -231,77 +225,70 @@ class DocumentUploaderWithOptionComp extends React.Component< fileSize: uploadedImage.size } - this.props.onComplete([...this.props.files, newDocument]) - this.props.onUploadingStateChanged && - this.props.onUploadingStateChanged(false) - - this.setState((prevState) => { - return { - ...prevState, - errorMessage: EMPTY_STRING, - fields: { - documentType: EMPTY_STRING, - documentData: EMPTY_STRING - }, - dropDownOptions: tempOptions, - // Remove from processing files - filesBeingProcessed: this.state.filesBeingProcessed.filter( - ({ label }) => label !== optionValues[1] - ) - } + props.onComplete([...props.files, newDocument]) + if (props.onUploadingStateChanged) { + props.onUploadingStateChanged(false) + } + + setErrorMessage(EMPTY_STRING) + setFields({ + documentType: EMPTY_STRING, + documentData: EMPTY_STRING }) + setDropdownOptions(tempOptions) + setFilesBeingProcessed((filesCurrentlyBeingProcessed) => + filesCurrentlyBeingProcessed.filter( + ({ label }) => label !== optionValues[1] + ) + ) } - onDelete = (image: IFileValue | IAttachmentValue) => { + const onDelete = (image: IFileValue | IAttachmentValue) => { const previewImage = image as IFileValue - const addableOption = this.props.options.find( + const addableOption = props.options.find( (item: ISelectOption) => item.value === previewImage.optionValues[1] ) as ISelectOption - const dropDownOptions = this.state.dropDownOptions.concat(addableOption) - this.setState(() => ({ dropDownOptions })) - this.props.onComplete( - this.props.files.filter((file) => file !== previewImage) - ) - this.closePreviewSection() + setDropdownOptions((options) => options.concat(addableOption)) + props.onComplete(props.files.filter((file) => file !== previewImage)) + closePreviewSection() } - closePreviewSection = () => { - this.setState({ previewImage: null }) + const closePreviewSection = () => { + setPreviewImage(null) } - selectForPreview = (previewImage: IFileValue | IAttachmentValue) => { - this.setState({ previewImage: previewImage as IFileValue }) + const selectForPreview = (previewImage: IFileValue | IAttachmentValue) => { + setPreviewImage(previewImage as IFileValue) } - getFormattedLabelForDocType = (docType: string) => { + const getFormattedLabelForDocType = (docType: string) => { const matchingOptionForDocType = - this.props.options && - this.props.options.find((option) => option.value === docType) + props.options && props.options.find((option) => option.value === docType) return matchingOptionForDocType && matchingOptionForDocType.label } - renderDocumentUploaderWithDocumentTypeBlock = () => { - const { name, intl, placeholder } = this.props - return this.props.splitView ? ( - this.state.dropDownOptions.map((opt, idx) => ( + const renderDocumentUploaderWithDocumentTypeBlock = () => { + const { name, placeholder } = props + return props.splitView ? ( + dropdownOptions.map((opt, idx) => ( 0} + options={dropdownOptions} + value={fields.documentType} + onChange={onChange} + isDisabled={filesBeingProcessed.length > 0} /> !this.isValid() && e.preventDefault()} - handleFileChange={this.handleFileChange} - disabled={this.state.filesBeingProcessed.length > 0} + onClick={(e) => !isValid() && e.preventDefault()} + handleFileChange={handleFileChange} + disabled={filesBeingProcessed.length > 0} /> ) } - render() { - const { label, intl, requiredErrorMessage } = this.props - - return ( - - - {this.state.errorMessage && ( - - {(requiredErrorMessage && - intl.formatMessage(requiredErrorMessage)) || - this.state.errorMessage} - + const { requiredErrorMessage, label } = props + + return ( + + + {errorMessage && ( + + {(requiredErrorMessage && + intl.formatMessage(requiredErrorMessage)) || + errorMessage} + + )} + + + + + {props.hideOnEmptyOption && dropdownOptions.length === 0 + ? null + : renderDocumentUploaderWithDocumentTypeBlock()} + + {previewImage && ( + - - - - {this.props.hideOnEmptyOption && this.state.dropDownOptions.length === 0 - ? null - : this.renderDocumentUploaderWithDocumentTypeBlock()} - - {this.state.previewImage && ( - - )} - - ) - } + )} + + ) } - -export const DocumentUploaderWithOption = injectIntl<'intl', IFullProps>( - DocumentUploaderWithOptionComp -) diff --git a/packages/client/src/components/form/FormFieldGenerator.tsx b/packages/client/src/components/form/FormFieldGenerator.tsx index 501591da02e..4233683397d 100644 --- a/packages/client/src/components/form/FormFieldGenerator.tsx +++ b/packages/client/src/components/form/FormFieldGenerator.tsx @@ -270,6 +270,8 @@ const GeneratedInputField = React.memo( splitView={fieldDefinition.splitView} files={value as IFileValue[]} extraValue={fieldDefinition.extraValue || ''} + compressImagesToSizeMB={fieldDefinition.compressImagesToSizeMB} + maxSizeMB={fieldDefinition.maxSizeMB} hideOnEmptyOption={fieldDefinition.hideOnEmptyOption} onComplete={(files: IFileValue[]) => { onSetFieldValue(fieldDefinition.name, files) diff --git a/packages/client/src/forms/index.ts b/packages/client/src/forms/index.ts index 1b2c5e6e2b2..a5cf744cce9 100644 --- a/packages/client/src/forms/index.ts +++ b/packages/client/src/forms/index.ts @@ -644,6 +644,8 @@ export interface IImageUploaderWithOptionsFormField extends IFormFieldBase { } export interface IDocumentUploaderWithOptionsFormField extends IFormFieldBase { type: typeof DOCUMENT_UPLOADER_WITH_OPTION + compressImagesToSizeMB?: number + maxSizeMB?: number options: ISelectOption[] hideOnEmptyOption?: boolean splitView?: boolean @@ -1140,6 +1142,8 @@ export interface Ii18nImageUploaderWithOptionsFormField export interface Ii18nDocumentUploaderWithOptions extends Ii18nFormFieldBase { type: typeof DOCUMENT_UPLOADER_WITH_OPTION options: SelectComponentOption[] + compressImagesToSizeMB?: number + maxSizeMB?: number hideOnEmptyOption?: boolean splitView?: boolean } diff --git a/packages/client/src/i18n/messages/views/imageUpload.ts b/packages/client/src/i18n/messages/views/imageUpload.ts index 1fa686ecd97..5e110681152 100644 --- a/packages/client/src/i18n/messages/views/imageUpload.ts +++ b/packages/client/src/i18n/messages/views/imageUpload.ts @@ -22,13 +22,13 @@ const messagesToDefine: IImageUploadMessages = { uploadError: { id: 'imageUploadOption.upload.error', defaultMessage: - 'File format not supported. Please attach a png, jpg or pdf (max 5mb)', + 'File format not supported. Please attach a png, jpg or pdf (max {maxSize}mb)', description: 'Show error messages while uploading' }, imageFormat: { id: 'imageUploadOption.upload.imageFormat', defaultMessage: - 'Image format not supported. Please attach a png or jpg (max 5mb)', + 'Image format not supported. Please attach a png or jpg (max {maxSize}mb)', description: 'Show error message if the selected image type is not supported' }, @@ -39,8 +39,10 @@ const messagesToDefine: IImageUploadMessages = { }, overSized: { id: 'imageUploadOption.upload.overSized', - defaultMessage: 'File is too large. Please attach file less than 5mb', - description: 'Error message for Attachment size greater than 5mb.' + defaultMessage: + 'File is too large. Please attach file less than {maxSize}mb', + description: + 'Error message for Attachment size greater than defined max size.' } } diff --git a/packages/client/src/utils/imageUtils.ts b/packages/client/src/utils/imageUtils.ts index 4308939a7e7..606aa8ca34f 100644 --- a/packages/client/src/utils/imageUtils.ts +++ b/packages/client/src/utils/imageUtils.ts @@ -24,6 +24,8 @@ export const ERROR_TYPES = { OVERSIZED: 'overSized' } +export const IMAGE_UPLOAD_MAX_SIZE_IN_BYTES = 5242880 + export const getBase64String = (file: File) => { return new Promise((resolve, reject) => { const reader = new FileReader() @@ -55,7 +57,7 @@ export const validateImage = async (uploadedImage: File) => { throw new Error(ERROR_TYPES.IMAGE_TYPE) } - if (uploadedImage.size > 5242880) { + if (uploadedImage.size > IMAGE_UPLOAD_MAX_SIZE_IN_BYTES) { throw new Error(ERROR_TYPES.OVERSIZED) } @@ -131,3 +133,6 @@ export async function fetchImageAsBase64(url: string): Promise { reader.readAsDataURL(blob) }) } + +export const bytesToMB = (bytes: number) => + Number(Number(bytes / (1024 * 1024)).toFixed(2)) diff --git a/packages/client/src/views/Settings/ImageLoader.tsx b/packages/client/src/views/Settings/ImageLoader.tsx index ba0eff5ee59..0d07878f33d 100644 --- a/packages/client/src/views/Settings/ImageLoader.tsx +++ b/packages/client/src/views/Settings/ImageLoader.tsx @@ -10,7 +10,13 @@ */ import * as React from 'react' import styled from 'styled-components' -import { IImage, validateImage, ERROR_TYPES } from '@client/utils/imageUtils' +import { + IImage, + validateImage, + ERROR_TYPES, + IMAGE_UPLOAD_MAX_SIZE_IN_BYTES, + bytesToMB +} from '@client/utils/imageUtils' import { ALLOWED_IMAGE_TYPE } from '@client/utils/constants' import { messages } from '@client/i18n/messages/views/imageUpload' import { WrappedComponentProps as IntlShapeProps, injectIntl } from 'react-intl' @@ -47,9 +53,17 @@ function ImageLoaderComp({ } catch (error) { if (error instanceof Error) { if (error.message === ERROR_TYPES.OVERSIZED) { - onError(intl.formatMessage(messages.overSized)) + onError( + intl.formatMessage(messages.overSized, { + maxSize: bytesToMB(IMAGE_UPLOAD_MAX_SIZE_IN_BYTES) + }) + ) } else { - onError(intl.formatMessage(messages.imageFormat)) + onError( + intl.formatMessage(messages.imageFormat, { + maxSize: bytesToMB(IMAGE_UPLOAD_MAX_SIZE_IN_BYTES) + }) + ) } } } finally { diff --git a/packages/client/src/views/SysAdmin/Config/Certificates/Certificates.tsx b/packages/client/src/views/SysAdmin/Config/Certificates/Certificates.tsx index 1e067195cae..fcaa68db555 100644 --- a/packages/client/src/views/SysAdmin/Config/Certificates/Certificates.tsx +++ b/packages/client/src/views/SysAdmin/Config/Certificates/Certificates.tsx @@ -68,6 +68,10 @@ import { Link, Text, Toggle } from '@client/../../components/lib' import { NOTIFICATION_STATUS } from '@client/views/SysAdmin/Config/Application/utils' import { configApplicationMutations } from '@client/views/SysAdmin/Config/Application/mutations' import { UserDetails } from '@client/utils/userUtils' +import { + bytesToMB, + IMAGE_UPLOAD_MAX_SIZE_IN_BYTES +} from '@client/utils/imageUtils' const Value = styled.span` ${({ theme }) => theme.fonts.reg16}; @@ -341,7 +345,10 @@ class CertificatesConfigComponent extends React.Component { } catch (err) { this.setState({ imageLoadingError: this.props.intl.formatMessage( - imageUploadMessages.imageFormat + imageUploadMessages.imageFormat, + { + maxSize: bytesToMB(IMAGE_UPLOAD_MAX_SIZE_IN_BYTES) + } ) }) } From bf7de7e89e60496ca849e577f6576fe8eb3dd593 Mon Sep 17 00:00:00 2001 From: Euan Millar Date: Thu, 13 Jun 2024 17:01:07 +0100 Subject: [PATCH 027/108] Merge pull request #7067 from opencrvs/remove-nonce-from-mosip-esignet Remove nonce check from MOSIP E-Signet --- packages/client/src/setupTests.ts | 3 +- .../OIDPVerificationCallback.test.tsx | 3 +- .../OIDPVerificationCallback.tsx | 5 +-- .../views/OIDPVerificationCallback/utils.ts | 35 ------------------- packages/gateway/src/constants.ts | 3 +- .../OIDPUserInfo/root-resolvers.test.ts | 5 ++- .../src/features/OIDPUserInfo/utils.ts | 13 +++---- packages/gateway/test/setupJest.ts | 5 ++- packages/user-mgnt/src/constants.ts | 3 -- 9 files changed, 16 insertions(+), 59 deletions(-) diff --git a/packages/client/src/setupTests.ts b/packages/client/src/setupTests.ts index 8998f0fb76c..55c0027e4d3 100644 --- a/packages/client/src/setupTests.ts +++ b/packages/client/src/setupTests.ts @@ -291,6 +291,5 @@ vi.mock('@client/views/OIDPVerificationCallback/utils', async () => ({ '@client/views/OIDPVerificationCallback/utils' )) as any), useExtractCallBackState: vi.fn(), - useQueryParams: vi.fn(), - useCheckNonce: vi.fn() + useQueryParams: vi.fn() })) diff --git a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.test.tsx b/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.test.tsx index d3c9cd1129e..953a5628f77 100644 --- a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.test.tsx +++ b/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.test.tsx @@ -20,7 +20,7 @@ import { waitFor, waitForElement } from '@client/tests/wait-for-element' import { vi, Mock } from 'vitest' import { OIDPVerificationCallback } from './OIDPVerificationCallback' import { URLSearchParams } from 'url' -import { useQueryParams, useExtractCallBackState, useCheckNonce } from './utils' +import { useQueryParams, useExtractCallBackState } from './utils' import { GET_OIDP_USER_INFO } from './queries' import { createDeclaration, storeDeclaration } from '@client/declarations' import { Event } from '@client/utils/gateway' @@ -131,7 +131,6 @@ beforeEach(async () => { ;(useQueryParams as Mock).mockImplementation( () => new URLSearchParams({ code: '1234' }) ) - ;(useCheckNonce as Mock).mockImplementation(() => true) await store.dispatch(checkAuth()) await store.dispatch(storeDeclaration(draft)) diff --git a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.tsx b/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.tsx index 749c2640531..627166ed96b 100644 --- a/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.tsx +++ b/packages/client/src/views/OIDPVerificationCallback/OIDPVerificationCallback.tsx @@ -19,7 +19,6 @@ import { useIntl } from 'react-intl' import { useDispatch, useSelector } from 'react-redux' import { addNidUserInfoToDeclaration, - useCheckNonce, useExtractCallBackState, useQueryParams } from '@client/views/OIDPVerificationCallback/utils' @@ -38,7 +37,6 @@ import { OIDP_VERIFICATION_CALLBACK } from '@client/navigation/routes' // OIDP Verification Callback // -- // Checks the ?state= query parameter for a JSON string like: { pathname: "/path/somewhere" } -// Checks that the &nonce= parameter matches the one in localStorage, removes it if yes, throws if not // Redirects to the pathname in state const Page = styled.div` @@ -65,7 +63,6 @@ const UserActionsContainer = styled.div` export const OIDPVerificationCallback = () => { const params = useQueryParams() const { pathname, declarationId, section } = useExtractCallBackState() - const isNonceOk = useCheckNonce() const code = params.get('code') const offlineData = useSelector(getOfflineData) const clientId = offlineData.systems.find((s) => s.type === 'NATIONAL_ID') @@ -91,7 +88,7 @@ export const OIDPVerificationCallback = () => { } }) - if (!pathname || !isNonceOk) { + if (!pathname) { // Do not redirect and let the hooks throw return null } diff --git a/packages/client/src/views/OIDPVerificationCallback/utils.ts b/packages/client/src/views/OIDPVerificationCallback/utils.ts index c748ad1c3fb..0f9b13eb526 100644 --- a/packages/client/src/views/OIDPVerificationCallback/utils.ts +++ b/packages/client/src/views/OIDPVerificationCallback/utils.ts @@ -22,8 +22,6 @@ import { useDispatch, useSelector } from 'react-redux' import { useLocation, useRouteMatch } from 'react-router' import { v4 as uuid } from 'uuid' -const OIDP_VERIFICATION_NONCE_LOCALSTORAGE_KEY = 'oidp-verification-nonce' - interface OIDPUserAddress { formatted?: string | null street_address?: string | null @@ -183,10 +181,6 @@ export function addNidUserInfoToDeclaration( declarationDataSection[`${section}NidVerification`] = oidpUserInfo.sub } -function generateNonce() { - return uuid() -} - function splitName(name: string | undefined | null = '') { if (!name) { return { firstName: '', lastName: '' } @@ -231,8 +225,6 @@ export function redirectToNidIntegration( currentSection: string, currentPathname: string ) { - const nonce = generateNonce() - window.localStorage.setItem(OIDP_VERIFICATION_NONCE_LOCALSTORAGE_KEY, nonce) const nidSystemSetting = offlineCountryConfig.systems.find( (s) => s.type === 'NATIONAL_ID' )?.settings @@ -242,7 +234,6 @@ export function redirectToNidIntegration( } const url = new URL(`${nidSystemSetting?.openIdProviderBaseUrl}authorize`) - url.searchParams.append('nonce', nonce) url.searchParams.append( 'client_id', nidSystemSetting?.openIdProviderClientId || '' @@ -264,32 +255,6 @@ export function redirectToNidIntegration( window.location.href = url.toString() } -export const useCheckNonce = () => { - const params = useQueryParams() - const [nonceOk, setNonceOk] = useState(false) - - useEffect(() => { - if (!params.get('nonce')) { - throw new Error('No nonce provided from OIDP callback.') - } - - const nonceMatches = - window.localStorage.getItem(OIDP_VERIFICATION_NONCE_LOCALSTORAGE_KEY) === - params.get('nonce') - - if (nonceMatches) { - window.localStorage.removeItem(OIDP_VERIFICATION_NONCE_LOCALSTORAGE_KEY) - setNonceOk(true) - } else { - throw new Error( - 'Nonce did not match the one sent to the integration before callback' - ) - } - }, [params]) - - return nonceOk -} - export const useExtractCallBackState = () => { const params = useQueryParams() diff --git a/packages/gateway/src/constants.ts b/packages/gateway/src/constants.ts index 2b39de2352f..ffda6697ff0 100644 --- a/packages/gateway/src/constants.ts +++ b/packages/gateway/src/constants.ts @@ -77,7 +77,8 @@ export const DEFAULT_TIMEOUT = 600000 export const MINIO_BUCKET = process.env.MINIO_BUCKET || 'ocrvs' export const OIDP_BASE_URL = process.env.NATIONAL_ID_OIDP_BASE_URL -export const OIDP_REST_URL = process.env.NATIONAL_ID_OIDP_REST_URL +export const OIDP_TOKEN_URL = process.env.NATIONAL_ID_OIDP_TOKEN_URL +export const OIDP_USERINFO_URL = process.env.NATIONAL_ID_OIDP_USERINFO_URL /** Base64 encoded RS256 JSON Web Key */ export const OIDP_CLIENT_PRIVATE_KEY = process.env.NATIONAL_ID_OIDP_CLIENT_PRIVATE_KEY diff --git a/packages/gateway/src/features/OIDPUserInfo/root-resolvers.test.ts b/packages/gateway/src/features/OIDPUserInfo/root-resolvers.test.ts index 940423f700f..56b1a3a6534 100644 --- a/packages/gateway/src/features/OIDPUserInfo/root-resolvers.test.ts +++ b/packages/gateway/src/features/OIDPUserInfo/root-resolvers.test.ts @@ -221,9 +221,8 @@ describe('get user info from OIDP national id integration', () => { redirectUri: 'http://localhost:3000/mosip-callback' } ) - - expect(fetch.mock.calls[0][0]).toMatch(/oauth\/token$/) - expect(fetch.mock.calls[1][0]).toMatch(/oidc\/userinfo$/) + expect(fetch.mock.calls[0][0]).toMatch(/oauth\/v2\/token$/) + expect(fetch.mock.calls[1][0]).toMatch(/oidc\/v2\/userinfo$/) expect(fetch.mock.calls[2][0]).toMatch( /Location\?name=Farajaland&type=ADMIN_STRUCTURE$/ ) diff --git a/packages/gateway/src/features/OIDPUserInfo/utils.ts b/packages/gateway/src/features/OIDPUserInfo/utils.ts index c552df60b5e..33cfccff04c 100644 --- a/packages/gateway/src/features/OIDPUserInfo/utils.ts +++ b/packages/gateway/src/features/OIDPUserInfo/utils.ts @@ -12,9 +12,10 @@ import * as jwt from 'jsonwebtoken' import * as jose from 'jose' import fetch from '@gateway/fetch' import { - OIDP_REST_URL, OIDP_CLIENT_PRIVATE_KEY, - OIDP_JWT_AUD_CLAIM + OIDP_JWT_AUD_CLAIM, + OIDP_TOKEN_URL, + OIDP_USERINFO_URL } from '@gateway/constants' import { logger } from '@gateway/logger' @@ -25,10 +26,6 @@ import { fetchFromHearth } from '@gateway/features/fhir/service' const TOKEN_GRANT_TYPE = 'authorization_code' const CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer' -const OIDP_TOKEN_ENDPOINT = - OIDP_REST_URL && new URL('oauth/token', OIDP_REST_URL).toString() -const OIDP_USERINFO_ENDPOINT = - OIDP_REST_URL && new URL('oidc/userinfo', OIDP_REST_URL).toString() const JWT_ALG = 'RS256' const JWT_EXPIRATION_TIME = '1h' @@ -94,7 +91,7 @@ export const fetchToken = async ({ client_assertion: await generateSignedJwt(clientId) }) - const request = await fetch(OIDP_TOKEN_ENDPOINT!, { + const request = await fetch(OIDP_TOKEN_URL!, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' @@ -107,7 +104,7 @@ export const fetchToken = async ({ } export const fetchUserInfo = async (accessToken: string) => { - const request = await fetch(OIDP_USERINFO_ENDPOINT!, { + const request = await fetch(OIDP_USERINFO_URL!, { headers: { Authorization: 'Bearer ' + accessToken } diff --git a/packages/gateway/test/setupJest.ts b/packages/gateway/test/setupJest.ts index ba602b45377..12052b031da 100644 --- a/packages/gateway/test/setupJest.ts +++ b/packages/gateway/test/setupJest.ts @@ -20,6 +20,9 @@ process.env.CERT_PUBLIC_KEY_PATH = join(__dirname, './cert.key.pub') process.env.NATIONAL_ID_OIDP_CLIENT_PRIVATE_KEY = 'ewogICAgInAiOiAiMVRMMlRPOWxNZnZOWThzeWVReFFrd3F1RThfdll5bV85ZS1yUkxRaV9reWJvLUMwUXJYVklQRFNfN2laV3I4WFB0MGlMWnJkemtjSzU0dGtKWGRkYWk3bEhxM3VyNndLU09uUHVPMURNS0stLXlNR3lCd0RfazdTbUdLUDlsTml3Q0pDT1Q2dDdjWEM1SnBEaVBNc05HQWNEUDZyRGFQQ2tlMzZUcjV5LW5NIiwKICAgICJrdHkiOiAiUlNBIiwKICAgICJxIjogIng4U1FwSHc2UlFnWmxHUC1EdWpiS1pRcUZxczAxU0ZsczFQa1lya25yM01rV1FrUFVGVDlubW5CbTlHWlVwbUV0TU9WZDc4SWVfdHV1UGZFVFo1SWYwTmt0bTNJdS1Pcm9jQzJBU3IzQnF0dUZyUnhUWTRJbnVBVnhHd0VuV0Frd1ZWR1dJQklEVkhSeHhGblAwZUo0YWNmVGVDcWs4QTE1cFRhOUo2MmY4ayIsCiAgICAiZCI6ICJubms3Q2RtT2hucVdyMTU1cW5hc25PY2pPamYyVEJLNlVpYUJOcWw1S1FBMmlJSnJGa0F1ZXFYcmwzM1J0eVgtZFFtOU1NTnhNLUYwMUpac3REME50eW1ZdXlzOVFMbGhKbld2RHlGLXlmMHJHOFJPVHROQkNuZjgxNUE2STQ1UzhqVUlXMGI1dl9lQlAxY1lKdWRLSW5QNlY0NVRZUEFlSjhKQ2hPeFJ2RlJHX2loOFVRaTdDZFZWNXFvVUVpX1lOWXNleTc1cTZpTFRiRVFFOExsNE9lMnRFNDMxTnltMTBaa185R2FNVEp0SU1YMm1iMW01blFfMTZmRC1ZNDZvWDlucW9zUUtUZ19uYmRoUFU3QWQwNW5MSjZFRER0X0JIbDNfc0d1blhrN3BhMjFTN1hfRjBQT0JrdG42dlNUV0FEZjQtM2pXaFNHa21yX3pyR3hLc1EiLAogICAgImUiOiAiQVFBQiIsCiAgICAicWkiOiAiRlpCaE55Uk5nMVhJVW44d1VFVGRCSEh4Qmx0Wk9tbDJhUzNXYlVZb3VuQlN1NDhoVk9BOGpWdFJFaWFBc25xUkxtaGNIN3V0aWVCTHBKazZsZ2pyM3RINnh3WklOSDRCb1NBYnRyUW5DMXd1ZE1fa1FCX1hpRk4tSFhPX0oyU2thV05nb19JSFFING1udXZnRUkxUEdpZGdwZzJ2NnJ6V3R3ZW5rbXhHblJnIiwKICAgICJkcCI6ICJNYkhMVDJ1TnZ2VGVqeUJTQjMwald1TG1hSl9UUU4zLWJLa00xdHJXUFVoR0R4RFZjNmRHb29MXzY3TnZxNE5YTzhQM3I0R2xxZXROVTJOZVdJMVdMT1g1YWdsSTFaSFlZOTU4R0xMVk1vVDgxelQyNDdZRUNFYl9ONTNoeUp6dks3SFFsZDlTVTFZQmM1LXhsajU0VTAwRHZOT3ZzMkkwZkNkb2JPcGZpcGsiLAogICAgImFsZyI6ICJSUzI1NiIsCiAgICAiZHEiOiAiYlJkRjJkMVJRTk5zaktHU1l2ZjhmeGNfYU1PMEJWUElvd2FFS1BsdDE1MHNVMGJrU3YwdXh1eF80eVN4OHU2TkR0M2o2TkcwdzJnS0RnNlg3NzhwWGY0aXFKRUpWcm04eDRkaW5QNm1pY2ppUkpuamFmUFBkMXR0NTZjSldodmYxb2hIOHhxU3ZsdFpFTG5MUlQ0LTZMQ0lJdEkydEpyNWxHTGpzMFJjNnlrIiwKICAgICJuIjogInBsNVE4QWVsT1ozWERyc093ems5T0ExNzR1WEF3ZnpxOW1NVXB2cVEwMC1sMFlKWGljZUlfWU13ZVJnS0tGTnpEMklEajhGNnJqaDh1THEwdjhiTE5oLWQzUEFwRHBTMTVOc3ZhN2U4VFZNR1paLVZJVDVKVGZqMzZsNWR2Q1oxa21MRUJ2ZjJhbzFHOVowMXU0NDNMZDRueEgzNHpkLTlUZU5VRXp4ejAweXUtOFBrRkJ5OGNySGVCR2JmcUlTLV9nbVJ6ZEIwclFQM29GT3hiNWJfa01WYUR6Wm5YSFVVemFIdDRNOEcxcHF2QjJOZzQzUDQ0d2NJME1YMVNHVkRQbGMtZVBfNjFjNW5qTzhoVnhnbUZzOUt0WVR5a0t3OXhsYUh6U1dCbG9ObVZFeG1Yd1ItckVzSTdJczdxOUpWTjdEVzNaNmYzRnk3NVpnN21rZXhTdyIKfQ==' process.env.NATIONAL_ID_OIDP_BASE_URL = 'http://localhost:27501/v1/oid/' -process.env.NATIONAL_ID_OIDP_REST_URL = 'http://localhost:27502/v1/oid/' +process.env.NATIONAL_ID_OIDP_TOKEN_URL = + 'http://localhost:27502/v1/esignet/oauth/v2/token' +process.env.NATIONAL_ID_OIDP_USERINFO_URL = + 'http://localhost:27502/v1/esignet/oidc/v2/userinfo' process.env.NATIONAL_ID_OIDP_JWT_AUD_CLAIM = 'http://localhost:27501/v1/idp/oauth/token' diff --git a/packages/user-mgnt/src/constants.ts b/packages/user-mgnt/src/constants.ts index d87807fb9ad..c8af7df6cc2 100644 --- a/packages/user-mgnt/src/constants.ts +++ b/packages/user-mgnt/src/constants.ts @@ -29,9 +29,6 @@ export const METRICS_URL = process.env.METRICS_URL || 'http://localhost:1050' export const NATIONAL_ID_OIDP_BASE_URL = process.env.NATIONAL_ID_OIDP_BASE_URL || null // e.g. https://api.esignet.io/v1/idp -export const NATIONAL_ID_OIDP_REST_URL = - process.env.NATIONAL_ID_OIDP_REST_URL || null - export const NATIONAL_ID_OIDP_CLIENT_ID = process.env.NATIONAL_ID_OIDP_CLIENT_ID || null From ac79a11c279c16a4e29e5ec2eeae552110b327d0 Mon Sep 17 00:00:00 2001 From: Pyry Rouvila Date: Thu, 23 May 2024 12:10:57 +0300 Subject: [PATCH 028/108] chore: ignore metabase vulnerability (#7034) tested running trivy for v0.49 and the error isn't there anymore --- .trivyignore.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.trivyignore.yaml b/.trivyignore.yaml index 2d51dc5d3ec..5b5318f4dc1 100644 --- a/.trivyignore.yaml +++ b/.trivyignore.yaml @@ -40,10 +40,12 @@ vulnerabilities: - id: CVE-2022-1471 statement: Dashboards vulns (java libs) - id: CVE-2024-25710 - statement: Metabase v0.46 vulnerability (remove when v0.49 is released) + statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 - id: CVE-2024-26308 - statement: Metabase v0.46 vulnerability (remove when v0.49 is released) + statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 - id: CVE-2024-22201 - statement: Metabase v0.46 vulnerability (remove when v0.49 is released) + statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 - id: CVE-2023-36478 - statement: Metabase v0.46 vulnerability (remove when v0.49 is released) + statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 + - id: CVE-2024-21634 + statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 From 7dc8e1e9057607c09586711da7c5892deab64d66 Mon Sep 17 00:00:00 2001 From: Pyry Rouvila Date: Tue, 11 Jun 2024 15:30:23 +0300 Subject: [PATCH 029/108] chore: ignore braces vulnerability issue (#7127) Co-authored-by: Riku Rouvila --- .trivyignore.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.trivyignore.yaml b/.trivyignore.yaml index 5b5318f4dc1..b9a54ee9952 100644 --- a/.trivyignore.yaml +++ b/.trivyignore.yaml @@ -49,3 +49,5 @@ vulnerabilities: statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 - id: CVE-2024-21634 statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 + - id: CVE-2024-4068 + statement: Transitive dependency of lint-staged, jest and msw. Not running in production. Likely fixed by upgrading. From 25729cf45f42c3cab007af12fd42efd07ad4f6ee Mon Sep 17 00:00:00 2001 From: Riku Rouvila Date: Fri, 14 Jun 2024 11:15:26 +0300 Subject: [PATCH 030/108] Merge pull request #7021 from opencrvs/ocrvs-7005 OCRVS-7005: Default to retrying the submission of records if something goes wrong in the backend --- packages/client/src/SubmissionController.ts | 22 ++++- .../src/components/interface/Navigation.tsx | 3 +- .../src/declarations/submissionMiddleware.ts | 23 ++--- .../src/i18n/messages/views/notifications.ts | 11 +++ packages/client/src/utils/referenceApi.ts | 4 +- .../src/views/OfficeHome/outbox/Outbox.tsx | 99 +++++++++++++------ 6 files changed, 113 insertions(+), 49 deletions(-) diff --git a/packages/client/src/SubmissionController.ts b/packages/client/src/SubmissionController.ts index d22361195c5..26dec84c31d 100644 --- a/packages/client/src/SubmissionController.ts +++ b/packages/client/src/SubmissionController.ts @@ -47,7 +47,7 @@ export const INPROGRESS_STATUS = [ SUBMISSION_STATUS.REQUESTING_CORRECTION ] as const -function isSubmissionAction(action: Action): action is SubmissionAction { +export function isSubmissionAction(action: Action): action is SubmissionAction { return Object.values(SubmissionAction).includes(action as SubmissionAction) } @@ -104,6 +104,7 @@ export class SubmissionController { /* eslint-disable no-console */ public sync = () => { + const firstSync = this.syncCount === 0 this.syncCount++ console.debug(`[${this.syncCount}] Starting sync...`) if (!isNavigatorOnline() || this.syncRunning) { @@ -116,11 +117,24 @@ export class SubmissionController { this.syncRunning = true this.requeueHangingDeclarations() - const declarations = this.getSubmitableDeclarations() + const submitableDeclarations = this.getSubmitableDeclarations() + + if (firstSync) { + const failedDeclarations = this.getDeclarations().filter( + (declaration) => + declaration.submissionStatus === SUBMISSION_STATUS.FAILED + ) + + submitableDeclarations.push(...failedDeclarations) + console.debug( + `[${this.syncCount}] First sync, adding ${failedDeclarations.length} failed declarations` + ) + } + console.debug( - `[${this.syncCount}] Syncing ${declarations.length} declarations` + `[${this.syncCount}] Syncing ${submitableDeclarations.length} declarations` ) - for (const declaration of declarations) { + for (const declaration of submitableDeclarations) { const action = declaration.action if (action && isSubmissionAction(action)) { this.store.dispatch( diff --git a/packages/client/src/components/interface/Navigation.tsx b/packages/client/src/components/interface/Navigation.tsx index faf110be929..ef0f03f5c48 100644 --- a/packages/client/src/components/interface/Navigation.tsx +++ b/packages/client/src/components/interface/Navigation.tsx @@ -407,7 +407,8 @@ const NavigationView = (props: IFullProps) => { ( [ ...ALLOWED_STATUS_FOR_RETRY, - ...INPROGRESS_STATUS + ...INPROGRESS_STATUS, + SUBMISSION_STATUS.FAILED ] as SUBMISSION_STATUS[] ).includes(draft.submissionStatus as SUBMISSION_STATUS) ).length diff --git a/packages/client/src/declarations/submissionMiddleware.ts b/packages/client/src/declarations/submissionMiddleware.ts index cd3a5e22925..ff895be522b 100644 --- a/packages/client/src/declarations/submissionMiddleware.ts +++ b/packages/client/src/declarations/submissionMiddleware.ts @@ -326,15 +326,8 @@ export const submissionMiddleware: Middleware<{}, IStoreState> = 2000 ) } catch (error) { - if (!(error instanceof ApolloError)) { - updateDeclaration(dispatch, { - ...declaration, - submissionStatus: SUBMISSION_STATUS.FAILED - }) - captureException(error) - return - } if ( + error instanceof ApolloError && error.graphQLErrors.length > 0 && error.graphQLErrors[0].extensions.code === 'UNASSIGNED' ) { @@ -346,11 +339,19 @@ export const submissionMiddleware: Middleware<{}, IStoreState> = dispatch(deleteDeclaration(declaration.id, client)) return } + if (error instanceof ApolloError && error.networkError) { + updateDeclaration(dispatch, { + ...declaration, + submissionStatus: SUBMISSION_STATUS.FAILED_NETWORK + }) + captureException(error) + return + } + updateDeclaration(dispatch, { ...declaration, - submissionStatus: error.networkError - ? SUBMISSION_STATUS.FAILED_NETWORK - : SUBMISSION_STATUS.FAILED + submissionStatus: SUBMISSION_STATUS.FAILED }) + captureException(error) } } diff --git a/packages/client/src/i18n/messages/views/notifications.ts b/packages/client/src/i18n/messages/views/notifications.ts index 29911d63288..a419dffc8f2 100644 --- a/packages/client/src/i18n/messages/views/notifications.ts +++ b/packages/client/src/i18n/messages/views/notifications.ts @@ -129,6 +129,12 @@ const messagesToDefine = { description: 'Label for declaration status waiting for reject', id: 'regHome.outbox.statusWaitingToSubmit' }, + retry: { + id: 'regHome.outbox.retry', + defaultMessage: 'Retry', + description: + 'Copy for "Retry" button in Outbox shown for records that failed to send' + }, userAuditSuccess: { defaultMessage: '{name} was {action, select, DEACTIVATE {deactivated} REACTIVATE {reactivated} other {deactivated}}', @@ -164,6 +170,11 @@ const messagesToDefine = { description: 'Label for declaration status waiting for connection', id: 'regHome.outbox.waitingToRetry' }, + failed: { + defaultMessage: 'Failed to send', + description: 'Label for declaration status failed', + id: 'regHome.outbox.failed' + }, downloadDeclarationFailed: { defaultMessage: 'Failed to download declaration. Please try again', description: 'Label for declaration downloading failed', diff --git a/packages/client/src/utils/referenceApi.ts b/packages/client/src/utils/referenceApi.ts index 3617e5df5fb..79c8ec7f18f 100644 --- a/packages/client/src/utils/referenceApi.ts +++ b/packages/client/src/utils/referenceApi.ts @@ -199,8 +199,8 @@ async function loadForms(): Promise { throw err } - if (res && res.status !== 201) { - throw Error(res.statusText) + if (res && !res.ok) { + throw new Error(res.statusText) } const response = await res.json() diff --git a/packages/client/src/views/OfficeHome/outbox/Outbox.tsx b/packages/client/src/views/OfficeHome/outbox/Outbox.tsx index 20c4ea0aefa..f0935889c4f 100644 --- a/packages/client/src/views/OfficeHome/outbox/Outbox.tsx +++ b/packages/client/src/views/OfficeHome/outbox/Outbox.tsx @@ -8,33 +8,29 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as React from 'react' -import { WQContentWrapper } from '@client/views/OfficeHome/WQContentWrapper' -import { useIntl } from 'react-intl' -import { navigationMessages } from '@client/i18n/messages/views/navigation' -import { getTheme } from '@opencrvs/components/lib/theme' +import { + ALLOWED_STATUS_FOR_RETRY, + IInProgressStatus, + INPROGRESS_STATUS, + IRetryStatus, + isSubmissionAction +} from '@client/SubmissionController' +import { IDeclaration, SUBMISSION_STATUS } from '@client/declarations' +import { declarationReadyForStatusChange } from '@client/declarations/submissionMiddleware' import { constantsMessages, dynamicConstantsMessages } from '@client/i18n/messages' -import { - ColumnContentAlignment, - COLUMNS, - Workqueue, - SORT_ORDER -} from '@opencrvs/components/lib/Workqueue' +import { navigationMessages } from '@client/i18n/messages/views/navigation' import { messages } from '@client/i18n/messages/views/notifications' -import { IDeclaration, SUBMISSION_STATUS } from '@client/declarations' -import { - ConnectionError, - StatusSubmissionWaiting as StatusWaiting -} from '@opencrvs/components/lib/icons' -import { useSelector } from 'react-redux' import { IStoreState } from '@client/store' +import { useOnlineStatus } from '@client/utils' import { formatPlainDate, isValidPlainDate } from '@client/utils/date-formatting' +import { getDeclarationFullName } from '@client/utils/draftUtils' +import { WQContentWrapper } from '@client/views/OfficeHome/WQContentWrapper' import { IconWithName, IconWithNameEvent, @@ -45,15 +41,21 @@ import { changeSortedColumn, getSortedItems } from '@client/views/OfficeHome/utils' -import { - ALLOWED_STATUS_FOR_RETRY, - IInProgressStatus, - INPROGRESS_STATUS, - IRetryStatus -} from '@client/SubmissionController' -import { useOnlineStatus } from '@client/utils' import { Spinner } from '@opencrvs/components/lib' -import { getDeclarationFullName } from '@client/utils/draftUtils' +import { + COLUMNS, + ColumnContentAlignment, + SORT_ORDER, + Workqueue +} from '@opencrvs/components/lib/Workqueue' +import { + ConnectionError, + StatusSubmissionWaiting as StatusWaiting +} from '@opencrvs/components/lib/icons' +import { getTheme } from '@opencrvs/components/lib/theme' +import * as React from 'react' +import { useIntl } from 'react-intl' +import { useDispatch, useSelector } from 'react-redux' const statusMessageMap = { [SUBMISSION_STATUS.READY_TO_SUBMIT]: messages.statusWaitingToSubmit, @@ -77,7 +79,8 @@ const statusMessageMap = { [SUBMISSION_STATUS.READY_TO_ISSUE]: messages.statusWaitingToIssue, [SUBMISSION_STATUS.CERTIFYING]: messages.statusCertifying, [SUBMISSION_STATUS.ISSUING]: messages.statusIssuing, - [SUBMISSION_STATUS.FAILED_NETWORK]: messages.waitingToRetry + [SUBMISSION_STATUS.FAILED_NETWORK]: messages.waitingToRetry, + [SUBMISSION_STATUS.FAILED]: messages.failed } as const const statusInprogressIconIdMap = { @@ -92,7 +95,10 @@ const statusInprogressIconIdMap = { [SUBMISSION_STATUS.ISSUING]: 'issuing' } -type OutboxSubmissionStatus = IRetryStatus | IInProgressStatus +type OutboxSubmissionStatus = + | IRetryStatus + | IInProgressStatus + | SUBMISSION_STATUS.FAILED function isInprogressStatus( status: OutboxSubmissionStatus @@ -130,7 +136,11 @@ const isOutboxDeclaration = ( } => Boolean(declaration.submissionStatus) && ( - [...ALLOWED_STATUS_FOR_RETRY, ...INPROGRESS_STATUS] as SUBMISSION_STATUS[] + [ + ...ALLOWED_STATUS_FOR_RETRY, + ...INPROGRESS_STATUS, + SUBMISSION_STATUS.FAILED + ] as SUBMISSION_STATUS[] ).includes(declaration.submissionStatus as SUBMISSION_STATUS) export function Outbox() { @@ -143,6 +153,7 @@ export function Outbox() { const declarations = useSelector((state: IStoreState) => state.declarationsState?.declarations.filter(isOutboxDeclaration) ) + const dispatch = useDispatch() React.useEffect(() => { function recordWindowWidth() { @@ -214,7 +225,33 @@ export function Outbox() { /> ), submissionStatus: statusText, - statusIndicator: icon ? [{ actionComponent: icon }] : null, + statusIndicator: + declaration.submissionStatus === SUBMISSION_STATUS.FAILED + ? [ + { + label: intl.formatMessage(messages.retry), + disabled: false, + handler: ( + e: + | React.MouseEvent + | undefined + ) => { + e && e.stopPropagation() + if (!isSubmissionAction(declaration.action!)) { + return + } + dispatch( + declarationReadyForStatusChange({ + ...declaration, + action: declaration.action + }) + ) + } + } + ] + : icon + ? [{ actionComponent: icon }] + : null, dateOfEvent } }) @@ -267,14 +304,14 @@ export function Outbox() { }, { label: '', - width: 21, + width: 15, key: 'submissionStatus', alignment: ColumnContentAlignment.RIGHT, color: theme.colors.supportingCopy }, { label: '', - width: 4, + width: 10, key: 'statusIndicator', isActionColumn: true } From c944f93ad666092e1e5231ec3d10dc532cd2902e Mon Sep 17 00:00:00 2001 From: Riku Rouvila Date: Thu, 13 Jun 2024 13:58:05 +0300 Subject: [PATCH 031/108] Merge pull request #7022 from opencrvs/consolidate-logging Only use hapi-pino in production, consolidate different logging modules under commons --- development-environment/dev.sh | 1 - packages/auth/package.json | 2 +- packages/auth/src/config/plugins.ts | 20 ++-- packages/auth/src/database.ts | 2 +- .../auth/src/features/authenticate/service.ts | 2 +- .../src/features/invalidateToken/handler.ts | 2 +- .../sendUserName/handler.test.ts | 2 +- .../retrievalSteps/sendUserName/handler.ts | 2 +- .../retrievalSteps/verifyNumber/handler.ts | 2 +- .../auth/src/features/verifyCode/handler.ts | 2 +- packages/auth/src/server.ts | 2 +- packages/commons/package.json | 7 +- packages/commons/src/index.ts | 1 + packages/{auth => commons}/src/logger.ts | 13 ++- packages/config/package.json | 2 +- packages/config/src/config/database.test.ts | 3 +- packages/config/src/config/database.ts | 6 +- packages/config/src/config/logger.ts | 17 ---- packages/config/src/config/plugins.ts | 20 ++-- .../application/applicationConfigHandler.ts | 2 +- .../certificate/certificateHandler.ts | 2 +- .../config/src/handlers/forms/formsHandler.ts | 11 ++- .../updateInformantSMSNotification/handler.ts | 2 +- packages/config/src/logger.ts | 17 ---- packages/config/src/server.ts | 4 +- packages/config/src/services/documents.ts | 2 +- packages/documents/package.json | 2 +- packages/documents/src/config/plugins.ts | 63 ++++++------ packages/documents/src/logger.ts | 17 ---- packages/gateway/package.json | 6 +- packages/gateway/src/config/plugins.ts | 21 ++-- .../src/features/OIDPUserInfo/utils.ts | 2 +- .../src/features/user/root-resolvers.ts | 2 +- .../src/features/user/utils/index.test.ts | 2 +- .../gateway/src/features/user/utils/index.ts | 2 +- packages/gateway/src/logger.ts | 17 ---- .../gateway/src/routes/verifyCode/handler.ts | 2 +- packages/gateway/src/server.ts | 2 +- packages/gateway/src/utils/documents.ts | 2 +- packages/gateway/src/utils/logger.ts | 22 ----- packages/gateway/src/utils/redis.ts | 2 +- packages/metrics/package.json | 2 +- packages/metrics/src/config/database.test.ts | 4 +- packages/metrics/src/config/database.ts | 6 +- packages/metrics/src/config/plugins.ts | 63 ++++++------ .../src/features/performance/viewRefresher.ts | 2 +- packages/metrics/src/influxdb/client.ts | 2 +- packages/metrics/src/logger.ts | 18 ---- packages/notification/package.json | 2 +- packages/notification/src/config/plugins.ts | 20 ++-- packages/notification/src/database.test.ts | 3 +- packages/notification/src/database.ts | 6 +- .../src/features/email/all-user-handler.ts | 2 +- .../src/features/email/service..ts | 2 +- .../src/features/sms/birth-handler.ts | 2 +- .../src/features/sms/death-handler.ts | 2 +- .../src/features/sms/service.test.ts | 2 +- .../notification/src/features/sms/service.ts | 2 +- .../src/features/sms/user-handler.ts | 2 +- packages/notification/src/logger.ts | 17 ---- packages/search/package.json | 2 +- packages/search/src/config/plugins.ts | 20 ++-- packages/search/src/config/routes.ts | 2 +- .../search/src/elasticsearch/dbhelper.test.ts | 2 +- packages/search/src/elasticsearch/dbhelper.ts | 4 +- .../search/src/features/delete/handler.ts | 2 +- .../search/src/features/fhir/fhir-utils.ts | 2 +- .../registration/assignment/handler.ts | 2 +- .../features/registration/birth/handler.ts | 2 +- .../features/registration/death/handler.ts | 2 +- .../registration/deduplicate/handler.ts | 2 +- .../registration/deduplicate/service.ts | 2 +- .../features/registration/marriage/handler.ts | 2 +- .../search/src/features/search/handler.ts | 2 +- .../search/src/features/search/service.ts | 2 +- packages/search/src/logger.ts | 17 ---- packages/user-mgnt/package.json | 2 +- packages/user-mgnt/src/config/plugins.ts | 20 ++-- packages/user-mgnt/src/database.test.ts | 3 +- packages/user-mgnt/src/database.ts | 6 +- .../src/features/activateUser/handler.test.ts | 2 +- .../src/features/activateUser/handler.ts | 2 +- .../src/features/changeAvatar/handler.ts | 2 +- .../src/features/changeEmail/handler.ts | 2 +- .../src/features/changePassword/handler.ts | 2 +- .../src/features/changePhone/handler.ts | 2 +- .../src/features/createUser/handler.ts | 2 +- .../src/features/createUser/service.test.ts | 2 +- .../src/features/createUser/service.ts | 2 +- .../src/features/resetPassword/handler.ts | 2 +- .../user-mgnt/src/features/system/handler.ts | 2 +- .../src/features/updateRole/handler.ts | 2 +- .../src/features/updateUser/handler.ts | 2 +- .../src/features/userAudit/handler.test.ts | 2 +- .../src/features/userAudit/handler.ts | 2 +- .../features/userSearchRecord/handler.test.ts | 2 +- .../src/features/userSearchRecord/handler.ts | 2 +- .../usernameSMSReminderInvite/handler.ts | 2 +- .../features/verifySecurityAnswer/handler.ts | 2 +- packages/user-mgnt/src/logger.ts | 17 ---- packages/user-mgnt/src/server.ts | 2 +- packages/webhooks/package.json | 2 +- packages/webhooks/src/config/plugins.ts | 20 ++-- packages/webhooks/src/database.ts | 11 ++- .../webhooks/src/features/event/handler.ts | 2 +- .../webhooks/src/features/manage/handler.ts | 2 +- packages/webhooks/src/logger.ts | 17 ---- packages/webhooks/src/processor.ts | 2 +- packages/webhooks/src/queue.ts | 2 +- packages/workflow/package.json | 2 +- packages/workflow/src/config/plugins.ts | 22 +++-- .../registration/fhir/fhir-bundle-modifier.ts | 9 +- .../features/registration/fhir/fhir-utils.ts | 2 +- .../registration/sms-notification-utils.ts | 2 +- .../src/features/registration/utils.ts | 8 +- packages/workflow/src/logger.ts | 17 ---- .../workflow/src/records/handler/create.ts | 2 +- .../workflow/src/records/handler/download.ts | 2 +- yarn.lock | 97 ++++++++++++++++++- 119 files changed, 406 insertions(+), 441 deletions(-) rename packages/{auth => commons}/src/logger.ts (70%) delete mode 100644 packages/config/src/config/logger.ts delete mode 100644 packages/config/src/logger.ts delete mode 100644 packages/documents/src/logger.ts delete mode 100644 packages/gateway/src/logger.ts delete mode 100644 packages/gateway/src/utils/logger.ts delete mode 100644 packages/metrics/src/logger.ts delete mode 100644 packages/notification/src/logger.ts delete mode 100644 packages/search/src/logger.ts delete mode 100644 packages/user-mgnt/src/logger.ts delete mode 100644 packages/webhooks/src/logger.ts delete mode 100644 packages/workflow/src/logger.ts diff --git a/development-environment/dev.sh b/development-environment/dev.sh index 3175d8b7a1e..b3ab7f3c66f 100755 --- a/development-environment/dev.sh +++ b/development-environment/dev.sh @@ -10,7 +10,6 @@ set -e DIR=$(cd "$(dirname "$0")"; pwd) export LANGUAGES="en,fr" -export LOG_LEVEL="error" if [ -n "$(uname -a | grep Ubuntu)" ]; then OS="UBUNTU" diff --git a/packages/auth/package.json b/packages/auth/package.json index 8ad5eb6a1a1..62a65c9d2b9 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest --coverage --silent --noStackTrace && yarn test:compilation", "test:watch": "jest --watch", diff --git a/packages/auth/src/config/plugins.ts b/packages/auth/src/config/plugins.ts index f3f7c841b28..0f733247518 100644 --- a/packages/auth/src/config/plugins.ts +++ b/packages/auth/src/config/plugins.ts @@ -8,27 +8,27 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ +import { SENTRY_DSN } from '@auth/constants' +import { ServerRegisterPluginObject } from '@hapi/hapi' +import { logger } from '@opencrvs/commons' import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@auth/constants' -import { logger } from '@auth/logger' -interface IHapiPlugin { - plugin: typeof Sentry | typeof Pino - options: Record -} +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: IHapiPlugin[] = [ - { + const plugins: IHapiPlugin[] = [] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ plugin: Pino, options: { prettyPrint: false, logPayload: false, instance: logger } - } - ] + }) + } if (SENTRY_DSN) { plugins.push({ diff --git a/packages/auth/src/database.ts b/packages/auth/src/database.ts index c1db79b41c0..c48ece96897 100644 --- a/packages/auth/src/database.ts +++ b/packages/auth/src/database.ts @@ -11,7 +11,7 @@ import * as redis from 'redis' import { REDIS_HOST } from '@auth/constants' import { promisify } from 'util' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' let redisClient: redis.RedisClient diff --git a/packages/auth/src/features/authenticate/service.ts b/packages/auth/src/features/authenticate/service.ts index e20fb42f285..6e372a3a1e2 100644 --- a/packages/auth/src/features/authenticate/service.ts +++ b/packages/auth/src/features/authenticate/service.ts @@ -31,7 +31,7 @@ import { sendVerificationCode, storeVerificationCode } from '@auth/features/verifyCode/service' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' import { unauthorized } from '@hapi/boom' import { chainW, tryCatch } from 'fp-ts/Either' import { pipe } from 'fp-ts/function' diff --git a/packages/auth/src/features/invalidateToken/handler.ts b/packages/auth/src/features/invalidateToken/handler.ts index 615204830a4..986bf8cce3e 100644 --- a/packages/auth/src/features/invalidateToken/handler.ts +++ b/packages/auth/src/features/invalidateToken/handler.ts @@ -13,7 +13,7 @@ import * as Joi from 'joi' import { internal } from '@hapi/boom' import { invalidateToken } from '@auth/features/invalidateToken/service' import { postUserActionToMetrics } from '@auth/features/authenticate/service' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' interface IInvalidateTokenPayload { token: string diff --git a/packages/auth/src/features/retrievalSteps/sendUserName/handler.test.ts b/packages/auth/src/features/retrievalSteps/sendUserName/handler.test.ts index 1af0225e33b..ca0c667cd36 100644 --- a/packages/auth/src/features/retrievalSteps/sendUserName/handler.test.ts +++ b/packages/auth/src/features/retrievalSteps/sendUserName/handler.test.ts @@ -14,7 +14,7 @@ import { storeRetrievalStepInformation, RetrievalSteps } from '@auth/features/retrievalSteps/verifyUser/service' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' const fetch = fetchAny as fetchAny.FetchMock diff --git a/packages/auth/src/features/retrievalSteps/sendUserName/handler.ts b/packages/auth/src/features/retrievalSteps/sendUserName/handler.ts index 08dc387800a..3eb07c40bdd 100644 --- a/packages/auth/src/features/retrievalSteps/sendUserName/handler.ts +++ b/packages/auth/src/features/retrievalSteps/sendUserName/handler.ts @@ -19,7 +19,7 @@ import { RetrievalSteps, deleteRetrievalStepInformation } from '@auth/features/retrievalSteps/verifyUser/service' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' import { PRODUCTION } from '@auth/constants' import { postUserActionToMetrics } from '@auth/features/authenticate/service' diff --git a/packages/auth/src/features/retrievalSteps/verifyNumber/handler.ts b/packages/auth/src/features/retrievalSteps/verifyNumber/handler.ts index 029f0a574a6..d87ba82857e 100644 --- a/packages/auth/src/features/retrievalSteps/verifyNumber/handler.ts +++ b/packages/auth/src/features/retrievalSteps/verifyNumber/handler.ts @@ -17,7 +17,7 @@ import { } from '@auth/features/retrievalSteps/verifyUser/service' import { checkVerificationCode } from '@auth/features/verifyCode/service' import { unauthorized } from '@hapi/boom' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' interface IVerifyNumberPayload { nonce: string diff --git a/packages/auth/src/features/verifyCode/handler.ts b/packages/auth/src/features/verifyCode/handler.ts index 00d65975c5d..2d913920494 100644 --- a/packages/auth/src/features/verifyCode/handler.ts +++ b/packages/auth/src/features/verifyCode/handler.ts @@ -20,7 +20,7 @@ import { createToken, postUserActionToMetrics } from '@auth/features/authenticate/service' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' import { WEB_USER_JWT_AUDIENCES, JWT_ISSUER } from '@auth/constants' interface IVerifyPayload { nonce: string diff --git a/packages/auth/src/server.ts b/packages/auth/src/server.ts index 425756dc547..bb8def41742 100644 --- a/packages/auth/src/server.ts +++ b/packages/auth/src/server.ts @@ -67,7 +67,7 @@ import sendUserNameHandler, { requestSchema as reqSendUserNameSchema } from '@auth/features/retrievalSteps/sendUserName/handler' import { tokenHandler } from '@auth/features/system/handler' -import { logger } from '@auth/logger' +import { logger } from '@opencrvs/commons' import { getPublicKey } from '@auth/features/authenticate/service' import anonymousTokenHandler, { responseSchema diff --git a/packages/commons/package.json b/packages/commons/package.json index a456da0153d..18b548ecb56 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -8,6 +8,7 @@ ".": "./build/dist/index.js", "./monitoring": "./build/dist/monitoring.js", "./types": "./build/dist/types.js", + "./logger": "./build/dist/logger.js", "./authentication": "./build/dist/authentication.js", "./http": "./build/dist/http.js", "./fixtures": "./build/dist/fixtures.js" @@ -19,7 +20,7 @@ "test:compilation": "tsc --noEmit", "postinstall": "yarn build", "build": "tsc --project tsconfig.build.json", - "build:watch": "tsc --watch", + "build:watch": "tsc --watch --preserveWatchOutput", "build:clean": "rm -rf build" }, "private": true, @@ -40,7 +41,8 @@ "node-fetch": "^2.6.7", "pkg-up": "^3.1.0", "typescript": "4.9.5", - "uuid": "^9.0.0" + "uuid": "^9.0.0", + "pino": "^7.0.0" }, "devDependencies": { "@typescript-eslint/eslint-plugin": "^4.5.0", @@ -50,6 +52,7 @@ "eslint-plugin-import": "^2.17.3", "eslint-plugin-prettier": "^4.0.0", "jest-fetch-mock": "^2.1.2", + "pino-pretty": "^11.0.0", "ts-jest": "^26.4.4" }, "lint-staged": { diff --git a/packages/commons/src/index.ts b/packages/commons/src/index.ts index d6c2f371441..491c5b6a8b8 100644 --- a/packages/commons/src/index.ts +++ b/packages/commons/src/index.ts @@ -12,3 +12,4 @@ export * from './token-verifier' export * from './uuid' export * from './documents' export * from './http' +export * from './logger' diff --git a/packages/auth/src/logger.ts b/packages/commons/src/logger.ts similarity index 70% rename from packages/auth/src/logger.ts rename to packages/commons/src/logger.ts index bc3f171a97d..a04b1567533 100644 --- a/packages/auth/src/logger.ts +++ b/packages/commons/src/logger.ts @@ -9,7 +9,18 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import pino from 'pino' -export const logger = pino() +export const logger = + process.env.NODE_ENV === 'production' + ? pino() + : pino({ + transport: { + target: 'pino-pretty', + options: { + colorize: true, + ignore: 'pid,hostname' + } + } + }) const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL if (level) { diff --git a/packages/config/package.json b/packages/config/package.json index fea6ba4645e..462c9c3f139 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -4,7 +4,7 @@ "description": "OpenCRVS public configuration microservice", "license": "MPL-2.0", "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest --coverage --silent --noStackTrace && yarn test:compilation", "test:watch": "jest --watch", diff --git a/packages/config/src/config/database.test.ts b/packages/config/src/config/database.test.ts index 9d786aa848b..aa8b972d95b 100644 --- a/packages/config/src/config/database.test.ts +++ b/packages/config/src/config/database.test.ts @@ -10,12 +10,13 @@ */ import * as mongoose from 'mongoose' import { start, stop } from '@config/config/database' -import { logger } from '@config/config/logger' +import { logger } from '@opencrvs/commons' jest.mock('mongoose', () => ({ connection: { on: jest.fn() }, + set: () => {}, connect: () => Promise.reject(), disconnect: () => {} })) diff --git a/packages/config/src/config/database.ts b/packages/config/src/config/database.ts index 5f9a309fe85..f356240fda7 100644 --- a/packages/config/src/config/database.ts +++ b/packages/config/src/config/database.ts @@ -10,10 +10,14 @@ */ import * as mongoose from 'mongoose' import { MONGO_URL } from '@config/config/constants' -import { logger } from '@config/config/logger' +import { logger } from '@opencrvs/commons' const db = mongoose.connection +// This prepares code for Mongoose >7 where strictQuery +// is set to false by default +mongoose.set('strictQuery', false) + db.on('disconnected', () => { logger.info('MongoDB disconnected') }) diff --git a/packages/config/src/config/logger.ts b/packages/config/src/config/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/config/src/config/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/config/src/config/plugins.ts b/packages/config/src/config/plugins.ts index e56a526119b..1112d36fd00 100644 --- a/packages/config/src/config/plugins.ts +++ b/packages/config/src/config/plugins.ts @@ -8,24 +8,28 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' -import * as Sentry from 'hapi-sentry' +import { logger } from '@opencrvs/commons' import { SENTRY_DSN } from '@config/config/constants' +import { ServerRegisterPluginObject } from '@hapi/hapi' import * as JWT from 'hapi-auth-jwt2' -import { logger } from '@config/config/logger' +import * as Pino from 'hapi-pino' +import * as Sentry from 'hapi-sentry' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - { + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ plugin: Pino, options: { prettyPrint: false, logPayload: false, instance: logger } - } - ] + }) + } if (SENTRY_DSN) { plugins.push({ diff --git a/packages/config/src/handlers/application/applicationConfigHandler.ts b/packages/config/src/handlers/application/applicationConfigHandler.ts index 8a4c94b97a3..cfa2ff5885c 100644 --- a/packages/config/src/handlers/application/applicationConfigHandler.ts +++ b/packages/config/src/handlers/application/applicationConfigHandler.ts @@ -12,7 +12,7 @@ import * as Hapi from '@hapi/hapi' import ApplicationConfig, { IApplicationConfigurationModel } from '@config/models/config' -import { logger } from '@config/config/logger' +import { logger } from '@opencrvs/commons' import { badData, internal } from '@hapi/boom' import * as Joi from 'joi' import { merge, pick } from 'lodash' diff --git a/packages/config/src/handlers/certificate/certificateHandler.ts b/packages/config/src/handlers/certificate/certificateHandler.ts index c4ebc5ab79b..7081820aba0 100644 --- a/packages/config/src/handlers/certificate/certificateHandler.ts +++ b/packages/config/src/handlers/certificate/certificateHandler.ts @@ -14,7 +14,7 @@ import Certificate, { Status, Event } from '@config/models/certificate' // IDeclarationConfigurationModel -import { logger } from '@config/config/logger' +import { logger } from '@opencrvs/commons' import * as Joi from 'joi' import { badRequest, notFound } from '@hapi/boom' import { verifyToken } from '@config/utils/verifyToken' diff --git a/packages/config/src/handlers/forms/formsHandler.ts b/packages/config/src/handlers/forms/formsHandler.ts index 2d6dd9b12ff..b5284cf45dc 100644 --- a/packages/config/src/handlers/forms/formsHandler.ts +++ b/packages/config/src/handlers/forms/formsHandler.ts @@ -15,7 +15,7 @@ import FormVersions, { } from '@config/models/formVersions' import * as Hapi from '@hapi/hapi' import fetch from 'node-fetch' -import { logger } from '@config/config/logger' +import { logger } from '@opencrvs/commons' import { badData } from '@hapi/boom' import { registrationForms } from './validation' import { fromZodError } from 'zod-validation-error' @@ -39,8 +39,11 @@ export default async function getForm( }) if (response.status !== 200) { - logger.error('Country config did not return 200 on forms endpoint') - return h.response().code(400) + logger.error( + `Core failed to fetch form definition from ${COUNTRY_CONFIG_URL}/forms. Check country config logs for more details` + ) + + return h.response().code(500) } const forms: IFormsPayload = await response.json() @@ -76,5 +79,5 @@ export default async function getForm( return h.response().code(400) } } - return h.response(forms).code(201) + return h.response(forms).code(200) } diff --git a/packages/config/src/handlers/informantSMSNotifications/updateInformantSMSNotification/handler.ts b/packages/config/src/handlers/informantSMSNotifications/updateInformantSMSNotification/handler.ts index 01c5488abc7..d8f849762a5 100644 --- a/packages/config/src/handlers/informantSMSNotifications/updateInformantSMSNotification/handler.ts +++ b/packages/config/src/handlers/informantSMSNotifications/updateInformantSMSNotification/handler.ts @@ -10,7 +10,7 @@ */ import * as Hapi from '@hapi/hapi' -import { logger } from '@config/config/logger' +import { logger } from '@opencrvs/commons' import * as Joi from 'joi' import InformantSMSNotification from '@config/models/informantSMSNotifications' import { badRequest } from '@hapi/boom' diff --git a/packages/config/src/logger.ts b/packages/config/src/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/config/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/config/src/server.ts b/packages/config/src/server.ts index 33e94b3ff60..484a8bd062b 100644 --- a/packages/config/src/server.ts +++ b/packages/config/src/server.ts @@ -24,11 +24,9 @@ import { import getRoutes from '@config/config/routes' import getPlugins from '@config/config/plugins' import * as database from '@config/config/database' -import { validateFunc } from '@opencrvs/commons' +import { validateFunc, logger } from '@opencrvs/commons' import { readFileSync } from 'fs' -import { logger } from '@config/logger' import { Boom, badRequest } from '@hapi/boom' - export const publicCert = readFileSync(CERT_PUBLIC_KEY_PATH) export async function createServer() { diff --git a/packages/config/src/services/documents.ts b/packages/config/src/services/documents.ts index 196a30b75cd..7158c86c94f 100644 --- a/packages/config/src/services/documents.ts +++ b/packages/config/src/services/documents.ts @@ -11,7 +11,7 @@ import fetch from 'node-fetch' import { DOCUMENTS_URL } from '@config/config/constants' import { internal } from '@hapi/boom' -import { logger } from '@config/logger' +import { logger } from '@opencrvs/commons' interface IAuthHeader { Authorization: string diff --git a/packages/documents/package.json b/packages/documents/package.json index 88b5bbf94b4..f67d1c2ec9c 100644 --- a/packages/documents/package.json +++ b/packages/documents/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "yarn test:compilation && jest --coverage --silent --noStackTrace", "test:watch": "jest --watch", diff --git a/packages/documents/src/config/plugins.ts b/packages/documents/src/config/plugins.ts index 76e92f42be7..276595b4b23 100644 --- a/packages/documents/src/config/plugins.ts +++ b/packages/documents/src/config/plugins.ts @@ -8,42 +8,41 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' +import { SENTRY_DSN } from '@documents/constants' +import { logger } from '@opencrvs/commons' import * as JWT from 'hapi-auth-jwt2' +import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@documents/constants' -import { logger } from '@documents/logger' + +import { ServerRegisterPluginObject } from '@hapi/hapi' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - ...(process.env.NODE_ENV === 'test' || process.env.LOG_LEVEL === 'silent' - ? [] - : [ - { - plugin: Pino, - options: { - prettyPrint: false, - logPayload: false, - instance: logger - } - }, - ...(!SENTRY_DSN - ? [] - : [ - { - plugin: Sentry, - options: { - client: { - environment: process.env.DOMAIN, - dsn: SENTRY_DSN - }, - catchLogErrors: true - } - } - ]) - ]) - ] + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ + plugin: Pino, + options: { + prettyPrint: false, + logPayload: false, + instance: logger + } + }) + } + if (SENTRY_DSN) { + plugins.push({ + plugin: Sentry, + options: { + client: { + environment: process.env.DOMAIN, + dsn: SENTRY_DSN + }, + catchLogErrors: true + } + }) + } return plugins } diff --git a/packages/documents/src/logger.ts b/packages/documents/src/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/documents/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/gateway/package.json b/packages/gateway/package.json index 7d7c0edda7a..068f519fa74 100644 --- a/packages/gateway/package.json +++ b/packages/gateway/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "scripts": { "postinstall": "if [ \"$NODE_ENV\" != \"production\" ]; then npx crlf --set=LF ../../node_modules/graphql-schema-typescript/**/* || npx crlf --set=LF ./node_modules/graphql-schema-typescript/**/* || true; fi", - "start": "yarn gen:schema && yarn gen:types && concurrently \"NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts\" \"yarn gen:types:watch\" \"yarn gen:schema:watch\"", + "start": "yarn gen:schema && yarn gen:types && concurrently \"NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts\" \"yarn gen:types:watch\" \"yarn gen:schema:watch\"", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest && yarn test:compilation", "test:watch": "jest --watch", @@ -14,8 +14,8 @@ "build:clean": "rm -rf build", "gen:schema": "node -e \"const importSchema = require('graphql-import').importSchema; console.log(importSchema('src/graphql/index.graphql'))\" > src/graphql/schema.graphql && yarn prettier --write src/graphql/schema.graphql", "gen:types": "graphql-schema-typescript generate-ts src/graphql/schema.graphql --output src/graphql/schema.d.ts --importStatements 'import {Context} from \"./context\"' --contextType Context && yarn prettier --write src/graphql/schema.d.ts", - "gen:schema:watch": "nodemon --on-change-only -e graphql -i src/graphql/schema.graphql -x 'yarn gen:schema'", - "gen:types:watch": "nodemon --on-change-only -w src/graphql/schema.graphql -x 'yarn gen:types'", + "gen:schema:watch": "nodemon --quiet --on-change-only -e graphql -i src/graphql/schema.graphql -x 'yarn gen:schema'", + "gen:types:watch": "nodemon --quiet --on-change-only -w src/graphql/schema.graphql -x 'yarn gen:types'", "open:cov": "yarn test && opener coverage/index.html", "lint": "eslint -c .eslintrc.js --fix ./src", "precommit": "lint-staged" diff --git a/packages/gateway/src/config/plugins.ts b/packages/gateway/src/config/plugins.ts index b4e110c8498..f34cb6b42c8 100644 --- a/packages/gateway/src/config/plugins.ts +++ b/packages/gateway/src/config/plugins.ts @@ -13,7 +13,7 @@ import * as JWT from 'hapi-auth-jwt2' import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' import { SENTRY_DSN } from '@gateway/constants' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import * as HapiSwagger from 'hapi-swagger' import { ServerRegisterPluginObject } from '@hapi/hapi' import * as H2o2 from '@hapi/h2o2' @@ -33,14 +33,6 @@ export const getPlugins = () => { const plugins = [ JWT, - { - plugin: Pino, - options: { - prettyPrint: true, - logPayload: false, - instance: logger - } - }, { plugin: HapiSwagger, options: swaggerOptions @@ -48,6 +40,17 @@ export const getPlugins = () => { H2o2 ] as Array> + if (process.env.NODE_ENV === 'production') { + plugins.push({ + plugin: Pino, + options: { + prettyPrint: false, + logPayload: false, + instance: logger + } + }) + } + if (SENTRY_DSN) { plugins.push({ plugin: Sentry, diff --git a/packages/gateway/src/features/OIDPUserInfo/utils.ts b/packages/gateway/src/features/OIDPUserInfo/utils.ts index 33cfccff04c..aa42fd4dae2 100644 --- a/packages/gateway/src/features/OIDPUserInfo/utils.ts +++ b/packages/gateway/src/features/OIDPUserInfo/utils.ts @@ -18,7 +18,7 @@ import { OIDP_USERINFO_URL } from '@gateway/constants' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import { OIDPUserInfo } from './oidp-types' import { Bundle, Location } from '@opencrvs/commons/types' import { fetchFromHearth } from '@gateway/features/fhir/service' diff --git a/packages/gateway/src/features/user/root-resolvers.ts b/packages/gateway/src/features/user/root-resolvers.ts index c27f068e0f6..bb80c257f54 100644 --- a/packages/gateway/src/features/user/root-resolvers.ts +++ b/packages/gateway/src/features/user/root-resolvers.ts @@ -29,7 +29,7 @@ import { GQLUserIdentifierInput, GQLUserInput } from '@gateway/graphql/schema' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import { checkVerificationCode } from '@gateway/routes/verifyCode/handler' import { UserInputError } from 'apollo-server-hapi' import fetch from '@gateway/fetch' diff --git a/packages/gateway/src/features/user/utils/index.test.ts b/packages/gateway/src/features/user/utils/index.test.ts index 7213503c10c..34cca636403 100644 --- a/packages/gateway/src/features/user/utils/index.test.ts +++ b/packages/gateway/src/features/user/utils/index.test.ts @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import { getUserMobile } from '@gateway/features/user/utils/' import * as fetchAny from 'jest-fetch-mock' const fetch = fetchAny as any diff --git a/packages/gateway/src/features/user/utils/index.ts b/packages/gateway/src/features/user/utils/index.ts index eb5de2f3f7c..f69d0094562 100644 --- a/packages/gateway/src/features/user/utils/index.ts +++ b/packages/gateway/src/features/user/utils/index.ts @@ -14,7 +14,7 @@ import { ISystemModelData, IUserModelData } from '@gateway/features/user/type-resolvers' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import * as decode from 'jwt-decode' import fetch from '@gateway/fetch' import { Scope } from '@opencrvs/commons/authentication' diff --git a/packages/gateway/src/logger.ts b/packages/gateway/src/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/gateway/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/gateway/src/routes/verifyCode/handler.ts b/packages/gateway/src/routes/verifyCode/handler.ts index 731229d5cdd..2ce99dcb62a 100644 --- a/packages/gateway/src/routes/verifyCode/handler.ts +++ b/packages/gateway/src/routes/verifyCode/handler.ts @@ -24,7 +24,7 @@ import { readFileSync } from 'fs' import * as jwt from 'jsonwebtoken' import fetch from '@gateway/fetch' import { unauthorized } from '@hapi/boom' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import * as t from 'io-ts' import * as F from 'fp-ts' diff --git a/packages/gateway/src/server.ts b/packages/gateway/src/server.ts index d3077cccb04..5c00d3d8d9e 100644 --- a/packages/gateway/src/server.ts +++ b/packages/gateway/src/server.ts @@ -32,7 +32,7 @@ import { import { ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core' import { getApolloConfig } from '@gateway/graphql/config' import * as database from '@gateway/utils/redis' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import { badRequest, Boom } from '@hapi/boom' import { RateLimitError } from './rate-limit' diff --git a/packages/gateway/src/utils/documents.ts b/packages/gateway/src/utils/documents.ts index 66d6ff8356a..2c0dc1ae737 100644 --- a/packages/gateway/src/utils/documents.ts +++ b/packages/gateway/src/utils/documents.ts @@ -11,7 +11,7 @@ import fetch from '@gateway/fetch' import { DOCUMENTS_URL } from '@gateway/constants' import { internal } from '@hapi/boom' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' import { IAuthHeader } from '@opencrvs/commons' export async function uploadSvg(fileData: string, authHeader: IAuthHeader) { diff --git a/packages/gateway/src/utils/logger.ts b/packages/gateway/src/utils/logger.ts deleted file mode 100644 index 00570937227..00000000000 --- a/packages/gateway/src/utils/logger.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import * as Bunyan from 'bunyan' - -export const getLogger = ( - logLevel: number | undefined, - appName: string | undefined -) => { - return Bunyan.createLogger({ - name: appName ? appName : 'testApp', - level: logLevel ? logLevel : 0, - serializers: Bunyan.stdSerializers - }) -} diff --git a/packages/gateway/src/utils/redis.ts b/packages/gateway/src/utils/redis.ts index 77cdcab2b7c..cda564209f1 100644 --- a/packages/gateway/src/utils/redis.ts +++ b/packages/gateway/src/utils/redis.ts @@ -11,7 +11,7 @@ import * as redis from 'redis' import { REDIS_HOST } from '@gateway/constants' import { promisify } from 'util' -import { logger } from '@gateway/logger' +import { logger } from '@opencrvs/commons' let redisClient: redis.RedisClient diff --git a/packages/metrics/package.json b/packages/metrics/package.json index 0e56159778f..50eda6defda 100644 --- a/packages/metrics/package.json +++ b/packages/metrics/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "yarn test:compilation && jest --coverage --silent --noStackTrace", "test:watch": "jest --watch", diff --git a/packages/metrics/src/config/database.test.ts b/packages/metrics/src/config/database.test.ts index d6f89776e1d..9c62263e207 100644 --- a/packages/metrics/src/config/database.test.ts +++ b/packages/metrics/src/config/database.test.ts @@ -10,14 +10,14 @@ */ import * as mongoose from 'mongoose' import { start, stop } from '@metrics/config/database' -import { logger } from '@metrics/logger' +import { logger } from '@opencrvs/commons' jest.mock('mongoose', () => ({ connection: { on: jest.fn() }, + set: () => {}, connect: () => Promise.reject(), - // tslint:disable-next-line no-empty disconnect: () => {} })) const wait = (time: number) => diff --git a/packages/metrics/src/config/database.ts b/packages/metrics/src/config/database.ts index 362de546d33..101e4c1df33 100644 --- a/packages/metrics/src/config/database.ts +++ b/packages/metrics/src/config/database.ts @@ -10,10 +10,14 @@ */ import * as mongoose from 'mongoose' import { MONGO_URL } from '@metrics/constants' -import { logger } from '@metrics/logger' +import { logger } from '@opencrvs/commons' const db = mongoose.connection +// This prepares code for Mongoose >7 where strictQuery +// is set to false by default +mongoose.set('strictQuery', false) + db.on('disconnected', () => { logger.info('MongoDB disconnected') }) diff --git a/packages/metrics/src/config/plugins.ts b/packages/metrics/src/config/plugins.ts index 1a61ddf7229..89e5bd35fe5 100644 --- a/packages/metrics/src/config/plugins.ts +++ b/packages/metrics/src/config/plugins.ts @@ -8,42 +8,41 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' +import { SENTRY_DSN } from '@metrics/constants' +import { logger } from '@opencrvs/commons' import * as JWT from 'hapi-auth-jwt2' +import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@metrics/constants' -import { logger } from '@metrics/logger' + +import { ServerRegisterPluginObject } from '@hapi/hapi' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - ...(process.env.NODE_ENV === 'test' || process.env.LOG_LEVEL === 'silent' - ? [] - : [ - { - plugin: Pino, - options: { - prettyPrint: false, - logPayload: false, - instance: logger - } - }, - ...(!SENTRY_DSN - ? [] - : [ - { - plugin: Sentry, - options: { - client: { - environment: process.env.DOMAIN, - dsn: SENTRY_DSN - }, - catchLogErrors: true - } - } - ]) - ]) - ] + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ + plugin: Pino, + options: { + prettyPrint: false, + logPayload: false, + instance: logger + } + }) + } + if (SENTRY_DSN) { + plugins.push({ + plugin: Sentry, + options: { + client: { + environment: process.env.DOMAIN, + dsn: SENTRY_DSN + }, + catchLogErrors: true + } + }) + } return plugins } diff --git a/packages/metrics/src/features/performance/viewRefresher.ts b/packages/metrics/src/features/performance/viewRefresher.ts index 7cd8f9a6ea0..0190137ba4a 100644 --- a/packages/metrics/src/features/performance/viewRefresher.ts +++ b/packages/metrics/src/features/performance/viewRefresher.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { HEARTH_MONGO_URL } from '@metrics/constants' -import { logger } from '@metrics/logger' +import { logger } from '@opencrvs/commons' import { MongoClient } from 'mongodb' /* diff --git a/packages/metrics/src/influxdb/client.ts b/packages/metrics/src/influxdb/client.ts index b02161bde59..890a8d485c5 100644 --- a/packages/metrics/src/influxdb/client.ts +++ b/packages/metrics/src/influxdb/client.ts @@ -14,7 +14,7 @@ import { INFLUX_HOST, INFLUX_PORT } from '@metrics/influxdb/constants' -import { logger } from '@metrics/logger' +import { logger } from '@opencrvs/commons' import { IPoints } from '@metrics/features/registration' import fetch from 'node-fetch' diff --git a/packages/metrics/src/logger.ts b/packages/metrics/src/logger.ts deleted file mode 100644 index 1b5fc33092c..00000000000 --- a/packages/metrics/src/logger.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL - -if (level) { - logger.level = level -} diff --git a/packages/notification/package.json b/packages/notification/package.json index cb4d66bcb9a..030c985ee67 100644 --- a/packages/notification/package.json +++ b/packages/notification/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest --coverage --silent --noStackTrace && yarn test:compilation", "test:watch": "jest --watch", diff --git a/packages/notification/src/config/plugins.ts b/packages/notification/src/config/plugins.ts index fa2c863d419..809bb945721 100644 --- a/packages/notification/src/config/plugins.ts +++ b/packages/notification/src/config/plugins.ts @@ -9,24 +9,28 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' +import { ServerRegisterPluginObject } from '@hapi/hapi' +import { SENTRY_DSN } from '@notification/constants' +import { logger } from '@opencrvs/commons' import * as JWT from 'hapi-auth-jwt2' +import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@notification/constants' -import { logger } from '@notification/logger' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - { + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ plugin: Pino, options: { prettyPrint: false, logPayload: false, instance: logger } - } - ] + }) + } if (SENTRY_DSN) { plugins.push({ diff --git a/packages/notification/src/database.test.ts b/packages/notification/src/database.test.ts index b92795d1271..68d8d4e560c 100644 --- a/packages/notification/src/database.test.ts +++ b/packages/notification/src/database.test.ts @@ -12,13 +12,14 @@ jest.mock('mongoose', () => ({ connection: { on: jest.fn() }, + set: () => {}, connect: () => Promise.reject(), disconnect: () => {} })) import * as mongoose from 'mongoose' import { start, stop } from '@notification/database' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' const wait = (time: number) => new Promise((resolve) => setTimeout(resolve, time)) diff --git a/packages/notification/src/database.ts b/packages/notification/src/database.ts index 0f538e900a5..d238a47a102 100644 --- a/packages/notification/src/database.ts +++ b/packages/notification/src/database.ts @@ -11,10 +11,14 @@ import * as mongoose from 'mongoose' import { MONGO_URL } from '@notification/constants' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' const db = mongoose.connection +// This prepares code for Mongoose >7 where strictQuery +// is set to false by default +mongoose.set('strictQuery', false) + db.on('disconnected', () => { logger.info('MongoDB disconnected') }) diff --git a/packages/notification/src/features/email/all-user-handler.ts b/packages/notification/src/features/email/all-user-handler.ts index 587bbf56514..1470683c756 100644 --- a/packages/notification/src/features/email/all-user-handler.ts +++ b/packages/notification/src/features/email/all-user-handler.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as Hapi from '@hapi/hapi' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' import * as Joi from 'joi' import { sendAllUserEmails } from './service.' diff --git a/packages/notification/src/features/email/service..ts b/packages/notification/src/features/email/service..ts index 9e933776e5e..0891ccf3f7b 100644 --- a/packages/notification/src/features/email/service..ts +++ b/packages/notification/src/features/email/service..ts @@ -12,7 +12,7 @@ import NotificationQueue, { NotificationQueueRecord } from '@notification/model/notificationQueue' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' import { notifyCountryConfig } from '@notification/features/sms/service' import { internal, tooManyRequests } from '@hapi/boom' import * as Hapi from '@hapi/hapi' diff --git a/packages/notification/src/features/sms/birth-handler.ts b/packages/notification/src/features/sms/birth-handler.ts index 524f6d728c6..59fd8da5edd 100644 --- a/packages/notification/src/features/sms/birth-handler.ts +++ b/packages/notification/src/features/sms/birth-handler.ts @@ -14,7 +14,7 @@ import { sendNotification, IEventMessageRecipient } from '@notification/features/sms/utils' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' import { messageKeys } from '@notification/i18n/messages' export interface IInProgressPayload extends IEventMessageRecipient { diff --git a/packages/notification/src/features/sms/death-handler.ts b/packages/notification/src/features/sms/death-handler.ts index 27e197cf3dc..2817d909157 100644 --- a/packages/notification/src/features/sms/death-handler.ts +++ b/packages/notification/src/features/sms/death-handler.ts @@ -16,7 +16,7 @@ import { IRejectionPayload } from '@notification/features/sms/birth-handler' import { sendNotification } from '@notification/features/sms/utils' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' import { messageKeys } from '@notification/i18n/messages' export async function sendDeathInProgressConfirmation( diff --git a/packages/notification/src/features/sms/service.test.ts b/packages/notification/src/features/sms/service.test.ts index 6d5b95eaeba..f34eb2f8ee4 100644 --- a/packages/notification/src/features/sms/service.test.ts +++ b/packages/notification/src/features/sms/service.test.ts @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' import { notifyCountryConfig } from '@notification/features/sms/service' import * as fetchAny from 'jest-fetch-mock' diff --git a/packages/notification/src/features/sms/service.ts b/packages/notification/src/features/sms/service.ts index ad7662e4ad3..c0732a174b2 100644 --- a/packages/notification/src/features/sms/service.ts +++ b/packages/notification/src/features/sms/service.ts @@ -11,7 +11,7 @@ import fetch from 'node-fetch' import { COUNTRY_CONFIG_URL } from '@notification/constants' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' export async function notifyCountryConfig( templateName: { diff --git a/packages/notification/src/features/sms/user-handler.ts b/packages/notification/src/features/sms/user-handler.ts index 3795e23b1fc..316a74d15ab 100644 --- a/packages/notification/src/features/sms/user-handler.ts +++ b/packages/notification/src/features/sms/user-handler.ts @@ -14,7 +14,7 @@ import { IMessageRecipient, sendNotification } from '@notification/features/sms/utils' -import { logger } from '@notification/logger' +import { logger } from '@opencrvs/commons' import { templateNames } from '@notification/i18n/messages' interface ICredentialsPayload extends IMessageRecipient { diff --git a/packages/notification/src/logger.ts b/packages/notification/src/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/notification/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/search/package.json b/packages/search/package.json index ee24cf940d9..851a6eb0c2d 100644 --- a/packages/search/package.json +++ b/packages/search/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest --coverage --silent --noStackTrace && yarn test:compilation", "test:watch": "jest --watch", diff --git a/packages/search/src/config/plugins.ts b/packages/search/src/config/plugins.ts index d341c8ab684..e3e1310a8d5 100644 --- a/packages/search/src/config/plugins.ts +++ b/packages/search/src/config/plugins.ts @@ -8,24 +8,28 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' +import { ServerRegisterPluginObject } from '@hapi/hapi' +import { SENTRY_DSN } from '@search/constants' +import { logger } from '@opencrvs/commons' import * as JWT from 'hapi-auth-jwt2' +import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@search/constants' -import { logger } from '@search/logger' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - { + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ plugin: Pino, options: { prettyPrint: false, logPayload: false, instance: logger } - } - ] + }) + } if (SENTRY_DSN) { plugins.push({ diff --git a/packages/search/src/config/routes.ts b/packages/search/src/config/routes.ts index dbdddc3f681..ae937a33d00 100644 --- a/packages/search/src/config/routes.ts +++ b/packages/search/src/config/routes.ts @@ -24,7 +24,7 @@ import { } from '@search/features/registration/assignment/handler' import { deleteOCRVSIndexHandler } from '@search/features/delete/handler' import { client } from '@search/elasticsearch/client' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { recordHandler } from '@search/features/registration/record/handler' import { getRecordByIdHandler } from '@search/features/records/handler' diff --git a/packages/search/src/elasticsearch/dbhelper.test.ts b/packages/search/src/elasticsearch/dbhelper.test.ts index 948abd282a9..00471361ec2 100644 --- a/packages/search/src/elasticsearch/dbhelper.test.ts +++ b/packages/search/src/elasticsearch/dbhelper.test.ts @@ -14,7 +14,7 @@ import { searchByCompositionId } from '@search/elasticsearch/dbhelper' import { mockCompositionBody } from '@search/test/utils' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { IBirthCompositionBody } from '@search/elasticsearch/utils' import { searchForBirthDuplicates } from '@search/features/registration/deduplicate/service' import { client } from '@search/elasticsearch/client' diff --git a/packages/search/src/elasticsearch/dbhelper.ts b/packages/search/src/elasticsearch/dbhelper.ts index 0e3ec347463..f212c3dd4f8 100644 --- a/packages/search/src/elasticsearch/dbhelper.ts +++ b/packages/search/src/elasticsearch/dbhelper.ts @@ -8,11 +8,11 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ +import * as elasticsearch from '@elastic/elasticsearch' +import { logger } from '@opencrvs/commons' import { OPENCRVS_INDEX_NAME } from '@search/constants' import { ISearchResponse } from '@search/elasticsearch/client' import { ICompositionBody } from '@search/elasticsearch/utils' -import { logger } from '@search/logger' -import * as elasticsearch from '@elastic/elasticsearch' export const indexComposition = async ( compositionIdentifier: string, diff --git a/packages/search/src/features/delete/handler.ts b/packages/search/src/features/delete/handler.ts index a47b15045cd..c53c90146d7 100644 --- a/packages/search/src/features/delete/handler.ts +++ b/packages/search/src/features/delete/handler.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as Hapi from '@hapi/hapi' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { internal } from '@hapi/boom' import { client } from '@search/elasticsearch/client' import { OPENCRVS_INDEX_NAME } from '@search/constants' diff --git a/packages/search/src/features/fhir/fhir-utils.ts b/packages/search/src/features/fhir/fhir-utils.ts index 352420f1b4e..474778a1180 100644 --- a/packages/search/src/features/fhir/fhir-utils.ts +++ b/packages/search/src/features/fhir/fhir-utils.ts @@ -32,7 +32,7 @@ import { ICompositionBody, IDeathCompositionBody } from '@search/elasticsearch/utils' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import fetch from 'node-fetch' export interface ITemplatedComposition extends fhir.Composition { diff --git a/packages/search/src/features/registration/assignment/handler.ts b/packages/search/src/features/registration/assignment/handler.ts index dcadd6c0da3..5172aa4eb46 100644 --- a/packages/search/src/features/registration/assignment/handler.ts +++ b/packages/search/src/features/registration/assignment/handler.ts @@ -12,7 +12,7 @@ import { updateEventToAddAssignment, updateEventToRemoveAssignment } from '@search/features/registration/assignment/service' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { internal } from '@hapi/boom' import * as Hapi from '@hapi/hapi' import { getTokenPayload } from '@search/utils/authUtils' diff --git a/packages/search/src/features/registration/birth/handler.ts b/packages/search/src/features/registration/birth/handler.ts index dfcb4c19fb0..455b091b8ac 100644 --- a/packages/search/src/features/registration/birth/handler.ts +++ b/packages/search/src/features/registration/birth/handler.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { upsertEvent } from '@search/features/registration/birth/service' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { internal } from '@hapi/boom' import * as Hapi from '@hapi/hapi' diff --git a/packages/search/src/features/registration/death/handler.ts b/packages/search/src/features/registration/death/handler.ts index e4dacb54e75..b6759ef6cdc 100644 --- a/packages/search/src/features/registration/death/handler.ts +++ b/packages/search/src/features/registration/death/handler.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { upsertEvent } from '@search/features/registration/death/service' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { internal } from '@hapi/boom' import * as Hapi from '@hapi/hapi' diff --git a/packages/search/src/features/registration/deduplicate/handler.ts b/packages/search/src/features/registration/deduplicate/handler.ts index df41576ed62..2cf923420ce 100644 --- a/packages/search/src/features/registration/deduplicate/handler.ts +++ b/packages/search/src/features/registration/deduplicate/handler.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as Hapi from '@hapi/hapi' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { internal } from '@hapi/boom' import { removeDuplicate } from '@search/features/registration/deduplicate/service' import { client } from '@search/elasticsearch/client' diff --git a/packages/search/src/features/registration/deduplicate/service.ts b/packages/search/src/features/registration/deduplicate/service.ts index 593dad36667..832a68dad6c 100644 --- a/packages/search/src/features/registration/deduplicate/service.ts +++ b/packages/search/src/features/registration/deduplicate/service.ts @@ -21,7 +21,7 @@ import { import { get } from 'lodash' import { ISearchResponse } from '@search/elasticsearch/client' import { OPENCRVS_INDEX_NAME } from '@search/constants' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { subYears, addYears, diff --git a/packages/search/src/features/registration/marriage/handler.ts b/packages/search/src/features/registration/marriage/handler.ts index 93ddf3d576f..e6e07703173 100644 --- a/packages/search/src/features/registration/marriage/handler.ts +++ b/packages/search/src/features/registration/marriage/handler.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { upsertEvent } from '@search/features/registration/marriage/service' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { internal } from '@hapi/boom' import * as Hapi from '@hapi/hapi' diff --git a/packages/search/src/features/search/handler.ts b/packages/search/src/features/search/handler.ts index daab49afff9..4b6848a7d0a 100644 --- a/packages/search/src/features/search/handler.ts +++ b/packages/search/src/features/search/handler.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as Hapi from '@hapi/hapi' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { badRequest, internal } from '@hapi/boom' import { DEFAULT_SIZE, advancedSearch } from '@search/features/search/service' import { ISearchCriteria } from '@search/features/search/types' diff --git a/packages/search/src/features/search/service.ts b/packages/search/src/features/search/service.ts index 212046cd308..5f8488c70c3 100644 --- a/packages/search/src/features/search/service.ts +++ b/packages/search/src/features/search/service.ts @@ -12,7 +12,7 @@ import { client, ISearchResponse } from '@search/elasticsearch/client' import { ApiResponse } from '@elastic/elasticsearch' import { ISearchCriteria, SortOrder } from '@search/features/search/types' import { advancedQueryBuilder } from '@search/features/search/utils' -import { logger } from '@search/logger' +import { logger } from '@opencrvs/commons' import { OPENCRVS_INDEX_NAME } from '@search/constants' export const DEFAULT_SIZE = 10 diff --git a/packages/search/src/logger.ts b/packages/search/src/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/search/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/user-mgnt/package.json b/packages/user-mgnt/package.json index 1c69e5f6247..296324b7abd 100644 --- a/packages/user-mgnt/package.json +++ b/packages/user-mgnt/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest --coverage --silent --noStackTrace && yarn test:compilation", "test:watch": "jest --watch", diff --git a/packages/user-mgnt/src/config/plugins.ts b/packages/user-mgnt/src/config/plugins.ts index fb03d1f1c8a..40487a91d66 100644 --- a/packages/user-mgnt/src/config/plugins.ts +++ b/packages/user-mgnt/src/config/plugins.ts @@ -8,24 +8,28 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' +import { ServerRegisterPluginObject } from '@hapi/hapi' +import { SENTRY_DSN } from '@user-mgnt/constants' +import { logger } from '@opencrvs/commons' import * as JWT from 'hapi-auth-jwt2' +import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@user-mgnt/constants' -import { logger } from '@user-mgnt/logger' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - { + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ plugin: Pino, options: { prettyPrint: false, logPayload: false, instance: logger } - } - ] + }) + } if (SENTRY_DSN) { plugins.push({ diff --git a/packages/user-mgnt/src/database.test.ts b/packages/user-mgnt/src/database.test.ts index 9c90fc4eadb..5077c71867f 100644 --- a/packages/user-mgnt/src/database.test.ts +++ b/packages/user-mgnt/src/database.test.ts @@ -12,13 +12,14 @@ jest.mock('mongoose', () => ({ connection: { on: jest.fn() }, + set: () => {}, connect: () => Promise.reject(), disconnect: () => {} })) import * as mongoose from 'mongoose' import { start, stop } from '@user-mgnt/database' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' const wait = (time: number) => new Promise((resolve) => setTimeout(resolve, time)) diff --git a/packages/user-mgnt/src/database.ts b/packages/user-mgnt/src/database.ts index 3b7ab471166..cf4bedf42b1 100644 --- a/packages/user-mgnt/src/database.ts +++ b/packages/user-mgnt/src/database.ts @@ -11,10 +11,14 @@ import * as mongoose from 'mongoose' import { MONGO_URL } from '@user-mgnt/constants' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' const db = mongoose.connection +// This prepares code for Mongoose >7 where strictQuery +// is set to false by default +mongoose.set('strictQuery', false) + db.on('disconnected', () => { logger.info('MongoDB disconnected') }) diff --git a/packages/user-mgnt/src/features/activateUser/handler.test.ts b/packages/user-mgnt/src/features/activateUser/handler.test.ts index 78d72237128..594bd14e5fa 100644 --- a/packages/user-mgnt/src/features/activateUser/handler.test.ts +++ b/packages/user-mgnt/src/features/activateUser/handler.test.ts @@ -13,7 +13,7 @@ import * as jwt from 'jsonwebtoken' import { readFileSync } from 'fs' import * as fetchMock from 'jest-fetch-mock' import User, { IUser } from '@user-mgnt/model/user' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import * as mockingoose from 'mockingoose' import { cloneDeep } from 'lodash' import { Types } from 'mongoose' diff --git a/packages/user-mgnt/src/features/activateUser/handler.ts b/packages/user-mgnt/src/features/activateUser/handler.ts index ea853ac11a1..0981d8539e7 100644 --- a/packages/user-mgnt/src/features/activateUser/handler.ts +++ b/packages/user-mgnt/src/features/activateUser/handler.ts @@ -13,7 +13,7 @@ import * as Joi from 'joi' import { unauthorized } from '@hapi/boom' import User, { IUserModel } from '@user-mgnt/model/user' import { generateSaltedHash, generateHash } from '@user-mgnt/utils/hash' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { statuses } from '@user-mgnt/utils/userUtils' interface ISecurityQNA { diff --git a/packages/user-mgnt/src/features/changeAvatar/handler.ts b/packages/user-mgnt/src/features/changeAvatar/handler.ts index d3a0bc51cac..69eee5b484a 100644 --- a/packages/user-mgnt/src/features/changeAvatar/handler.ts +++ b/packages/user-mgnt/src/features/changeAvatar/handler.ts @@ -12,7 +12,7 @@ import * as Hapi from '@hapi/hapi' import * as Joi from 'joi' import { unauthorized } from '@hapi/boom' import User, { IUserModel } from '@user-mgnt/model/user' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { statuses } from '@user-mgnt/utils/userUtils' interface IChangeAvatarPayload { diff --git a/packages/user-mgnt/src/features/changeEmail/handler.ts b/packages/user-mgnt/src/features/changeEmail/handler.ts index 2fad93cac75..747eb11eb3a 100644 --- a/packages/user-mgnt/src/features/changeEmail/handler.ts +++ b/packages/user-mgnt/src/features/changeEmail/handler.ts @@ -12,7 +12,7 @@ import * as Hapi from '@hapi/hapi' import * as Joi from 'joi' import { unauthorized } from '@hapi/boom' import User, { IUserModel } from '@user-mgnt/model/user' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { statuses } from '@user-mgnt/utils/userUtils' import { resolve } from 'url' import fetch from 'node-fetch' diff --git a/packages/user-mgnt/src/features/changePassword/handler.ts b/packages/user-mgnt/src/features/changePassword/handler.ts index e4826cfa591..0187e0efb1f 100644 --- a/packages/user-mgnt/src/features/changePassword/handler.ts +++ b/packages/user-mgnt/src/features/changePassword/handler.ts @@ -13,7 +13,7 @@ import * as Joi from 'joi' import { unauthorized } from '@hapi/boom' import User, { IUserModel } from '@user-mgnt/model/user' import { generateHash } from '@user-mgnt/utils/hash' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { statuses } from '@user-mgnt/utils/userUtils' import { postUserActionToMetrics } from '@user-mgnt/features/changePhone/handler' diff --git a/packages/user-mgnt/src/features/changePhone/handler.ts b/packages/user-mgnt/src/features/changePhone/handler.ts index 06a78306b3a..7ad4afc464f 100644 --- a/packages/user-mgnt/src/features/changePhone/handler.ts +++ b/packages/user-mgnt/src/features/changePhone/handler.ts @@ -12,7 +12,7 @@ import * as Hapi from '@hapi/hapi' import * as Joi from 'joi' import { unauthorized } from '@hapi/boom' import User, { IUserModel } from '@user-mgnt/model/user' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { statuses } from '@user-mgnt/utils/userUtils' import { resolve } from 'url' import fetch from 'node-fetch' diff --git a/packages/user-mgnt/src/features/createUser/handler.ts b/packages/user-mgnt/src/features/createUser/handler.ts index 705f20b88ca..902cd9842f0 100644 --- a/packages/user-mgnt/src/features/createUser/handler.ts +++ b/packages/user-mgnt/src/features/createUser/handler.ts @@ -17,7 +17,7 @@ import { sendCredentialsNotification, getCatchmentAreaIdsByPrimaryOfficeId } from '@user-mgnt/features/createUser/service' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import User, { IUser, IUserModel } from '@user-mgnt/model/user' import { generateSaltedHash, diff --git a/packages/user-mgnt/src/features/createUser/service.test.ts b/packages/user-mgnt/src/features/createUser/service.test.ts index 83cec5213e3..c789ff750e2 100644 --- a/packages/user-mgnt/src/features/createUser/service.test.ts +++ b/packages/user-mgnt/src/features/createUser/service.test.ts @@ -14,7 +14,7 @@ import * as mockingoose from 'mockingoose' import * as fetchMock from 'jest-fetch-mock' import * as jwt from 'jsonwebtoken' import { readFileSync } from 'fs' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' const fetch = fetchMock as fetchMock.FetchMock const mockUser = { diff --git a/packages/user-mgnt/src/features/createUser/service.ts b/packages/user-mgnt/src/features/createUser/service.ts index d87d8e8f725..54a17b62213 100644 --- a/packages/user-mgnt/src/features/createUser/service.ts +++ b/packages/user-mgnt/src/features/createUser/service.ts @@ -11,7 +11,7 @@ import { FHIR_URL, NOTIFICATION_SERVICE_URL } from '@user-mgnt/constants' import User, { IUser, IUserName, UserRole } from '@user-mgnt/model/user' import fetch from 'node-fetch' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' export const createFhirPractitioner = ( user: IUser, diff --git a/packages/user-mgnt/src/features/resetPassword/handler.ts b/packages/user-mgnt/src/features/resetPassword/handler.ts index 49d7b0c6fcf..20d7b96efb2 100644 --- a/packages/user-mgnt/src/features/resetPassword/handler.ts +++ b/packages/user-mgnt/src/features/resetPassword/handler.ts @@ -18,7 +18,7 @@ import { } from '@user-mgnt/utils/hash' import { getUserId, hasDemoScope, statuses } from '@user-mgnt/utils/userUtils' import { NOTIFICATION_SERVICE_URL } from '@user-mgnt/constants' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { postUserActionToMetrics } from '@user-mgnt/features/changePhone/handler' import fetch from 'node-fetch' diff --git a/packages/user-mgnt/src/features/system/handler.ts b/packages/user-mgnt/src/features/system/handler.ts index 2258e0902d3..664986db97b 100644 --- a/packages/user-mgnt/src/features/system/handler.ts +++ b/packages/user-mgnt/src/features/system/handler.ts @@ -18,7 +18,7 @@ import { createFhirPractitionerRole, postFhir } from '@user-mgnt/features/createUser/service' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import System, { ISystemModel, WebhookPermissions diff --git a/packages/user-mgnt/src/features/updateRole/handler.ts b/packages/user-mgnt/src/features/updateRole/handler.ts index 60a8a6fcb98..f37daecea84 100644 --- a/packages/user-mgnt/src/features/updateRole/handler.ts +++ b/packages/user-mgnt/src/features/updateRole/handler.ts @@ -11,7 +11,7 @@ import * as Hapi from '@hapi/hapi' import { Types } from 'mongoose' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { UserRole } from '@user-mgnt/model/user' import SystemRole, { ISystemRoleModel, diff --git a/packages/user-mgnt/src/features/updateUser/handler.ts b/packages/user-mgnt/src/features/updateUser/handler.ts index 0e38516c86e..fdeafc4a209 100644 --- a/packages/user-mgnt/src/features/updateUser/handler.ts +++ b/packages/user-mgnt/src/features/updateUser/handler.ts @@ -18,7 +18,7 @@ import { getCatchmentAreaIdsByPrimaryOfficeId, postFhir } from '@user-mgnt/features/createUser/service' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import User, { IUser, IUserModel } from '@user-mgnt/model/user' import { getUserId } from '@user-mgnt/utils/userUtils' import { QA_ENV } from '@user-mgnt/constants' diff --git a/packages/user-mgnt/src/features/userAudit/handler.test.ts b/packages/user-mgnt/src/features/userAudit/handler.test.ts index 4e011e29387..ddea64e750e 100644 --- a/packages/user-mgnt/src/features/userAudit/handler.test.ts +++ b/packages/user-mgnt/src/features/userAudit/handler.test.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { createServer } from '@user-mgnt/server' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import User, { AUDIT_ACTION, AUDIT_REASON, IUser } from '@user-mgnt/model/user' import { readFileSync } from 'fs' import * as fetchMock from 'jest-fetch-mock' diff --git a/packages/user-mgnt/src/features/userAudit/handler.ts b/packages/user-mgnt/src/features/userAudit/handler.ts index a41f25c0efa..359dfc32163 100644 --- a/packages/user-mgnt/src/features/userAudit/handler.ts +++ b/packages/user-mgnt/src/features/userAudit/handler.ts @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import User, { AUDIT_ACTION, AUDIT_REASON, diff --git a/packages/user-mgnt/src/features/userSearchRecord/handler.test.ts b/packages/user-mgnt/src/features/userSearchRecord/handler.test.ts index 058188ff6a0..7cc66c80593 100644 --- a/packages/user-mgnt/src/features/userSearchRecord/handler.test.ts +++ b/packages/user-mgnt/src/features/userSearchRecord/handler.test.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { createServer } from '@user-mgnt/server' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import User, { IUser } from '@user-mgnt/model/user' import { readFileSync } from 'fs' import * as fetchMock from 'jest-fetch-mock' diff --git a/packages/user-mgnt/src/features/userSearchRecord/handler.ts b/packages/user-mgnt/src/features/userSearchRecord/handler.ts index 250d285b948..aef505b9977 100644 --- a/packages/user-mgnt/src/features/userSearchRecord/handler.ts +++ b/packages/user-mgnt/src/features/userSearchRecord/handler.ts @@ -8,7 +8,7 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import User, { IUserModel, Event } from '@user-mgnt/model/user' import { unauthorized } from '@hapi/boom' import * as Hapi from '@hapi/hapi' diff --git a/packages/user-mgnt/src/features/usernameSMSReminderInvite/handler.ts b/packages/user-mgnt/src/features/usernameSMSReminderInvite/handler.ts index d9c44f403bf..7658f25019a 100644 --- a/packages/user-mgnt/src/features/usernameSMSReminderInvite/handler.ts +++ b/packages/user-mgnt/src/features/usernameSMSReminderInvite/handler.ts @@ -14,7 +14,7 @@ import User, { IUserModel } from '@user-mgnt/model/user' import { unauthorized } from '@hapi/boom' import { sendUserName } from './service' import { postUserActionToMetrics } from '@user-mgnt/features/changePhone/handler' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { getUserId } from '@user-mgnt/utils/userUtils' interface IResendUsernameSMSPayload { diff --git a/packages/user-mgnt/src/features/verifySecurityAnswer/handler.ts b/packages/user-mgnt/src/features/verifySecurityAnswer/handler.ts index 02968cd03d9..4e572b422b4 100644 --- a/packages/user-mgnt/src/features/verifySecurityAnswer/handler.ts +++ b/packages/user-mgnt/src/features/verifySecurityAnswer/handler.ts @@ -13,7 +13,7 @@ import * as Joi from 'joi' import { unauthorized, conflict } from '@hapi/boom' import User, { IUserModel } from '@user-mgnt/model/user' import { generateHash } from '@user-mgnt/utils/hash' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { getRandomQuestionKey } from '@user-mgnt/features/verifyUser/handler' import { isNonEmptyArray } from '@user-mgnt/utils/non-empty-array' diff --git a/packages/user-mgnt/src/logger.ts b/packages/user-mgnt/src/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/user-mgnt/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/user-mgnt/src/server.ts b/packages/user-mgnt/src/server.ts index 7936b15fd44..ddd862ab7b7 100644 --- a/packages/user-mgnt/src/server.ts +++ b/packages/user-mgnt/src/server.ts @@ -20,7 +20,7 @@ import getPlugins from '@user-mgnt/config/plugins' import * as database from '@user-mgnt/database' import { readFileSync } from 'fs' import { getRoutes } from '@user-mgnt/config/routes' -import { logger } from '@user-mgnt/logger' +import { logger } from '@opencrvs/commons' import { badRequest, Boom } from '@hapi/boom' const publicCert = readFileSync(CERT_PUBLIC_KEY_PATH) diff --git a/packages/webhooks/package.json b/packages/webhooks/package.json index 0270c3ee426..f3eb6976e5a 100644 --- a/packages/webhooks/package.json +++ b/packages/webhooks/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest --coverage --silent --noStackTrace --forceExit && yarn test:compilation", "test:watch": "jest --watch", diff --git a/packages/webhooks/src/config/plugins.ts b/packages/webhooks/src/config/plugins.ts index a9e46cca461..1eed22f0da1 100644 --- a/packages/webhooks/src/config/plugins.ts +++ b/packages/webhooks/src/config/plugins.ts @@ -8,24 +8,28 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' +import { ServerRegisterPluginObject } from '@hapi/hapi' +import { logger } from '@opencrvs/commons' +import { SENTRY_DSN } from '@webhooks/constants' import * as JWT from 'hapi-auth-jwt2' +import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@webhooks/constants' -import { logger } from '@webhooks/logger' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - { + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ plugin: Pino, options: { prettyPrint: false, logPayload: false, instance: logger } - } - ] + }) + } if (SENTRY_DSN) { plugins.push({ diff --git a/packages/webhooks/src/database.ts b/packages/webhooks/src/database.ts index abac86b821a..87ae1b8b3ae 100644 --- a/packages/webhooks/src/database.ts +++ b/packages/webhooks/src/database.ts @@ -10,10 +10,14 @@ */ import * as mongoose from 'mongoose' import { MONGO_URL, REDIS_HOST } from '@webhooks/constants' -import { logger } from '@webhooks/logger' +import { logger } from '@opencrvs/commons' import Redis, * as IORedis from 'ioredis' const db = mongoose.connection +// This prepares code for Mongoose >7 where strictQuery +// is set to false by default +mongoose.set('strictQuery', false) + db.on('disconnected', () => { logger.info('MongoDB disconnected') }) @@ -33,7 +37,10 @@ export function getRedis(): IORedis.Redis { const connect = async (): Promise => { try { - redisConnection = new Redis(REDIS_HOST) + redisConnection = new Redis({ + host: REDIS_HOST, + maxRetriesPerRequest: null + }) redisConnection.on('error', (error) => { logger.error('Redis connection error', error) diff --git a/packages/webhooks/src/features/event/handler.ts b/packages/webhooks/src/features/event/handler.ts index 28965aba19f..ca4728e190c 100644 --- a/packages/webhooks/src/features/event/handler.ts +++ b/packages/webhooks/src/features/event/handler.ts @@ -17,7 +17,7 @@ import { transformDeathBundle } from '@webhooks/features/event/service' import { EventType, ISystem } from '@webhooks/features/manage/service' -import { logger } from '@webhooks/logger' +import { logger } from '@opencrvs/commons' import Webhook, { IWebhookModel, TRIGGERS } from '@webhooks/model/webhook' import { getQueue } from '@webhooks/queue' import { Queue } from 'bullmq' diff --git a/packages/webhooks/src/features/manage/handler.ts b/packages/webhooks/src/features/manage/handler.ts index 51ad15c2cf9..7965b309b6c 100644 --- a/packages/webhooks/src/features/manage/handler.ts +++ b/packages/webhooks/src/features/manage/handler.ts @@ -19,7 +19,7 @@ import { } from '@webhooks/features/manage/service' import { internal } from '@hapi/boom' import Webhook, { TRIGGERS } from '@webhooks/model/webhook' -import { logger } from '@webhooks/logger' +import { logger } from '@opencrvs/commons' import * as uuid from 'uuid/v4' import fetch from 'node-fetch' import { resolve } from 'url' diff --git a/packages/webhooks/src/logger.ts b/packages/webhooks/src/logger.ts deleted file mode 100644 index bc3f171a97d..00000000000 --- a/packages/webhooks/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'silent' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/webhooks/src/processor.ts b/packages/webhooks/src/processor.ts index 3e71cb330a4..b8cbed6fa19 100644 --- a/packages/webhooks/src/processor.ts +++ b/packages/webhooks/src/processor.ts @@ -10,7 +10,7 @@ */ import fetch from 'node-fetch' -import { logger } from '@webhooks/logger' +import { logger } from '@opencrvs/commons' import { Worker } from 'bullmq' import * as IORedis from 'ioredis' diff --git a/packages/webhooks/src/queue.ts b/packages/webhooks/src/queue.ts index 7fe9f89145f..fc528ca1c44 100644 --- a/packages/webhooks/src/queue.ts +++ b/packages/webhooks/src/queue.ts @@ -12,7 +12,7 @@ import { REDIS_HOST, QUEUE_NAME } from '@webhooks/constants' import { Queue, QueueEvents, Worker, Job } from 'bullmq' import { EventEmitter } from 'events' -import { logger } from '@webhooks/logger' +import { logger } from '@opencrvs/commons' import { getRedis } from '@webhooks/database' import { initWorker } from '@webhooks/processor' diff --git a/packages/workflow/package.json b/packages/workflow/package.json index 0f661c6e7cb..14fcd65e17f 100644 --- a/packages/workflow/package.json +++ b/packages/workflow/package.json @@ -5,7 +5,7 @@ "license": "MPL-2.0", "private": true, "scripts": { - "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --exec ts-node -r tsconfig-paths/register src/index.ts", + "start": "cross-env NODE_ENV=development NODE_OPTIONS=--dns-result-order=ipv4first nodemon --quiet --exec ts-node -r tsconfig-paths/register src/index.ts", "start:prod": "TS_NODE_BASEURL=./build/dist/src node -r tsconfig-paths/register build/dist/src/index.js", "test": "jest --coverage --silent --noStackTrace && yarn test:compilation", "test:watch": "jest --watch", diff --git a/packages/workflow/src/config/plugins.ts b/packages/workflow/src/config/plugins.ts index 8b42a971dc2..b84086c20d5 100644 --- a/packages/workflow/src/config/plugins.ts +++ b/packages/workflow/src/config/plugins.ts @@ -8,24 +8,28 @@ * * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ -import * as Pino from 'hapi-pino' +import { ServerRegisterPluginObject } from '@hapi/hapi' +import { SENTRY_DSN } from '@workflow/constants' +import { logger } from '@opencrvs/commons' import * as JWT from 'hapi-auth-jwt2' +import * as Pino from 'hapi-pino' import * as Sentry from 'hapi-sentry' -import { SENTRY_DSN } from '@workflow/constants' -import { logger } from '@workflow/logger' + +type IHapiPlugin = ServerRegisterPluginObject export default function getPlugins() { - const plugins: any[] = [ - JWT, - { + const plugins: IHapiPlugin[] = [{ plugin: JWT, options: {} }] + + if (process.env.NODE_ENV === 'production') { + plugins.push({ plugin: Pino, options: { - prettyPrint: true, + prettyPrint: false, logPayload: false, instance: logger } - } - ] + }) + } if (SENTRY_DSN) { plugins.push({ diff --git a/packages/workflow/src/features/registration/fhir/fhir-bundle-modifier.ts b/packages/workflow/src/features/registration/fhir/fhir-bundle-modifier.ts index 06886748e72..d79694f029a 100644 --- a/packages/workflow/src/features/registration/fhir/fhir-bundle-modifier.ts +++ b/packages/workflow/src/features/registration/fhir/fhir-bundle-modifier.ts @@ -9,20 +9,20 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as Hapi from '@hapi/hapi' -import { UUID } from '@opencrvs/commons' +import { UUID, logger } from '@opencrvs/commons' import { Bundle, Composition, Patient, Practitioner, RegistrationNumber, + RegistrationStatus, + ResourceIdentifier, Saved, Task, - findExtension, - RegistrationStatus, WaitingForValidationRecord, + findExtension, getResourceFromBundleById, - ResourceIdentifier, resourceIdentifierToUUID } from '@opencrvs/commons/types' import { APPLICATION_CONFIG_URL, COUNTRY_CONFIG_URL } from '@workflow/constants' @@ -49,7 +49,6 @@ import { getPractitionerRef, getSystem } from '@workflow/features/user/utils' -import { logger } from '@workflow/logger' import { ITokenPayload, USER_SCOPE, diff --git a/packages/workflow/src/features/registration/fhir/fhir-utils.ts b/packages/workflow/src/features/registration/fhir/fhir-utils.ts index 796e629e045..7c0cf597d24 100644 --- a/packages/workflow/src/features/registration/fhir/fhir-utils.ts +++ b/packages/workflow/src/features/registration/fhir/fhir-utils.ts @@ -29,7 +29,6 @@ import { getPatientBySection } from '@workflow/features/registration/utils' import * as Hapi from '@hapi/hapi' -import { logger } from '@workflow/logger' import { SECTION_CODE } from '@workflow/features/events/utils' import { getTaskEventType } from '@workflow/features/task/fhir/utils' import { @@ -45,6 +44,7 @@ import { findExtension, isSaved } from '@opencrvs/commons/types' +import { logger } from '@opencrvs/commons' export async function getSharedContactMsisdn(fhirBundle: Bundle) { if (!fhirBundle || !fhirBundle.entry) { diff --git a/packages/workflow/src/features/registration/sms-notification-utils.ts b/packages/workflow/src/features/registration/sms-notification-utils.ts index cdffd0b78f8..bcf34081e14 100644 --- a/packages/workflow/src/features/registration/sms-notification-utils.ts +++ b/packages/workflow/src/features/registration/sms-notification-utils.ts @@ -10,7 +10,7 @@ */ import { APPLICATION_CONFIG_URL } from '@workflow/constants' import fetch from 'node-fetch' -import { logger } from '@workflow/logger' +import { logger } from '@opencrvs/commons' export enum InformantNotificationName { birthInProgressSMS = 'birthInProgressSMS', diff --git a/packages/workflow/src/features/registration/utils.ts b/packages/workflow/src/features/registration/utils.ts index 07c556cd052..b433ff3da4d 100644 --- a/packages/workflow/src/features/registration/utils.ts +++ b/packages/workflow/src/features/registration/utils.ts @@ -15,9 +15,7 @@ import { } from '@workflow/constants' import { EVENT_TYPE } from '@workflow/features/registration/fhir/constants' import { concatenateName } from '@workflow/features/registration/fhir/fhir-utils' -import { logger } from '@workflow/logger' -import fetch from 'node-fetch' -import * as ShortUIDGen from 'short-uid' + import { Bundle, BundleEntry, @@ -32,6 +30,10 @@ import { import { MAKE_CORRECTION_EXTENSION_URL } from '@workflow/features/task/fhir/constants' import { getTaskEventType } from '@workflow/features/task/fhir/utils' +import { logger } from '@opencrvs/commons' +import fetch from 'node-fetch' +import * as ShortUIDGen from 'short-uid' + export enum FHIR_RESOURCE_TYPE { COMPOSITION = 'Composition', TASK = 'Task', diff --git a/packages/workflow/src/logger.ts b/packages/workflow/src/logger.ts deleted file mode 100644 index dfdcc123e73..00000000000 --- a/packages/workflow/src/logger.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. - * - * OpenCRVS is also distributed under the terms of the Civil Registration - * & Healthcare Disclaimer located at http://opencrvs.org/license. - * - * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. - */ -import pino from 'pino' -export const logger = pino() - -const level = process.env.NODE_ENV === 'test' ? 'error' : process.env.LOG_LEVEL -if (level) { - logger.level = level -} diff --git a/packages/workflow/src/records/handler/create.ts b/packages/workflow/src/records/handler/create.ts index c70bc1a627d..202608d7ed9 100644 --- a/packages/workflow/src/records/handler/create.ts +++ b/packages/workflow/src/records/handler/create.ts @@ -69,7 +69,7 @@ import { toValidated, toWaitingForExternalValidationState } from '@workflow/records/state-transitions' -import { logger } from '@workflow/logger' +import { logger } from '@opencrvs/commons' const requestSchema = z.object({ event: z.custom(), diff --git a/packages/workflow/src/records/handler/download.ts b/packages/workflow/src/records/handler/download.ts index 3e8dcc5a2e0..0017e5e8a51 100644 --- a/packages/workflow/src/records/handler/download.ts +++ b/packages/workflow/src/records/handler/download.ts @@ -24,7 +24,7 @@ import { toDownloaded } from '@workflow/records/state-transitions' import { hasScope, inScope } from '@opencrvs/commons/authentication' import { sendBundleToHearth } from '@workflow/records/fhir' import { indexBundleToRoute } from '@workflow/records/search' -import { logger } from '@workflow/logger' +import { logger } from '@opencrvs/commons' import { auditEvent } from '@workflow/records/audit' function getDownloadedOrAssignedExtension( diff --git a/yarn.lock b/yarn.lock index fe2423c1c01..cbf2527aca9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8591,6 +8591,13 @@ abbrev@1, abbrev@^1.0.0: resolved "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + abstract-logging@^2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/abstract-logging/-/abstract-logging-2.0.1.tgz" @@ -10031,6 +10038,14 @@ buffer@^5.1.0, buffer@^5.5.0, buffer@^5.6.0: base64-js "^1.3.1" ieee754 "^1.1.13" +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + buildcheck@~0.0.6: version "0.0.6" resolved "https://registry.npmjs.org/buildcheck/-/buildcheck-0.0.6.tgz" @@ -10749,7 +10764,7 @@ colord@^2.9.3: resolved "https://registry.npmjs.org/colord/-/colord-2.9.3.tgz" integrity sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw== -colorette@^2.0.16, colorette@^2.0.20: +colorette@^2.0.16, colorette@^2.0.20, colorette@^2.0.7: version "2.0.20" resolved "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== @@ -11633,6 +11648,11 @@ dateformat@^3.0.0: resolved "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== +dateformat@^4.6.3: + version "4.6.3" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.6.3.tgz#556fa6497e5217fedb78821424f8a1c22fa3f4b5" + integrity sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA== + debounce@^1.2.0: version "1.2.1" resolved "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz" @@ -13242,6 +13262,11 @@ event-emitter@^0.3.5, event-emitter@~0.3.5: d "1" es5-ext "~0.10.14" +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== + eventemitter3@^3.0.0: version "3.1.2" resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz" @@ -13493,6 +13518,11 @@ extract-zip@^2.0.1: optionalDependencies: "@types/yauzl" "^2.9.1" +fast-copy@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/fast-copy/-/fast-copy-3.0.2.tgz#59c68f59ccbcac82050ba992e0d5c389097c9d35" + integrity sha512-dl0O9Vhju8IrcLndv2eU4ldt1ftXMqqfgN4H1cpmGV7P6jeB9FwpN9a2c8DPGE1Ys88rNUJVYDHq73CGAGOPfQ== + fast-csv@^4.3.6: version "4.3.6" resolved "https://registry.npmjs.org/fast-csv/-/fast-csv-4.3.6.tgz" @@ -13586,7 +13616,7 @@ fast-redact@^3.0.0: resolved "https://registry.npmjs.org/fast-redact/-/fast-redact-3.3.0.tgz" integrity sha512-6T5V1QK1u4oF+ATxs1lWUmlEk6P2T9HqJG3e2DnHOdVgZy2rFJBoEnrIedcTXlkAHU/zKC+7KETJ+KGGKwxgMQ== -fast-safe-stringify@^2.0.7, fast-safe-stringify@^2.0.8: +fast-safe-stringify@^2.0.7, fast-safe-stringify@^2.0.8, fast-safe-stringify@^2.1.1: version "2.1.1" resolved "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz" integrity sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA== @@ -14846,6 +14876,11 @@ headers-utils@^1.2.0: resolved "https://registry.npmjs.org/headers-utils/-/headers-utils-1.2.5.tgz" integrity sha512-DAzV5P/pk3wTU/8TLZN+zFTDv4Xa1QDTU8pRvovPetcOMbmqq8CwsAvZBLPZHH6usxyy31zMp7I4aCYb6XIf6w== +help-me@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/help-me/-/help-me-5.0.0.tgz#b1ebe63b967b74060027c2ac61f9be12d354a6f6" + integrity sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg== + history@^4.7.2, history@^4.9.0: version "4.10.1" resolved "https://registry.npmjs.org/history/-/history-4.10.1.tgz" @@ -16579,6 +16614,11 @@ jose@^4.13.1: resolved "https://registry.yarnpkg.com/jose/-/jose-4.15.5.tgz#6475d0f467ecd3c630a1b5dadd2735a7288df706" integrity sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg== +joycon@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" + integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== + js-levenshtein@^1.1.6: version "1.1.6" resolved "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz" @@ -19463,6 +19503,11 @@ on-exit-leak-free@^0.2.0: resolved "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz" integrity sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg== +on-exit-leak-free@^2.1.0: + version "2.1.2" + resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz#fed195c9ebddb7d9e4c3842f93f281ac8dadd3b8" + integrity sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA== + on-finished@2.4.1: version "2.4.1" resolved "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz" @@ -20101,6 +20146,14 @@ pify@^5.0.0: resolved "https://registry.npmjs.org/pify/-/pify-5.0.0.tgz" integrity sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA== +pino-abstract-transport@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pino-abstract-transport/-/pino-abstract-transport-1.2.0.tgz#97f9f2631931e242da531b5c66d3079c12c9d1b5" + integrity sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q== + dependencies: + readable-stream "^4.0.0" + split2 "^4.0.0" + pino-abstract-transport@v0.5.0: version "0.5.0" resolved "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-0.5.0.tgz" @@ -20109,6 +20162,26 @@ pino-abstract-transport@v0.5.0: duplexify "^4.1.2" split2 "^4.0.0" +pino-pretty@^11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/pino-pretty/-/pino-pretty-11.0.0.tgz#9b883f7b933f58fa94caa44225aab302409461ef" + integrity sha512-YFJZqw59mHIY72wBnBs7XhLGG6qpJMa4pEQTRgEPEbjIYbng2LXEZZF1DoyDg9CfejEy8uZCyzpcBXXG0oOCwQ== + dependencies: + colorette "^2.0.7" + dateformat "^4.6.3" + fast-copy "^3.0.0" + fast-safe-stringify "^2.1.1" + help-me "^5.0.0" + joycon "^3.1.1" + minimist "^1.2.6" + on-exit-leak-free "^2.1.0" + pino-abstract-transport "^1.0.0" + pump "^3.0.0" + readable-stream "^4.0.0" + secure-json-parse "^2.4.0" + sonic-boom "^3.0.0" + strip-json-comments "^3.1.1" + pino-std-serializers@^3.1.0: version "3.2.0" resolved "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-3.2.0.tgz" @@ -21191,6 +21264,17 @@ readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.5, readable string_decoder "~1.1.1" util-deprecate "~1.0.1" +readable-stream@^4.0.0: + version "4.5.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-4.5.2.tgz#9e7fc4c45099baeed934bff6eb97ba6cf2729e09" + integrity sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g== + dependencies: + abort-controller "^3.0.0" + buffer "^6.0.3" + events "^3.3.0" + process "^0.11.10" + string_decoder "^1.3.0" + readable-stream@~1.0.31: version "1.0.34" resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" @@ -22442,6 +22526,13 @@ sonic-boom@^2.2.1: dependencies: atomic-sleep "^1.0.0" +sonic-boom@^3.0.0: + version "3.8.1" + resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-3.8.1.tgz#d5ba8c4e26d6176c9a1d14d549d9ff579a163422" + integrity sha512-y4Z8LCDBuum+PBP3lSV7RHrXscqksve/bi0as7mhwVnBW+/wUqKT/2Kb7um8yqcFy0duYbbPxzt89Zy2nOCaxg== + dependencies: + atomic-sleep "^1.0.0" + sort-keys@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz" @@ -22955,7 +23046,7 @@ string.prototype.trimstart@^1.0.7: define-properties "^1.2.0" es-abstract "^1.22.1" -string_decoder@^1.1.1: +string_decoder@^1.1.1, string_decoder@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz" integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== From 604db1fe78121938ba15ffc16694358e048c6276 Mon Sep 17 00:00:00 2001 From: Pyry Rouvila Date: Wed, 19 Jun 2024 10:23:25 +0300 Subject: [PATCH 032/108] chore(v1.5.0): handle `ws` security error (#7192) * chore: handle security error * fix: yaml format --- .trivyignore.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.trivyignore.yaml b/.trivyignore.yaml index b9a54ee9952..1d7f2b383d0 100644 --- a/.trivyignore.yaml +++ b/.trivyignore.yaml @@ -51,3 +51,5 @@ vulnerabilities: statement: Metabase v0.46 vulnerability, fixed in Metabase v0.49 - id: CVE-2024-4068 statement: Transitive dependency of lint-staged, jest and msw. Not running in production. Likely fixed by upgrading. + - id: CVE-2024-37890 + statement: ws vulnerability, transitive dependency of jest, storybook, graphql-codegen, not running in production. From c31c4f70552476d7a234c1ff330a7ebfaa7ffbfd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:34:37 +0300 Subject: [PATCH 033/108] chore(v1.5.0): deprecate admin UI menu items (#7191) * Placeholder commit for PR #7155 * chore: deprecate admin UI menu items (#7155) * chore: deprecate admin ui menu items * chore(changelog) * fix: remove tests for application and certificate * chore(changelog): update wording --------- Co-authored-by: github-actions Co-authored-by: Pyry Rouvila --- CHANGELOG.md | 4 + packages/client/src/App.tsx | 38 ------ .../components/interface/Navigation.test.tsx | 2 - .../src/components/interface/Navigation.tsx | 113 ++++-------------- 4 files changed, 26 insertions(+), 131 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0864d2ee8bd..c7ac9a5d8d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ We are dropping support for 'agentDefault' to be used as initial value for SELECT_WITH_DYNAMIC_OPTIONS type of fields. The country config package now must return the form with prepopulated initial values to show default addresses. [#6871](https://github.com/opencrvs/opencrvs-core/issues/6871) +- #### Remove system admin UI items: Application, Certificates, User roles, Informant notifications + + We have now moved to configuring these items directly from country configuration repository. + ## New features - Add loading spinners before JavaScript bundle has loaded for both login and client diff --git a/packages/client/src/App.tsx b/packages/client/src/App.tsx index 84d79b934b5..af613f7f7ae 100644 --- a/packages/client/src/App.tsx +++ b/packages/client/src/App.tsx @@ -47,8 +47,6 @@ import { AppStore } from './store' import { CorrectionForm, CorrectionReviewForm } from './views/CorrectionForm' import { VerifyCorrector } from './views/CorrectionForm/VerifyCorrector' import { RecordAudit } from './views/RecordAudit/RecordAudit' -import { ApplicationConfig } from './views/SysAdmin/Config/Application' -import { CertificatesConfig } from './views/SysAdmin/Config/Certificates' import { UserList } from './views/SysAdmin/Team/user/UserList' import { SystemList } from './views/SysAdmin/Config/Systems/Systems' import VSExport from './views/SysAdmin/Vsexports/VSExport' @@ -62,11 +60,9 @@ import { Leaderboards } from '@client/views/Performance/Leaderboards' import { PerformanceDashboard } from '@client/views/Performance/Dashboard' import { SystemRoleType } from '@client/utils/gateway' import { AdministrativeLevels } from '@client/views/Organisation/AdministrativeLevels' -import InformantNotification from '@client/views/SysAdmin/Communications/InformantSMSNotification/InformantSMSNotification' import { VerifyCertificatePage } from '@client/views/VerifyCertificate/VerifyCertificatePage' import { IssueCertificate } from '@client/views/IssueCertificate/IssueCertificate' import { IssuePayment } from '@client/views/IssueCertificate/IssueCollectorForm/IssuePayment' -import UserRoles from '@client/views/SysAdmin/Config/UserRoles/UserRoles' import { OIDPVerificationCallback } from './views/OIDPVerificationCallback/OIDPVerificationCallback' import { ApolloProvider } from '@client/utils/ApolloProvider' import { Home } from '@client/views/OfficeHome/Home' @@ -257,24 +253,6 @@ export function App(props: IAppProps) { } component={OfficeHome} /> - - - - { expect(testComponent.exists('#navigation_config_main')).toBeTruthy() testComponent.find('#navigation_config_main').hostNodes().simulate('click') testComponent.update() - expect(testComponent.exists('#navigation_application')).toBeTruthy() - expect(testComponent.exists('#navigation_certificate')).toBeTruthy() }) it('No application related tabs', async () => { diff --git a/packages/client/src/components/interface/Navigation.tsx b/packages/client/src/components/interface/Navigation.tsx index ef0f03f5c48..2a89c4bb893 100644 --- a/packages/client/src/components/interface/Navigation.tsx +++ b/packages/client/src/components/interface/Navigation.tsx @@ -19,11 +19,8 @@ import { navigationMessages } from '@client/i18n/messages/views/navigation' import { goToAdvancedSearchResult, goToAllUserEmail, - goToApplicationConfig, - goToCertificateConfig, goToDashboardView, goToHomeTab, - goToInformantNotification, goToLeaderBoardsView, goToOrganisationView, goToPerformanceStatistics, @@ -31,7 +28,6 @@ import { goToSettings, goToSystemList, goToTeamView, - goToUserRolesConfig, goToVSExport } from '@client/navigation' import { ADVANCED_SEARCH_RESULT } from '@client/navigation/routes' @@ -223,10 +219,7 @@ interface IProps { interface IDispatchProps { goToHomeTab: typeof goToHomeTab - goToCertificateConfigAction: typeof goToCertificateConfig goToVSExportsAction: typeof goToVSExport - goToUserRolesConfigAction: typeof goToUserRolesConfig - goToApplicationConfigAction: typeof goToApplicationConfig goToAdvancedSearchResultAction: typeof goToAdvancedSearchResult redirectToAuthentication: typeof redirectToAuthentication goToPerformanceViewAction: typeof goToPerformanceView @@ -239,7 +232,6 @@ interface IDispatchProps { goToPerformanceStatistics: typeof goToPerformanceStatistics updateRegistrarWorkqueue: typeof updateRegistrarWorkqueue setAdvancedSearchParam: typeof setAdvancedSearchParam - goToInformantNotification: typeof goToInformantNotification goToAllUserEmail: typeof goToAllUserEmail } @@ -303,11 +295,8 @@ const NavigationView = (props: IFullProps) => { enableMenuSelection = true, loadWorkqueueStatuses = true, activeMenuItem, - goToCertificateConfigAction, - goToUserRolesConfigAction, goToVSExportsAction, goToSystemViewAction, - goToApplicationConfigAction, goToAdvancedSearchResultAction, navigationWidth, workqueue, @@ -321,7 +310,6 @@ const NavigationView = (props: IFullProps) => { goToPerformanceStatistics, goToDashboardView, goToLeaderBoardsView, - goToInformantNotification, goToAllUserEmail, className } = props @@ -721,54 +709,17 @@ const NavigationView = (props: IFullProps) => { /> {(isConfigExpanded || configTab.includes(activeMenuItem)) && ( - <> - - - - - - - + )} )} @@ -802,33 +753,17 @@ const NavigationView = (props: IFullProps) => { /> {(isCommunationExpanded || conmmunicationTab.includes(activeMenuItem)) && ( - <> - - - + )} )} @@ -1027,9 +962,6 @@ export const Navigation = connect< IStoreState >(mapStateToProps, { goToHomeTab, - goToCertificateConfigAction: goToCertificateConfig, - goToUserRolesConfigAction: goToUserRolesConfig, - goToApplicationConfigAction: goToApplicationConfig, goToAdvancedSearchResultAction: goToAdvancedSearchResult, goToVSExportsAction: goToVSExport, goToPerformanceViewAction: goToPerformanceView, @@ -1043,7 +975,6 @@ export const Navigation = connect< goToPerformanceStatistics, goToLeaderBoardsView, goToDashboardView, - goToInformantNotification, goToAllUserEmail })(injectIntl(withRouter(NavigationView))) From d913c88de992b88c7d86cf3e9366afb556574abc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:34:54 +0300 Subject: [PATCH 034/108] fix(v1.5.0): certificate overflowing on the preview screen (#7193) * Placeholder commit for PR #7157 * fix: certificate overflowing on the preview screen (#7157) * fix: certificate overflowing on the preview screen * fix: add the mobile title/actions back * fix: linter not understanding css comment * chore(changelog) --------- Co-authored-by: github-actions Co-authored-by: Pyry Rouvila --- CHANGELOG.md | 3 +++ .../ReviewCertificateAction.tsx | 23 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7ac9a5d8d7..49db2688c26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,9 @@ - Fix Removed duplicateTrackingId check in createDuplicateTask method [#7081](https://github.com/opencrvs/opencrvs-core/pull/7081) - Fix print record page for an unsaved declaration [#6893](https://github.com/opencrvs/opencrvs-core/issues/6893) - Fix Reset pagination to default page (1) when location changes in UserList [#6481](https://github.com/opencrvs/opencrvs-core/issues/6481) +- Fix Disabling 'Mark as duplicate' button when duplicate reason is empty too [#7083](https://github.com/opencrvs/opencrvs-core/pull/7083) +- Fix certificate overflowing in preview certificate view [#7157](https://github.com/opencrvs/opencrvs-core/pull/7157) +- Fix records going completely missing when an unexpected error happens in the backend [#7021](https://github.com/opencrvs/opencrvs-core/pull/7021) ## Refactor diff --git a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.tsx b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.tsx index a77159b9ec4..ee0ef030366 100644 --- a/packages/client/src/views/PrintCertificate/ReviewCertificateAction.tsx +++ b/packages/client/src/views/PrintCertificate/ReviewCertificateAction.tsx @@ -33,7 +33,12 @@ import styled from 'styled-components' import { constantsMessages } from '@client/i18n/messages' import { usePrintableCertificate } from './usePrintableCertificate' -const CertificateContainer = styled.div`` +const CertificateContainer = styled.div` + svg { + /* limits the certificate overflowing on small screens */ + max-width: 100%; + } +` const ReviewCertificateFrame = ({ children @@ -77,6 +82,22 @@ const ReviewCertificateFrame = ({ } + mobileTitle={intl.formatMessage( + certificateMessages.certificateCollectionTitle + )} + mobileLeft={ + + } + mobileRight={ + + } /> } skipToContentText={intl.formatMessage( From 9a59d744dd5b0fbdc9ab54af576d06169655a9ee Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Thu, 13 Jun 2024 11:57:50 +0600 Subject: [PATCH 035/108] added missing 'requesterOther' params in client queries --- packages/client/src/utils/gateway.ts | 4 ++++ packages/client/src/views/DataProvider/death/queries.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/client/src/utils/gateway.ts b/packages/client/src/utils/gateway.ts index 3ab96d5f388..04fe091d432 100644 --- a/packages/client/src/utils/gateway.ts +++ b/packages/client/src/utils/gateway.ts @@ -4516,6 +4516,7 @@ export type FetchDeathRegistrationForReviewQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null hasShowedVerifiedDocument?: boolean | null noSupportingDocumentationRequired?: boolean | null date?: any | null @@ -4843,6 +4844,7 @@ export type FetchDeathRegistrationForCertificationQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null date?: any | null action?: RegAction | null regStatus?: RegStatus | null @@ -5244,6 +5246,7 @@ export type FetchMarriageRegistrationForReviewQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null hasShowedVerifiedDocument?: boolean | null noSupportingDocumentationRequired?: boolean | null date?: any | null @@ -5603,6 +5606,7 @@ export type FetchMarriageRegistrationForCertificateQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null hasShowedVerifiedDocument?: boolean | null date?: any | null action?: RegAction | null diff --git a/packages/client/src/views/DataProvider/death/queries.ts b/packages/client/src/views/DataProvider/death/queries.ts index 9f742134b88..0315d6b98bd 100644 --- a/packages/client/src/views/DataProvider/death/queries.ts +++ b/packages/client/src/views/DataProvider/death/queries.ts @@ -287,6 +287,7 @@ export const GET_DEATH_REGISTRATION_FOR_REVIEW = gql` } otherReason requester + requesterOther hasShowedVerifiedDocument noSupportingDocumentationRequired date @@ -555,6 +556,7 @@ export const GET_DEATH_REGISTRATION_FOR_CERTIFICATION = gql` history { otherReason requester + requesterOther date action regStatus From 4cc0814e3bd2b84e2e5e6022c7a58c452d42929f Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 20 Jun 2024 07:46:47 +0000 Subject: [PATCH 036/108] Placeholder commit for PR #7200 From f4addb25c364a72b7031c232c3b828d78c298fb0 Mon Sep 17 00:00:00 2001 From: Tameem Bin Haider Date: Fri, 21 Jun 2024 12:29:51 +0600 Subject: [PATCH 037/108] feat: added progressbar when loading #6641 (#6894) * feat: added progressbar when loading * fix: handling unhandled error * amend: enforce progressbars min visiblity in PROD only * feat: reused LoadingBar in page.tsx * refactor the speed of the loading bar and texts * refactor: moved styles from progress-container into root * refactor: moved `LoadingBar` to `@opencrvs/components` * Revert "refactor: moved styles from progress-container into root" This reverts commit 1c8d4ce3987f76d3c2409790b895bd4e2f8aa802. * refactor: change class to avoid clash * amend: change id in index.html --------- Co-authored-by: naftis --- packages/client/index.html | 101 ++++++++++-------- packages/client/public/images/logo-90x90.svg | 22 ++++ packages/client/src/components/Page.tsx | 25 +---- .../client/src/components/ProtectedPage.tsx | 42 +++----- .../components/src/LoadingBar/LoadingBar.tsx | 66 ++++++++++++ packages/components/src/LoadingBar/index.ts | 11 ++ packages/components/src/index.ts | 1 + 7 files changed, 171 insertions(+), 97 deletions(-) create mode 100644 packages/client/public/images/logo-90x90.svg create mode 100644 packages/components/src/LoadingBar/LoadingBar.tsx create mode 100644 packages/components/src/LoadingBar/index.ts diff --git a/packages/client/index.html b/packages/client/index.html index 6dc526a4a58..75f6c3f8e1a 100644 --- a/packages/client/index.html +++ b/packages/client/index.html @@ -39,70 +39,81 @@ -
- - - - - +
+ OpenCRVS logo +
+
+
+

Installing application...

+
diff --git a/packages/client/public/images/logo-90x90.svg b/packages/client/public/images/logo-90x90.svg new file mode 100644 index 00000000000..7e24a831b0c --- /dev/null +++ b/packages/client/public/images/logo-90x90.svg @@ -0,0 +1,22 @@ + + + + \ No newline at end of file diff --git a/packages/client/src/components/Page.tsx b/packages/client/src/components/Page.tsx index 5f83989a72a..d1a60ba15b6 100644 --- a/packages/client/src/components/Page.tsx +++ b/packages/client/src/components/Page.tsx @@ -9,12 +9,11 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import * as React from 'react' -import styled, { keyframes } from 'styled-components' +import styled from 'styled-components' import { RouteComponentProps, withRouter } from 'react-router' import { connect } from 'react-redux' import { IStoreState } from '@opencrvs/client/src/store' import { setInitialDeclarations } from '@client/declarations' -import { Spinner } from '@opencrvs/components/lib/Spinner' import { getOfflineData, getOfflineDataLoaded, @@ -32,6 +31,7 @@ import { getInitialDeclarationsLoaded } from '@client/declarations/selectors' import { isRegisterFormReady } from '@client/forms/register/declaration-selectors' import { IOfflineData } from '@client/offline/reducer' import { isNavigatorOnline } from '@client/utils' +import { LoadingBar } from '@opencrvs/components/src/LoadingBar/LoadingBar' const StyledPage = styled.div` background: ${({ theme }) => theme.colors.background}; @@ -51,25 +51,6 @@ const StyledPage = styled.div` box-sizing: border-box; } ` - -const spinnerAppearAnimation = keyframes` - 85% { opacity: 0; } - 100% { opacity: 1; } -` - -const StyledSpinner = styled(Spinner)` - opacity: 0; - position: absolute; - margin-left: -24px; - margin-top: -24px; - top: calc(50% - 20px); - left: 50%; - width: 40px; - height: 40px; - /** Show spinner after 2 seconds */ - animation: ${spinnerAppearAnimation} 2s forwards; -` - interface IPageProps { initialDeclarationsLoaded: boolean offlineDataLoaded: boolean @@ -144,7 +125,7 @@ class Component extends React.Component< } else { return ( <> - + ) } diff --git a/packages/client/src/components/ProtectedPage.tsx b/packages/client/src/components/ProtectedPage.tsx index 472483b88cf..08373911ec1 100644 --- a/packages/client/src/components/ProtectedPage.tsx +++ b/packages/client/src/components/ProtectedPage.tsx @@ -26,12 +26,11 @@ import { import { connect } from 'react-redux' import { refreshOfflineData } from '@client/offline/actions' import { PropsWithChildren } from 'react' -import styled, { keyframes } from 'styled-components' -import { Spinner } from '@opencrvs/components/lib/Spinner' import { ForgotPIN } from '@client/views/Unlock/ForgotPIN' import { showPINUpdateSuccessToast } from '@client/notification/actions' import { CreatePin } from '@client/views/PIN/CreatePin' import { redirectToAuthentication } from '@client/profile/profileActions' +import { LoadingBar } from '@opencrvs/components/src/LoadingBar/LoadingBar' export const SCREEN_LOCK = 'screenLock' type OwnProps = PropsWithChildren<{ @@ -54,28 +53,6 @@ interface IProtectPageState { type Props = OwnProps & DispatchProps & RouteComponentProps<{}> -const SpinnerBackground = styled.div` - background: ${({ theme }) => theme.colors.grey100}; - min-height: 100vh; -` - -const spinnerAppearAnimation = keyframes` - 85% { opacity: 0; } - 100% { opacity: 1; } -` - -const StyledSpinner = styled(Spinner)` - opacity: 0; - position: absolute; - margin-left: -24px; - margin-top: -24px; - top: calc(50% - 20px); - left: 50%; - width: 40px; - height: 40px; - /** Show spinner after 2 seconds */ - animation: ${spinnerAppearAnimation} 2s forwards; -` class ProtectedPageComponent extends React.Component { constructor(props: Props) { super(props) @@ -93,6 +70,7 @@ class ProtectedPageComponent extends React.Component { } async componentDidMount() { + const mountedOn = Date.now() const newState = { ...this.state } if (await storage.getItem(SCREEN_LOCK)) { @@ -113,7 +91,15 @@ class ProtectedPageComponent extends React.Component { } newState.loading = false - this.setState(newState) + const timeSinceMount = Date.now() - mountedOn + const progress = document.getElementById('progress') + if (progress != null) progress.style.width = '100%' + setTimeout( + () => { + this.setState(newState) + }, + import.meta.env.PROD ? Math.max(200, 2000 - timeSinceMount) : 0 + ) setInterval(async () => { if (!(await refreshToken())) this.props.redirectToAuthentication() @@ -180,11 +166,7 @@ class ProtectedPageComponent extends React.Component { } renderLoadingScreen() { - return ( - - - - ) + return } conditionalRenderUponSecuredState() { diff --git a/packages/components/src/LoadingBar/LoadingBar.tsx b/packages/components/src/LoadingBar/LoadingBar.tsx new file mode 100644 index 00000000000..6f9e09f9e51 --- /dev/null +++ b/packages/components/src/LoadingBar/LoadingBar.tsx @@ -0,0 +1,66 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ +import { Text } from '../Text' +import React from 'react' +import styled, { keyframes } from 'styled-components' + +const ProgressBackground = styled.div` + background: ${({ theme }) => theme.colors.grey100}; + height: 100vh; + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +` + +const ProgressBar = styled.div` + width: 276px; + height: 8px; + margin-top: 27px; + border-radius: 100px; + opacity: 0px; + background: ${({ theme }) => theme.colors.grey300}; +` + +const ProgressAnimation = keyframes` + 0% { min-width: 5%; } + 1% { min-width: 20%; } + 2% { min-width: 40%; } + 10% { min-width: 60%; } + 50% { min-width: 80%; } + 100% { min-width: 90%; } + ` +const Progress = styled.div` + width: 0; + height: 8px; + gap: 0px; + border-radius: 100px; + opacity: 0px; + background: ${({ theme }) => theme.colors.blueDark}; + animation: ${ProgressAnimation} 300s ease; +` +export const LoadingBar = () => ( + + OpenCRVS Logo + + + + + Loading records... + + +) diff --git a/packages/components/src/LoadingBar/index.ts b/packages/components/src/LoadingBar/index.ts new file mode 100644 index 00000000000..89af8652e18 --- /dev/null +++ b/packages/components/src/LoadingBar/index.ts @@ -0,0 +1,11 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * + * OpenCRVS is also distributed under the terms of the Civil Registration + * & Healthcare Disclaimer located at http://opencrvs.org/license. + * + * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. + */ +export * from './LoadingBar' diff --git a/packages/components/src/index.ts b/packages/components/src/index.ts index 445ce514067..e8be3cd7af5 100644 --- a/packages/components/src/index.ts +++ b/packages/components/src/index.ts @@ -46,6 +46,7 @@ export * from './ListReview' export * from './ListUser' export * from './ListViewSimplified' export * from './Loader' +export * from './LoadingBar' export * from './LoadingGrey' export * from './LocationSearch' export * from './Modal' From a5b6af11e0f1d6608693e095df1b2b7a76a63b0a Mon Sep 17 00:00:00 2001 From: Jamil Date: Fri, 7 Jun 2024 13:06:32 +0600 Subject: [PATCH 038/108] amend: make src of logo global (#7102) chore: update changelog --- CHANGELOG.md | 1 + packages/components/src/LoadingBar/LoadingBar.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49db2688c26..9ccd675b7eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ ## New features - Add loading spinners before JavaScript bundle has loaded for both login and client +- Add loading bar before javaScript bundle has loaded for client and when fetching records [#6641](https://github.com/opencrvs/opencrvs-core/issues/6641) - Support for landscape certificate templates - Allow defining maxLength attribute for number type fields [#6356](https://github.com/opencrvs/opencrvs-core/issues/6356) - Certificate handlebar for registration fees `registrationFees` [#6817](https://github.com/opencrvs/opencrvs-core/issues/6817) diff --git a/packages/components/src/LoadingBar/LoadingBar.tsx b/packages/components/src/LoadingBar/LoadingBar.tsx index 6f9e09f9e51..22a559fd843 100644 --- a/packages/components/src/LoadingBar/LoadingBar.tsx +++ b/packages/components/src/LoadingBar/LoadingBar.tsx @@ -51,7 +51,7 @@ const Progress = styled.div` export const LoadingBar = () => ( OpenCRVS Logo Date: Thu, 13 Jun 2024 11:57:50 +0600 Subject: [PATCH 039/108] added missing 'requesterOther' params in client queries --- packages/client/src/utils/gateway.ts | 4 ++++ packages/client/src/views/DataProvider/death/queries.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/client/src/utils/gateway.ts b/packages/client/src/utils/gateway.ts index 3ab96d5f388..04fe091d432 100644 --- a/packages/client/src/utils/gateway.ts +++ b/packages/client/src/utils/gateway.ts @@ -4516,6 +4516,7 @@ export type FetchDeathRegistrationForReviewQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null hasShowedVerifiedDocument?: boolean | null noSupportingDocumentationRequired?: boolean | null date?: any | null @@ -4843,6 +4844,7 @@ export type FetchDeathRegistrationForCertificationQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null date?: any | null action?: RegAction | null regStatus?: RegStatus | null @@ -5244,6 +5246,7 @@ export type FetchMarriageRegistrationForReviewQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null hasShowedVerifiedDocument?: boolean | null noSupportingDocumentationRequired?: boolean | null date?: any | null @@ -5603,6 +5606,7 @@ export type FetchMarriageRegistrationForCertificateQuery = { __typename?: 'History' otherReason?: string | null requester?: string | null + requesterOther?: string | null hasShowedVerifiedDocument?: boolean | null date?: any | null action?: RegAction | null diff --git a/packages/client/src/views/DataProvider/death/queries.ts b/packages/client/src/views/DataProvider/death/queries.ts index 9f742134b88..0315d6b98bd 100644 --- a/packages/client/src/views/DataProvider/death/queries.ts +++ b/packages/client/src/views/DataProvider/death/queries.ts @@ -287,6 +287,7 @@ export const GET_DEATH_REGISTRATION_FOR_REVIEW = gql` } otherReason requester + requesterOther hasShowedVerifiedDocument noSupportingDocumentationRequired date @@ -555,6 +556,7 @@ export const GET_DEATH_REGISTRATION_FOR_CERTIFICATION = gql` history { otherReason requester + requesterOther date action regStatus From 12e86aa484c89cc52bdabf04a1ec5f5dd68d196f Mon Sep 17 00:00:00 2001 From: Tareq Date: Mon, 10 Jun 2024 20:21:50 +0600 Subject: [PATCH 040/108] removed 'declarationJurisdictionId' while calculating AdvancedSearchForm validity --- packages/client/src/views/SearchResult/AdvancedSearch.tsx | 4 +++- packages/components/src/SearchTool/SearchTool.tsx | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/client/src/views/SearchResult/AdvancedSearch.tsx b/packages/client/src/views/SearchResult/AdvancedSearch.tsx index df6572dd29d..21beee054eb 100644 --- a/packages/client/src/views/SearchResult/AdvancedSearch.tsx +++ b/packages/client/src/views/SearchResult/AdvancedSearch.tsx @@ -80,7 +80,9 @@ const dateFieldTypes = [ export const isAdvancedSearchFormValid = (value: IBaseAdvancedSearchState) => { const validNonDateFields = Object.keys(value).filter( (key) => - !['event', 'eventLocationType'].includes(key) && + !['event', 'eventLocationType', 'declarationJurisdictionId'].includes( + key + ) && !dateFieldTypes.includes(key) && Boolean(value[key as keyof IBaseAdvancedSearchState]) ) diff --git a/packages/components/src/SearchTool/SearchTool.tsx b/packages/components/src/SearchTool/SearchTool.tsx index f42a7c0cf11..c8dce6b53a0 100644 --- a/packages/components/src/SearchTool/SearchTool.tsx +++ b/packages/components/src/SearchTool/SearchTool.tsx @@ -274,10 +274,9 @@ export class SearchTool extends React.Component { })} {this.props.navigationList?.map((item) => { return ( - + From 625f13239229a35c689244214a0c5ff6c77e2d5b Mon Sep 17 00:00:00 2001 From: Tareq Date: Fri, 31 May 2024 17:56:46 +0600 Subject: [PATCH 044/108] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e22e64064c..400df9e4eb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ - Fix "Print and issue to groom|bride" is added to a different variable [#7046](https://github.com/opencrvs/opencrvs-core/issues/7046) - Fix removed duplicateTrackingId check in createDuplicateTask method [#7024](https://github.com/opencrvs/opencrvs-core/issues/7024) - Fix address property handling and corrected country data transformation logic [#6989](https://github.com/opencrvs/opencrvs-core/issues/6989) +- Fix client modal glitches on integrations page [#7002] (https://github.com/opencrvs/opencrvs-core/issues/7002) ## Refactor From 8d696f001b4525d37b01d521b3365e74f9780afc Mon Sep 17 00:00:00 2001 From: Tareq Date: Fri, 21 Jun 2024 14:21:28 +0600 Subject: [PATCH 045/108] Fix "Print and issue to groom|bride" is added to a different variable --- .../certificate/fieldDefinitions/collectorSection.ts | 8 ++++---- packages/client/src/i18n/messages/form.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts b/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts index 328906fdc0a..d306f3df5be 100644 --- a/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts +++ b/packages/client/src/forms/certificate/fieldDefinitions/collectorSection.ts @@ -623,8 +623,8 @@ export const collectMarriageCertificateFormSection: IFormSection = { ) ], options: [ - { value: 'BRIDE', label: formMessages.brideName }, - { value: 'GROOM', label: formMessages.groomName }, + { value: 'BRIDE', label: formMessages.certifyRecordToBride }, + { value: 'GROOM', label: formMessages.certifyRecordToGroom }, { value: 'OTHER', label: formMessages.someoneElseCollector }, { value: 'PRINT_IN_ADVANCE', @@ -997,8 +997,8 @@ const birthCertCollectorOptions = [ ] const marriageCertCollectorOptions = [ - { value: 'BRIDE', label: formMessages.brideName }, - { value: 'GROOM', label: formMessages.groomName } + { value: 'BRIDE', label: formMessages.certifyRecordToBride }, + { value: 'GROOM', label: formMessages.certifyRecordToGroom } ] const birthIssueCollectorFormOptions = [ diff --git a/packages/client/src/i18n/messages/form.ts b/packages/client/src/i18n/messages/form.ts index dbed7f96ac8..deb82eb168c 100644 --- a/packages/client/src/i18n/messages/form.ts +++ b/packages/client/src/i18n/messages/form.ts @@ -222,6 +222,16 @@ export const formMessageDescriptors = { description: 'Label for father select option to certify record', id: 'form.field.label.app.certifyRecordTo.father' }, + certifyRecordToGroom: { + defaultMessage: 'Print and issue to groom', + description: 'Label for groom select option to certify record', + id: 'form.field.label.app.certifyRecordTo.groom' + }, + certifyRecordToBride: { + defaultMessage: 'Print and issue to bride', + description: 'Label for bride select option to certify record', + id: 'form.field.label.app.certifyRecordTo.bride' + }, typeOfId: { defaultMessage: 'Type of ID', description: "Input label for certificate collector's id type options", From 8e6b5c84500c4f300869ce17fbde368d42ea51f7 Mon Sep 17 00:00:00 2001 From: Tareq Date: Thu, 30 May 2024 16:34:56 +0600 Subject: [PATCH 046/108] groom and bride default name fix --- packages/client/src/i18n/messages/form.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/src/i18n/messages/form.ts b/packages/client/src/i18n/messages/form.ts index deb82eb168c..f454c5a3545 100644 --- a/packages/client/src/i18n/messages/form.ts +++ b/packages/client/src/i18n/messages/form.ts @@ -268,12 +268,12 @@ export const formMessageDescriptors = { id: 'form.field.label.informantsRelationWithDeceased' }, brideName: { - defaultMessage: 'Print and issue to bride', + defaultMessage: 'Bride', description: 'Form section name for Bride', id: 'form.section.bride.name' }, groomName: { - defaultMessage: 'Print and issue to groom', + defaultMessage: 'Groom', description: 'Form section name for Groom', id: 'form.section.groom.name' }, From 0cf8e800bfa375cb2ca41427dd6bfcea3f4bf203 Mon Sep 17 00:00:00 2001 From: Tareq Date: Wed, 19 Jun 2024 18:36:49 +0600 Subject: [PATCH 047/108] removed 'declarationJurisdictionId' from IAdvancedSearchFormState --- .../src/components/form/FormFieldGenerator.tsx | 4 ++-- .../client/src/search/advancedSearch/utils.ts | 10 ++++------ .../src/views/SearchResult/AdvancedSearch.tsx | 18 ++++++++---------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/client/src/components/form/FormFieldGenerator.tsx b/packages/client/src/components/form/FormFieldGenerator.tsx index 4233683397d..37477cb7c8c 100644 --- a/packages/client/src/components/form/FormFieldGenerator.tsx +++ b/packages/client/src/components/form/FormFieldGenerator.tsx @@ -123,7 +123,7 @@ import { generateLocations } from '@client/utils/locationUtils' import { getUserDetails } from '@client/profile/profileSelectors' import { buttonMessages } from '@client/i18n/messages/buttons' import { DateRangePickerForFormField } from '@client/components/DateRangePickerForFormField' -import { IBaseAdvancedSearchState } from '@client/search/advancedSearch/utils' +import { IAdvancedSearchFormState } from '@client/search/advancedSearch/utils' import { UserDetails } from '@client/utils/userUtils' import { VerificationButton } from '@opencrvs/components/lib/VerificationButton' import { useOnlineStatus } from '@client/utils' @@ -713,7 +713,7 @@ interface IFormSectionProps { onSetTouched?: (func: ISetTouchedFunction) => void requiredErrorMessage?: MessageDescriptor onUploadingStateChanged?: (isUploading: boolean) => void - initialValues?: IBaseAdvancedSearchState + initialValues?: IAdvancedSearchFormState } interface IStateProps { diff --git a/packages/client/src/search/advancedSearch/utils.ts b/packages/client/src/search/advancedSearch/utils.ts index 691411fecf6..a6d13c55ae8 100644 --- a/packages/client/src/search/advancedSearch/utils.ts +++ b/packages/client/src/search/advancedSearch/utils.ts @@ -60,7 +60,6 @@ const baseKeysSameAsStore = [ 'registrationNumber', 'trackingId', 'declarationLocationId', - 'declarationJurisdictionId', 'eventCountry', 'eventLocationId', 'eventLocationLevel1', @@ -82,7 +81,7 @@ const baseKeysSameAsStore = [ 'informantFamilyName' ] as const -export interface IBaseAdvancedSearchState { +export interface IAdvancedSearchFormState { event?: string registrationStatuses?: string dateOfEvent?: IDateRangePickerValue @@ -95,7 +94,6 @@ export interface IBaseAdvancedSearchState { dateOfRegistrationEnd?: string placeOfRegistration?: string declarationLocationId?: string - declarationJurisdictionId?: string eventLocationType?: string eventCountry?: string eventLocationId?: string @@ -134,7 +132,7 @@ export interface IBaseAdvancedSearchState { } export const transformAdvancedSearchLocalStateToStoreData = ( - localState: IBaseAdvancedSearchState, + localState: IAdvancedSearchFormState, offlineData: IOfflineData ): IAdvancedSearchParamState => { let transformedStoreState: IAdvancedSearchParamState = @@ -273,8 +271,8 @@ export const transformStoreDataToAdvancedSearchLocalState = ( reduxState: IAdvancedSearchParamState, offlineData: IOfflineData, eventType: string -): IBaseAdvancedSearchState => { - const localState: IBaseAdvancedSearchState = baseKeysSameAsStore.reduce( +): IAdvancedSearchFormState => { + const localState: IAdvancedSearchFormState = baseKeysSameAsStore.reduce( (ac, curr) => { return { ...ac, [curr]: reduxState[curr] } }, diff --git a/packages/client/src/views/SearchResult/AdvancedSearch.tsx b/packages/client/src/views/SearchResult/AdvancedSearch.tsx index 21beee054eb..9b63ce6d388 100644 --- a/packages/client/src/views/SearchResult/AdvancedSearch.tsx +++ b/packages/client/src/views/SearchResult/AdvancedSearch.tsx @@ -35,7 +35,7 @@ import { getOfflineData } from '@client/offline/selectors' import { Accordion } from '@client/../../components/lib/Accordion' import { getAccordionActiveStateMap, - IBaseAdvancedSearchState, + IAdvancedSearchFormState, isValidDateRangePickerValue, transformAdvancedSearchLocalStateToStoreData, transformStoreDataToAdvancedSearchLocalState @@ -77,21 +77,19 @@ const dateFieldTypes = [ 'informantDoB' ] -export const isAdvancedSearchFormValid = (value: IBaseAdvancedSearchState) => { +export const isAdvancedSearchFormValid = (value: IAdvancedSearchFormState) => { const validNonDateFields = Object.keys(value).filter( (key) => - !['event', 'eventLocationType', 'declarationJurisdictionId'].includes( - key - ) && + !['event', 'eventLocationType'].includes(key) && !dateFieldTypes.includes(key) && - Boolean(value[key as keyof IBaseAdvancedSearchState]) + Boolean(value[key as keyof IAdvancedSearchFormState]) ) //handle date fields separately const validDateFields = dateFieldTypes.filter( (key) => - value[key as keyof IBaseAdvancedSearchState] && + value[key as keyof IAdvancedSearchFormState] && isValidDateRangePickerValue( - value[key as keyof IBaseAdvancedSearchState] as IDateRangePickerValue + value[key as keyof IAdvancedSearchFormState] as IDateRangePickerValue ) ) @@ -103,7 +101,7 @@ const BirthSection = () => { const intl = useIntl() const advancedSearchParamsState = useSelector(AdvancedSearchParamsSelector) const offlineData = useSelector(getOfflineData) - const [formState, setFormState] = useState({ + const [formState, setFormState] = useState({ ...transformStoreDataToAdvancedSearchLocalState( advancedSearchParamsState, offlineData, @@ -306,7 +304,7 @@ const DeathSection = () => { const intl = useIntl() const advancedSearchParamsState = useSelector(AdvancedSearchParamsSelector) const offlineData = useSelector(getOfflineData) - const [formState, setFormState] = useState({ + const [formState, setFormState] = useState({ ...transformStoreDataToAdvancedSearchLocalState( advancedSearchParamsState, offlineData, From 9db14b4e5a61ec73f57a111a5844d25742b66ece Mon Sep 17 00:00:00 2001 From: Muhammed Tareq Aziz Date: Thu, 20 Jun 2024 23:31:13 +0600 Subject: [PATCH 048/108] correct import in test file --- packages/client/src/search/advancedSearch/utils.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/src/search/advancedSearch/utils.test.ts b/packages/client/src/search/advancedSearch/utils.test.ts index 0575f287c34..16852aa09aa 100644 --- a/packages/client/src/search/advancedSearch/utils.test.ts +++ b/packages/client/src/search/advancedSearch/utils.test.ts @@ -9,7 +9,7 @@ * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS. */ import { - IBaseAdvancedSearchState, + IAdvancedSearchFormState, transformAdvancedSearchLocalStateToStoreData, transformStoreDataToAdvancedSearchLocalState } from '@client/search/advancedSearch/utils' @@ -17,7 +17,7 @@ import { mockOfflineData } from '@client/tests/mock-offline-data' import { IAdvancedSearchParamState } from '@client/search/advancedSearch/reducer' describe('Transforms advancedSearch local state to advancedSearch store state properly', () => { - const mockLocalState: IBaseAdvancedSearchState = { + const mockLocalState: IAdvancedSearchFormState = { event: 'birth', registrationStatuses: 'IN_REVIEW', eventCountry: 'FAR', From f660cbc81617d454445b6c4cb65a76219b6a94ac Mon Sep 17 00:00:00 2001 From: Tareq Date: Fri, 21 Jun 2024 15:30:12 +0600 Subject: [PATCH 049/108] DuplicateForm test code updated - the change now ensures that duplicate tracking id and reason both are populated in order to duplicate a declaration --- .../views/RegisterForm/duplicate/DuplicateForm.test.tsx | 8 +++++++- .../src/views/RegisterForm/duplicate/DuplicateForm.tsx | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx index 0170af08e5e..aae94005d82 100644 --- a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx +++ b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.test.tsx @@ -107,13 +107,19 @@ describe('when in device of large viewport', () => { .props().disabled ).toBeTruthy() }) - it('enable the duplicate button on modal when select duplicate Id', async () => { + it('enable the duplicate button on modal when select duplicate Id and describe-reason has valu', async () => { duplicateFormComponent .find('#mark-as-duplicate') .hostNodes() .first() .simulate('click') selectOption(duplicateFormComponent, '#selectTrackingId', 'BK7VQ0U') + duplicateFormComponent + .find(`#describe-reason`) + .hostNodes() + .simulate('change', { + target: { id: `#describe-reason`, value: 'Duplicate' } + }) expect( duplicateFormComponent .find('#mark-as-duplicate-button') diff --git a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx index 77ea5985dc9..3a2d4f80e67 100644 --- a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx +++ b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx @@ -178,7 +178,7 @@ export const DuplicateForm = (props: IProps) => { dispatch(goToHome()) } }} - disabled={!Boolean(selectedTrackingId) || !Boolean(comment)} + disabled={!(Boolean(selectedTrackingId) && Boolean(comment))} > {intl.formatMessage(duplicateMessages.markAsDuplicateButton)} @@ -203,11 +203,12 @@ export const DuplicateForm = (props: IProps) => { label: id.trackingId }))} /> - + {intl.formatMessage(duplicateMessages.markAsDuplicateReason)} Date: Fri, 21 Jun 2024 16:32:12 +0600 Subject: [PATCH 050/108] fix(v1.5.0): missing heading in mobile view for duplicate (#7217) * Placeholder commit for PR #7210 * fix: missing heading in mobile view for duplicate Co-authored-by: Jamil --- .../client/src/views/RegisterForm/duplicate/DuplicateForm.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx index 5f157495398..9174160bb65 100644 --- a/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx +++ b/packages/client/src/views/RegisterForm/duplicate/DuplicateForm.tsx @@ -135,6 +135,7 @@ export const DuplicateForm = (props: IProps) => { name: getName(), trackingId: String(data.registration.trackingId) })} + showTitleOnMobile={true} subtitle={intl.formatMessage( duplicateMessages.duplicateContentSubtitle, { From 1fa41b87984767edf8aef0a4f6df7377210c171a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 16:32:59 +0600 Subject: [PATCH 051/108] fix(v1.5.0): amend date of certification for verifying certificate (#7218) * fix: show certified date in qr code verification page * chore: add comment for last certfied date * fix: amend certificate time extraction logic * fix: update certified at message id --------- Co-authored-by: Md. Ashikul Alam --- .../i18n/messages/views/verifyCertificate.ts | 6 +++--- .../VerifyCertificatePage.tsx | 18 ++++++++++++++++-- .../useVerificationRecordDetails.ts | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/packages/client/src/i18n/messages/views/verifyCertificate.ts b/packages/client/src/i18n/messages/views/verifyCertificate.ts index 3bf07583c0d..031cc323c78 100644 --- a/packages/client/src/i18n/messages/views/verifyCertificate.ts +++ b/packages/client/src/i18n/messages/views/verifyCertificate.ts @@ -29,7 +29,7 @@ interface IVerifyCertificateMessages registar: MessageDescriptor brn: MessageDescriptor drn: MessageDescriptor - createdAt: MessageDescriptor + certifiedAt: MessageDescriptor toastMessage: MessageDescriptor } @@ -110,8 +110,8 @@ const messagesToDefine: IVerifyCertificateMessages = { defaultMessage: 'Name of registar', description: 'Label for name of registar center' }, - createdAt: { - id: 'verifyCertificate.createdAt', + certifiedAt: { + id: 'verifyCertificate.certifiedAt', defaultMessage: 'Date of certification', description: 'Label for date of certification' }, diff --git a/packages/client/src/views/VerifyCertificate/VerifyCertificatePage.tsx b/packages/client/src/views/VerifyCertificate/VerifyCertificatePage.tsx index fd5afffc9ee..19e3207caa7 100644 --- a/packages/client/src/views/VerifyCertificate/VerifyCertificatePage.tsx +++ b/packages/client/src/views/VerifyCertificate/VerifyCertificatePage.tsx @@ -49,6 +49,7 @@ import { EMPTY_STRING } from '@client/utils/constants' import { compact } from 'lodash' import { useVerificationRecordDetails } from './useVerificationRecordDetails' import { generateFullAddress } from '@client/utils/locationUtils' +import { SUBMISSION_STATUS } from '@client/declarations' const Container = styled.div<{ size: string; checking: boolean }>` position: relative; @@ -244,6 +245,16 @@ export function VerifyCertificatePage() { if (isDeathRegistration(data)) return data.deceased?.gender } + const getLastCertifiedDate = (data: RecordDetails) => { + // find first certified action from history sorted in ascending order by time + return ( + data.history && + data.history.find( + (item) => item?.regStatus?.toString() === SUBMISSION_STATUS.CERTIFIED + ) + )?.date + } + // This function currently supports upto two location levels const getLocation = (data: RecordDetails) => { const location = data.eventLocation @@ -466,12 +477,15 @@ export function VerifyCertificatePage() { - {intl.formatMessage(messageToDefine.createdAt)} + {intl.formatMessage(messageToDefine.certifiedAt)} } value={ - {formatDate(new Date(data.createdAt), 'dd MMMM yyyy')} + {formatDate( + new Date(getLastCertifiedDate(data)), + 'dd MMMM yyyy' + )} } /> diff --git a/packages/client/src/views/VerifyCertificate/useVerificationRecordDetails.ts b/packages/client/src/views/VerifyCertificate/useVerificationRecordDetails.ts index 251971838f9..eeb211f80c6 100644 --- a/packages/client/src/views/VerifyCertificate/useVerificationRecordDetails.ts +++ b/packages/client/src/views/VerifyCertificate/useVerificationRecordDetails.ts @@ -48,6 +48,7 @@ const FETCH_RECORD_DETAILS_FOR_VERIFICATION = gql` history { action regStatus + date user { name { firstNames From ac7ca00f3b7eacc212d54e23e9d11171c4feb0a0 Mon Sep 17 00:00:00 2001 From: Jamil Date: Fri, 21 Jun 2024 17:53:36 +0600 Subject: [PATCH 052/108] fix: made `completenessRate` a number before sorting (#7221) --- .../completenessRates/CompletenessDataTable.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/client/src/views/SysAdmin/Performance/reports/completenessRates/CompletenessDataTable.tsx b/packages/client/src/views/SysAdmin/Performance/reports/completenessRates/CompletenessDataTable.tsx index ffc9f55d7d6..84e582f4c6e 100644 --- a/packages/client/src/views/SysAdmin/Performance/reports/completenessRates/CompletenessDataTable.tsx +++ b/packages/client/src/views/SysAdmin/Performance/reports/completenessRates/CompletenessDataTable.tsx @@ -101,9 +101,8 @@ function CompletenessDataTableComponent(props: ITableProps) { ? item.estimated.toFixed(2) : Math.round(item.estimated) ), - completenessRate: `${Number( + completenessRate: (item[props.completenessRateTime] / item.estimated) * 100 - ).toFixed(2)}%` })) return locationContent @@ -126,9 +125,8 @@ function CompletenessDataTableComponent(props: ITableProps) { ? item.estimated.toFixed(2) : Math.round(item.estimated) ), - completenessRate: `${Number( + completenessRate: (item[props.completenessRateTime] / item.estimated) * 100 - ).toFixed(2)}%` })) return timeContent @@ -158,7 +156,12 @@ function CompletenessDataTableComponent(props: ITableProps) { content, sortOrder.map(({ key }) => key), sortOrder.map(({ value }) => value) - ) + ).map((item) => { + return { + ...item, + completenessRate: item.completenessRate.toFixed(2) + '%' + } + }) const firstColProp = base.baseType === COMPLETENESS_RATE_REPORT_BASE.LOCATION From 874f2c59daad1fa1d588aa11516e8038e2a73d21 Mon Sep 17 00:00:00 2001 From: jamil314 Date: Wed, 19 Jun 2024 19:59:00 +0600 Subject: [PATCH 053/108] feat: added `Correction requested` option to advance search dropdown --- .../src/forms/advancedSearch/fieldDefinitions/Birth.ts | 4 ++++ .../client/src/i18n/messages/views/advancedSearchForm.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/client/src/forms/advancedSearch/fieldDefinitions/Birth.ts b/packages/client/src/forms/advancedSearch/fieldDefinitions/Birth.ts index 4eb3bf37728..d7ecb69d184 100644 --- a/packages/client/src/forms/advancedSearch/fieldDefinitions/Birth.ts +++ b/packages/client/src/forms/advancedSearch/fieldDefinitions/Birth.ts @@ -74,6 +74,10 @@ export const advancedSearchBirthSectionRegistrationDetails: IFormSectionGroup = { value: 'ARCHIVED', label: advancedSearchForm.recordStatusAchived + }, + { + value: 'CORRECTION_REQUESTED', + label: advancedSearchForm.recordStatusCorrectionRequested } ] } diff --git a/packages/client/src/i18n/messages/views/advancedSearchForm.ts b/packages/client/src/i18n/messages/views/advancedSearchForm.ts index 386a88cd6c4..9b13ad49e96 100644 --- a/packages/client/src/i18n/messages/views/advancedSearchForm.ts +++ b/packages/client/src/i18n/messages/views/advancedSearchForm.ts @@ -30,6 +30,7 @@ interface IAdvancedSearchMessages recordStatusRegistered: MessageDescriptor recordStatusCertified: MessageDescriptor recordStatusAchived: MessageDescriptor + recordStatusCorrectionRequested: MessageDescriptor show: MessageDescriptor hide: MessageDescriptor } @@ -125,6 +126,11 @@ const messagesToDefine: IAdvancedSearchMessages = { description: 'Option for form field: status of record', id: 'advancedSearch.form.recordStatusAchived' }, + recordStatusCorrectionRequested: { + defaultMessage: 'Correction requested', + description: 'Option for form field: status of record', + id: 'advancedSearch.form.recordStatusCorrectionRequested' + }, hide: { defaultMessage: 'Hide', description: 'Label for hide button when accordion is closed', From b40daa7892d2f8859097db6ea88d4d96526b305b Mon Sep 17 00:00:00 2001 From: jamil314 Date: Thu, 20 Jun 2024 10:38:33 +0600 Subject: [PATCH 054/108] amend: add `correction requested` in `death` --- .../client/src/forms/advancedSearch/fieldDefinitions/Death.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/client/src/forms/advancedSearch/fieldDefinitions/Death.ts b/packages/client/src/forms/advancedSearch/fieldDefinitions/Death.ts index ac0b8936201..d2fca692f7d 100644 --- a/packages/client/src/forms/advancedSearch/fieldDefinitions/Death.ts +++ b/packages/client/src/forms/advancedSearch/fieldDefinitions/Death.ts @@ -74,6 +74,10 @@ export const advancedSearchDeathSectionRegistrationDetails: IFormSectionGroup = { value: 'ARCHIVED', label: advancedSearchForm.recordStatusAchived + }, + { + value: 'CORRECTION_REQUESTED', + label: advancedSearchForm.recordStatusCorrectionRequested } ] } From 3b32499c3736dded25624c14eef0ac15f522361e Mon Sep 17 00:00:00 2001 From: Tareq Date: Fri, 21 Jun 2024 18:12:27 +0600 Subject: [PATCH 055/108] ITextAreaProps updated in TextArea element --- .../client/src/components/form/FormFieldGenerator.tsx | 1 + .../src/views/RegisterForm/duplicate/DuplicateForm.tsx | 4 +++- .../src/views/RegisterForm/review/ReviewSection.tsx | 9 ++++----- .../Communications/AllUserEmail/AllUserEmail.tsx | 2 +- packages/components/src/TextArea/TextArea.tsx | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/client/src/components/form/FormFieldGenerator.tsx b/packages/client/src/components/form/FormFieldGenerator.tsx index 37477cb7c8c..0588937baf8 100644 --- a/packages/client/src/components/form/FormFieldGenerator.tsx +++ b/packages/client/src/components/form/FormFieldGenerator.tsx @@ -448,6 +448,7 @@ const GeneratedInputField = React.memo(