-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(*): added the ability to add and remove ubos * refactor(*): pr review changes * chore(*): updated packages * fix(workflow-service): fixed path to definition * chore(workflows-service): no longer importing from data-migrations * removed unused import * fixed failing test
- Loading branch information
Showing
58 changed files
with
1,495 additions
and
337 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { apiClient } from '@/common/api-client/api-client'; | ||
|
||
import { Method } from '@/common/enums'; | ||
|
||
import { handleZodError } from '@/common/utils/handle-zod-error/handle-zod-error'; | ||
import { z } from 'zod'; | ||
|
||
export const translateUiDefinition = async ({ | ||
id, | ||
partialUiDefinition, | ||
}: { | ||
id: string; | ||
partialUiDefinition: Record<string, unknown>; | ||
}) => { | ||
const [data, error] = await apiClient({ | ||
endpoint: `../case-management/ui-definition/${id}/translate/en`, | ||
method: Method.POST, | ||
body: { | ||
partialUiDefinition, | ||
}, | ||
schema: z.record(z.string(), z.unknown()), | ||
}); | ||
|
||
return handleZodError(error, data); | ||
}; |
16 changes: 16 additions & 0 deletions
16
...-definition/hooks/queries/useTranslateUiDefinitionQuery/useTranslateUiDefinitionQuery.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,16 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { uiDefinitionQueryKeys } from '@/domains/ui-definition/query-keys'; | ||
|
||
export const useTranslateUiDefinitionQuery = ({ | ||
id, | ||
partialUiDefinition, | ||
}: { | ||
id: string; | ||
partialUiDefinition: Record<string, unknown>; | ||
}) => { | ||
return useQuery({ | ||
...uiDefinitionQueryKeys.translate({ id, partialUiDefinition }), | ||
enabled: !!partialUiDefinition && !!id, | ||
}); | ||
}; |
22 changes: 22 additions & 0 deletions
22
apps/backoffice-v2/src/domains/ui-definition/query-keys.ts
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,22 @@ | ||
import { createQueryKeys } from '@lukemorales/query-key-factory'; | ||
import { translateUiDefinition } from './fetchers'; | ||
|
||
export const uiDefinitionQueryKeys = createQueryKeys('ui-definition', { | ||
translate: ({ | ||
id, | ||
partialUiDefinition, | ||
}: { | ||
id: string; | ||
partialUiDefinition: Record<string, unknown>; | ||
}) => { | ||
return { | ||
queryKey: [ | ||
{ | ||
id, | ||
partialUiDefinition, | ||
}, | ||
], | ||
queryFn: () => translateUiDefinition({ id, partialUiDefinition }), | ||
}; | ||
}, | ||
}); |
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
43 changes: 43 additions & 0 deletions
43
...ce-v2/src/domains/workflows/hooks/mutations/useCreateUboMutation/useCreateUboMutation.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,43 @@ | ||
import { apiClient } from '@/common/api-client/api-client'; | ||
|
||
import { Method } from '@/common/enums'; | ||
|
||
import { z } from 'zod'; | ||
|
||
import { handleZodError } from '@/common/utils/handle-zod-error/handle-zod-error'; | ||
|
||
import { toast } from 'sonner'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { useQueryClient } from '@tanstack/react-query'; | ||
import { t } from 'i18next'; | ||
|
||
export const useCreateUboMutation = ({ | ||
workflowId, | ||
onSuccess, | ||
}: { | ||
workflowId: string; | ||
onSuccess: () => void; | ||
}) => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async (ubo: Record<string, unknown>) => { | ||
const [data, error] = await apiClient({ | ||
endpoint: `../case-management/workflows/${workflowId}/ubos`, | ||
method: Method.POST, | ||
body: ubo, | ||
schema: z.undefined(), | ||
}); | ||
|
||
return handleZodError(error, data); | ||
}, | ||
onSuccess: () => { | ||
void queryClient.invalidateQueries(); | ||
toast.success(t('toast:ubo_created.success')); | ||
onSuccess(); | ||
}, | ||
onError: () => { | ||
toast.error(t('toast:ubo_created.error')); | ||
}, | ||
}); | ||
}; |
36 changes: 36 additions & 0 deletions
36
...mains/workflows/hooks/mutations/useDeleteUbosByIdsMutation/useDeleteUbosByIdsMutation.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,36 @@ | ||
import { apiClient } from '@/common/api-client/api-client'; | ||
|
||
import { z } from 'zod'; | ||
|
||
import { handleZodError } from '@/common/utils/handle-zod-error/handle-zod-error'; | ||
|
||
import { toast } from 'sonner'; | ||
import { Method } from '@/common/enums'; | ||
import { useQueryClient } from '@tanstack/react-query'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { t } from 'i18next'; | ||
|
||
export const useDeleteUbosByIdsMutation = ({ workflowId }: { workflowId: string }) => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async (ids: string[]) => { | ||
const [data, error] = await apiClient({ | ||
endpoint: `../case-management/workflows/${workflowId}/ubos`, | ||
method: Method.DELETE, | ||
body: { ids }, | ||
schema: z.undefined(), | ||
}); | ||
|
||
return handleZodError(error, data); | ||
}, | ||
onSuccess: () => { | ||
void queryClient.invalidateQueries(); | ||
|
||
toast.success(t('toast:ubo_deleted.success')); | ||
}, | ||
onError: () => { | ||
toast.error(t('toast:ubo_deleted.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
Oops, something went wrong.