Skip to content
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
d92321a
define edit action config
cibelius Dec 8, 2025
b3ced82
progress with ui
cibelius Dec 8, 2025
a6d54d3
add edit action menu
cibelius Dec 10, 2025
23d27d4
progress with action menu
cibelius Dec 10, 2025
26b4093
progress
cibelius Dec 10, 2025
83810e3
remove unused import
cibelius Dec 10, 2025
42fbcce
fix lint issue
cibelius Dec 10, 2025
34be82f
fix test
cibelius Dec 10, 2025
bd3ed9b
fix lint issue
cibelius Dec 10, 2025
470fe7d
remove unused export
cibelius Dec 10, 2025
f164ff4
refactor
cibelius Dec 10, 2025
f90e744
Merge remote-tracking branch 'origin/develop' into ocrvs-10939
cibelius Dec 10, 2025
97b77c5
remove console log
cibelius Dec 10, 2025
2cc3694
fix role
cibelius Dec 10, 2025
5a36167
allow edit only if form has changes and no errors
cibelius Dec 10, 2025
d50cded
fix translation
cibelius Dec 10, 2025
fccf5b5
Merge branch 'develop' into ocrvs-10939
cibelius Dec 10, 2025
c47daf1
fix role
cibelius Dec 10, 2025
f7c9110
dont use update action for edits
cibelius Dec 10, 2025
d06e37a
Merge branch 'develop' into ocrvs-10939
cibelius Dec 10, 2025
7e7b39e
fixes
cibelius Dec 11, 2025
0435866
Merge remote-tracking branch 'origin/develop' into ocrvs-10939
cibelius Dec 11, 2025
f5cc2a4
minor fixes
cibelius Dec 11, 2025
dae3a25
minor refactor
cibelius Dec 11, 2025
5323474
add edit audit details
cibelius Dec 11, 2025
8c66843
fix allowed actions logic
cibelius Dec 11, 2025
f5e3efd
minor fixes
cibelius Dec 11, 2025
a517d3f
fix tests
cibelius Dec 11, 2025
52b1aa5
fix test
cibelius Dec 11, 2025
db5531e
progress with reason input
cibelius Dec 11, 2025
4821380
progress with comments field
cibelius Dec 11, 2025
e90dda1
fix test data
cibelius Dec 12, 2025
7b6c1bd
add comment
cibelius Dec 12, 2025
ddd5238
fix test
cibelius Dec 12, 2025
9a272a2
Merge branch 'develop' into ocrvs-10939
cibelius Dec 12, 2025
80f9454
use edit in rejection flow, improvements
cibelius Dec 12, 2025
5a8c801
storybook test fixes
cibelius Dec 12, 2025
00e49e5
remove console logs
cibelius Dec 12, 2025
59554d7
update test snapshots
cibelius Dec 12, 2025
e5497f7
remove unused export
cibelius Dec 12, 2025
5442550
fix tests
cibelius Dec 12, 2025
d50d0ca
fix tests
cibelius Dec 12, 2025
c800a67
move canDirectlyRegister check to disabling, not hiding
cibelius Dec 12, 2025
8a6a6fe
Merge branch 'develop' into ocrvs-10939
cibelius Dec 13, 2025
41d05a5
remove unnecessary eslint rule
cibelius Dec 13, 2025
14f54c3
refactor
cibelius Dec 13, 2025
0a52d16
refactor
cibelius Dec 15, 2025
5431dac
move omitOverwrittenActions() to getCurrentEventState() level
cibelius Dec 15, 2025
282f6fb
try fix
cibelius Dec 15, 2025
db73c78
Merge remote-tracking branch 'origin/develop' into ocrvs-10939
cibelius Dec 15, 2025
30d641b
fix test
cibelius Dec 15, 2025
4cf6cf0
remove console log
cibelius Dec 15, 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

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions packages/client/src/tests/test-data-generators.ts

Large diffs are not rendered by default.

108 changes: 92 additions & 16 deletions packages/client/src/v2-events/custom-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
ArchiveActionInput,
MarkAsDuplicateActionInput,
ActionStatus,
ValidatorContext
ValidatorContext,
EditActionInput
} from '@opencrvs/commons/client'
import { trpcClient } from '@client/v2-events/trpc'

Expand All @@ -34,6 +35,10 @@ export interface CustomMutationParams {
annotation?: EventState
}

export interface EditRequestParams extends CustomMutationParams {
content: EditActionInput['content']
}

export interface CorrectionRequestParams extends CustomMutationParams {
event: EventDocument
context: ValidatorContext
Expand Down Expand Up @@ -77,21 +82,6 @@ export async function registerOnDeclare({
return declaredEvent
}

// update is a patch, no need to send again.
const validatedEvent = await trpcClient.event.actions.validate.request.mutate(
{
declaration: {},
annotation,
eventId,
transactionId,
keepAssignment: true
}
)

if (hasPotentialDuplicates(validatedEvent, eventConfiguration)) {
return validatedEvent
}

const latestResponse = await trpcClient.event.actions.register.request.mutate(
{
declaration: {},
Expand All @@ -104,6 +94,92 @@ export async function registerOnDeclare({
return latestResponse
}

export async function editAndRegister({
eventId,
declaration,
transactionId,
annotation,
content,
eventConfiguration
}: EditRequestParams) {
await trpcClient.event.actions.edit.request.mutate({
declaration,
annotation,
eventId,
transactionId,
keepAssignment: true,
content
})

// TODO CIHAN: do declare only if its not been notified previously?
// const declaredEvent = await trpcClient.event.actions.declare.request.mutate({
// declaration,
// annotation,
// eventId,
// transactionId,
// keepAssignment: true
// })

// if (hasPotentialDuplicates(declaredEvent, eventConfiguration)) {
// return declaredEvent
// }

return trpcClient.event.actions.register.request.mutate({
declaration,
annotation,
eventId,
transactionId
})
}

export async function editAndDeclare({
eventId,
declaration,
transactionId,
annotation,
content
}: EditRequestParams) {
await trpcClient.event.actions.edit.request.mutate({
declaration,
annotation,
eventId,
transactionId,
keepAssignment: true,
content
})

return trpcClient.event.actions.declare.request.mutate({
declaration,
annotation,
eventId,
transactionId
})
}

export async function editAndNotify({
eventId,
declaration,
transactionId,
annotation,
content
}: EditRequestParams) {
await trpcClient.event.actions.edit.request.mutate({
declaration,
annotation,
eventId,
transactionId,
keepAssignment: true,
content
})

return trpcClient.event.actions.notify.request.mutate({
declaration,
annotation,
eventId,
transactionId
})
}

/**
* Runs a sequence of actions from declare to validate.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ export const DirectsRejectedNotifiedToDeclare: Story = {
}
},
{
path: ROUTES.V2.EVENTS.DECLARE.REVIEW.path,
path: ROUTES.V2.EVENTS.EDIT.REVIEW.path,
Component: () => {
return (
<div>
{ROUTES.V2.EVENTS.DECLARE.REVIEW.buildPath({
{ROUTES.V2.EVENTS.EDIT.REVIEW.buildPath({
eventId: rejectedNotifiedEvent.event.id
})}
</div>
Expand All @@ -122,7 +122,7 @@ export const DirectsRejectedNotifiedToDeclare: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement)
const actionButton = await canvas.findByRole('button', {
name: 'Review'
name: 'Edit'
})

await userEvent.click(actionButton)
Expand All @@ -131,7 +131,7 @@ export const DirectsRejectedNotifiedToDeclare: Story = {
await waitFor(async () => {
await expect(
canvas.getByText(
ROUTES.V2.EVENTS.DECLARE.REVIEW.buildPath({
ROUTES.V2.EVENTS.EDIT.REVIEW.buildPath({
eventId: rejectedNotifiedEvent.event.id
})
)
Expand Down Expand Up @@ -177,11 +177,11 @@ export const DirectsRejectedDeclaredToDeclared: Story = {
}
},
{
path: ROUTES.V2.EVENTS.DECLARE.REVIEW.path,
path: ROUTES.V2.EVENTS.EDIT.REVIEW.path,
Component: () => {
return (
<div>
{ROUTES.V2.EVENTS.DECLARE.REVIEW.buildPath({
{ROUTES.V2.EVENTS.EDIT.REVIEW.buildPath({
eventId: rejectedDeclaredEvent.event.id
})}
</div>
Expand All @@ -196,7 +196,7 @@ export const DirectsRejectedDeclaredToDeclared: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement)
const actionButton = await canvas.findByRole('button', {
name: 'Review'
name: 'Edit'
})

await userEvent.click(actionButton)
Expand All @@ -205,7 +205,7 @@ export const DirectsRejectedDeclaredToDeclared: Story = {
await waitFor(async () => {
await expect(
canvas.getByText(
ROUTES.V2.EVENTS.DECLARE.REVIEW.buildPath({
ROUTES.V2.EVENTS.EDIT.REVIEW.buildPath({
eventId: rejectedDeclaredEvent.event.id
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
EventConfig,
EventDocument,
EventState,
getAcceptedActions,
getDeclaration,
isFieldDisplayedOnReview,
ValidatorContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { hasAnnotationChanged, getDeclarationComparison } from './utils'
* Indicates that declaration action changed declaration content. Satisfies V1 spec.
*/
export const DECLARATION_ACTION_UPDATE = 'UPDATE' as const
type DECLARATION_ACTION_UPDATE = typeof DECLARATION_ACTION_UPDATE
export type DECLARATION_ACTION_UPDATE = typeof DECLARATION_ACTION_UPDATE

type UpdateActionDocument = Omit<ActionDocument, 'type'> & {
type: DECLARATION_ACTION_UPDATE
Expand Down Expand Up @@ -139,7 +139,7 @@ export function expandWithClientSpecificActions(
): EventHistoryActionDocument[] {
return extractHistoryActions(fullEvent).flatMap<EventHistoryActionDocument>(
(action) => {
if (isDeclarationAction(action)) {
if (isDeclarationAction(action) && action.type !== ActionType.EDIT) {
if (
!hasDeclarationChanged(
fullEvent,
Expand Down
Loading
Loading