Skip to content

Commit 7d3124e

Browse files
authored
Merge pull request #6522 from opencrvs/ocrvs-6492
filter unassigned data with an additional action
2 parents 69e3b77 + 6b7b6be commit 7d3124e

File tree

7 files changed

+231
-13
lines changed

7 files changed

+231
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@
1717
Locations are now seeded in smaller segments instead of one big collection. The newer approach has improved performance to a significant extent and also clears the interruption caused for a large number of country config locations
1818
- Filter user information such as usernames and authentication codes from server logs
1919
- Core not recognizing "occupation" as an optional field for deceased
20+
- Unassign declaration from a user if the declaration has already been proceeded through the workqueues by a separate user
21+
22+
## Dependency upgrades
23+
- #### Metabase from v0.45.2.1 to v0.46.6.1
2024

2125
See [Releases](https://github.com/opencrvs/opencrvs-core/releases) for release notes of older releases.

packages/client/src/components/Notification.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import {
3030
hideCreateUserErrorToast,
3131
hideCreateUserFormDuplicateEmailErrorToast,
3232
hideUserReconnectedToast,
33-
hideDuplicateRecordsToast
33+
hideDuplicateRecordsToast,
34+
hideUnassignedDeclarationsToast
3435
} from '@client/notification/actions'
3536
import { TOAST_MESSAGES } from '@client/user/userReducer'
3637
import { goToDeclarationRecordAudit } from '@client/navigation'
@@ -52,6 +53,7 @@ type DispatchProps = {
5253
hideUnassignedModal: typeof hideUnassignedModal
5354
hideCreateUserErrorToast: typeof hideCreateUserErrorToast
5455
hideCreateUserFormDuplicateEmailErrorToast: typeof hideCreateUserFormDuplicateEmailErrorToast
56+
hideUnassignedDeclarationsToast: typeof hideUnassignedDeclarationsToast
5557
hideUserReconnectedToast: typeof hideUserReconnectedToast
5658
goToDeclarationRecordAudit: typeof goToDeclarationRecordAudit
5759
}
@@ -86,6 +88,10 @@ class Component extends React.Component<
8688
this.props.hideCreateUserFormDuplicateEmailErrorToast()
8789
}
8890

91+
hideUnassignedDeclarationsToast = () => {
92+
this.props.hideUnassignedDeclarationsToast()
93+
}
94+
8995
hideUserAuditSuccessToast = () => {
9096
this.props.hideUserAuditSuccessToast()
9197
}
@@ -113,7 +119,8 @@ class Component extends React.Component<
113119
userCreateDuplicateEmailFailedToast,
114120
userReconnectedToast,
115121
goToDeclarationRecordAudit,
116-
isOnline
122+
isOnline,
123+
unassignedDeclarations
117124
} = this.props
118125

119126
const userFormSubmitErrorMessage = isOnline
@@ -267,6 +274,20 @@ class Component extends React.Component<
267274
})}
268275
</Toast>
269276
)}
277+
{unassignedDeclarations.length > 0 && (
278+
<Toast
279+
id="unassignedDeclarationsToast"
280+
type="info"
281+
onClose={this.hideUnassignedDeclarationsToast}
282+
>
283+
{intl.formatMessage(messages.unassigned, {
284+
trackingId:
285+
unassignedDeclarations.length > 3
286+
? `${unassignedDeclarations.slice(0, 3).join(', ')}...`
287+
: unassignedDeclarations.join(', ')
288+
})}
289+
</Toast>
290+
)}
270291
{/* More notification types can be added here */}
271292
</div>
272293
)
@@ -291,6 +312,7 @@ const mapStateToProps = (store: IStoreState) => {
291312
downloadDeclarationFailedToast:
292313
store.notification.downloadDeclarationFailedToast,
293314
unassignedModal: store.notification.unassignedModal,
315+
unassignedDeclarations: store.notification.unassignedDeclarations,
294316
userCreateDuplicateMobileFailedToast:
295317
store.notification.userCreateDuplicateMobileFailedToast,
296318
userCreateDuplicateEmailFailedToast:
@@ -313,6 +335,7 @@ export const NotificationComponent = withRouter(
313335
hideCreateUserErrorToast,
314336
hideCreateUserFormDuplicateEmailErrorToast,
315337
hideUserReconnectedToast,
316-
goToDeclarationRecordAudit
338+
goToDeclarationRecordAudit,
339+
hideUnassignedDeclarationsToast
317340
})(injectIntl(withOnlineStatus(Component)))
318341
)

packages/client/src/declarations/index.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ import { getOfflineData } from '@client/offline/selectors'
6666
import { IOfflineData } from '@client/offline/reducer'
6767
import {
6868
showDownloadDeclarationFailedToast,
69-
ShowDownloadDeclarationFailedToast
69+
ShowDownloadDeclarationFailedToast,
70+
ShowUnassignedDeclarations,
71+
showUnassignedDeclarations
7072
} from '@client/notification/actions'
7173
import differenceInMinutes from 'date-fns/differenceInMinutes'
7274
import { MARK_EVENT_UNASSIGNED } from '@client/views/DataProvider/birth/mutations'
@@ -105,6 +107,8 @@ const CLEAR_CORRECTION_AND_PRINT_CHANGES = 'CLEAR_CORRECTION_AND_PRINT_CHANGES'
105107
const ENQUEUE_UNASSIGN_DECLARATION = 'DECLARATION/ENQUEUE_UNASSIGN'
106108
const UNASSIGN_DECLARATION = 'DECLARATION/UNASSIGN'
107109
const UNASSIGN_DECLARATION_SUCCESS = 'DECLARATION/UNASSIGN_SUCCESS'
110+
const REMOVE_UNASSIGNED_DECLARATIONS =
111+
'DECLARATION/REMOVE_UNASSIGNED_DECLARATIONS'
108112

109113
export enum SUBMISSION_STATUS {
110114
DRAFT = 'DRAFT',
@@ -395,6 +399,14 @@ interface IDownloadDeclaration {
395399
}
396400
}
397401

402+
interface IRemoveUnassignedDeclarationAction {
403+
type: typeof REMOVE_UNASSIGNED_DECLARATIONS
404+
payload: {
405+
currentlyDownloadedDeclarations: IDeclaration[]
406+
unassignedDeclarations: IDeclaration[]
407+
}
408+
}
409+
398410
interface IDownloadDeclarationSuccess {
399411
type: typeof DOWNLOAD_DECLARATION_SUCCESS
400412
payload: {
@@ -467,6 +479,8 @@ export type Action =
467479
| IEnqueueUnassignDeclaration
468480
| IUnassignDeclaration
469481
| IUnassignDeclarationSuccess
482+
| IRemoveUnassignedDeclarationAction
483+
| ShowUnassignedDeclarations
470484

471485
export interface IUserData {
472486
userID: string
@@ -591,6 +605,14 @@ export function archiveDeclaration(
591605
}
592606
}
593607

608+
export const RemoveUnassignedDeclarationsActionCreator = (payload: {
609+
currentlyDownloadedDeclarations: IDeclaration[]
610+
unassignedDeclarations: IDeclaration[]
611+
}): IRemoveUnassignedDeclarationAction => ({
612+
type: REMOVE_UNASSIGNED_DECLARATIONS,
613+
payload: payload
614+
})
615+
594616
export function deleteDeclaration(
595617
declarationId: string,
596618
client: ApolloClient<{}>
@@ -1859,6 +1881,19 @@ export const declarationsReducer: LoopReducer<IDeclarationsState, Action> = (
18591881
{ sequence: true }
18601882
)
18611883
)
1884+
case REMOVE_UNASSIGNED_DECLARATIONS:
1885+
const unassignedDeclarationTrackingIds =
1886+
action.payload.unassignedDeclarations.map(
1887+
(dec) => dec.data.registration.trackingId
1888+
) as string[]
1889+
1890+
return loop(
1891+
{
1892+
...state,
1893+
declarations: action.payload.currentlyDownloadedDeclarations
1894+
},
1895+
Cmd.action(showUnassignedDeclarations(unassignedDeclarationTrackingIds))
1896+
)
18621897
default:
18631898
return state
18641899
}

packages/client/src/notification/actions.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export const HIDE_PIN_UPDATE_SUCCESS = 'HIDE_PIN_UPDATE_SUCCESS'
4848

4949
export const SHOW_UNASSIGNED = 'SHOW_UNASSIGNED'
5050
export const HIDE_UNASSIGNED = 'HIDE_UNASSIGNED'
51+
export const SHOW_UNASSIGNED_DECLARATIONS = 'SHOW_UNASSIGNED_DECLARATIONS'
52+
export const HIDE_UNASSIGNED_DECLARATIONS_TOAST =
53+
'HIDE_UNASSIGNED_DECLARATIONS_TOAST'
5154

5255
type ConfigurationErrorAction = {
5356
type: typeof CONFIGURATION_ERROR
@@ -119,6 +122,10 @@ type HideCreateUserDuplicateEmailErrorToast = {
119122
type: typeof HIDE_CREATE_USER_DUPLICATE_EMAIL_ERROR_TOAST
120123
}
121124

125+
type HideUnassignedDeclarationsToast = {
126+
type: typeof HIDE_UNASSIGNED_DECLARATIONS_TOAST
127+
}
128+
122129
export type ShowUserAuditSuccessToast = {
123130
type: typeof SHOW_USER_AUDIT_SUCCESS_TOAST
124131
payload: {
@@ -169,6 +176,11 @@ export interface ShowUnassignedPayload extends Record<string, string> {
169176
trackingId: string
170177
}
171178

179+
export type ShowUnassignedDeclarations = {
180+
type: typeof SHOW_UNASSIGNED_DECLARATIONS
181+
payload: string[]
182+
}
183+
172184
type ShowUnassigned = {
173185
type: typeof SHOW_UNASSIGNED
174186
payload: ShowUnassignedPayload
@@ -305,10 +317,22 @@ export const showUnassigned = (
305317
payload: data
306318
})
307319

320+
export const showUnassignedDeclarations = (
321+
unassignedDeclarationTrackingIds: string[]
322+
): ShowUnassignedDeclarations => ({
323+
type: SHOW_UNASSIGNED_DECLARATIONS,
324+
payload: unassignedDeclarationTrackingIds
325+
})
326+
308327
export const hideUnassignedModal = (): HideUnassigned => ({
309328
type: HIDE_UNASSIGNED
310329
})
311330

331+
export const hideUnassignedDeclarationsToast =
332+
(): HideUnassignedDeclarationsToast => ({
333+
type: HIDE_UNASSIGNED_DECLARATIONS_TOAST
334+
})
335+
312336
export type Action =
313337
| SessionExpiredAction
314338
| ConfigurationErrorAction
@@ -335,3 +359,5 @@ export type Action =
335359
| HideDuplicateRecordsToast
336360
| ShowUserReconnectedToastAction
337361
| HideUserReconnectedToastAction
362+
| ShowUnassignedDeclarations
363+
| HideUnassignedDeclarationsToast

packages/client/src/notification/reducer.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export type NotificationState = {
4949
duplicateTrackingId: string | null
5050
downloadDeclarationFailedToast: boolean
5151
unassignedModal: ShowUnassignedPayload | null
52+
unassignedDeclarations: string[]
5253
userCreateDuplicateMobileFailedToast: userCreateDuplicateMobileFailedToastState
5354
userCreateDuplicateEmailFailedToast: userCreateDuplicateEmailFailedToastState
5455
userReconnectedToast: boolean
@@ -78,7 +79,8 @@ const initialState: NotificationState = {
7879
visible: false,
7980
email: null
8081
},
81-
userReconnectedToast: false
82+
userReconnectedToast: false,
83+
unassignedDeclarations: []
8284
}
8385

8486
export const notificationReducer: LoopReducer<
@@ -228,6 +230,16 @@ export const notificationReducer: LoopReducer<
228230
...state,
229231
unassignedModal: action.payload
230232
}
233+
case actions.SHOW_UNASSIGNED_DECLARATIONS:
234+
return {
235+
...state,
236+
unassignedDeclarations: action.payload
237+
}
238+
case actions.HIDE_UNASSIGNED_DECLARATIONS_TOAST:
239+
return {
240+
...state,
241+
unassignedDeclarations: []
242+
}
231243
case actions.HIDE_UNASSIGNED:
232244
return {
233245
...state,

packages/client/src/tests/mock-graphql-responses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const birthDeclarationForReview = {
145145
status: [
146146
{
147147
comments: null,
148-
type: 'DECLARED',
148+
type: 'REJECTED',
149149
timestamp: '2022-04-28T15:19:12.858Z',
150150
__typename: 'RegWorkflow'
151151
},

0 commit comments

Comments
 (0)