Skip to content

Commit

Permalink
chore: merge conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Usmanfee committed Dec 13, 2024
1 parent ba399a4 commit 82b8975
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 145 deletions.
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
51 changes: 13 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,10 @@ 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'

type FormDataType = {
title: string
Expand Down Expand Up @@ -134,7 +135,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 +260,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 +480,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

0 comments on commit 82b8975

Please sign in to comment.