Skip to content

Commit

Permalink
Merge branch 'release/v2.2.0-RC2' into feat/541/ospm
Browse files Browse the repository at this point in the history
  • Loading branch information
lavanya-bmw authored Aug 29, 2024
2 parents 72cd024 + 578365b commit 60b727f
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 68 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- **Onboarding Service Provider Management**:
- Create new page for onboarding service provider management [#1052](https://github.com/eclipse-tractusx/portal-frontend/pull/1052)
- Service Subscription
- Update auto setup api response data in the service subscription response overlay
- Partner Network
- Change interface of the partner network apis. add /members to the POST api and update the business logic accordingly

## 2.2.0-RC1

Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ npm/npmjs/@babel/template/7.24.0, MIT, approved, clearlydefined
npm/npmjs/@babel/traverse/7.24.1, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #13926
npm/npmjs/@babel/types/7.24.0, MIT, approved, clearlydefined
npm/npmjs/@bcoe/v8-coverage/0.2.3, ISC AND MIT, approved, clearlydefined
npm/npmjs/@catena-x/portal-shared-components/3.0.29, Apache-2.0 AND CC-BY-4.0 AND OFL-1.1, approved, #14247
npm/npmjs/@catena-x/portal-shared-components/3.2.0, Apache-2.0 AND CC-BY-4.0 AND OFL-1.1, approved, #16029
npm/npmjs/@cspotcode/source-map-support/0.8.1, MIT, approved, clearlydefined
npm/npmjs/@date-io/core/3.0.0, MIT, approved, clearlydefined
npm/npmjs/@date-io/date-fns/3.0.0, MIT, approved, #14023
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.0.29",
"@catena-x/portal-shared-components": "^3.1.3",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@hookform/error-message": "^2.0.1",
Expand Down
11 changes: 6 additions & 5 deletions src/components/overlays/ActivateServiceSubscription/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,21 @@ export default function ActivateserviceSubscription({
body: [
[
t('serviceSubscription.activation.userId'),
techUserInfo?.technicalUserInfo.technicalClientId ?? '',
techUserInfo?.technicalUserInfo[0]?.technicalClientId ?? '',
],
[
t('serviceSubscription.activation.sercret'),
techUserInfo?.technicalUserInfo.technicalUserSecret ?? '',
techUserInfo?.technicalUserInfo[0]?.technicalUserSecret ?? '',
],
[
t('serviceSubscription.activation.url'),
techUserInfo?.clientInfo?.clientUrl ?? 'n/a',
],
[
t('serviceSubscription.activation.technicaluserType'),
techUserInfo?.technicalUserInfo.technicalUserPermissions.join(', ') ??
'',
techUserInfo?.technicalUserInfo[0]?.technicalUserPermissions?.join(
', '
) ?? '',
],
],
edit: [
Expand All @@ -127,7 +128,7 @@ export default function ActivateserviceSubscription({
},
{
icon: false,
copyValue: techUserInfo?.technicalUserInfo.technicalUserSecret,
copyValue: techUserInfo?.technicalUserInfo[0]?.technicalUserSecret,
},
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,36 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { useFetchBusinessPartnersQuery } from 'features/newPartnerNetwork/partnerNetworkApiSlice'
import { useFetchBusinessPartnerAddressMutation } from 'features/newPartnerNetwork/partnerNetworkApiSlice'
import BusinessPartnerDetailContent from './BusinessPartnerDetailContent'
import { useEffect, useState } from 'react'
import { type BusinessPartner } from 'features/partnerNetwork/types'

const BusinessPartnerDetail = ({ id }: { id: string }) => {
const { data } = useFetchBusinessPartnersQuery({
page: 0,
args: {
expr: id,
},
})
const [bpMutation] = useFetchBusinessPartnerAddressMutation()
const [items, setItems] = useState<BusinessPartner[]>()
const callApi = async () => {
await bpMutation({
bpnLs: [id],
legalName: '',
})
.unwrap()
.then((data) => {
setItems(data.content)
})
.catch(() => {
setItems([])
})
}

useEffect(() => {
callApi()
}, [])

return (
<>
{data?.content?.length && (
<BusinessPartnerDetailContent selectedRowBPN={data.content[0]} />
{items?.length && (
<BusinessPartnerDetailContent selectedRowBPN={items[0]} />
)}
</>
)
Expand Down
127 changes: 96 additions & 31 deletions src/components/pages/PartnerNetwork/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
import 'components/pages/PartnerNetwork/PartnerNetwork.scss'
import { useTranslation } from 'react-i18next'
import {
useFetchBusinessPartnersQuery,
useFetchBusinessPartnersMutation,
useFetchBusinessPartnerAddressMutation,
} from 'features/newPartnerNetwork/partnerNetworkApiSlice'
import {
PageHeader,
PageLoadingTable,
Table,
type PaginResult,
} from '@catena-x/portal-shared-components'
import { useSelector } from 'react-redux'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import { updatePartnerSelector } from 'features/control/updates'
import { PartnerNetworksTableColumns } from 'components/pages/PartnerNetwork/partnerNetworkTableColumns'
import type { BusinessPartner } from 'features/newPartnerNetwork/types'
import Patterns from 'types/Patterns'
import Patterns, { isBPN } from 'types/Patterns'
import { useFetchMemberCompaniesQuery } from 'features/newPartnerNetwork/partnerNetworkPortalApiSlice'
import {
isContentPresent,
Expand All @@ -46,42 +46,94 @@ import { type BusinessPartnerAddressResponse } from 'features/partnerNetwork/typ
const PartnerNetwork = () => {
const { t } = useTranslation()
const [expr, setExpr] = useState<string>('')
const [refresh, setRefresh] = useState<number>(0)
const [bpn, setBpn] = useState<string>('')
const searchInputData = useSelector(updatePartnerSelector)
const columns = PartnerNetworksTableColumns(t)
const [mutationRequest] = useFetchBusinessPartnerAddressMutation()
const { data } = useFetchMemberCompaniesQuery()
const [fetchMembers] = useFetchBusinessPartnersMutation()

const validateSearchText = (text: string): boolean =>
Patterns.SEARCH.test(text.trim())
const [page, setPage] = useState<number>(0)
const [allItems, setAllItems] = useState<BusinessPartner[]>([])
const [memberData, setMemberData] = useState<PaginResult<BusinessPartner>>()
const [loading, setLoading] = useState<boolean>(false)
const [fetchArgs, setFetchArgs] = useState({
args: {
expr,
},
page,
})

const [allItems, setAllItems] = useState<BusinessPartner[]>()
const fetchAllMembers = async () => {
await fetchMembers(fetchArgs)
.unwrap()
.then((payload) => {
setMemberData(payload)
if (isContentPresent(payload) && payload.content.length === 0) {
setAllItems([])
setLoading(false)
} else {
setCountryAttributes(payload)
}
})
.catch(() => {
setAllItems([])
})
setLoading(false)
}

const fetchAndApply = async (cData: PaginResult<BusinessPartner>) => {
//BPDM response does not has content attribute. Check for it and proceed
if (isContentPresent(cData) && cData.content.length === 0) {
setAllItems([])
return
}
useEffect(() => {
setLoading(true)
if (data && data.length > 0) fetchAllMembers()
}, [data, fetchArgs])

const result = cData.content.map((x: BusinessPartner) => x.bpnl)
const setCountryAttributes = (payload: PaginResult<BusinessPartner>) => {
let finalObj = JSON.parse(JSON.stringify(payload?.content))
finalObj = addCountryAttribute(
finalObj,
payload.content as unknown as BusinessPartnerAddressResponse[]
)
finalObj = addMemberAttribute(finalObj, data)
setAllItems((i) => (page === 0 ? finalObj : i.concat(finalObj)))
}

const fetchAndApply = async (result: string[]) => {
await mutationRequest({ bpnLs: result, legalName: '' })
.unwrap()
.then((payload: PaginResult<BusinessPartnerAddressResponse>) => {
//new country attribute && member attributes based on the response
let finalObj = JSON.parse(JSON.stringify(cData?.content))
finalObj = addCountryAttribute(
finalObj,
payload.content as unknown as BusinessPartnerAddressResponse[]
)
finalObj = addMemberAttribute(finalObj, data)
setAllItems(finalObj)
.then((payload) => {
setCountryAttributes(payload)
})
.catch(() => {
setAllItems([])
})

setLoading(false)
}

useEffect(() => {
setFetchArgs({
args: {
expr,
},
page,
})
}, [page, expr])

useEffect(() => {
if (bpn === '') {
setFetchArgs({
args: {
expr: '',
},
page: 0,
})
}
setLoading(true)
fetchAndApply([bpn])
}, [bpn])

return (
<main className="partner-network-page-container">
<PageHeader
Expand All @@ -91,29 +143,42 @@ const PartnerNetwork = () => {
/>

<section id="identity-management-id">
<PageLoadingTable<BusinessPartner, { expr: string }>
<Table
autoFocus={false}
searchExpr={expr}
searchExpr={expr || bpn}
toolbarVariant={'ultimate'}
hasBorder={false}
columnHeadersBackgroundColor={'transparent'}
searchPlaceholder={t('content.partnernetwork.searchfielddefaulttext')}
searchInputData={searchInputData}
onSearch={(expr: string) => {
if (expr === '') {
setBpn('')
setExpr('')
setPage(0)
}
if (expr !== '' && !validateSearchText(expr)) return
setRefresh(Date.now())
setExpr(expr)
setAllItems([])
if (isBPN(expr)) setBpn(expr)
else setExpr(expr)
}}
searchDebounce={1000}
title={t('content.partnernetwork.tabletitle')}
loadLabel={t('global.actions.loadmore')}
fetchHook={useFetchBusinessPartnersQuery}
fetchHookArgs={{ expr }}
fetchHookRefresh={refresh}
getRowId={(row: { bpnl: string }) => row.bpnl ?? ''}
columns={columns}
callbackToPage={fetchAndApply}
allItems={allItems}
loading={loading}
rows={allItems}
rowsCount={allItems?.length}
noRowsMsg={t('content.companyData.table.noRowsMsg')}
nextPage={() => {
setPage(page + 1)
}}
hasMore={
memberData?.meta &&
memberData.meta.page < memberData.meta.totalPages - 1
}
hideFooterPagination={true}
/>
</section>
</main>
Expand Down
41 changes: 25 additions & 16 deletions src/features/newPartnerNetwork/partnerNetworkApiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,53 @@ import type {
PaginFetchArgs,
} from '@catena-x/portal-shared-components'
import type { BusinessPartner } from './types'
import Patterns from 'types/Patterns'
import type { BusinessPartnerAddressResponse } from 'features/partnerNetwork/types'
import { isBPN } from 'types/Patterns'

export interface BusinessPartnerRequest {
bpnLs: string[]
legalName: string
}

const checkIfBPNLNumber = (text: string): boolean =>
Patterns.BPN.test(text.trim())

export const apiSlice = createApi({
reducerPath: 'rtk/admin/partnerNetwork',
baseQuery: fetchBaseQuery(apiBpdmPoolQuery()),
endpoints: (builder) => ({
fetchBusinessPartnerAddress: builder.mutation<
PaginResult<BusinessPartnerAddressResponse>,
PaginResult<BusinessPartner>,
BusinessPartnerRequest
>({
query: (body) => ({
url: '/legal-entities/search?page=0&size=30',
url: '/members/legal-entities/search?page=0&size=10',
method: 'POST',
body,
}),
}),
fetchBusinessPartners: builder.query<
fetchBusinessPartners: builder.mutation<
PaginResult<BusinessPartner>,
PaginFetchArgs
>({
query: (fetchArgs) => {
if (fetchArgs.args.expr && !checkIfBPNLNumber(fetchArgs.args.expr)) {
return `/legal-entities?page=${
fetchArgs.page
}&size=10&legalName=${fetchArgs.args!.expr}`
} else if (checkIfBPNLNumber(fetchArgs.args.expr)) {
return `/legal-entities/${fetchArgs.args!.expr}`
let url = ''
let body = {}
if (fetchArgs.args.expr && !isBPN(fetchArgs.args.expr)) {
url = `/members/legal-entities/search?page=${fetchArgs.page}&size=10`
body = {
bpnl: [],
legalName: fetchArgs.args.expr,
}
} else if (isBPN(fetchArgs.args.expr)) {
url = `/members/legal-entities/search?page=${fetchArgs.page}&size=10`
body = {
bpnl: [fetchArgs.args.expr],
legalName: '',
}
} else {
return `/legal-entities?page=${fetchArgs.page}&size=10`
url = `/members/legal-entities/search?page=${fetchArgs.page}&size=10`
}
return {
url,
method: 'POST',
body,
}
},
// Add an ESLint exception until there is a solution
Expand Down Expand Up @@ -96,5 +105,5 @@ export const apiSlice = createApi({

export const {
useFetchBusinessPartnerAddressMutation,
useFetchBusinessPartnersQuery,
useFetchBusinessPartnersMutation,
} = apiSlice
2 changes: 1 addition & 1 deletion src/features/serviceManagement/apiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export type ActivateSubscriptionRequest = {
}

export type ActivateSubscriptionResponse = {
technicalUserInfo: TechnicalUserInfoType
technicalUserInfo: TechnicalUserInfoType[]
clientInfo: ClientInfoType
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@catena-x/portal-shared-components@^3.0.29":
version "3.0.29"
resolved "https://registry.yarnpkg.com/@catena-x/portal-shared-components/-/portal-shared-components-3.0.29.tgz#85f83ce4a3d7b8d19c9719af9cd138a93070269a"
integrity sha512-VFzU+Krmt6doZWPLMn91FvqTXbF/bACKkdm7e+cAyGkiarTs4hL1iv4wjtgwSp/Uq0qZUKBL46N6Ouxyw5p3iQ==
"@catena-x/portal-shared-components@^3.1.3":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@catena-x/portal-shared-components/-/portal-shared-components-3.2.0.tgz#dcf4b3c4b3c2576801d6c3d9cb5f85ce8a2635d6"
integrity sha512-uy2jgIcGBcbWsg0MBN44b3W0MM6ZXrdmN5YeObGq9PW6D4fiGJviCGbqw12u0Zm20dNgchoCquArkJaSnv1uTw==
dependencies:
"@date-io/date-fns" "^3.0.0"
"@emotion/react" "^11.11.4"
Expand Down

0 comments on commit 60b727f

Please sign in to comment.