Skip to content

Commit

Permalink
front: fix project image not displayed in stdcm (#3953)
Browse files Browse the repository at this point in the history
  • Loading branch information
SharglutDev authored Apr 19, 2023
1 parent 88b7db4 commit e64ca0b
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { useMemo, useState } from 'react';
import { PROJECTS_URI } from 'applications/operationalStudies/components/operationalStudiesConsts';
import { get } from 'common/requests';
import { getDocument } from 'common/api/documentApi';
import { MiniCardsImageProps } from './ScenarioExploratorTypes';

export default function Project2Image({ project }: MiniCardsImageProps) {
const [imageUrl, setImageUrl] = useState<string>();

useMemo(async () => {
if (!project || !project.image_url) return;
if (!project || !project.image) return;
try {
const image = await get(`${PROJECTS_URI}${project.id}/image/`, { responseType: 'blob' });
if (image) setImageUrl(URL.createObjectURL(image));
const blobImage = await getDocument(project.image as number);
if (blobImage) setImageUrl(URL.createObjectURL(blobImage));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.error(error);
Expand Down

0 comments on commit e64ca0b

Please sign in to comment.