Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(service marketplace): fix detail images #1197

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ npm/npmjs/@babel/template/7.25.0, MIT, approved, clearlydefined
npm/npmjs/@babel/traverse/7.25.6, MIT, approved, clearlydefined
npm/npmjs/@babel/types/7.25.6, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #16040
npm/npmjs/@bcoe/v8-coverage/0.2.3, ISC AND MIT, approved, clearlydefined
npm/npmjs/@catena-x/portal-shared-components/3.7.3, Apache-2.0 AND CC-BY-4.0 AND OFL-1.1, approved, #17145
npm/npmjs/@catena-x/portal-shared-components/3.7.4, Apache-2.0 AND CC-BY-4.0 AND OFL-1.1, approved, #17145
npm/npmjs/@colors/colors/1.5.0, MIT, approved, clearlydefined
npm/npmjs/@cspotcode/source-map-support/0.8.1, MIT, approved, clearlydefined
npm/npmjs/@cypress/request/3.0.6, Apache-2.0, approved, clearlydefined
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
]
},
"dependencies": {
"@catena-x/portal-shared-components": "^3.7.3",
"@catena-x/portal-shared-components": "^3.7.4",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@hookform/error-message": "^2.0.1",
Expand Down
10 changes: 6 additions & 4 deletions src/components/pages/AdminBoardDetail/AdminBoardDetail.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@
gap: 56px;
}

.lead-image > img {
border-radius: 16px;
max-width: 100%;
width: 412px;
.lead-image {
max-width: 288px;
& > img {
border-radius: 16px;
width: 100%;
}
}
.service-app-content {
flex: 1;
Expand Down
9 changes: 6 additions & 3 deletions src/components/pages/ServiceAdminBoardDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
Button,
StaticTable,
Typography,
Image,
} from '@catena-x/portal-shared-components'
import { useNavigate, useParams } from 'react-router-dom'
import '../AdminBoardDetail/AdminBoardDetail.scss'
import { getAssetBase } from 'services/EnvironmentService'
import {
type ServiceDetailsType,
useFetchBoardServiceDetailsQuery,
Expand All @@ -42,6 +42,8 @@ import { Grid, Box, Divider } from '@mui/material'
import { download } from 'utils/downloadUtils'
import { DocumentTypeText } from 'features/apps/types'
import { DocumentTypeId } from 'features/appManagement/apiSlice'
import { fetchImageWithToken } from 'services/ImageService'
import { getApiBase } from 'services/EnvironmentService'

enum TableData {
SUCCESS = 'SUCCESS',
Expand Down Expand Up @@ -132,9 +134,10 @@ export default function ServiceAdminBoardDetail() {
<Box className="service-content">
<div className="service-board-header">
<div className="lead-image">
<img
src={`${getAssetBase()}/images/content/ServiceMarketplace.png`}
<Image
src={`${getApiBase()}/api/services/${appId}/serviceDocuments/${serviceData?.documents?.SERVICE_LEADIMAGE?.[0].documentId}`}
alt={serviceData.title}
loader={fetchImageWithToken}
/>
</div>
<Box className="service-app-content">
Expand Down
14 changes: 12 additions & 2 deletions src/components/pages/ServiceMarketplace/RecommendedServices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import { useNavigate } from 'react-router-dom'
import type { ServiceRequest } from 'features/serviceMarketplace/serviceApiSlice'
import './ServiceMarketplace.scss'
import NoItems from '../NoItems'
import { getAssetBase } from 'services/EnvironmentService'
import { fetchImageWithToken } from 'services/ImageService'
import { getApiBase } from 'services/EnvironmentService'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { ServiceTypeIdsEnum } from 'features/serviceManagement/apiSlice'
Expand Down Expand Up @@ -73,9 +74,18 @@ export default function RecommendedServices({
<CardHorizontal
borderRadius={6}
image={{
src: `${getApiBase()}/api/services/${service.id}/serviceDocuments/${service?.leadPictureId}`,
alt: 'App Card',
src: `${getAssetBase()}/images/content/ServiceMarketplace.png`,
style: {
flex: '0 0 33.333333%',
maxWidth: '33.333333%',
minHeight: '200px',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center',
},
}}
imageLoader={fetchImageWithToken}
label={service.provider}
buttonText="Details"
onBtnClick={() => {
Expand Down
14 changes: 12 additions & 2 deletions src/components/pages/ServiceMarketplace/ServicesElements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import type { ServiceRequest } from 'features/serviceMarketplace/serviceApiSlice'
import './ServiceMarketplace.scss'
import { getAssetBase } from 'services/EnvironmentService'
import { useCallback } from 'react'
import { ServiceTypeIdsEnum } from 'features/serviceManagement/apiSlice'
import { getApiBase } from 'services/EnvironmentService'
import { fetchImageWithToken } from 'services/ImageService'

export default function ServicesElements({
services,
Expand Down Expand Up @@ -81,9 +82,18 @@ export default function ServicesElements({
<CardHorizontal
borderRadius={6}
image={{
src: `${getApiBase()}/api/services/${service.id}/serviceDocuments/${service?.leadPictureId}`,
alt: 'App Card',
src: `${getAssetBase()}/images/content/ServiceMarketplace.png`,
style: {
flex: '0 0 33.333333%',
maxWidth: '33.333333%',
minHeight: '200px',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center',
},
}}
imageLoader={fetchImageWithToken}
label={service.provider}
buttonText="Details"
onBtnClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
display: flex;
flex-wrap: wrap;
.lead-image {
width: 288px;
height: 288px;
overflow: hidden;
img {
border-radius: 16px;
width: '288px';
height: '288px';
width: 100%;
height: 100%;
object-fit: fill;
}
}
.marketplace-app-content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
********************************************************************************/

import { useDispatch } from 'react-redux'
import { Button, Typography } from '@catena-x/portal-shared-components'
import { Button, Typography, Image } from '@catena-x/portal-shared-components'
import { useTranslation } from 'react-i18next'
import { useParams } from 'react-router-dom'
import type { ServiceRequest } from 'features/serviceMarketplace/serviceApiSlice'
import { show } from 'features/control/overlay'
import { OVERLAYS, ROLES } from 'types/Constants'
import './MarketplaceHeader.scss'
import { setSuccessType } from 'features/serviceMarketplace/slice'
import { getAssetBase } from 'services/EnvironmentService'
import { Box } from '@mui/material'
import { ServiceTypeIdsEnum } from 'features/serviceManagement/apiSlice'
import { userHasPortalRole } from 'services/AccessService'
import { getApiBase } from 'services/EnvironmentService'
import { fetchImageWithToken } from 'services/ImageService'

export default function MarketplaceHeader({
item,
Expand Down Expand Up @@ -88,9 +89,10 @@ export default function MarketplaceHeader({
return (
<div className="service-marketplace-header">
<div className="lead-image">
<img
src={`${getAssetBase()}/images/content/ServiceMarketplace.png`}
<Image
src={`${getApiBase()}/api/services/${serviceId}/serviceDocuments/${item?.leadPictureId}`}
alt={item.title}
loader={fetchImageWithToken}
/>
</div>
<Box className="marketplace-app-content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ import {
useFetchDocumentMutation,
useFetchServiceStatusQuery,
} from 'features/serviceManagement/apiSlice'
import { useCallback, useEffect, useState } from 'react'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import { Divider } from '@mui/material'
import ArticleOutlinedIcon from '@mui/icons-material/ArticleOutlined'
import { useParams } from 'react-router-dom'
import { download } from 'utils/downloadUtils'
import { type DocumentData } from 'features/apps/types'
import { DocumentTypeId } from 'features/appManagement/apiSlice'
import { getApiBase } from 'services/EnvironmentService'
import { fetchImageWithToken } from 'services/ImageService'

export default function ServiceDetails() {
const { t } = useTranslation('servicerelease')
Expand All @@ -47,7 +49,6 @@ export default function ServiceDetails() {
refetchOnMountOrArgChange: true,
}).data
const [fetchDocument] = useFetchDocumentMutation()
const [leadImg, setLeadImg] = useState<string>('')

const getServiceTypes = useCallback(() => {
const newArr: string[] = []
Expand Down Expand Up @@ -77,25 +78,6 @@ export default function ServiceDetails() {
}
}

const setLeadingImg = async () => {
try {
const response = await fetchDocument({
appId: serviceId,
documentId: fetchServiceStatus?.leadPictureId,
}).unwrap()
const file = response.data
setLeadImg(URL.createObjectURL(file))
} catch (error) {
console.log(error)
}
}

useEffect(() => {
if (fetchServiceStatus) {
setLeadingImg()
}
}, [fetchServiceStatus])

return (
<main>
<div>
Expand All @@ -112,9 +94,18 @@ export default function ServiceDetails() {
<CardHorizontal
borderRadius={6}
image={{
src: `${getApiBase()}/api/services/${serviceId}/serviceDocuments/${fetchServiceStatus?.leadPictureId}`,
alt: 'Service Card',
src: leadImg,
style: {
flex: '0 0 33.333333%',
maxWidth: '33.333333%',
minHeight: '200px',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center',
},
}}
imageLoader={fetchImageWithToken}
label={''}
buttonText=""
onBtnClick={() => {
Expand Down
53 changes: 15 additions & 38 deletions src/components/shared/basic/ReleaseProcess/AppMarketCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ import {
type LanguageStatusType,
type UseCaseType,
} from 'features/appManagement/types'
import { useFetchDocumentByIdMutation } from 'features/apps/apiSlice'
import { download } from 'utils/downloadUtils'
import { extractFileData } from 'utils/fileUtils'
import { getApiBase } from 'services/EnvironmentService'
import { fetchImageWithToken } from 'services/ImageService'
import { useFetchDocumentByIdMutation } from 'features/apps/apiSlice'

type FormDataType = {
title: string
Expand All @@ -100,6 +102,7 @@ export default function AppMarketCard() {
const appId = useSelector(appIdSelector)
const [pageScrolled, setPageScrolled] = useState(false)
const [deleteSuccess, setDeleteSuccess] = useState(false)
const [fetchDocumentById] = useFetchDocumentByIdMutation()

const useCasesListData = useFetchUseCasesQuery().data
const useCasesList = useMemo(() => useCasesListData ?? [], [useCasesListData])
Expand Down Expand Up @@ -134,7 +137,6 @@ export default function AppMarketCard() {
salesManagerType[]
>([defaultSalesManagerValue])
const [salesManagerId, setSalesManagerId] = useState<string | null>(null)
const [fetchDocumentById] = useFetchDocumentByIdMutation()
const [cardImage, setCardImage] = useState(LogoGrayData)
const {
data: fetchAppStatus,
Expand Down Expand Up @@ -260,40 +262,6 @@ export default function AppMarketCard() {
}
}, [cardImageData])

useEffect(() => {
if (appStatusData?.documents?.APP_LEADIMAGE?.[0].documentId) {
void fetchCardImage(
appStatusData?.documents?.APP_LEADIMAGE[0].documentId,
appStatusData?.documents?.APP_LEADIMAGE[0].documentName
)
}
reset(defaultValues)
}, [appStatusData])

const setFileStatus = (
documentId: string,
documentName: string,
status: UploadFileStatus
) => {
setValue('uploadImage.leadPictureUri', {
id: documentId,
name: documentName,
status,
} as unknown as string | null)
}

const fetchCardImage = async (documentId: string, documentName: string) => {
try {
const response = await fetchDocumentById({ appId, documentId }).unwrap()
const file = response.data
setFileStatus(documentId, documentName, UploadStatus.UPLOAD_SUCCESS)
setCardImage(URL.createObjectURL(file))
} catch (error) {
setFileStatus(documentId, documentName, UploadStatus.UPLOAD_SUCCESS)
console.error(error, 'ERROR WHILE FETCHING IMAGE')
}
}

const cardAppTitle =
getValues().title ??
t('content.apprelease.appMarketCard.defaultCardAppTitle')
Expand Down Expand Up @@ -514,9 +482,18 @@ export default function AppMarketCard() {
label={cardAppProvider ?? ''}
title={cardAppTitle}
image={{
alt: cardImageAlt,
src: cardImage,
src: `${getApiBase()}/api/services/${appId}/serviceDocuments/${appStatusData?.documents?.APP_LEADIMAGE?.[0].documentId}`,
alt: 'App Card',
style: {
flex: '0 0 33.333333%',
maxWidth: '33.333333%',
minHeight: '200px',
backgroundRepeat: 'no-repeat',
backgroundSize: 'cover',
backgroundPosition: 'center',
},
}}
imageLoader={fetchImageWithToken}
borderRadius={0}
description={cardDescription}
backgroundColor="#F3F3F3"
Expand Down
Loading
Loading