Skip to content

Commit

Permalink
Merge pull request #6522 from opencrvs/ocrvs-6492
Browse files Browse the repository at this point in the history
filter unassigned data with an additional action
  • Loading branch information
euanmillar committed Feb 23, 2024
2 parents 69e3b77 + 6b7b6be commit 7d3124e
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
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
- Filter user information such as usernames and authentication codes from server logs
- Core not recognizing "occupation" as an optional field for deceased
- Unassign declaration from a user if the declaration has already been proceeded through the workqueues by a separate user

## Dependency upgrades
- #### Metabase from v0.45.2.1 to v0.46.6.1

See [Releases](https://github.com/opencrvs/opencrvs-core/releases) for release notes of older releases.
29 changes: 26 additions & 3 deletions packages/client/src/components/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
hideCreateUserErrorToast,
hideCreateUserFormDuplicateEmailErrorToast,
hideUserReconnectedToast,
hideDuplicateRecordsToast
hideDuplicateRecordsToast,
hideUnassignedDeclarationsToast
} from '@client/notification/actions'
import { TOAST_MESSAGES } from '@client/user/userReducer'
import { goToDeclarationRecordAudit } from '@client/navigation'
Expand All @@ -52,6 +53,7 @@ type DispatchProps = {
hideUnassignedModal: typeof hideUnassignedModal
hideCreateUserErrorToast: typeof hideCreateUserErrorToast
hideCreateUserFormDuplicateEmailErrorToast: typeof hideCreateUserFormDuplicateEmailErrorToast
hideUnassignedDeclarationsToast: typeof hideUnassignedDeclarationsToast
hideUserReconnectedToast: typeof hideUserReconnectedToast
goToDeclarationRecordAudit: typeof goToDeclarationRecordAudit
}
Expand Down Expand Up @@ -86,6 +88,10 @@ class Component extends React.Component<
this.props.hideCreateUserFormDuplicateEmailErrorToast()
}

hideUnassignedDeclarationsToast = () => {
this.props.hideUnassignedDeclarationsToast()
}

hideUserAuditSuccessToast = () => {
this.props.hideUserAuditSuccessToast()
}
Expand Down Expand Up @@ -113,7 +119,8 @@ class Component extends React.Component<
userCreateDuplicateEmailFailedToast,
userReconnectedToast,
goToDeclarationRecordAudit,
isOnline
isOnline,
unassignedDeclarations
} = this.props

const userFormSubmitErrorMessage = isOnline
Expand Down Expand Up @@ -267,6 +274,20 @@ class Component extends React.Component<
})}
</Toast>
)}
{unassignedDeclarations.length > 0 && (
<Toast
id="unassignedDeclarationsToast"
type="info"
onClose={this.hideUnassignedDeclarationsToast}
>
{intl.formatMessage(messages.unassigned, {
trackingId:
unassignedDeclarations.length > 3
? `${unassignedDeclarations.slice(0, 3).join(', ')}...`
: unassignedDeclarations.join(', ')
})}
</Toast>
)}
{/* More notification types can be added here */}
</div>
)
Expand All @@ -291,6 +312,7 @@ const mapStateToProps = (store: IStoreState) => {
downloadDeclarationFailedToast:
store.notification.downloadDeclarationFailedToast,
unassignedModal: store.notification.unassignedModal,
unassignedDeclarations: store.notification.unassignedDeclarations,
userCreateDuplicateMobileFailedToast:
store.notification.userCreateDuplicateMobileFailedToast,
userCreateDuplicateEmailFailedToast:
Expand All @@ -313,6 +335,7 @@ export const NotificationComponent = withRouter(
hideCreateUserErrorToast,
hideCreateUserFormDuplicateEmailErrorToast,
hideUserReconnectedToast,
goToDeclarationRecordAudit
goToDeclarationRecordAudit,
hideUnassignedDeclarationsToast
})(injectIntl(withOnlineStatus(Component)))
)
37 changes: 36 additions & 1 deletion packages/client/src/declarations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ import { getOfflineData } from '@client/offline/selectors'
import { IOfflineData } from '@client/offline/reducer'
import {
showDownloadDeclarationFailedToast,
ShowDownloadDeclarationFailedToast
ShowDownloadDeclarationFailedToast,
ShowUnassignedDeclarations,
showUnassignedDeclarations
} from '@client/notification/actions'
import differenceInMinutes from 'date-fns/differenceInMinutes'
import { MARK_EVENT_UNASSIGNED } from '@client/views/DataProvider/birth/mutations'
Expand Down Expand Up @@ -105,6 +107,8 @@ const CLEAR_CORRECTION_AND_PRINT_CHANGES = 'CLEAR_CORRECTION_AND_PRINT_CHANGES'
const ENQUEUE_UNASSIGN_DECLARATION = 'DECLARATION/ENQUEUE_UNASSIGN'
const UNASSIGN_DECLARATION = 'DECLARATION/UNASSIGN'
const UNASSIGN_DECLARATION_SUCCESS = 'DECLARATION/UNASSIGN_SUCCESS'
const REMOVE_UNASSIGNED_DECLARATIONS =
'DECLARATION/REMOVE_UNASSIGNED_DECLARATIONS'

export enum SUBMISSION_STATUS {
DRAFT = 'DRAFT',
Expand Down Expand Up @@ -395,6 +399,14 @@ interface IDownloadDeclaration {
}
}

interface IRemoveUnassignedDeclarationAction {
type: typeof REMOVE_UNASSIGNED_DECLARATIONS
payload: {
currentlyDownloadedDeclarations: IDeclaration[]
unassignedDeclarations: IDeclaration[]
}
}

interface IDownloadDeclarationSuccess {
type: typeof DOWNLOAD_DECLARATION_SUCCESS
payload: {
Expand Down Expand Up @@ -467,6 +479,8 @@ export type Action =
| IEnqueueUnassignDeclaration
| IUnassignDeclaration
| IUnassignDeclarationSuccess
| IRemoveUnassignedDeclarationAction
| ShowUnassignedDeclarations

export interface IUserData {
userID: string
Expand Down Expand Up @@ -591,6 +605,14 @@ export function archiveDeclaration(
}
}

export const RemoveUnassignedDeclarationsActionCreator = (payload: {
currentlyDownloadedDeclarations: IDeclaration[]
unassignedDeclarations: IDeclaration[]
}): IRemoveUnassignedDeclarationAction => ({
type: REMOVE_UNASSIGNED_DECLARATIONS,
payload: payload
})

export function deleteDeclaration(
declarationId: string,
client: ApolloClient<{}>
Expand Down Expand Up @@ -1859,6 +1881,19 @@ export const declarationsReducer: LoopReducer<IDeclarationsState, Action> = (
{ sequence: true }
)
)
case REMOVE_UNASSIGNED_DECLARATIONS:
const unassignedDeclarationTrackingIds =
action.payload.unassignedDeclarations.map(
(dec) => dec.data.registration.trackingId
) as string[]

return loop(
{
...state,
declarations: action.payload.currentlyDownloadedDeclarations
},
Cmd.action(showUnassignedDeclarations(unassignedDeclarationTrackingIds))
)
default:
return state
}
Expand Down
26 changes: 26 additions & 0 deletions packages/client/src/notification/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export const HIDE_PIN_UPDATE_SUCCESS = 'HIDE_PIN_UPDATE_SUCCESS'

export const SHOW_UNASSIGNED = 'SHOW_UNASSIGNED'
export const HIDE_UNASSIGNED = 'HIDE_UNASSIGNED'
export const SHOW_UNASSIGNED_DECLARATIONS = 'SHOW_UNASSIGNED_DECLARATIONS'
export const HIDE_UNASSIGNED_DECLARATIONS_TOAST =
'HIDE_UNASSIGNED_DECLARATIONS_TOAST'

type ConfigurationErrorAction = {
type: typeof CONFIGURATION_ERROR
Expand Down Expand Up @@ -119,6 +122,10 @@ type HideCreateUserDuplicateEmailErrorToast = {
type: typeof HIDE_CREATE_USER_DUPLICATE_EMAIL_ERROR_TOAST
}

type HideUnassignedDeclarationsToast = {
type: typeof HIDE_UNASSIGNED_DECLARATIONS_TOAST
}

export type ShowUserAuditSuccessToast = {
type: typeof SHOW_USER_AUDIT_SUCCESS_TOAST
payload: {
Expand Down Expand Up @@ -169,6 +176,11 @@ export interface ShowUnassignedPayload extends Record<string, string> {
trackingId: string
}

export type ShowUnassignedDeclarations = {
type: typeof SHOW_UNASSIGNED_DECLARATIONS
payload: string[]
}

type ShowUnassigned = {
type: typeof SHOW_UNASSIGNED
payload: ShowUnassignedPayload
Expand Down Expand Up @@ -305,10 +317,22 @@ export const showUnassigned = (
payload: data
})

export const showUnassignedDeclarations = (
unassignedDeclarationTrackingIds: string[]
): ShowUnassignedDeclarations => ({
type: SHOW_UNASSIGNED_DECLARATIONS,
payload: unassignedDeclarationTrackingIds
})

export const hideUnassignedModal = (): HideUnassigned => ({
type: HIDE_UNASSIGNED
})

export const hideUnassignedDeclarationsToast =
(): HideUnassignedDeclarationsToast => ({
type: HIDE_UNASSIGNED_DECLARATIONS_TOAST
})

export type Action =
| SessionExpiredAction
| ConfigurationErrorAction
Expand All @@ -335,3 +359,5 @@ export type Action =
| HideDuplicateRecordsToast
| ShowUserReconnectedToastAction
| HideUserReconnectedToastAction
| ShowUnassignedDeclarations
| HideUnassignedDeclarationsToast
14 changes: 13 additions & 1 deletion packages/client/src/notification/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type NotificationState = {
duplicateTrackingId: string | null
downloadDeclarationFailedToast: boolean
unassignedModal: ShowUnassignedPayload | null
unassignedDeclarations: string[]
userCreateDuplicateMobileFailedToast: userCreateDuplicateMobileFailedToastState
userCreateDuplicateEmailFailedToast: userCreateDuplicateEmailFailedToastState
userReconnectedToast: boolean
Expand Down Expand Up @@ -78,7 +79,8 @@ const initialState: NotificationState = {
visible: false,
email: null
},
userReconnectedToast: false
userReconnectedToast: false,
unassignedDeclarations: []
}

export const notificationReducer: LoopReducer<
Expand Down Expand Up @@ -228,6 +230,16 @@ export const notificationReducer: LoopReducer<
...state,
unassignedModal: action.payload
}
case actions.SHOW_UNASSIGNED_DECLARATIONS:
return {
...state,
unassignedDeclarations: action.payload
}
case actions.HIDE_UNASSIGNED_DECLARATIONS_TOAST:
return {
...state,
unassignedDeclarations: []
}
case actions.HIDE_UNASSIGNED:
return {
...state,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/tests/mock-graphql-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const birthDeclarationForReview = {
status: [
{
comments: null,
type: 'DECLARED',
type: 'REJECTED',
timestamp: '2022-04-28T15:19:12.858Z',
__typename: 'RegWorkflow'
},
Expand Down
Loading

0 comments on commit 7d3124e

Please sign in to comment.