Skip to content

Commit

Permalink
feat: separate query for sent for review tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Zangetsu101 committed Dec 30, 2024
1 parent f7785d0 commit 64a4b6e
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/client/src/ListSyncController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import { client } from '@client/utils/apolloClient'
import { REGISTRATION_HOME_QUERY } from '@client/views/OfficeHome/queries'

export async function syncRegistrarWorkqueue(
userId: string,
locationId: string,
reviewStatuses: string[],
pageSize: number,
inProgressSkip: number,
healthSystemSkip: number,
reviewSkip: number,
rejectSkip: number,
sentForReviewSkip: number,
approvalSkip: number,
externalValidationSkip: number,
printSkip: number,
Expand All @@ -28,13 +30,15 @@ export async function syncRegistrarWorkqueue(
const queryResult = await client.query({
query: REGISTRATION_HOME_QUERY,
variables: {
userId,
declarationLocationId: locationId,
pageSize,
reviewStatuses: reviewStatuses,
inProgressSkip: inProgressSkip,
healthSystemSkip: healthSystemSkip,
reviewSkip: reviewSkip,
rejectSkip: rejectSkip,
sentForReviewSkip,
approvalSkip: approvalSkip,
externalValidationSkip: externalValidationSkip,
printSkip: printSkip,
Expand Down
5 changes: 4 additions & 1 deletion packages/client/src/components/interface/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ const NavigationView = (props: IFullProps) => {
sentForApproval: !initialSyncDone
? 0
: filteredData.approvalTab?.totalItems || 0,
sentForReview: !initialSyncDone
? 0
: filteredData.sentForReviewTab?.totalItems || 0,
externalValidation:
window.config.FEATURES.EXTERNAL_VALIDATION_WORKQUEUE && !initialSyncDone
? 0
Expand Down Expand Up @@ -318,7 +321,7 @@ const NavigationView = (props: IFullProps) => {
label={intl.formatMessage(
navigationMessages[WORKQUEUE_TABS.sentForReview]
)}
count={declarationCount.readyForReview}
count={declarationCount.sentForReview}
isSelected={tabId === WORKQUEUE_TABS.sentForReview}
onClick={() => {
props.router.navigate(
Expand Down
10 changes: 10 additions & 0 deletions packages/client/src/declarations/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ describe('query result filtering tests', () => {
],
totalItems: 5
},
sentForReviewTab: {
results: [
{ id: 'READY_TO_SUBMIT' },
{ id: 'SUBMITTING' },
{ id: 'SUBMITED' },
{ id: 'FAILED' },
{ id: 'SUBMITTING' }
],
totalItems: 5
},
externalValidationTab: {
results: [{ id: 'WAITING_FOR_VALIDATION' }],
totalItems: 1
Expand Down
4 changes: 4 additions & 0 deletions packages/client/src/declarations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,10 @@ export function filterProcessingDeclarationsFromQuery(
queryData.rejectTab,
processingDeclarationIds
),
sentForReviewTab: filterProcessingDeclarations(
queryData.sentForReviewTab,
processingDeclarationIds
),
approvalTab: filterProcessingDeclarations(
queryData.approvalTab,
processingDeclarationIds
Expand Down
7 changes: 5 additions & 2 deletions packages/client/src/views/OfficeHome/OfficeHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class OfficeHomeView extends React.Component<
healthSystemCurrentPage: number,
progressCurrentPage: number,
reviewCurrentPage: number,
sentForReviewCurrentPage: number,
approvalCurrentPage: number,
printCurrentPage: number,
issueCurrentPage: number,
Expand Down Expand Up @@ -357,9 +358,9 @@ class OfficeHomeView extends React.Component<
{tabId === WORKQUEUE_TABS.sentForReview && (
<SentForReview
queryData={{
data: filteredData.reviewTab
data: filteredData.sentForReviewTab
}}
paginationId={reviewCurrentPage}
paginationId={sentForReviewCurrentPage}
pageSize={this.pageSize}
onPageChange={this.onPageChange}
loading={loading}
Expand Down Expand Up @@ -391,6 +392,7 @@ class OfficeHomeView extends React.Component<
notificationTab,
inProgressTab,
reviewTab,
sentForReviewTab,
approvalTab,
printTab,
issueTab,
Expand All @@ -415,6 +417,7 @@ class OfficeHomeView extends React.Component<
notificationTab,
inProgressTab,
reviewTab,
sentForReviewTab,
approvalTab,
printTab,
issueTab,
Expand Down
23 changes: 23 additions & 0 deletions packages/client/src/views/OfficeHome/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ const EVENT_SEARCH_RESULT_FIELDS = gql`
export const REGISTRATION_HOME_QUERY = gql`
${EVENT_SEARCH_RESULT_FIELDS}
query registrationHome(
$userId: String!
$declarationLocationId: String!
$pageSize: Int
$inProgressSkip: Int
$healthSystemSkip: Int
$reviewStatuses: [String]
$reviewSkip: Int
$rejectSkip: Int
$sentForReviewSkip: Int
$approvalSkip: Int
$externalValidationSkip: Int
$printSkip: Int
Expand Down Expand Up @@ -152,7 +154,28 @@ export const REGISTRATION_HOME_QUERY = gql`
...EventSearchFields
}
}
sentForReviewTab: searchEvents(
userId: $userId
advancedSearchParameters: {
declarationLocationId: $declarationLocationId
registrationStatuses: [
"DECLARED"
"IN_PROGRESS"
"VALIDATED"
"WAITING_VALIDATION"
"REGISTERED"
]
}
count: $pageSize
skip: $sentForReviewSkip
) {
totalItems
results {
...EventSearchFields
}
}
approvalTab: searchEvents(
userId: $userId
advancedSearchParameters: {
declarationLocationId: $declarationLocationId
registrationStatuses: ["VALIDATED", "CORRECTION_REQUESTED"]
Expand Down
1 change: 1 addition & 0 deletions packages/client/src/workqueue/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface IQueryData {
notificationTab: GQLEventSearchResultSet
reviewTab: GQLEventSearchResultSet
rejectTab: GQLEventSearchResultSet
sentForReviewTab: GQLEventSearchResultSet
approvalTab: GQLEventSearchResultSet
printTab: GQLEventSearchResultSet
issueTab: GQLEventSearchResultSet
Expand Down
9 changes: 8 additions & 1 deletion packages/client/src/workqueue/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const workqueueInitialState: WorkqueueState = {
notificationTab: { totalItems: 0, results: [] },
reviewTab: { totalItems: 0, results: [] },
rejectTab: { totalItems: 0, results: [] },
sentForReviewTab: { totalItems: 0, results: [] },
approvalTab: { totalItems: 0, results: [] },
printTab: { totalItems: 0, results: [] },
issueTab: { totalItems: 0, results: [] },
Expand All @@ -86,6 +87,7 @@ const workqueueInitialState: WorkqueueState = {
notificationTab: 1,
reviewTab: 1,
rejectTab: 1,
sentForReviewTab: 1,
approvalTab: 1,
externalValidationTab: 1,
printTab: 1,
Expand All @@ -94,12 +96,12 @@ const workqueueInitialState: WorkqueueState = {
}

interface IWorkqueuePaginationParams {
userId?: string
pageSize: number
inProgressSkip: number
healthSystemSkip: number
reviewSkip: number
rejectSkip: number
sentForReviewSkip: number
approvalSkip: number
externalValidationSkip: number
printSkip: number
Expand Down Expand Up @@ -355,19 +357,22 @@ async function getWorkqueueData(
reviewSkip,
rejectSkip,
approvalSkip,
sentForReviewSkip,
externalValidationSkip,
printSkip,
issueSkip
} = workqueuePaginationParams

const result = await syncRegistrarWorkqueue(
userDetails.practitionerId,
registrationLocationId,
reviewStatuses,
pageSize,
inProgressSkip,
healthSystemSkip,
reviewSkip,
rejectSkip,
sentForReviewSkip,
approvalSkip,
externalValidationSkip,
printSkip,
Expand Down Expand Up @@ -449,6 +454,7 @@ export const workqueueReducer: LoopReducer<WorkqueueState, WorkqueueActions> = (
const {
printTab,
reviewTab,
sentForReviewTab,
approvalTab,
inProgressTab,
externalValidationTab,
Expand All @@ -465,6 +471,7 @@ export const workqueueReducer: LoopReducer<WorkqueueState, WorkqueueActions> = (
healthSystemSkip: Math.max(notificationTab - 1, 0) * pageSize,
reviewSkip: Math.max(reviewTab - 1, 0) * pageSize,
rejectSkip: Math.max(rejectTab - 1, 0) * pageSize,
sentForReviewSkip: Math.max(sentForReviewTab - 1, 0) * pageSize,
approvalSkip: Math.max(approvalTab - 1, 0) * pageSize,
externalValidationSkip:
Math.max(externalValidationTab - 1, 0) * pageSize,
Expand Down

0 comments on commit 64a4b6e

Please sign in to comment.