Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function Pages() {
pageId={currentPageId}
setFormData={(data) => setFormValues(data)}
showReviewButton={searchParams.from === 'review'}
validatorContext={validatorContext}
validatorContext={{ ...validatorContext, event }}
onPageChange={(nextPageId: string) =>
navigate(
ROUTES.V2.EVENTS.DECLARE.PAGES.buildPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function Review() {
formConfig={formConfig}
reviewFields={reviewConfig.fields}
title={formatMessage(reviewConfig.title, form)}
validatorContext={validatorContext}
validatorContext={{ ...validatorContext, event }}
onAnnotationChange={(values) => setAnnotation(values)}
onEdit={handleEdit}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function Pages() {
pageId={currentPageId}
setFormData={(data) => setFormValues(data)}
showReviewButton={searchParams.from === 'review'}
validatorContext={validatorContext}
validatorContext={{ ...validatorContext, event }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed if you already are passing event in useValidatorContext, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, good catch, thanks @pankaj-pant ! forgot to update this, I will do it

onPageChange={(nextPageId: string) =>
navigate(
ROUTES.V2.EVENTS.REGISTER.PAGES.buildPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export function Review() {
previousFormValues={previousFormValues}
reviewFields={reviewConfig.fields}
title={formatMessage(reviewConfig.title, form)}
validatorContext={validatorContext}
validatorContext={{ ...validatorContext, event }}
onAnnotationChange={(values) => setAnnotation(values)}
onEdit={handleEdit}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function Pages() {
pageId={currentPageId}
setFormData={(data) => setFormValues(data)}
showReviewButton={searchParams.from === 'review'}
validatorContext={validatorContext}
validatorContext={{ ...validatorContext, event }}
onPageChange={(nextPageId: string) =>
navigate(
ROUTES.V2.EVENTS.VALIDATE.PAGES.buildPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export function Review() {
previousFormValues={previousFormValues}
reviewFields={reviewConfig.fields}
title={formatMessage(reviewConfig.title, form)}
validatorContext={validatorContext}
validatorContext={{ ...validatorContext, event }}
onAnnotationChange={(values) => setAnnotation(values)}
onEdit={handleEdit}
>
Expand Down
9 changes: 6 additions & 3 deletions packages/commons/src/conditionals/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { TranslationConfig } from '../events/TranslationConfig'
import { ITokenPayload } from '../authentication'
import { UUID } from '../uuid'
import { ageToDate } from '../events/utils'
import { ActionType } from '../client'
import { ActionType, EventDocument } from '../client'

const ajv = new Ajv({
$data: true,
Expand Down Expand Up @@ -185,7 +185,8 @@ export function isConditionMet(
$now: formatISO(new Date(), { representation: 'date' }),
$online: isOnline(),
$user: context.user,
$leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? []
$leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
$event: context.event
})
}

Expand Down Expand Up @@ -215,6 +216,7 @@ export function areConditionsMet(
export type ValidatorContext = {
user?: ITokenPayload
leafAdminStructureLocationIds?: Array<{ id: UUID }>
event?: EventDocument
}

function isFieldConditionMet(
Expand All @@ -236,7 +238,8 @@ function isFieldConditionMet(
$now: formatISO(new Date(), { representation: 'date' }),
$online: isOnline(),
$user: context.user,
$leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? []
$leafAdminStructureLocationIds: context.leafAdminStructureLocationIds ?? [],
$event: context.event
})

return validConditionals.includes(conditionalType)
Expand Down
2 changes: 1 addition & 1 deletion packages/events/src/router/middleware/validate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export const validateAction: MiddlewareFunction<
token: ctx.token
})

const context = await getValidatorContext(ctx.token)
const context = { ...(await getValidatorContext(ctx.token)), event }

const declaration = getCurrentEventState(event, eventConfig).declaration

Expand Down
Loading