-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
86 changed files
with
1,077 additions
and
336 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
35 changes: 35 additions & 0 deletions
35
apps/backoffice-v2/src/common/components/molecules/ImageOCR/ImageOCR.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,35 @@ | ||
import { ctw } from '@/common/utils/ctw/ctw'; | ||
import { ComponentProps, FunctionComponent } from 'react'; | ||
import { Loader2, ScanTextIcon } from 'lucide-react'; | ||
|
||
export interface IImageOCR extends ComponentProps<'button'> { | ||
onOcrPressed?: () => void; | ||
isOcrDisabled: boolean; | ||
isLoadingOCR?: boolean; | ||
} | ||
|
||
export const ImageOCR: FunctionComponent<IImageOCR> = ({ | ||
isOcrDisabled, | ||
onOcrPressed, | ||
className, | ||
isLoadingOCR, | ||
...props | ||
}) => ( | ||
<button | ||
{...props} | ||
type="button" | ||
className={ctw( | ||
'btn btn-circle btn-ghost btn-sm bg-base-300/70 text-[0.688rem] focus:outline-primary disabled:bg-base-300/70', | ||
isLoadingOCR, | ||
className, | ||
)} | ||
onClick={() => onOcrPressed?.()} | ||
disabled={isOcrDisabled || isLoadingOCR} | ||
> | ||
{isLoadingOCR ? ( | ||
<Loader2 className="animate-spin stroke-foreground" /> | ||
) : ( | ||
<ScanTextIcon className={'p-0.5'} /> | ||
)} | ||
</button> | ||
); |
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
apps/backoffice-v2/src/domains/entities/hooks/mutations/useDocumentOcr/useDocumentOcr.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,30 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { fetchWorkflowDocumentOCRResult } from '@/domains/workflows/fetchers'; | ||
import { toast } from 'sonner'; | ||
import { t } from 'i18next'; | ||
import { workflowsQueryKeys } from '@/domains/workflows/query-keys'; | ||
import { useFilterId } from '@/common/hooks/useFilterId/useFilterId'; | ||
|
||
export const useDocumentOcr = ({ workflowId }: { workflowId: string }) => { | ||
const filterId = useFilterId(); | ||
const workflowById = workflowsQueryKeys.byId({ workflowId, filterId }); | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: ({ documentId }: { documentId: string }) => { | ||
return fetchWorkflowDocumentOCRResult({ | ||
workflowRuntimeId: workflowId, | ||
documentId, | ||
}); | ||
}, | ||
onSuccess: (data, variables) => { | ||
void queryClient.invalidateQueries(workflowsQueryKeys._def); | ||
toast.success(t('toast:document_ocr.success')); | ||
}, | ||
onError: (error, variables) => { | ||
console.error('OCR error:', error, 'for document:', variables.documentId); | ||
void queryClient.invalidateQueries(workflowsQueryKeys._def); | ||
toast.error(t('toast:document_ocr.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
1 change: 0 additions & 1 deletion
1
...onents/CallToActionLegacy/hooks/useCallToActionLegacyLogic/useCallToActionLegacyLogic.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
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
3 changes: 3 additions & 0 deletions
3
apps/backoffice-v2/src/lib/blocks/components/MultiDocuments/interfaces.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
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.