Skip to content

Commit

Permalink
fix(sd document): update SD document download API (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw authored Aug 28, 2024
1 parent 6192911 commit 0464b1a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

- **IDP management**
- Fixed statusTag color in status coloumn [#978](https://github.com/eclipse-tractusx/portal-frontend/pull/978)
- **Connector Management**
- Updated SD document download API to fix downloading SD document issue [#1038](https://github.com/eclipse-tractusx/portal-frontend/pull/1038)
- **Service Release Process**
- Fixed back button navigation to service management instead of navigating to home page[#1038](https://github.com/eclipse-tractusx/portal-frontend/pull/1038)
- **Application Requests**
- Fixed 'activeTab' conditions to load data for Tab-2(Registration Process) [#1050](https://github.com/eclipse-tractusx/portal-frontend/pull/1050)

Expand Down
15 changes: 6 additions & 9 deletions src/components/pages/EdcConnector/ConnectorDetailsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ import {
useDeleteConnectorMutation,
useUpdateConnectorUrlMutation,
useFetchConnectorDetailsQuery,
useFetchSdDocumentMutation,
} from 'features/connector/connectorApiSlice'
import { Box, Divider, Grid } from '@mui/material'
import ArticleOutlinedIcon from '@mui/icons-material/ArticleOutlined'
import { useEffect, useState } from 'react'
import { error, success } from 'services/NotifyService'
import EditIcon from '@mui/icons-material/Edit'
import Patterns from 'types/Patterns'
import { useFetchDocumentMutation } from 'features/serviceManagement/apiSlice'
import { download } from 'utils/downloadUtils'
import UserService from 'services/UserService'
import { ROLES } from 'types/Constants'
Expand All @@ -59,7 +59,7 @@ const ConnectorDetailsOverlay = ({
overlayData,
}: DeleteConfirmationOverlayProps) => {
const { t } = useTranslation()
const [fetchDocumentById] = useFetchDocumentMutation()
const [fetchSDDocument] = useFetchSdDocumentMutation()
const {
data: fetchConnectorDetails,
isFetching,
Expand Down Expand Up @@ -135,10 +135,7 @@ const ConnectorDetailsOverlay = ({
const handleDownloadFn = async (documentId: string, documentName: string) => {
if (fetchConnectorDetails?.id) {
try {
const response = await fetchDocumentById({
appId: fetchConnectorDetails.id,
documentId,
}).unwrap()
const response = await fetchSDDocument(documentId).unwrap()

const fileType = response.headers.get('content-type')
const file = response.data
Expand Down Expand Up @@ -600,8 +597,8 @@ const ConnectorDetailsOverlay = ({
null ? (
t('content.edcconnector.details.noDocumentAvailable')
) : (
<>
<ArticleOutlinedIcon sx={{ color: '#9c9c9c' }} />
<Box sx={{ display: 'flex' }}>
<ArticleOutlinedIcon sx={{ color: '#9c9c9c', mr: 1 }} />
<button
className="document-button-link"
onClick={() =>
Expand All @@ -616,7 +613,7 @@ const ConnectorDetailsOverlay = ({
'content.edcconnector.details.selfDescriptionDocument'
)}
</button>
</>
</Box>
)}
</Typography>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import { ButtonLabelTypes } from '..'
import RetryOverlay from '../components/RetryOverlay'
import { success, error } from 'services/NotifyService'
import { DocumentTypeId } from 'features/appManagement/apiSlice'
import { PAGES } from 'types/Constants'

type FormDataType = {
title: string
Expand Down Expand Up @@ -520,7 +521,7 @@ export default function OfferCard() {
setServiceCardSnackbar(false)
}}
onBackIconClick={() => {
navigate('/home')
navigate(`/${PAGES.SERVICE_MANAGEMENT}`)
}}
// Add an ESLint exception until there is a solution
// eslint-disable-next-line
Expand Down
10 changes: 10 additions & 0 deletions src/features/connector/connectorApiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ export const apiSlice = createApi({
body: data.body,
}),
}),
fetchSdDocument: builder.mutation({
query: (documentId) => ({
url: `/api/administration/documents/selfDescription/${documentId}`,
responseHandler: async (response) => ({
headers: response.headers,
data: await response.blob(),
}),
}),
}),
}),
})

Expand All @@ -186,4 +195,5 @@ export const {
useFetchOfferSubscriptionsQuery,
useFetchDecentralIdentityUrlsQuery,
useUpdateConnectorUrlMutation,
useFetchSdDocumentMutation,
} = apiSlice

0 comments on commit 0464b1a

Please sign in to comment.