-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): added an endpoint to update a document's decision (#796)
* feat(*): added an endpoint to update a document's decision * refactor(workflows-service): minimized changes made to decision object on document
- Loading branch information
Showing
15 changed files
with
326 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...omains/entities/hooks/mutations/useApproveTaskByIdMutation/useApproveTaskByIdMutation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import toast from 'react-hot-toast'; | ||
import { t } from 'i18next'; | ||
import { fetchWorkflowDecision } from '../../../../workflows/fetchers'; | ||
import { workflowsQueryKeys } from '../../../../workflows/query-keys'; | ||
import { Action } from '../../../../../common/enums'; | ||
|
||
export const useApproveTaskByIdMutation = (workflowId: string) => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: ({ documentId }: { documentId: string }) => | ||
fetchWorkflowDecision({ | ||
workflowId, | ||
documentId, | ||
body: { | ||
decision: Action.APPROVE.toLowerCase(), | ||
}, | ||
}), | ||
onSuccess: () => { | ||
// workflowsQueryKeys._def is the base key for all workflows queries | ||
void queryClient.invalidateQueries(workflowsQueryKeys._def); | ||
|
||
toast.success(t('toast:approve_document.success')); | ||
}, | ||
onError: () => { | ||
toast.error(t('toast:approve_document.error')); | ||
}, | ||
}); | ||
}; |
31 changes: 31 additions & 0 deletions
31
.../domains/entities/hooks/mutations/useRejectTaskByIdMutation/useRejectTaskByIdMutation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import toast from 'react-hot-toast'; | ||
import { t } from 'i18next'; | ||
import { fetchWorkflowDecision } from '../../../../workflows/fetchers'; | ||
import { workflowsQueryKeys } from '../../../../workflows/query-keys'; | ||
import { Action } from '../../../../../common/enums'; | ||
|
||
export const useRejectTaskByIdMutation = (workflowId: string) => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: ({ documentId, reason }: { documentId: string; reason?: string }) => | ||
fetchWorkflowDecision({ | ||
workflowId, | ||
documentId, | ||
body: { | ||
decision: Action.REJECT.toLowerCase(), | ||
reason, | ||
}, | ||
}), | ||
onSuccess: () => { | ||
// workflowsQueryKeys._def is the base key for all workflows queries | ||
void queryClient.invalidateQueries(workflowsQueryKeys._def); | ||
|
||
toast.success(t('toast:reject_document.success')); | ||
}, | ||
onError: () => { | ||
toast.error(t('toast:reject_document.error')); | ||
}, | ||
}); | ||
}; |
31 changes: 31 additions & 0 deletions
31
...ains/entities/hooks/mutations/useRevisionTaskByIdMutation/useRevisionTaskByIdMutation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import toast from 'react-hot-toast'; | ||
import { t } from 'i18next'; | ||
import { fetchWorkflowDecision } from '../../../../workflows/fetchers'; | ||
import { workflowsQueryKeys } from '../../../../workflows/query-keys'; | ||
import { Action } from '../../../../../common/enums'; | ||
|
||
export const useRevisionTaskByIdMutation = (workflowId: string) => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: ({ documentId, reason }: { documentId: string; reason?: string }) => | ||
fetchWorkflowDecision({ | ||
workflowId, | ||
documentId, | ||
body: { | ||
decision: Action.REVISION.toLowerCase(), | ||
reason, | ||
}, | ||
}), | ||
onSuccess: () => { | ||
// workflowsQueryKeys._def is the base key for all workflows queries | ||
void queryClient.invalidateQueries(workflowsQueryKeys._def); | ||
|
||
toast.success(t('toast:ask_revision_document.success')); | ||
}, | ||
onError: () => { | ||
toast.error(t('toast:ask_revision_document.error')); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.