Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
9d77d8a
fix: pass event document to conditionals
tahmidrahman-dsi Nov 17, 2025
7fc3c6a
chore: also pass event in validate action middleware
tahmidrahman-dsi Nov 18, 2025
8545e01
fix: make changes to all possible required places
tahmidrahman-dsi Nov 18, 2025
59c72b6
chore: add tests for alpha-print-button that shows hasAction conditional
tahmidrahman-dsi Nov 18, 2025
053d0b8
chore: update CHANGELOG.md
tahmidrahman-dsi Nov 18, 2025
3b42e45
fix: update implementations
tahmidrahman-dsi Nov 19, 2025
4fadb77
fix: pass event in action procedure
tahmidrahman-dsi Nov 19, 2025
9d9fe10
chore: update CHANGELOG.md to link the corresponding issue
tahmidrahman-dsi Nov 19, 2025
48b4220
Merge branch 'release-v1.9.2' into fix/pass-event-document-to-conditi…
tahmidrahman-dsi Nov 26, 2025
956ed84
chore(wip): tests
tahmidrahman-dsi Nov 26, 2025
48fd3be
refactor: get story parameters from conditional and validation context
tahmidrahman-dsi Nov 27, 2025
980cd23
Merge branch 'release-v1.9.2' into fix/pass-event-document-to-conditi…
tahmidrahman-dsi Nov 28, 2025
9ff1f00
Merge branch 'release-v1.9.2' into fix/pass-event-document-to-conditi…
tahmidrahman-dsi Dec 9, 2025
8dd497b
Merge branch 'release-v1.9.3' into fix/pass-event-document-to-conditi…
tahmidrahman-dsi Dec 9, 2025
74571ab
Merge branch 'release-v1.9.3' into fix/pass-event-document-to-conditi…
tahmidrahman-dsi Dec 12, 2025
b3808bc
update CHANGELOG.md
tahmidrahman-dsi Dec 12, 2025
14bd875
Merge branch 'release-v1.9.3' into fix/pass-event-document-to-conditi…
tahmidrahman-dsi Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

HTTP input now accepts `field('..')` references in the HTTP body definition.

## 1.9.2

### Bug fixes

- Fixes an issue where `event.hasAction` was not working in form configurations [#11074](https://github.com/opencrvs/opencrvs-core/issues/11074)

## 1.9.1

### Breaking changes
Expand Down
9 changes: 7 additions & 2 deletions packages/client/.storybook/decorators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import React from 'react'
import type { Decorator } from '@storybook/react'
import {
EventDocument,
getOrThrow,
getTokenPayload,
LocationType,
Expand Down Expand Up @@ -57,7 +58,10 @@ export const withValidatorContext: Decorator = (Story, context) => {
/>
)
}
export function getTestValidatorContext(userRole?: TestUserRole) {
export function getTestValidatorContext(
userRole?: TestUserRole,
event?: EventDocument
) {
let token

if (userRole === TestUserRole.Enum.FIELD_AGENT) {
Expand All @@ -82,6 +86,7 @@ export function getTestValidatorContext(userRole?: TestUserRole) {

return {
user,
leafAdminStructureLocationIds
leafAdminStructureLocationIds,
event
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function ReadonlyView() {
const { eventId } = useTypedParams(ROUTES.V2.EVENTS.DECLARE.REVIEW)
const events = useEvents()
const event = events.getEvent.viewEvent(eventId)
const validatorContext = useValidatorContext()
const validatorContext = useValidatorContext(event)

const maybeAuth = useAuthentication()
const authentication = getOrThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ export function Onboarding() {
const [{ workqueue }] = useTypedSearchParams(
ROUTES.V2.EVENTS.REQUEST_CORRECTION.ONBOARDING
)
const validatorContext = useValidatorContext()

const events = useEvents()
const annotation = useActionAnnotation((state) => state.getAnnotation())
const setAnnotation = useActionAnnotation((state) => state.setAnnotation)

const event = events.getEvent.getFromCache(eventId)
const validatorContext = useValidatorContext(event)

const navigate = useNavigate()
const intl = useIntl()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function getCorrectablePages(formPages: PageConfig[]) {
}

export function Pages() {
const validatorContext = useValidatorContext()
const { eventId, pageId } = useTypedParams(ROUTES.V2.EVENTS.REGISTER.PAGES)
const [searchParams] = useTypedSearchParams(ROUTES.V2.EVENTS.REGISTER.PAGES)
const setFormValues = useEventFormData((state) => state.setFormValues)
Expand All @@ -51,6 +50,7 @@ export function Pages() {
const { modal } = useEventFormNavigation()

const event = events.getEvent.getFromCache(eventId)
const validatorContext = useValidatorContext(event)

const { eventConfiguration: configuration } = useEventConfiguration(
event.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export function Review() {
const intl = useIntl()
const navigate = useNavigate()
const events = useEvents()
const validatorContext = useValidatorContext()

const event = events.getEvent.getFromCache(eventId)
const validatorContext = useValidatorContext(event)

const { eventConfiguration: configuration } = useEventConfiguration(
event.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ export function Summary() {
ROUTES.V2.EVENTS.REQUEST_CORRECTION.SUMMARY
)

const validatorContext = useValidatorContext()
const [showPrompt, setShowPrompt] = React.useState(false)
const eventFormNavigation = useEventFormNavigation()
const navigate = useNavigate()
const intl = useIntl()

const events = useEvents()
const event = events.getEvent.getFromCache(eventId)
const validatorContext = useValidatorContext(event)
const { eventConfiguration } = useEventConfiguration(event.type)
const eventIndex = getCurrentEventState(event, eventConfiguration)
const togglePrompt = () => setShowPrompt(!showPrompt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export function Review() {
const { eventId } = useTypedParams(ROUTES.V2.EVENTS.REVIEW_CORRECTION.REVIEW)
const events = useEvents()

const validatorContext = useValidatorContext()
const event = events.getEvent.getFromCache(eventId)
const validatorContext = useValidatorContext(event)

const { eventConfiguration: configuration } = useEventConfiguration(
event.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function Pages() {
const { saveAndExitModal, handleSaveAndExit } = useSaveAndExitModal()
const { getFormValues, setFormValues } = useEventFormData()
const formValues = getFormValues()
const validatorContext = useValidatorContext()
const event = events.getEvent.getFromCache(eventId)
const validatorContext = useValidatorContext(event)

const { eventConfiguration: configuration } = useEventConfiguration(
event.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ export function Review() {
const drafts = useDrafts()
const navigate = useNavigate()

const validatorContext = useValidatorContext()
const [modal, openModal] = useModal()
const { formatMessage } = useIntlFormatMessageWithFlattenedParams()
const { closeActionView } = useEventFormNavigation()
const { saveAndExitModal, handleSaveAndExit } = useSaveAndExitModal()

const event = events.getEvent.getFromCache(eventId)
const validatorContext = useValidatorContext(event)

const { eventConfiguration: config } = useEventConfiguration(event.type)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import styled from 'styled-components'
import { useIntl } from 'react-intl'
import {
DeclarationFormConfig,
EventDocument,
EventIndex,
EventState,
FieldConfig,
Expand Down Expand Up @@ -115,24 +116,31 @@ function UserFullName({ userId }: { userId: string }) {

export function DuplicateComparison({
originalEvent,
potentialDuplicateEvent
potentialDuplicateEvent,
originalEventState,
potentialDuplicateEventState
}: {
originalEvent: EventIndex
potentialDuplicateEvent: EventIndex
originalEvent: EventDocument
potentialDuplicateEvent: EventDocument
originalEventState: EventIndex
potentialDuplicateEventState: EventIndex
}) {
const intl = useIntl()
const validatorContext = useValidatorContext()
const validatorContextOfOriginalEvent = useValidatorContext(originalEvent)
const validatorContextOfPotentialDuplicateEvent = useValidatorContext(
potentialDuplicateEvent
)

const flattenedIntl = useIntlFormatMessageWithFlattenedParams()
const { eventConfiguration } = useEventConfiguration(originalEvent.type)
const { eventConfiguration } = useEventConfiguration(originalEventState.type)

const flattenedPotentialDuplicateEvent = flattenEventIndex(
potentialDuplicateEvent
potentialDuplicateEventState
)
const flattenedOriginalEvent = flattenEventIndex(originalEvent)
const flattenedOriginalEvent = flattenEventIndex(originalEventState)

const originalDeclaration = originalEvent.declaration
const potentialDuplicateDeclaration = potentialDuplicateEvent.declaration
const originalDeclaration = originalEventState.declaration
const potentialDuplicateDeclaration = potentialDuplicateEventState.declaration

const hideFieldTypes = [
...FieldTypesToHideInReview,
Expand All @@ -144,8 +152,16 @@ export function DuplicateComparison({
eventConfiguration.declaration.pages
.filter(
(page) =>
isPageVisible(page, originalDeclaration, validatorContext) ||
isPageVisible(page, potentialDuplicateDeclaration, validatorContext)
isPageVisible(
page,
originalDeclaration,
validatorContextOfOriginalEvent
) ||
isPageVisible(
page,
potentialDuplicateDeclaration,
validatorContextOfPotentialDuplicateEvent
)
)
.map((page) => ({
title: intl.formatMessage(page.title),
Expand All @@ -155,12 +171,12 @@ export function DuplicateComparison({
isFieldDisplayedOnReview(
field,
originalDeclaration,
validatorContext
validatorContextOfOriginalEvent
) ||
isFieldDisplayedOnReview(
field,
potentialDuplicateDeclaration,
validatorContext
validatorContextOfPotentialDuplicateEvent
)
)
.filter(
Expand Down Expand Up @@ -209,10 +225,10 @@ export function DuplicateComparison({
{
label: intl.formatMessage(summaryMessages.status.label),
rightValue: flattenedIntl.formatMessage(summaryMessages.status.value, {
'event.status': potentialDuplicateEvent.status
'event.status': potentialDuplicateEventState.status
}),
leftValue: flattenedIntl.formatMessage(summaryMessages.status.value, {
'event.status': originalEvent.status
'event.status': originalEventState.status
})
},
{
Expand All @@ -225,13 +241,13 @@ export function DuplicateComparison({
rightValue: flattenedIntl.formatMessage(
summaryMessages.trackingId.value,
{
'event.trackingId': potentialDuplicateEvent.trackingId
'event.trackingId': potentialDuplicateEventState.trackingId
}
),
leftValue: flattenedIntl.formatMessage(
summaryMessages.trackingId.value,
{
'event.trackingId': originalEvent.trackingId
'event.trackingId': originalEventState.trackingId
}
)
},
Expand Down Expand Up @@ -286,10 +302,10 @@ export function DuplicateComparison({
{
actualTrackingId: (
<Text color="negative" element="span" variant="bold18">
{originalEvent.trackingId}
{originalEventState.trackingId}
</Text>
),
duplicateTrackingId: potentialDuplicateEvent.trackingId
duplicateTrackingId: potentialDuplicateEventState.trackingId
}
)}
>
Expand All @@ -303,16 +319,16 @@ export function DuplicateComparison({
<ComparisonListView
key={`comparison-${index}`}
headings={[
originalEvent.trackingId,
potentialDuplicateEvent.trackingId
originalEventState.trackingId,
potentialDuplicateEventState.trackingId
]}
>
{sections.data.map((item, id) => (
<ComparisonListView.Row
key={`row-${id}`}
heading={{
right: potentialDuplicateEvent.trackingId,
left: originalEvent.trackingId
right: potentialDuplicateEventState.trackingId,
left: originalEventState.trackingId
}}
label={
<Text color="grey600" element="span" variant="bold16">
Expand Down Expand Up @@ -355,7 +371,7 @@ export function DuplicateComparison({
<SupportingDocumentWrapper gap={25} justifyContent={'space-between'}>
<div style={{ flex: 1 }}>
<Text color="redDark" element="p" variant="bold14">
{originalEvent.trackingId}
{originalEventState.trackingId}
</Text>
<DocumentViewer
comparisonView={true}
Expand All @@ -374,7 +390,7 @@ export function DuplicateComparison({
</div>
<div style={{ flex: 1 }}>
<Text color="grey400" element="p" variant="bold14">
{potentialDuplicateEvent.trackingId}
{potentialDuplicateEventState.trackingId}
</Text>
<DocumentViewer
comparisonView={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import styled from 'styled-components'
import { useNavigate } from 'react-router-dom'
import {
ActionType,
EventDocument,
EventIndex,
getActionReview,
getCurrentEventState,
Expand Down Expand Up @@ -127,12 +128,11 @@ const TopBar = styled.div`
function ReviewDuplicate() {
const { eventId } = useTypedParams(ROUTES.V2.EVENTS.DECLARE.REVIEW)

const validatorContext = useValidatorContext()

const intl = useIntl()
const navigate = useNavigate()
const events = useEvents()
const event = events.getEvent.findFromCache(eventId).data
const validatorContext = useValidatorContext(event)

useEffect(() => {
if (!event) {
Expand All @@ -157,15 +157,18 @@ function ReviewDuplicate() {
const eventState = getCurrentEventState(event, configuration)

const potentialDuplicates = eventState.potentialDuplicates.reduce<
Record<string, EventIndex>
Record<string, { eventState: EventIndex; event: EventDocument }>
>((acc, { id, trackingId }) => {
const localEvent = findLocalEventDocument(id)
if (!localEvent) {
throw new Error(
`Event with id ${id} and trackingId ${trackingId} not found in cache.`
)
}
acc[trackingId] = getCurrentEventState(localEvent, configuration)
acc[trackingId] = {
eventState: getCurrentEventState(localEvent, configuration),
event: localEvent
}
return acc
}, {})

Expand Down Expand Up @@ -224,8 +227,12 @@ function ReviewDuplicate() {
</React.Suspense>
) : (
<DuplicateComparison
originalEvent={eventState}
potentialDuplicateEvent={potentialDuplicates[selectedTab]}
originalEvent={event}
originalEventState={eventState}
potentialDuplicateEvent={potentialDuplicates[selectedTab].event}
potentialDuplicateEventState={
potentialDuplicates[selectedTab].eventState
}
/>
)}
</Frame>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function Pages() {
const { eventConfiguration: configuration } = useEventConfiguration(
event.type
)
const validatorContext = useValidatorContext()
const validatorContext = useValidatorContext(event)
const eventIndex = getCurrentEventState(event, configuration)
const certTemplateFieldConfig = useCertificateTemplateSelectorFieldConfig(
event.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export function Review() {

const { getAnnotation } = useActionAnnotation()
const annotation = getAnnotation()
const validatorContext = useValidatorContext()

if (!templateId) {
throw new Error('Please select a template from the previous step')
Expand All @@ -163,8 +162,9 @@ export function Review() {

const { getEvent, onlineActions } = useEvents()
const fullEvent = getEvent.getFromCache(eventId)

const validatorContext = useValidatorContext(fullEvent)
const actions = getAcceptedActions(fullEvent)

const userIds = getUserIdsFromActions(actions, [SystemRole.enum.HEALTH])

const { getUsers } = useUsers()
Expand Down
Loading