From 8b5dc0c97f4296d242ac6ce87b25d89c16561a82 Mon Sep 17 00:00:00 2001 From: Omri Levy <61207713+Omri-Levy@users.noreply.github.com> Date: Tue, 22 Aug 2023 19:26:37 +0300 Subject: [PATCH] Fix base 64 images (#952) * fix(backoffice-v2): now checking if an image url is a url and not base64, and updated seed * refactor(backoffice-v2): removed untintentional code * revert(backoffice-v2): returned documents data to be inline --- .../ImageViewer/ImageViewer.SelectedImage.tsx | 1 - .../src/pages/Entity/hooks/useTasks/useTasks.tsx | 10 +++++----- services/workflows-service/scripts/seed.ts | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/backoffice-v2/src/common/components/organisms/ImageViewer/ImageViewer.SelectedImage.tsx b/apps/backoffice-v2/src/common/components/organisms/ImageViewer/ImageViewer.SelectedImage.tsx index b5f9cd5398..dfcd00ed00 100644 --- a/apps/backoffice-v2/src/common/components/organisms/ImageViewer/ImageViewer.SelectedImage.tsx +++ b/apps/backoffice-v2/src/common/components/organisms/ImageViewer/ImageViewer.SelectedImage.tsx @@ -1,7 +1,6 @@ import { BallerineImage } from '../../atoms/BallerineImage'; import { forwardRef, useCallback, useEffect, useState } from 'react'; import { ctw } from '../../../utils/ctw/ctw'; -import { useImageViewerContext } from './hooks/useImageViewerContext/useImageViewerContext'; import { useSelectedImage } from './hooks/useSelectedImage/useSelectedImage'; import { TSelectedImageProps } from './interfaces'; diff --git a/apps/backoffice-v2/src/pages/Entity/hooks/useTasks/useTasks.tsx b/apps/backoffice-v2/src/pages/Entity/hooks/useTasks/useTasks.tsx index 896ec9a412..881906081a 100644 --- a/apps/backoffice-v2/src/pages/Entity/hooks/useTasks/useTasks.tsx +++ b/apps/backoffice-v2/src/pages/Entity/hooks/useTasks/useTasks.tsx @@ -12,15 +12,16 @@ import { omitPropsFromObject, } from '../useEntity/utils'; import { getDocumentsByCountry, isObject } from '@ballerine/common'; +import * as React from 'react'; import { ComponentProps, useMemo } from 'react'; import { toStartCase } from '../../../../common/utils/to-start-case/to-start-case'; import { octetToFileType } from '../../../../common/octet-to-file-type/octet-to-file-type'; import { useCaseDecision } from '../../components/Case/hooks/useCaseDecision/useCaseDecision'; import { X } from 'lucide-react'; -import * as React from 'react'; import { useRevisionTaskByIdMutation } from '../../../../domains/entities/hooks/mutations/useRevisionTaskByIdMutation/useRevisionTaskByIdMutation'; import { MotionBadge } from '../../../../common/components/molecules/MotionBadge/MotionBadge'; +import { z } from 'zod'; const motionProps: ComponentProps = { exit: { opacity: 0, transition: { duration: 0.2 } }, @@ -274,10 +275,9 @@ export const useTasks = ({ title: `${convertSnakeCaseToTitleCase(category)} - ${convertSnakeCaseToTitleCase( docType, )}${metadata?.side ? ` - ${metadata?.side}` : ''}`, - imageUrl: - type === 'pdf' - ? octetToFileType(results[docIndex][pageIndex], `application/${type}`) - : results[docIndex][pageIndex], + imageUrl: z.string().url().safeParse(results[docIndex][pageIndex]).success + ? results[docIndex][pageIndex] + : octetToFileType(results[docIndex][pageIndex], `application/${type}`), fileType: type, })) ?? [], }, diff --git a/services/workflows-service/scripts/seed.ts b/services/workflows-service/scripts/seed.ts index b6f709c9a9..a2a751e1a8 100644 --- a/services/workflows-service/scripts/seed.ts +++ b/services/workflows-service/scripts/seed.ts @@ -294,7 +294,7 @@ async function seed(bcryptSalt: string | number) { { provider: 'http', uri: imageUri3, - type: 'pdf', + type: 'png', ballerineFileId: await persistImageFile(client, imageUri3, project1.id), data: '', metadata: {}, @@ -418,7 +418,7 @@ async function seed(bcryptSalt: string | number) { { provider: 'http', uri: imageUri3, - type: 'pdf', + type: 'png', data: '', ballerineFileId: await persistImageFile(client, imageUri3, project1.id), metadata: {},